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

set the decode parameters using sps

Mon Mar 11, 2019 10:13 am

Hi,
Is there a way to set the decoder width and heigth of the input/output port using the sps? I know that pass it in the extradata field in the format input port (like in the example https://github.com/raspberrypi/userland ... _basic_2.c) is used to set the h264 prifile, level etc..... Thanks!

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

Re: set the decode parameters using sps

Mon Mar 11, 2019 11:42 am

The width/height parameters on the input port don't matter.

Just pass the SPS/PPS headers into the codec as normal buffers and the component will process them. If you felt like it then you could set the MMAL_BUFFER_HEADER_FLAG_CONFIG flag as well so the codec knows the content before parsing.
Passing them as extradata allows a slight speed optimisation on startup, but it's not needed.
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.

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

Re: set the decode parameters using sps

Mon Mar 11, 2019 5:02 pm

OK, it works. For the output port is there a similar trick?

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

Re: set the decode parameters using sps

Mon Mar 11, 2019 5:36 pm

longo92 wrote:
Mon Mar 11, 2019 5:02 pm
OK, it works. For the output port is there a similar trick?
What sort of trick are you envisaging?
IIRC If you set the output port parameters to exactly match what the codec is going to produce then it should happily skip the FORMAT_CHANGED step and immediately start decoding frames. Beyond that I can't see anything much that you can really expect to be going on with the output port.
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.

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

Re: set the decode parameters using sps

Mon Mar 11, 2019 6:32 pm

I mean if you don't know the resolution of the incoming streaming and you want infer at run time. Is there a way? For inpurt port is passing the sps/pps but what options for the output port?

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

Re: set the decode parameters using sps

Mon Mar 11, 2019 8:58 pm

longo92 wrote:
Mon Mar 11, 2019 6:32 pm
I mean if you don't know the resolution of the incoming streaming and you want infer at run time. Is there a way? For inpurt port is passing the sps/pps but what options for the output port?
Configure the input port to be encoding H264. Pass the SPS/PPS into the input port. You'll get a MMAL_EVENT_FORMAT_CHANGED event on the output port which provides you the detected format - that's what the conditional starting at https://github.com/raspberrypi/userland ... c_2.c#L290 is handling.
This is true for any decoding component, so would also be true for MJPEG decoding, or for use with image_decode for JPEG/PNG/GIF/BMP decoding.
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.

Return to “Graphics programming”