return ff_qsv_error(ret);
}
- q->async_fifo = av_fifo_alloc((1 + 16) *
- (sizeof(mfxSyncPoint) + sizeof(QSVFrame*)));
- if (!q->async_fifo)
- return AVERROR(ENOMEM);
+ avctx->pix_fmt = AV_PIX_FMT_NV12;
+ avctx->profile = param.mfx.CodecProfile;
+ avctx->level = param.mfx.CodecLevel;
+ avctx->coded_width = param.mfx.FrameInfo.Width;
+ avctx->coded_height = param.mfx.FrameInfo.Height;
+ avctx->width = param.mfx.FrameInfo.CropW - param.mfx.FrameInfo.CropX;
+ avctx->height = param.mfx.FrameInfo.CropH - param.mfx.FrameInfo.CropY;
+
+ /* maximum decoder latency should be not exceed max DPB size for h.264 and
+ HEVC which is 16 for both cases.
+ So weare pre-allocating fifo big enough for 17 elements:
+ */
++ if (!q->async_fifo) {
++ q->async_fifo = av_fifo_alloc((1 + 16) *
++ (sizeof(mfxSyncPoint) + sizeof(QSVFrame*)));
++ if (!q->async_fifo)
++ return AVERROR(ENOMEM);
++ }
+
+ q->input_fifo = av_fifo_alloc(1024*16);
+ if (!q->input_fifo)
+ return AVERROR(ENOMEM);
+
+ q->engine_ready = 1;
+
return 0;
}