Page 1 of 1

MMAL Image decoder

Posted: Mon Jul 13, 2020 11:48 am
by longo92
Hi,
Is there a way to force the image decoder to use the pixel format on output port chosen by the user when enbaling the port, instead of being modified by MMAL_EVENT_FORMAT_CHANGED.
I'm writing my own c++ image decoder class (wrapper around mmal decoder, based on this: https://github.com/6by9/userland/blob/h ... peg/jpeg.c).

More precisely, the output port supports the following formats:

image decoder port vc.ril.image_decode:out:0 supported encodings: RGB2 //aka RGB_5_6_5
image decoder port vc.ril.image_decode:out:0 supported encodings: I420
image decoder port vc.ril.image_decode:out:0 supported encodings: I422
image decoder port vc.ril.image_decode:out:0 supported encodings: RGBA
image decoder port vc.ril.image_decode:out:0 supported encodings: BGRA

I set RGB2, in the setup phase, but when i decode :
-in a PNG image the MMAL_EVENT_FORMAT_CHANGED switches to RGBA.
-in a JPEG image the MMAL_EVENT_FORMAT_CHANGED switches to I420.
Is there a way to avoid that and force the decoder to use the format chosen by the user ?

Another question: the MMAL_ENCODING_OPAQUE is not listed, is it correct? I'm using firmware of 12/02/2020. (There was a similar problem with the video decoder viewtopic.php?f=67&t=226416&p=1390005#p1390005).


Thanks,
Alessandro

Re: MMAL Image decoder

Posted: Mon Jul 13, 2020 12:39 pm
by 6by9
longo92 wrote:
Mon Jul 13, 2020 11:48 am
Hi,
Is there a way to force the image decoder to use the pixel format on output port chosen by the user when enbaling the port, instead of being modified by MMAL_EVENT_FORMAT_CHANGED.
I'm writing my own c++ image decoder class (wrapper around mmal decoder, based on this: https://github.com/6by9/userland/blob/h ... peg/jpeg.c).

More precisely, the output port supports the following formats:

image decoder port vc.ril.image_decode:out:0 supported encodings: RGB2 //aka RGB_5_6_5
image decoder port vc.ril.image_decode:out:0 supported encodings: I420
image decoder port vc.ril.image_decode:out:0 supported encodings: I422
image decoder port vc.ril.image_decode:out:0 supported encodings: RGBA
image decoder port vc.ril.image_decode:out:0 supported encodings: BGRA

I set RGB2, in the setup phase, but when i decode :
-in a PNG image the MMAL_EVENT_FORMAT_CHANGED switches to RGBA.
-in a JPEG image the MMAL_EVENT_FORMAT_CHANGED switches to I420.
Is there a way to avoid that and force the decoder to use the format chosen by the user ?
If you wish to change the format, then do so after the MMAL_EVENT_FORMAT_CHANGED event.
However there are restrictions in that the decoders are decoding directly into the provided output buffer, therefore the codec has to natively support decode into that format.
GIF supports RGB565
BMP, PNG, PPM, and TGA support RGBA.
JPEG supports I420 or I422.
So largely you don't have a choice of format.
longo92 wrote:Another question: the MMAL_ENCODING_OPAQUE is not listed, is it correct? I'm using firmware of 12/02/2020. (There was a similar problem with the video decoder viewtopic.php?f=67&t=226416&p=1390005#p1390005).
OPAQUE means pass a reference to the internal image pool which is used for reference frames and similar.
The image codecs don't use an internal image pool as the codecs decode directly into the output buffer, therefore it is correct that they don't support MMAL_ENCODING_OPAQUE.

Re: MMAL Image decoder

Posted: Mon Jul 13, 2020 1:00 pm
by longo92
Thanks for the clarification.
Is there some doc where i can get the detalide info you gave me, in particular:
GIF supports RGB565
BMP, PNG, PPM, and TGA support RGBA.
JPEG supports I420 or I422.
Or Do you gather them using OpenMax calls?
However there are restrictions in that the decoders are decoding directly into the provided output buffer, therefore the codec has to natively support decode into that format.
Do you mean that if i set RGBA will be a conversion stage (performed by isp) ?

Re: MMAL Image decoder

Posted: Mon Jul 13, 2020 1:52 pm
by 6by9
longo92 wrote:
Mon Jul 13, 2020 1:00 pm
Thanks for the clarification.
Is there some doc where i can get the detalide info you gave me, in particular:
GIF supports RGB565
BMP, PNG, PPM, and TGA support RGBA.
JPEG supports I420 or I422.
Or Do you gather them using OpenMax calls?
I don't know of any docs or functional calls to retrieve that. I referred back to the firmware source as I knnew there was a table of codecs and compatible formats towards the top of the file.
longo92 wrote:
However there are restrictions in that the decoders are decoding directly into the provided output buffer, therefore the codec has to natively support decode into that format.
Do you mean that if i set RGBA will be a conversion stage (performed by isp) ?
No, I mean you can swap between I420 and I422 for JPEG. I thought some of the other codecs supported a number of output bit depths, but seemingly not. I'm slightly surprised as for encode the codecs are more accepting on formats.
There are no internal conversions available within image_decode.

AltStyle によって変換されたページ (->オリジナル) /