[問題] Intel Media SDK硬體解碼畫面不清
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
Intel Media SDK 2014 R2
問題(Question):
我用Intel Media SDK解碼播放h264的影片
用軟體解碼(MFX_IMPL_SOFTWARE)畫面會清晰
但用硬體解碼畫面卻會有破格
餵入的資料(Input):
// 若我改用MFX_IMPL_SOFTWARE解碼出來的畫面就正確了
mfxIMPL impl = MFX_IMPL_HARDWARE;
mfxVersion ver = { {8, 1} };
................
// 輸入的參數
memset(&mfxVideoParams, 0, sizeof(mfxVideoParams));
mfxVideoParams.mfx.CodecId = MFX_CODEC_AVC;
mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
................
預期的正確結果(Expected Output):
正確清晰的影像
錯誤結果(Wrong Output):
I-Frame外的畫面會有部分不清晰(像是有殘影)
程式碼(Code):(請善用置底文網頁, 記得排版)
decode動作沒寫出(因為經過軟體驅動畫面是對的)
列出初始化,及設定動作如下:
mfxStatus gv::IMSDK_video_decode_chip::Initialize(mfxIMPL impl, mfxVersion
ver, MFXVideoSession* pSession, mfxFrameAllocator* pmfxAllocator)
{
mfxStatus sts = MFX_ERR_NONE;
// Initialize Intel Media SDK Session
sts = pSession->Init(impl, &ver);
//MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
return sts;
}
bool gv::IMSDK_video_decode_chip::init(int codec, const ColorSpace
output_video_color_space, int video_width, int video_height)
{
// Initialize Intel Media SDK session
// - MFX_IMPL_AUTO_ANY selects HW acceleration if available (on any adapter)
// - Version 1.0 is selected for greatest backwards compatibility.
// OS specific notes
// - On Windows both SW and HW libraries may present
// - On Linux only HW library only is available
// If more recent API features are needed, change the version accordingly
//mfxIMPL impl = MFX_IMPL_SOFTWARE;
mfxIMPL impl = MFX_IMPL_HARDWARE;
mfxVersion ver = { {8, 1} };
mfxStatus sts = MFX_ERR_NONE;
FILE* fSource;
sts = Initialize(impl, ver, &session, NULL);
// Set required video parameters for decode
memset(&mfxVideoParams, 0, sizeof(mfxVideoParams));
mfxVideoParams.mfx.CodecId = MFX_CODEC_AVC;
mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
// Prepare Media SDK bit stream buffer
// - Arbitrary buffer size for this example
memset(&mfxBS, 0, sizeof(mfxBS));
mfxBS.MaxLength = 1024 * 1024;
mfxBS.Data = new mfxU8[mfxBS.MaxLength];
mfxDEC = new MFXVideoDECODE(session);
......
}
gv::VideoDecodeChip::VideoDataPtr
gv::IMSDK_video_decode_chip::decode(VideoData* pVideoData, size_t index)
{
sts = ReadBitStreamData(&mfxBS, pVideoData,index);
sts = mfxDEC->DecodeHeader(&mfxBS, &mfxVideoParams);
// Query number of required surfaces for decoder
mfxFrameAllocRequest Request;
memset(&Request, 0, sizeof(Request));
sts = mfxDEC->QueryIOSurf(&mfxVideoParams, &Request);
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);
//mfxU16 width = _videoWidth;
//mfxU16 height =_videoHeight;
mfxU8 bitsPerPixel = 12; // NV12 format is a 12 bits per pixel
format
mfxU32 surfaceSize = width * height * bitsPerPixel / 8;
surfaceBuffers = (mfxU8*) new mfxU8[surfaceSize * numSurfaces];
// Allocate surface headers (mfxFrameSurface1) for decoder
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;
}
// Initialize the Media SDK decoder
sts = mfxDEC->Init(&mfxVideoParams);
.....
}
補充說明(Supplement):
是否還有其他參數要設定
才能解除這個問題?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.250.32.153
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1409565931.A.008.html
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章