Problems with G2D API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with G2D API

Jump to solution
2,002 Views
christhi
Contributor II

Hi everybody,

I use the I.MX 8M Plus with Hardknott Yocto.

I have a problem understanding and using the G2D API. I try to implement the following:

Input Image ( ARGB32 format, Size(x1,y1)  ) should be converted to Output Image ( RGB format, Size(x2, y2) )

I create the input and output buffers and surfaces in the constructor like that:

g2dInputBuffer  = g2d_alloc(m_inputCameraFormat.height * m_inputCameraFormat.width * 4, 1);
g2dOutputBuffer = g2d_alloc(m_modelInputInformations.height * m_modelInputInformations.width * 3, 1);
inputSurface = new g2d_surface();
inputSurface->format = G2D_XRGB8888;
inputSurface->left = 0;
inputSurface->top = 0;
inputSurface->right = m_inputCameraFormat.width;
inputSurface->bottom = m_inputCameraFormat.height;
inputSurface->stride = m_inputCameraFormat.width;
inputSurface->width = m_inputCameraFormat.width;
inputSurface->height = m_inputCameraFormat.height;
inputSurface->rot = G2D_ROTATION_0;

outputSurface = new g2d_surface();
outputSurface->format = G2D_RGB888;
outputSurface->left = 0;
outputSurface->top = 0;
outputSurface->right = m_modelInputInformations.width;
outputSurface->bottom = m_modelInputInformations.height;
outputSurface->stride = m_modelInputInformations.width;
outputSurface->width = m_modelInputInformations.width;
outputSurface->height = m_modelInputInformations.height;
outputSurface->rot = G2D_ROTATION_0;

 

After that I want the converting for every incoming input frame like that:

    void *handle = nullptr;
g2d_open(&handle);
g2dInputBuffer->buf_vaddr = const_cast<void*>(inputBuffer);
inputSurface->planes[0] = g2dInputBuffer->buf_paddr;
outputSurface->planes[0] = g2dOutputBuffer->buf_paddr;
g2d_blit(handle, inputSurface, outputSurface);
g2d_close(handle);

 

I get the following error message: g2d_blit_2d, line1397: Invalid dst format 10!

Has anybody some help or advice?

Thank you !

Tags (2)
0 Kudos
1 Solution
1,966 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello christhi,

RGB888 is not supported for CSC. Supported SRC/DST CSC format can be found in i.MX_Graphics_User's_Guide.pdf:

Bio_TICFSL_0-1635423072730.png

 

RGBs format: { (string)RGB16, (string)RGBx, (string)RGBA, (string)BGRA, (string)BGRx, (string)BGR16, (string)ARGB, (string)ABGR, (string)xRGB, (string)xBGR }

Regards

View solution in original post

5 Replies
1,967 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello christhi,

RGB888 is not supported for CSC. Supported SRC/DST CSC format can be found in i.MX_Graphics_User's_Guide.pdf:

Bio_TICFSL_0-1635423072730.png

 

RGBs format: { (string)RGB16, (string)RGBx, (string)RGBA, (string)BGRA, (string)BGRx, (string)BGR16, (string)ARGB, (string)ABGR, (string)xRGB, (string)xBGR }

Regards

1,818 Views
quercuspau
Contributor II

Hello,

From this table, I understand that all the formats from src column can be converted to RGB.

Regarding to RGB888, IMX Graphics user guide mentions:

• RGB pixel buffer only uses planes [0], buffer address is with 16 bytes alignment on i.MX 6 (except i.MX 6Quad Plus), 1 pixel alignment on i.MX 6Quad Plus, i.MX 7ULP and i.MX 8 family devices.
• NV12: Y in planes [0], UV in planes [1], with 64bytes alignment,
• I420: Y in planes [0], U in planes [1], U in planes [2], with 64 bytes alignment
• The cropped region in source surface is specified with left, top, right and bottom parameters.
• RGB stride alignment is 16 bytes on i.MX 6 (except i.MX 6Quad Plus), 1 pixel alignment on i.MX 6Quad Plus, i.MX 7ULP and i.MX 8 family devices, both for source and destination surface.
....

If I understood correctly, i.MX 6 (except i.MX 6Quad Plus) only support 16/32 bits RGB. However other IMX that uses G2D doesn't have this limitation, only requires pixel alignment that can be 8/16/24/32 bits. In this case, RGB888 should work.

Am I wrong?

Thanks for you support

 

0 Kudos
1,939 Views
christhi
Contributor II

Hello,

is it possible to "delete" the alpha channel from the RGBA8888 image using only the G2D API? I need a RGB888 image and at this moment I use the sharing buffers mechanism. For scaling I use the g2d API and after that I convert the image to RGB888 using OpenCV. Because I can't use OpenCV for GPU acceleration I would prefer only using the G2D API.

Thank you for your help !

0 Kudos
1,048 Views
malik_cisse
Senior Contributor I

Hi Christhi,
Could you solve this issue.
I am using imx8mp CPU and YUYV to RGB G2D conversion can only output RGBs8888 (32bit).
Like you I need RGB888 (24bit). I don't want to use OpenCV or other processing. I would like to do this entirely in the GPU.
Thank you,

0 Kudos
1,943 Views
christhi
Contributor II

Hello,

thank you for that !

I thought the RGBs format contains the RGB888 format.

0 Kudos