VPP convert YV12 to RGB4

VPP convert YV12 to RGB4

imagem de Valentin P.

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


5 posts / 0 new
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de andy4us

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

try :

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

imagem de Valentin P.

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[i]->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[i]->Data.R = &surfaceBuffersOut[surfaceSize * i];
        pVPPSurfacesOut[i]->Data.G =  pVPPSurfacesOut[i]->Data.R +width*height;
        pVPPSurfacesOut[i]->Data.B =  pVPPSurfacesOut[i]->Data.G +width*height;
        pVPPSurfacesOut[i]->Data.A =  pVPPSurfacesOut[i]->Data.B + width*height;
        pVPPSurfacesOut[i]->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.


Download imgconverti.png525.94 KB
Download forza480.bmp1012.55 KB
Download imgconverti1.png482.31 KB
imagem de andy4us

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[i]->Data.B = &surfaceBuffersOut[surfaceSize * i];
        pVPPSurfacesOut[i]->Data.G =  pVPPSurfacesOut[i]->Data.B + 1;
        pVPPSurfacesOut[i]->Data.R =  pVPPSurfacesOut[i]->Data.B + 2;
        pVPPSurfacesOut[i]->Data.A =  pVPPSurfacesOut[i]->Data.B + 3;

      pVPPSurfacesOut[i]->Data.Pitch = 720*4;

Your images are typical of mixing planar and chunky data

imagem de Valentin P.

ok thks andy.

Faça login para deixar um comentário.