VPP convert YV12 to RGB4

VPP convert YV12 to RGB4

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[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;
    }

Thanks.

5 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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;

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.

Fichiers joints: 

Fichier attachéTaille
Télécharger imgconverti.png525.94 Ko
Télécharger forza480.bmp1012.55 Ko
Télécharger imgconverti1.png482.31 Ko

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

ok thks andy.

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui