Posts: 3
Joined: Mon Jun 24, 2019 2:27 pm

Support for Luminance (Grayscale) Formats?

Mon Jun 24, 2019 2:48 pm


I'm trying to encode/save a live video feed from a monochrome CMOS camera for a scientific application. I would like to pass an uncompressed 8 or 16 bit grayscale buffer to the OpenMAX encoder, using the OMX_COLOR_FormatL8 or OMX_COLOR_FormatL16. However, when I do this, I get an "illegal parameter" error:

Code: Select all = CAMERA_RESOLUTION_X; = CAMERA_RESOLUTION_Y; = 30 << 16; =; =; = OMX_COLOR_FormatL8; // DOESN'T WORK!
Converting the buffer to 8-8-8 RGB and changing the last two lines as follows works fine:

Code: Select all = * 3; = OMX_COLOR_Format24bitRGB888;
My question is: does the raspberry pi encoder support luminance/gray formats? If so what am I setting wrong in the parameter? If not, is there an available YUV format that maxes out the luminance value? (i.e. something like "YUV16:0:0"). And on that note, how can I list all available/supported OpenMAX formats on the pi?

There's also scarce documentation about nSliceHeight for uncompressed non-planar formats. I'm setting it to the entire frameheight, but I'm not sure if I should be setting it to a smaller value like 16 - any advice there would be appreciated.

My full code snippet is here if that helps:

Thanks very much!

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

Re: Support for Luminance (Grayscale) Formats?

Tue Jun 25, 2019 8:13 am

To check the formats support by a port, you enumerate them through OMX_<domain>_PARAM_PORTFORMATTYPE, eg for an image domain port.
OMX_IMAGE_PARAM_PORTFORMATTYPE is used to enumerate the various data input/output format supported by the port
No, there is no support for just luma formats, however using OMX_COLOR_FormatYUV420PackedPlanar and setting the chroma to 128 would give the same results. There are no 16bit per component image formats supported.

nSliceHeight controls the height of each slice. The spec is a little woolly as to whether the client or component sets it, so we generally allow the client to do so if the component supports it. If it doesn't support it then it'll reject the port format.
Setting it to less than the frameheight (often the frame height rounded up to a multiple of 16) is generally only useful if you are in a very low memory situation, and you'll then want several buffers allocated to avoid stalling both sides as 1 buffer gets passed back and forth. Typically components accept a value of either 16 or aligned frameheight, and not intermediate values.
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.

Posts: 3
Joined: Mon Jun 24, 2019 2:27 pm

Re: Support for Luminance (Grayscale) Formats?

Wed Jun 26, 2019 1:54 am

Fantastic, thanks for the information!

Return to “OpenMAX”