I'm using the simple_2_decode sample, instead of writing to file I wanted to write to memory. Somewhere along the way I'm getting some bad output. Here are the two functions where I take the output surface and write to an external buffer.
If anymore information is required to help debug, please let me know.
I'm doing H264 (ES) -> NV12 -> YUV420 in memory
mfxStatus WriteSectionMemory(mfxU8* plane, mfxU16 factor, mfxU16 chunksize, mfxFrameInfo* pInfo, mfxFrameData* pData, mfxU32 i, mfxU32 j, unsigned char* out) { mfxU8* plane2 = plane + (pInfo->CropY * pData->Pitch / factor + pInfo->CropX) + i * pData->Pitch + j; int test = (int)memcpy(out, plane2, chunksize); if (chunksize != test) return MFX_ERR_UNDEFINED_BEHAVIOR; return MFX_ERR_NONE; } int WriteRawFrame(mfxFrameSurface1* pSurface, unsigned char *output) { mfxFrameInfo* pInfo = &pSurface->Info; mfxFrameData* pData = &pSurface->Data; mfxU32 i, j, h, w; mfxI32 pitch, nByteWrite; mfxU8* ptr; unsigned char *poutput = output; mfxStatus sts = MFX_ERR_NONE; int frameBytes = 0; for (i = 0; i < pInfo->CropH; i++) { sts = WriteSectionMemory(pData->Y, 1, pInfo->CropW, pInfo, pData, i, 0, poutput); poutput += pInfo->CropW; frameBytes += pInfo->CropW; } h = pInfo->CropH/2; w = pInfo->CropW; for (i = 0; i < h; i++) { for (j = 0; j < w; j += 2) { sts = WriteSectionMemory(pData->UV, 2, 1, pInfo, pData, i, j, poutput); poutput += 1; frameBytes++; } } for (i = 0; i < h; i++) { for (j = 1; j < w; j += 2) { sts = WriteSectionMemory(pData->UV, 2, 1, pInfo, pData, i, j, poutput); poutput += 1; frameBytes++; } } return frameBytes; }
Below is what the output looks like when using the normal file writing functions, and the bad output is from these memory output functions. Any ideas on what could be causing the warping/discoloration?