longo92
Posts: 35
Joined: Mon Sep 03, 2018 3:45 pm
Contact: Website Skype

Dynamic resizer resolution change

Mon Sep 03, 2018 3:56 pm

Hi,
I have a resizer attached to a camera component with tunneling (camera video port tunneled to reszier input port), on resizer output port i have a callback (called each frame) that makes some calculations on frame data. If i want change the resizer resolution dinamically how can i? I see that there is a parameter "MMAL_PARAMETER_RESIZE_T " in mmal_parameters_camera.h but when i use mmal_port_parameter_set on the resizer output port mmal says that argument is invalid. Someone aleady use this functionality? Thanks

P.S.: Sorry for my english

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5944
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Dynamic resizer resolution change

Mon Sep 03, 2018 4:04 pm

You must disable the port before you:
- set up the new port format
- call mmal_port_format_commit
- enable the port again
- provide it buffers (potentially of a new size, therefore requiring reallocating the pool).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

longo92
Posts: 35
Joined: Mon Sep 03, 2018 3:45 pm
Contact: Website Skype

Re: Dynamic resizer resolution change

Mon Sep 03, 2018 4:13 pm

OK, but the program blocks on mmal_disable_port on resizer output port (the port "linked" to the callback), possible reasons?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5944
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Dynamic resizer resolution change

Mon Sep 03, 2018 4:25 pm

longo92 wrote:
Mon Sep 03, 2018 4:13 pm
OK, but the program blocks on mmal_disable_port on resizer output port (the port "linked" to the callback), possible reasons?
At a guess you've called the mmal_port_disable from the callback context.
Disable has to be able to return all the buffers, calling the callback on each of them, and it won't complete until it has done that. If you've blocked the callback context by calling mmal_port_disable from it, then it will stall.

Have a look at https://github.com/raspberrypi/userland ... _basic_2.c as a basic example. That is decoding an H264 encoded video clip where the resolution of the clip isn't known in advance. MMAL will send it a buffer with buffer->cmd == MMAL_EVENT_FORMAT_CHANGED, and it then actions disabling the port, destroying the pool, reconfiguring the port, create a new pool, and then enabling the port again and giving it those buffers.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

longo92
Posts: 35
Joined: Mon Sep 03, 2018 3:45 pm
Contact: Website Skype

Re: Dynamic resizer resolution change

Wed Sep 05, 2018 6:49 am

You are right, now it works like a charm but, just for cuoriosity, when can you use MMAL_PARAMETER_RESIZE_T ?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5944
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Dynamic resizer resolution change

Wed Sep 05, 2018 7:06 am

longo92 wrote:
Wed Sep 05, 2018 6:49 am
You are right, now it works like a charm but, just for cuoriosity, when can you use MMAL_PARAMETER_RESIZE_T ?
It is for use on the resize component ("vc.ril.resize")
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

longo92
Posts: 35
Joined: Mon Sep 03, 2018 3:45 pm
Contact: Website Skype

Re: Dynamic resizer resolution change

Thu Sep 06, 2018 7:36 am

OK, i use it on the resizer component ("vc.ril.resize").
If i do like you said it works :
  1. disable port
  2. set up new format
  3. call mmal_port_format_commit
  4. enable port again
  5. provide it buffers (with the porper size and allocating the pool).
If i do using MMAL_PARAM_RESIZE_T it doesn't work:
  1. disable port
  2. setting MMAL_PARAMA_RESIZE_T with the following value
    MMAL_PARAMETER_RESIZE_T param_res;
    param_res.hdr.id = MMAL_PARAMETER_RESIZE_PARAMS;
    param_res.hdr.size = sizeof(param_res);

    param_res.mode = MMAL_RESIZE_NONE;
    param_res.preserve_aspect_ratio = MMAL_TRUE;
    param_res.allow_upscaling = MMAL_FALSE;
    param_res.max_width = desired_width;
    param_res.max_height = desired_height;
  3. Setting the resizer output port
    int ret = mmal_status_to_int(mmal_port_parameter_set(resizer->output[0], &param_res.hdr));
  4. enable port again
  5. provide it buffers (with the porper size and allocating the pool).

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5944
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Dynamic resizer resolution change

Thu Sep 06, 2018 9:29 am

MMAL_PARAMETER_RESIZE_PARAMS is triggered when the INPUT port of resize is enabled, and will trigger a settings changed event on the output port.
It does not support disabling only the output port, changing MMAL_PARAMETER_RESIZE_PARAMS on the output port, and reenabling only the output port.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Graphics programming”