anderson110
Posts: 2
Joined: Wed Aug 28, 2019 3:57 am

MMAL_DISPLAY_SET_DEST_RECT usage

Wed Aug 28, 2019 4:08 am

I am getting started with some mmal based code to process video from the raspberry pi camera. I am trying to render a preview to the screen, and there's something that's confusing me.

In all the examples I can find, you can either render full screen, in which case you set:

MMAL_DISPLAYREGION_T param;
...
param.set |= MMAL_DISPLAY_SET_FULLSCREEN;
param.fullscreen = 1;

OR you can render to a rect, in which case the example code is:

param.set |= (MMAL_DISPLAY_SET_DEST_RECT | MMAL_DISPLAY_SET_FULLSCREEN);
param.fullscreen = 0;
param.dest_rect = [...];

(see, for example, here: https://github.com/raspberrypi/userland ... iew.c#L120)

My question is: why do you set the MMAL_DISPLAY_SET_FULLSCREEN flag in the case when you're not rendering full screen? If you remove it, no rendering appears. With it included, rendering to the specified dest_rect occurs. This seems pretty confusing, but maybe I'm missing something.

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

Re: MMAL_DISPLAY_SET_DEST_RECT usage

Wed Aug 28, 2019 10:31 am

MMAL_DISPLAYREGION_T has members for setting up many different parameters. You may not wish to set all of them in any one particular update call, therefore the set field dictates which sets of fields should be updated on this call.

In your case you wish to update fullscreen (to a value of 0 as it defaults to 1), hence you have to set MMAL_DISPLAY_SET_FULLSCREEN in set.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

anderson110
Posts: 2
Joined: Wed Aug 28, 2019 3:57 am

Re: MMAL_DISPLAY_SET_DEST_RECT usage

Wed Aug 28, 2019 3:00 pm

Ah! That seems at least approximately coherent now. Thank you.

(Seems like an odd design, though. If you have to set both the param and a flag that you want to set the param, wouldn't it be simpler and less error prone to have setters for each parameter?)

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

Re: MMAL_DISPLAY_SET_DEST_RECT usage

Wed Aug 28, 2019 3:20 pm

It all comes from the older OpenMax IL API and OMX_IndexConfigDisplayRegion
http://www.jvcref.com/files/PI/document ... playRegion
It is a vendor specific extension, but would have been added back in around 2007-2008. You learn a lot over time working with these forms of APIs, but backwards compatibility means you have to live with earlier decisions.
Individual parameters for each portion becomes lots of boiler plate, and makes it impossible to change several parameters in an atomic manner. Each call would also require a round trip to the GPU, therefore setting multiple parameters would take longer.

I'll agree that doing a "get" to get all the current settings, modify the overall structure, and then a set, would have been a nicer API in some regards, but there you go.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
dividuum
Posts: 181
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

Re: MMAL_DISPLAY_SET_DEST_RECT usage

Fri Aug 30, 2019 3:18 pm

6by9 wrote:
Wed Aug 28, 2019 3:20 pm
It all comes from the older OpenMax IL API and OMX_IndexConfigDisplayRegion
While we're at it: Is there any difference in setting fullscreen to 1 compared to 0 and then setting the dest_rect to the full screen size? The result in `vcgencmd dispmanx_list` is exactly the same as expected. Is there some hidden optimization somewhere or does it just make things easier if you don't want to deal with screen sizes?
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

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

Re: MMAL_DISPLAY_SET_DEST_RECT usage

Fri Aug 30, 2019 3:36 pm

dividuum wrote:
Fri Aug 30, 2019 3:18 pm
While we're at it: Is there any difference in setting fullscreen to 1 compared to 0 and then setting the dest_rect to the full screen size? The result in `vcgencmd dispmanx_list` is exactly the same as expected. Is there some hidden optimization somewhere or does it just make things easier if you don't want to deal with screen sizes?
I don't think it makes any realy difference.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
dividuum
Posts: 181
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

Re: MMAL_DISPLAY_SET_DEST_RECT usage

Fri Aug 30, 2019 3:39 pm

I don't think it makes any realy difference.
Thanks.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

Return to “Graphics programming”