h.264 ビデオに intel-media-sdk デコーダーを使用しようとしています。デコーダーを初期化するための私のコードは次のとおりです。
mfxStatus decoder::initDecoder(HWND window, mfxBitstream *Header) {
mfxStatus sts = MFX_ERR_NONE;
mfxVersion ver = { { 0, 1 } };
mfxVideoParam mfxVideoParams;
mfxFrameAllocator mfxAllocator;
mfxFrameAllocResponse mfxResponse;
sts = m_mfxSession.Init(MFX_IMPL_AUTO_ANY, &ver); //sts = MFX_ERR_NONE
if (sts == MFX_ERR_NONE) {
sts = m_mfxSession.SetHandle(MFX_HANDLE_DIRECT3D_DEVICE_MANAGER9,
m_renderer.initD3d(GetIntelDeviceAdapterNum(), window)); //sts = MFX_ERR_NONE
if (sts == MFX_ERR_NONE) {
mfxAllocator.pthis = m_mfxSession;
sts = m_mfxSession.SetFrameAllocator(&mfxAllocator); //sts = MFX_ERR_NONE
if (sts == MFX_ERR_NONE) {
MFXVideoDECODE mfxDEC(m_mfxSession);
m_mfxVideoDecode = mfxDEC;
memset(&mfxVideoParams, 0, sizeof(mfxVideoParams));
mfxVideoParams.mfx.CodecId = MFX_CODEC_AVC;
mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
sts = m_mfxVideoDecode.DecodeHeader(Header, &mfxVideoParams); //sts = MFX_ERR_NONE
if (sts == MFX_ERR_NONE) {
memset(&m_mfxRequest, 0, sizeof(m_mfxRequest));
sts = m_mfxVideoDecode.QueryIOSurf(&mfxVideoParams, &m_mfxRequest); //sts = MFX_ERR_NONE
if (sts == MFX_ERR_NONE) {
sts = m_renderer.allocSurfaces(mfxAllocator.pthis, &m_mfxRequest, &mfxResponse);
if (sts == MFX_ERR_NONE) {
m_pmfxSurfaces = new mfxFrameSurface1 *[m_mfxRequest.NumFrameSuggested];
for (int i = 0; i < m_mfxRequest.NumFrameSuggested; i++) {
m_pmfxSurfaces[i] = new mfxFrameSurface1;
memset(m_pmfxSurfaces[i], 0, sizeof(mfxFrameSurface1));
memcpy(&(m_pmfxSurfaces[i]->Info), &(mfxVideoParams.mfx.FrameInfo), sizeof(mfxFrameInfo));
// MID (memory id) represents one video NV12 surface
m_pmfxSurfaces[i]->Data.MemId = mfxResponse.mids[i];
};
sts = m_mfxVideoDecode.Init(&mfxVideoParams); //sts = MFX_ERR_MEMORY_ALLOC
}
}
}
}
}
}
return sts;
}
ご覧のとおりMFXVideoDECODE::Init(mfxVideoParam*)
(内部的に を呼び出しますMFXVideoDECODE_Init
) が返されますMFX_ERR_MEMORY_ALLOC
が、ここで奇妙なことはこのドキュメントにあり、この関数にはこの戻り値がないと言われています。
に関するデバッグ情報を次に示しますmfxVideoParams
。
AllocId = 0、AsyncDepth = 0、IOPattern = 16、mfx.CodecId = 541283905、mfx.CodecProfile = 77、mfx.CodecLevel = 30、vpp.In.FourCC = 842094158、vpp.In.Width = 864、vpp.In。高さ = 480、vpp.In.CropW = 854、vpp.In.CropH = 480、vpp.In.BufferSize = 31458144、vpp.In.AspectRatioW = 1、vpp.In.AspectRatioH = 1、vpp.In.PicStruct = 1、vpp.In.ChromaFormat = 1
ここで使用されるヘッダーの一部のメンバーデータ定義は次のとおりです。
MFXVideoSession m_mfxSession;
MFXVideoDECODE m_mfxVideoDecode;
mfxFrameAllocRequest m_mfxRequest;
mfxFrameSurface1** m_pmfxSurfaces;
そして、この問題に関連する可能性のある、現在動作しているデバイスに関する情報を次に示します。
- オペレーティング システム: Windows 8.1
- プロセッサ: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHZ
- システムの種類 : 64 ビット オペレーティング システム、x64 ベースのプロセッサ
- 搭載メモリ(RAM):8.00GB
最後に、まったく同じ状況を再現するために、このサイトbig_buck_bunny_1080p_h264.mov
から名前の付いたビデオをダウンロードし、ffmpeg で h264 に抽出して、プログラムで使用しました。