Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

VPP convert YV12 to RGB4

Valentin_P_1
Beginner
558 Views

Hi ! I try to convert a frame YUV420 to RGB32 with vpp conversion but when i draw the new picture I don't retrieve the same picture

I think the problem is the initialization of mfxframesurface for RGB4.

My code :

  // Allocate surfaces for VPP: Out
    width = (mfxU16)VPPParams.vpp.Out.Width;
    height = (mfxU16)VPPParams.vpp.Out.Height;
   surfaceSize = width * height*4 ;
    mfxU8* surfaceBuffersOut = (mfxU8 *)new mfxU8[surfaceSize * nVPPSurfNumOut];

    pVPPSurfacesOut = new mfxFrameSurface1*[nVPPSurfNumOut];
    MSDK_CHECK_POINTER(pVPPSurfacesOut, MFX_ERR_MEMORY_ALLOC);
    for (int i = 0; i < nVPPSurfNumOut; i++)
    {       
        pVPPSurfacesOut = new mfxFrameSurface1;
        memset(pVPPSurfacesOut, 0, sizeof(mfxFrameSurface1));
        memcpy(&(pVPPSurfacesOut->Info), &(VPPParams.vpp.Out), sizeof(mfxFrameInfo));
        pVPPSurfacesOut->Data.R = &surfaceBuffersOut[surfaceSize * i];
        pVPPSurfacesOut->Data.G =  pVPPSurfacesOut->Data.R + width * height;
        pVPPSurfacesOut->Data.B =  pVPPSurfacesOut->Data.R + width * height*2;
        pVPPSurfacesOut->Data.A =  pVPPSurfacesOut->Data.R + width * height*3;
        pVPPSurfacesOut->Data.Pitch = width;
    }

Thanks.

0 Kudos
4 Replies
andy4us
Beginner
558 Views

Not sure the output is planar, I think it is probably chunky

try :

        pVPPSurfacesOut->Data.R = &surfaceBuffersOut[surfaceSize * i];
        pVPPSurfacesOut->Data.G =  pVPPSurfacesOut->Data.R + 1;
        pVPPSurfacesOut->Data.B =  pVPPSurfacesOut->Data.R + 2;
        pVPPSurfacesOut->Data.A =  pVPPSurfacesOut->Data.R + 3;

0 Kudos
Valentin_P_1
Beginner
558 Views

If i try this and I display the pVPPSurfacesOut[nSurfIdxOut]->Data.R, pVPPSurfacesOut[nSurfIdxOut]->Data.G, pVPPSurfacesOut[nSurfIdxOut]->Data.B and pVPPSurfacesOut[nSurfIdxOut]->Data.A. I find the picture imgconverti.png. The real picture is forza480.bmp. But I change the pitch  (pVPPSurfacesOut->Data.Pitch = 720*4;) I find the imgconverti1.png. If I copy the R with Height*Width*4 I find the correct picture. The problem is the pitch?

If i do this :

pVPPSurfacesOut->Data.R = &surfaceBuffersOut[surfaceSize * i];
        pVPPSurfacesOut->Data.G =  pVPPSurfacesOut->Data.R +width*height;
        pVPPSurfacesOut->Data.B =  pVPPSurfacesOut->Data.G +width*height;
        pVPPSurfacesOut->Data.A =  pVPPSurfacesOut->Data.B + width*height;
        pVPPSurfacesOut->Data.Pitch = 720*4;

I retrieve the Width*Height/4 picture in R, the second Width*Height/4 picture in G, ... I display the correct picture.

0 Kudos
andy4us
Beginner
558 Views

I'm doing RGB4 to NV12, the opposite to you. However, I suspect that this is true. The data is stored as chunky, not planar. It is also BGRA, not RGBA. So in memory, the image data is stored as BGRA, BGRA, not BBBBBBBBBB, GGGGGGGGGGG, RRRRRRRRR, AAAAAAAAAAA etc. That is why you can just copy width*height*4 and you get the correct image. Base on what I see when I do RGBA to NV12, I still think the correct way to initialise it is

    pVPPSurfacesOut->Data.B = &surfaceBuffersOut[surfaceSize * i];
        pVPPSurfacesOut->Data.G =  pVPPSurfacesOut->Data.B + 1;
        pVPPSurfacesOut->Data.R =  pVPPSurfacesOut->Data.B + 2;
        pVPPSurfacesOut->Data.A =  pVPPSurfacesOut->Data.B + 3;

      pVPPSurfacesOut->Data.Pitch = 720*4;

Your images are typical of mixing planar and chunky data

0 Kudos
Valentin_P_1
Beginner
558 Views

ok thks andy.

0 Kudos
Reply