This allows use to export the required frame pool size to the caller in
get_buffer(), before the decoder is initialized.
---
This is an API break, since previously get_buffer() was always called after
MFXVideoDECODE_Init() (and therefore after user's custom frame allocation
callback invoked by libmfx), now it's called before.
Suggestions how to do it better are welcome.
---
libavcodec/qsvdec.c | 44 +++++++++++++++++++++++---------------------
libavcodec/qsvdec.h | 2 ++
2 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index ca6f781..c74aa20 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -72,7 +72,6 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext
*q, mfxSession ses
static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxSession
session)
{
- mfxVideoParam param = { { 0 } };
int ret;
if (!q->async_fifo) {
@@ -93,28 +92,22 @@ static int qsv_decode_init(AVCodecContext *avctx,
QSVContext *q, mfxSession sess
if (ret < 0)
return ret;
- param.mfx.CodecId = ret;
- param.mfx.CodecProfile = avctx->profile;
- param.mfx.CodecLevel = avctx->level;
+ q->param.mfx.CodecId = ret;
+ q->param.mfx.CodecProfile = avctx->profile;
+ q->param.mfx.CodecLevel = avctx->level;
- param.mfx.FrameInfo.BitDepthLuma = 8;
- param.mfx.FrameInfo.BitDepthChroma = 8;
- param.mfx.FrameInfo.Shift = 0;
- param.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
- param.mfx.FrameInfo.Width = avctx->coded_width;
- param.mfx.FrameInfo.Height = avctx->coded_height;
- param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
+ q->param.mfx.FrameInfo.BitDepthLuma = 8;
+ q->param.mfx.FrameInfo.BitDepthChroma = 8;
+ q->param.mfx.FrameInfo.Shift = 0;
+ q->param.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
+ q->param.mfx.FrameInfo.Width = avctx->coded_width;
+ q->param.mfx.FrameInfo.Height = avctx->coded_height;
+ q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
- param.IOPattern = q->iopattern;
- param.AsyncDepth = q->async_depth;
- param.ExtParam = q->ext_buffers;
- param.NumExtParam = q->nb_ext_buffers;
-
- ret = MFXVideoDECODE_Init(q->session, ¶m);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error initializing the MFX video
decoder\n");
- return ff_qsv_error(ret);
- }
+ q->param.IOPattern = q->iopattern;
+ q->param.AsyncDepth = q->async_depth;
+ q->param.ExtParam = q->ext_buffers;
+ q->param.NumExtParam = q->nb_ext_buffers;
return 0;
}
@@ -234,6 +227,15 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
if (ret < 0)
return ret;
+ if (!q->decoder_initialized) {
+ ret = MFXVideoDECODE_Init(q->session, &q->param);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error initializing the MFX video
decoder\n");
+ return ff_qsv_error(ret);
+ }
+ q->decoder_initialized = 1;
+ }
+
ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ? &bs :
NULL,
insurf, &outsurf, &sync);
if (ret == MFX_WRN_DEVICE_BUSY)
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index 698d8c8..f8be5a2 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -43,6 +43,8 @@ typedef struct QSVContext {
// one
mfxSession internal_session;
+ int decoder_initialized;
+
/**
* a linked list of frames currently being used by QSV
*/
--
2.0.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel