Frame allocator

Frame allocator

Hi,

I am trying to develop a decoding application using IMSDK. I am facing issues with the frame allocator. 

First, I try the application provided by imsdk : sample_decode.exe mpeg2 -i test.m2v -o test.yuv -hw. In this case (hardware implementation, API version 1.0), frame allocator is called "by hand" in the CDecodingPipeline::AllocFrames function. It is never called during the m_pmfxDEC->Init() call. I am actually in the case of system memory allocations.

Then, I try to implement the same in my application. I do have exactly the same parameters as input for each MFX call (I use C API instead of C++, but I do not think it matters), but during the MFXVideoDECODE_Init call, frame allocator is called and request d3d surfaces. 

How can I reproduce the behavior of the sample_decode code ?

Thanks for your help

2 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.

Hi,

without details on your implementation it is hard to say what exactly is going on.

But, if you used the sample memory allocator classes which are part of the SDK and you initialized them using MFX_IOPATTERN_OUT_SYSTEM_MEMORY then there is no reason the D3D frame allocator should be called.

Note that if you plan to use only system memory surfaces for decode then you are not required to create a frame allocator. You can instead allocate your surfaces manually as in the code example below.

Regards,
Petter

// Query number of required surfaces for decoder
mfxFrameAllocRequest Request;
memset(&Request, 0, sizeof(Request));
sts = mfxDEC.QueryIOSurf(&mfxVideoParams, &Request);
MSDK_IGNORE_MFX_STS(sts, MFX_WRN_PARTIAL_ACCELERATION);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);

mfxU16 numSurfaces = Request.NumFrameSuggested;

// Allocate surfaces for decoder
// - Width and height of buffer must be aligned, a multiple of 32
// - Frame surface array keeps pointers all surface planes and general frame info
mfxU16 width = (mfxU16)MSDK_ALIGN32(Request.Info.Width);
mfxU16 height = (mfxU16)MSDK_ALIGN32(Request.Info.Height);
mfxU8 bitsPerPixel = 12; // NV12 format is a 12 bits per pixel format
mfxU32 surfaceSize = width * height * bitsPerPixel / 8;
mfxU8* surfaceBuffers = (mfxU8 *)new mfxU8[surfaceSize * numSurfaces];

mfxFrameSurface1** pmfxSurfaces = new mfxFrameSurface1*[numSurfaces];
MSDK_CHECK_POINTER(pmfxSurfaces, MFX_ERR_MEMORY_ALLOC);
for (int i = 0; i < numSurfaces; i++)
{
pmfxSurfaces[i] = new mfxFrameSurface1;
memset(pmfxSurfaces[i], 0, sizeof(mfxFrameSurface1));
memcpy(&(pmfxSurfaces[i]->Info), &(mfxVideoParams.mfx.FrameInfo), sizeof(mfxFrameInfo));
pmfxSurfaces[i]->Data.Y = &surfaceBuffers[surfaceSize * i];
pmfxSurfaces[i]->Data.U = pmfxSurfaces[i]->Data.Y + width * height;
pmfxSurfaces[i]->Data.V = pmfxSurfaces[i]->Data.U + 1;
pmfxSurfaces[i]->Data.Pitch = width;
}

.

Laisser un commentaire

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