Scale and change format in one call g2d

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Scale and change format in one call g2d

3,278 次查看
marcinch
Contributor II

Dear community,

Is there option to scale and change format in one call of g2d_blit?

The platform is imx8mp where I'm trying convert YUYV (1920x1080) into NV12 (1280x720). In the end g2d_blit returns G2D_STATUS_FAIL.

 

I would be grateful for any tips in this topic.

Regards, Marcin

标记 (2)
0 项奖励
回复
16 回复数

3,252 次查看
joanxie
NXP TechSupport
NXP TechSupport

what processor do you use? you also can refer to the attachment to understand the gpu2d api meanings

0 项奖励
回复

3,247 次查看
marcinch
Contributor II

Processor is i.MX 8M Plus, additionaly table on page 6 is saying that SRC(G2D_YUYV) / DST(G2D_NV12) conversion is possible Y(*).

0 项奖励
回复

3,232 次查看
joanxie
NXP TechSupport
NXP TechSupport

sorry, I missed you mentioned imx8mp already, I checked gpu2d can support this, you can refer to nxp source code, for imx8mp, normally we use imxcompositor_g2d to test this, so I search this source code and attach here, imxcompositor_g2d will call g2d_bilt to do this CSC job, you can refer to the source code

0 项奖励
回复

3,210 次查看
marcinch
Contributor II

How does this relate to the fact that gst-inspect shows that imxcompositor_g2d src pad accept RGB format variants and not YUYV like you suggested?

  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-raw
                 format: { (string)RGB16, (string)RGBx, (string)RGBA, (string)BGRA, (string)BGRx, (string)BGR16, (string)ARGB, (string)ABGR, (string)xRGB, (string)xBGR }
      video/x-raw(memory:SystemMemory, meta:GstVideoOverlayComposition)
                 format: { (string)RGB16, (string)RGBx, (string)RGBA, (string)BGRA, (string)BGRx, (string)BGR16, (string)ARGB, (string)ABGR, (string)xRGB, (string)xBGR }
    Type: GstAggregatorPad
    Pad Properties:
      emit-signals        : Send signals to signal data consumption
                            flags: readable, writable
                            Boolean. Default: false

 

0 项奖励
回复

3,129 次查看
joanxie
NXP TechSupport
NXP TechSupport

I found the code I sent to you removed NV12 as output because of some reason, if you just want to test, you can add it in the code, I tested before, it works, the patch is as below, you also can use imxvideoconvert_g2d

static G2dFmtMap g2d_fmts_map[] = {
{GST_VIDEO_FORMAT_RGB16, G2D_RGB565, 16},
{GST_VIDEO_FORMAT_RGBx, G2D_RGBX8888, 32},
{GST_VIDEO_FORMAT_RGBA, G2D_RGBA8888, 32},
{GST_VIDEO_FORMAT_BGRA, G2D_BGRA8888, 32},
{GST_VIDEO_FORMAT_BGRx, G2D_BGRX8888, 32},
{GST_VIDEO_FORMAT_BGR16, G2D_BGR565, 16},
{GST_VIDEO_FORMAT_ARGB, G2D_ARGB8888, 32},
{GST_VIDEO_FORMAT_ABGR, G2D_ABGR8888, 32},
{GST_VIDEO_FORMAT_xRGB, G2D_XRGB8888, 32},
{GST_VIDEO_FORMAT_xBGR, G2D_XBGR8888, 32},

+{GST_VIDEO_FORMAT_NV12, G2D_NV12, 12},

//this only for separate YUV format and RGB format
{GST_VIDEO_FORMAT_UNKNOWN, -1, 1},

{GST_VIDEO_FORMAT_I420, G2D_I420, 12},
{GST_VIDEO_FORMAT_NV12, G2D_NV12, 12},

0 项奖励
回复

3,119 次查看
marcinch
Contributor II

Refering to g2d-samples there is g2d_basic.c code with several use cases. This code almost shows what I would like to achieve. There is g2d resize test performance section where I modified only src.format and dst.format like below

src.left = 0;
src.top = 0;
src.right = (test_width > 1280) ? 1280 : test_width >> 1;
src.bottom = (test_height > 720) ? 720 : test_height >> 1;
src.stride = (test_width > 1280) ? 1280 : test_width >> 1;
src.width = (test_width > 1280) ? 1280 : test_width >> 1;
src.height = (test_height > 720) ? 720 : test_height >> 1;
src.rot = G2D_ROTATION_0;
src.format= G2D_YUYV;

dst.left = 0;
dst.top = 0;
dst.right = test_width;
dst.bottom = test_height;
dst.stride = test_width;
dst.width = test_width;
dst.height = test_height;
dst.rot = G2D_ROTATION_0;
dst.format= G2D_NV12;
as a result, I'm getting
 
YUYV 90 rotation time 4502us, 222fps, 464Mpixel/s ........
YUYV 270 rotation time 4559us, 219fps, 458Mpixel/s ........
---------------- g2d resize test performance ----------------
resize test from 1280x720 to 1920x1088:
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
g2d_blit_2d: fail with status -1
0 项奖励
回复

3,067 次查看
joanxie
NXP TechSupport
NXP TechSupport

I didn't test this sample code yet, if could pls use imxvideoconvert_g2d , I have built and checked the format support, as I mentioned before, because this is general GPU 2D API for different soc, so internal team removed some formats support, could you confirm your input source is correct format, right? how about testing./g2d_yuv_test 

0 项奖励
回复

2,985 次查看
marcinch
Contributor II
Can we focus on C example what I mentioned in previous comment instead of gstreamer (it isn't main domain of my project)?
0 项奖励
回复

2,969 次查看
joanxie
NXP TechSupport
NXP TechSupport

I don't think I said gstreamer in my last reply, do you mind testing g2d_yuv_test which is simple C code as my last reply mentions?

https://github.com/nxp-imx/g2d-samples/tree/imx_2.1/yuv_test

 

0 项奖励
回复

2,960 次查看
marcinch
Contributor II
~/g2d_samples# ./g2d_yuv_test --format yuyv-nv12 --source 1920x1080 --wh 1920x1080 --dest 1280x720 videotest_1920_1080_YUY2.raw 
Segmentation fault

where videotest_1920_1080_YUY2.raw file was generated by using gst-launch

gst-launch-1.0 --verbose videotestsrc num-buffers=1 ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=1/1 ! videoconvert ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=1/1 ! filesink location=videotest_1920_1080_YUY2.raw

 

0 项奖励
回复

2,832 次查看
joanxie
NXP TechSupport
NXP TechSupport

it seems the command you used isn't correct, I tested successfully, try to refer to my command

joanxie_0-1744459259993.png

 

0 项奖励
回复

2,750 次查看
marcinch
Contributor II

I use the same command and input file as you indicated in your replay and it works!

  • yuyv (1024x768) -> nv12 (1024x768)

1.PNG

I created new raw file with 1920x1080 resolution using ffmpeg tool and I called once again g2d_ yuv_test, and it also works!

  • yuyv (1920x1080) -> nv12 (1920x1080)

2.PNG

The last scenario when I want to change the output format and size simultaneously shows error messages.

  • yuyv (1920x1080) -> nv12 (1280x720)

3.PNG

0 项奖励
回复

2,728 次查看
joanxie
NXP TechSupport
NXP TechSupport

try to set -w 1920x1280

0 项奖励
回复

2,715 次查看
marcinch
Contributor II

Your suggestion is giving same result as in my previous efforts, I mean return status -1.

4.PNG

0 项奖励
回复

2,681 次查看
joanxie
NXP TechSupport
NXP TechSupport

refer to the reference manual, yuv dst resizing doesn't supported by the imx8mp g2d

 

joanxie_1-1744778243732.png

 

 

 

0 项奖励
回复

2,913 次查看
joanxie
NXP TechSupport
NXP TechSupport

ok let me reproduce this and tell you later

0 项奖励
回复