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

Support for Luminance (Grayscale) Formats?

Mon Jun 24, 2019 2:48 pm

Hi,

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

    def.format.video.nFrameWidth = CAMERA_RESOLUTION_X;
    def.format.video.nFrameHeight = CAMERA_RESOLUTION_Y;
    def.format.video.xFramerate = 30 << 16;
    def.format.video.nSliceHeight = def.format.video.nFrameHeight;
    def.format.video.nStride = def.format.video.nFrameWidth;
    def.format.video.eColorFormat = 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

   def.format.video.nStride = def.format.video.nFrameWidth * 3;
   def.format.video.eColorFormat = 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:
https://github.com/deganii/ids/blob/master/main.c#L410

Thanks very much!
Ismail

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7131
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.
4.4.4 OMX_IMAGE_PARAM_PORTFORMATTYPE
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.

idegani
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”