- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use linux media sdk:
i have a problem about MFX_ERR_INCOMPATIBLE_VIDEO_PARAM,why?
h264 stream-->decode(it's ok) -->vpp(sts = MFX_ERR_INCOMPATIBLE_VIDEO_PARAM),i don't know why return the error.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Process:
(network stream)h264->decoder(nv12)->vpp(rgb32).
it's ok but when i revise the source stream width( 1156),vpp return MFX_ERR_INCOMPATIBLE_VIDEO_PARAM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this is source file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The actual surface width and height have must be multiple of 16, but the "Crop" values can be use to describe the are of the surface that contain data of interest.
Width and height of the video frame in pixels; Width must be a multiple of 16. Height must be a multiple of 16 for progressive frame sequence and a multiple of 32 otherwise. |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks u repy now width height already multiple of 16 in code. i don't know where code the problem.
h264->nv12->rgb32
sts = ReadBitStreamData1(&mfxBS, data, length); data = NULL;length = 0; //sts = ReadBitStreamData1(&mfxBS, _data, _data_end); LOG_INFO("line:%d,sts:%d",__LINE__, sts); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); sts = pmfxDEC->DecodeHeader(&mfxBS, &mfxVideoParams); LOG_INFO("line:%d,sts:%d",__LINE__,sts ); //mfxVideoParams.mfx.FrameInfo.FourCC=MFX_FOURCC_RGB4; //mfxVideoParams.mfx.JPEGColorFormat= MFX_CHROMAFORMAT_YUV444; //mfxVideoParams.mfx.JPEGColorFormat= MFX_JPEG_COLORFORMAT_RGB; MSDK_IGNORE_MFX_STS(sts, MFX_WRN_PARTIAL_ACCELERATION); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); mfxVideoParams.AsyncDepth = 1; printf(" AsyncDepth:%d\n", mfxVideoParams.AsyncDepth); // Validate video decode parameters (optional) //sts = pmfxDEC->Query(&mfxVideoParams, &mfxVideoParams); //MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); printf("xx w:%d,h:%d\n", mfxVideoParams.mfx.FrameInfo.CropW, mfxVideoParams.mfx.FrameInfo.CropH); // Initialize VPP parameters // - For simplistic memory management, system memory surfaces are used to store the raw frames // (Note that when using HW acceleration D3D surfaces are prefered, for better performance) memset(&VPPParams, 0, sizeof(VPPParams)); // Input data VPPParams.vpp.In.FourCC = MFX_FOURCC_NV12; VPPParams.vpp.In.ChromaFormat = MFX_CHROMAFORMAT_YUV420; VPPParams.vpp.In.CropX = 0; VPPParams.vpp.In.CropY = 0; VPPParams.vpp.In.CropW = mfxVideoParams.mfx.FrameInfo.CropW; VPPParams.vpp.In.CropH = mfxVideoParams.mfx.FrameInfo.CropH; VPPParams.vpp.In.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; VPPParams.vpp.In.FrameRateExtN = 30; VPPParams.vpp.In.FrameRateExtD = 1; // width must be a multiple of 16 // height must be a multiple of 16 in case of frame picture and a multiple of 32 in case of field picture VPPParams.vpp.In.Width = MSDK_ALIGN16(VPPParams.vpp.In.CropW); VPPParams.vpp.In.Height = (MFX_PICSTRUCT_PROGRESSIVE == VPPParams.vpp.In.PicStruct)? MSDK_ALIGN16(VPPParams.vpp.In.CropH) : MSDK_ALIGN32(VPPParams.vpp.In.CropH); // Output data VPPParams.vpp.Out.FourCC = MFX_FOURCC_RGB4; VPPParams.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_YUV420; VPPParams.vpp.Out.CropX = 0; VPPParams.vpp.Out.CropY = 0; //VPPParams.vpp.Out.CropW = VPPParams.vpp.In.CropW/2; // Resize to half size resolution //VPPParams.vpp.Out.CropH = VPPParams.vpp.In.CropH/2; VPPParams.vpp.Out.CropW = VPPParams.vpp.In.CropW; // Resize to half size resolution VPPParams.vpp.Out.CropH = VPPParams.vpp.In.CropH; VPPParams.vpp.Out.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; VPPParams.vpp.Out.FrameRateExtN = 30; VPPParams.vpp.Out.FrameRateExtD = 1; // width must be a multiple of 16 // height must be a multiple of 16 in case of frame picture and a multiple of 32 in case of field picture VPPParams.vpp.Out.Width = MSDK_ALIGN16(VPPParams.vpp.Out.CropW); VPPParams.vpp.Out.Height = (MFX_PICSTRUCT_PROGRESSIVE == VPPParams.vpp.Out.PicStruct)? MSDK_ALIGN16(VPPParams.vpp.Out.CropH) : MSDK_ALIGN32(VPPParams.vpp.Out.CropH); VPPParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY | MFX_IOPATTERN_OUT_SYSTEM_MEMORY; // Query number of required surfaces for decoder mfxFrameAllocRequest DecRequest; memset(&DecRequest, 0, sizeof(DecRequest)); sts = pmfxDEC->QueryIOSurf(&mfxVideoParams, &DecRequest); MSDK_IGNORE_MFX_STS(sts, MFX_WRN_PARTIAL_ACCELERATION); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); // Query number of required surfaces for VPP mfxFrameAllocRequest VPPRequest[2];// [0] - in, [1] - out memset(&VPPRequest, 0, sizeof(mfxFrameAllocRequest)*2); sts = pmfxVPP->QueryIOSurf(&VPPParams, VPPRequest); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); // Determine the required number of surfaces for decoder output (VPP input) and for VPP output nSurfNumDecVPP = DecRequest.NumFrameSuggested + VPPRequest[0].NumFrameSuggested; nSurfNumVPPOut = VPPRequest[1].NumFrameSuggested; // Allocate surfaces for decoder and VPP In // - 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(DecRequest.Info.Width); mfxU16 height = (mfxU16)MSDK_ALIGN32(DecRequest.Info.Height); mfxU8 bitsPerPixel = 12; // NV12 format is a 12 bits per pixel format mfxU32 surfaceSize = width * height * bitsPerPixel / 8; surfaceBuffers = (mfxU8 *)new mfxU8[surfaceSize * nSurfNumDecVPP]; pmfxSurfaces = new mfxFrameSurface1*[nSurfNumDecVPP]; MSDK_CHECK_POINTER(pmfxSurfaces, MFX_ERR_MEMORY_ALLOC); for (int i = 0; i < nSurfNumDecVPP; i++) { pmfxSurfaces = new mfxFrameSurface1; memset(pmfxSurfaces, 0, sizeof(mfxFrameSurface1)); memcpy(&(pmfxSurfaces->Info), &(mfxVideoParams.mfx.FrameInfo), sizeof(mfxFrameInfo)); pmfxSurfaces->Data.Y = &surfaceBuffers[surfaceSize * i]; pmfxSurfaces->Data.U = pmfxSurfaces->Data.Y + width * height; pmfxSurfaces->Data.V = pmfxSurfaces->Data.U + 1; pmfxSurfaces->Data.Pitch = width; } // Allocate surfaces for VPP Out // - Width and height of buffer must be aligned, a multiple of 32 // - Frame surface array keeps pointers all surface planes and general frame info width = (mfxU16)MSDK_ALIGN32(VPPRequest[1].Info.Width); height = (mfxU16)MSDK_ALIGN32(VPPRequest[1].Info.Height); bitsPerPixel = 32; // RGB32 format is a 32 bits per pixel format surfaceSize = width * height * bitsPerPixel / 8; surfaceBuffers2 = (mfxU8 *)new mfxU8[surfaceSize * nSurfNumVPPOut]; pmfxSurfaces2 = new mfxFrameSurface1*[nSurfNumVPPOut]; MSDK_CHECK_POINTER(pmfxSurfaces2, MFX_ERR_MEMORY_ALLOC); for (int i = 0; i < nSurfNumVPPOut; i++) { pmfxSurfaces2 = new mfxFrameSurface1; memset(pmfxSurfaces2, 0, sizeof(mfxFrameSurface1)); memcpy(&(pmfxSurfaces2->Info), &(VPPParams.vpp.Out), sizeof(mfxFrameInfo)); pmfxSurfaces2->Data.B = &surfaceBuffers[surfaceSize * i]; pmfxSurfaces2->Data.G = pmfxSurfaces2->Data.B + 1; pmfxSurfaces2->Data.R = pmfxSurfaces2->Data.B + 2; pmfxSurfaces2->Data.A = pmfxSurfaces2->Data.B + 3; pmfxSurfaces2->Data.Pitch = width*4; //pmfxSurfaces2->Data.Y = &surfaceBuffers[surfaceSize * i]; //pmfxSurfaces2->Data.U = pmfxSurfaces2->Data.Y + width * height; //pmfxSurfaces2->Data.V = pmfxSurfaces2->Data.U + 1; //pmfxSurfaces2->Data.Pitch = width; } // Initialize the Media SDK decoder sts = pmfxDEC->Init(&mfxVideoParams); MSDK_IGNORE_MFX_STS(sts, MFX_WRN_PARTIAL_ACCELERATION); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); // Initialize Media SDK VPP sts = pmfxVPP->Init(&VPPParams); MSDK_IGNORE_MFX_STS(sts, MFX_WRN_PARTIAL_ACCELERATION); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); printf("vpp iw:%d,ih:%d,ow:%d,oh:%d\n", VPPParams.vpp.In.Width, VPPParams.vpp.In.Height, VPPParams.vpp.Out.Width, VPPParams.vpp.Out.Height); // =============================================================== // Start decoding the frames from the stream head_flag =1; #ifdef ENABLE_BENCHMARK LARGE_INTEGER tStart, tEnd; QueryPerformanceFrequency(&tStart); double freq = (double)tStart.QuadPart; QueryPerformanceCounter(&tStart); #endif } // Stage 1: Main decoding loop if(sts == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) { sts = pmfxVPP->Reset(&VPPParams); return 0; } while (MFX_ERR_NONE <= sts || MFX_ERR_MORE_DATA == sts || MFX_ERR_MORE_SURFACE == sts) { if (MFX_WRN_DEVICE_BUSY == sts) sleep(1/1000); // Wait if device is busy, then repeat the same call to DecodeFrameAsync if (MFX_ERR_MORE_DATA == sts) { ++nframe; //printf("nframe:%d\r\n",nframe++); //sts = ReadBitStreamData(&mfxBS, fSource); // Read more data into input bit stream sts = ReadBitStreamData1(&mfxBS, data, length); //sts = ReadBitStreamData1(&mfxBS, _data, _data_end); data = NULL; length = 0; MSDK_BREAK_ON_ERROR(sts); } if (MFX_ERR_MORE_SURFACE == sts || MFX_ERR_NONE == sts) { nIndex = GetFreeSurfaceIndex(pmfxSurfaces, nSurfNumDecVPP); // Find free frame surface MSDK_CHECK_ERROR(MFX_ERR_NOT_FOUND, nIndex, MFX_ERR_MEMORY_ALLOC); } // Decode a frame asychronously (returns immediately) sts = pmfxDEC->DecodeFrameAsync(&mfxBS, pmfxSurfaces[nIndex], &pmfxOutSurface, &syncpD); // Ignore warnings if output is available, // if no output and no action required just repeat the DecodeFrameAsync call if (MFX_ERR_NONE < sts && syncpD) sts = MFX_ERR_NONE; if (MFX_ERR_NONE == sts) { //printf("decode w:%d,h:%d\n", pmfxOutSurface->Info.CropW, pmfxOutSurface->Info.CropH); nIndex2 = GetFreeSurfaceIndex(pmfxSurfaces2, nSurfNumVPPOut); // Find free frame surface MSDK_CHECK_ERROR(MFX_ERR_NOT_FOUND, nIndex2, MFX_ERR_MEMORY_ALLOC); for (;;) { // Process a frame asychronously (returns immediately) sts = pmfxVPP->RunFrameVPPAsync(pmfxOutSurface, pmfxSurfaces2[nIndex2], NULL, &syncpV); if (MFX_ERR_NONE < sts && !syncpV) // repeat the call if warning and no output { if (MFX_WRN_DEVICE_BUSY == sts) sleep(1/1000); // wait if device is busy } else if (MFX_ERR_NONE < sts && syncpV) { sts = MFX_ERR_NONE; // ignore warnings if output is available break; } else break; // not a warning } // VPP needs more data, let decoder decode another frame as input if (MFX_ERR_MORE_DATA == sts) { continue; } else if (MFX_ERR_MORE_SURFACE == sts) { // Not relevant for the illustrated workload! Therefore not handled. // Relevant for cases when VPP produces more frames at output than consumes at input. E.g. framerate conversion 30 fps -> 60 fps break; } else{ MSDK_BREAK_ON_ERROR(sts); } } if (MFX_ERR_NONE == sts) sts = mfxSession.SyncOperation(syncpV, 60000); // Synchronize. Wait until decoded frame is ready if (MFX_ERR_NONE == sts) { ++nFrame; LOG_INFO("SUCESS W:%d,H:%d,P:%d\n", pmfxSurfaces2[nIndex2]->Info.CropW, pmfxSurfaces2[nIndex2]->Info.CropH, pmfxSurfaces2[nIndex2]->Data.Pitch); MSDK_BREAK_ON_ERROR(sts); if(flag) printf("loss!\n"); else CopyRGB32(pmfxSurfaces2[nIndex2]->Data.B,(uint32_t*)_frame,pmfxSurfaces2[nIndex2]->Info.CropW,pmfxSurfaces2[nIndex2]->Info.CropH,pmfxSurfaces2[nIndex2]->Data.Pitch); return 1; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i found the problem,decode init (width height ) not equal vppinit(width height),decode height > vpp height 16bit,i don't know why.
i fix code:
VPPParams.vpp.In.Width = MSDK_ALIGN16(VPPParams.vpp.In.CropW);
VPPParams.vpp.In.Height = (MFX_PICSTRUCT_PROGRESSIVE == VPPParams.vpp.In.PicStruct)?
MSDK_ALIGN16(VPPParams.vpp.In.CropH) : MSDK_ALIGN32(VPPParams.vpp.In.CropH);
==>
VPPParams.vpp.In.Width = mfxVideoParams.mfx.FrameInfo.Width
;
VPPParams.vpp.In.Height = mfxVideoParams.mfx.FrameInfo.Height;
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page