25 #include <sys/types.h>
27 #include <mfx/mfxvideo.h>
44 case MFX_ERR_MEMORY_ALLOC:
45 case MFX_ERR_NOT_ENOUGH_BUFFER:
47 case MFX_ERR_INVALID_HANDLE:
49 case MFX_ERR_DEVICE_FAILED:
50 case MFX_ERR_DEVICE_LOST:
51 case MFX_ERR_LOCK_MEMORY:
53 case MFX_ERR_NULL_PTR:
54 case MFX_ERR_UNDEFINED_BEHAVIOR:
55 case MFX_ERR_NOT_INITIALIZED:
57 case MFX_ERR_UNSUPPORTED:
58 case MFX_ERR_NOT_FOUND:
60 case MFX_ERR_MORE_DATA:
61 case MFX_ERR_MORE_SURFACE:
62 case MFX_ERR_MORE_BITSTREAM:
64 case MFX_ERR_INCOMPATIBLE_VIDEO_PARAM:
65 case MFX_ERR_INVALID_VIDEO_PARAM:
92 return MFX_CODEC_MPEG2;
106 mfxIMPL impl = MFX_IMPL_AUTO_ANY;
120 if (impl & MFX_IMPL_SOFTWARE)
122 else if (impl & MFX_IMPL_HARDWARE)
123 desc =
"hardware accelerated";
128 "Initialized an internal MFX session using %s implementation\n",
138 MFXVideoDECODE_Close(q->
session);
145 mfxVideoParam param = { { 0 } };
159 param.mfx.CodecId =
ret;
160 param.mfx.CodecProfile = avctx->
profile;
161 param.mfx.CodecLevel = avctx->
level;
163 param.mfx.FrameInfo.BitDepthLuma = 8;
164 param.mfx.FrameInfo.BitDepthChroma = 8;
165 param.mfx.FrameInfo.Shift = 0;
166 param.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
169 param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
176 ret = MFXVideoDECODE_Init(q->
session, ¶m);
281 mfxFrameSurface1 *insurf;
282 mfxFrameSurface1 *outsurf;
284 mfxBitstream bs = { { { 0 } } };
288 bs.Data = avpkt->
data;
289 bs.DataLength = avpkt->
size;
290 bs.MaxLength = bs.DataLength;
291 bs.TimeStamp = avpkt->
pts;
299 ret = MFXVideoDECODE_DecodeFrameAsync(q->
session, avpkt->
size ? &bs :
NULL,
300 insurf, &outsurf, &sync);
301 if (ret == MFX_WRN_DEVICE_BUSY)
304 }
while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE);
306 if (ret != MFX_ERR_NONE &&
307 ret != MFX_ERR_MORE_DATA &&
308 ret != MFX_WRN_VIDEO_PARAM_CHANGED &&
309 ret != MFX_ERR_MORE_SURFACE) {
317 MFXVideoCORE_SyncOperation(q->
session, sync, 60000);
322 "The returned surface does not correspond to any frame\n");
330 frame->
pkt_pts = frame->
pts = outsurf->Data.TimeStamp;
333 outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_TRIPLING ? 4 :
334 outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_DOUBLING ? 2 :
335 outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_REPEATED ? 1 : 0;
337 outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF;
339 !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
344 return bs.DataOffset;