MVVadim
Posts: 7
Joined: Sat Feb 09, 2013 11:02 am

Hardware accelerated video scaling

Mon Feb 18, 2013 9:16 am

Hello everybody,
Could you tell me, please, is there such a thing like hardware accelerated upscaling? I need to change size of frames before displaying them.

linuxstb
Posts: 77
Joined: Sat Jul 07, 2012 11:07 pm

Re: Hardware accelerated video scaling

Mon Feb 18, 2013 5:31 pm

Yes. If you use the video_render component (the standard way to play video), then the default behaviour is for it to scale full-screen. You need to do something special to not display it full-screen.

MVVadim
Posts: 7
Joined: Sat Feb 09, 2013 11:02 am

Re: Hardware accelerated video scaling

Tue Feb 19, 2013 11:04 am

Thanks! Can I adjust it to simply read raw video data from file and display it in full-screen mode? As I understood, if a video frame has another aspect ratio than target display, then I will have black bars on my screen?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23682
Joined: Sat Jul 30, 2011 7:41 pm

Re: Hardware accelerated video scaling

Tue Feb 19, 2013 1:33 pm

MVVadim wrote:Thanks! Can I adjust it to simply read raw video data from file and display it in full-screen mode? As I understood, if a video frame has another aspect ratio than target display, then I will have black bars on my screen?
Well, if you retain aspect ratio, and the screen is a different aspect to the source imagery, then you will have black bars.

As for feeding data in to the video_render component, you will need to write some buffer handling code to transfer data from where you have it to where the renderer wants it.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

mpr
Posts: 22
Joined: Wed Mar 27, 2013 6:56 pm

Re: Hardware accelerated video scaling

Thu Apr 18, 2013 7:40 pm

Depending on what sort of scaling you want to do, I've had very good luck with using the OMX_CONFIG_DISPLAYREGIONTYPE structure. My experience with the Broadcom OMX is that out of the box it basically upscales everything to whatever the output screen resolution is. I use the code below to place my videos at the top left of the screen at their original resolution. You can play with the output dimensions and screen coordinates and get all sorts of scaling effects.

Invoke this before setting the state of video_render to "executing".

Code: Select all

OMX_CONFIG_DISPLAYREGIONTYPE drt;
memset(&drt, 0, sizeof(drt));
drt.nVersion.nVersion = OMX_VERSION;
drt.nSize = sizeof(drt);
drt.nPortIndex = 90;
drt.src_rect.x_offset=0;
drt.src_rect.y_offset=0;
drt.src_rect.width=*width*
drt.src_rect.height=*height*
drt.dest_rect.x_offset=0;
drt.dest_rect.y_offset=0;
drt.dest_rect.width=*width*
drt.dest_rect.height=*height*
drt.fullscreen = OMX_FALSE;
drt.noaspect = OMX_TRUE;

drt.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_SRC_RECT | OMX_DISPLAY_SET_DEST_RECT | OMX_DISPLAY_SET_FULLSCREEN | OMX_DISPLAY_SET_NOASPECT);
if(OMX_SetConfig(ILC_GET_HANDLE(video_render), OMX_IndexConfigDisplayRegion, &drt) != OMX_ErrorNone) {
  //error handling
}

Return to “OpenMAX”