Message ID | 20210426030341.3274799-1-wenbin.chen@intel.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,1/3] libavcodec/qsvdec: reinit decoder according to decode() return value | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
Ping on this patch. > -----Original Message----- > From: Chen, Wenbin <wenbin.chen@intel.com> > Sent: Monday, April 26, 2021 11:04 AM > To: ffmpeg-devel@ffmpeg.org > Cc: Chen, Wenbin <wenbin.chen@intel.com> > Subject: [PATCH 1/3] libavcodec/qsvdec: reinit decoder according to decode() > return value > > From: "Chen,Wenbin" <wenbin.chen@intel.com> > > FFmpeg-qsv decoder reinit codec when width and height change, but there > are not only resolution change need to reinit codec. I change it to use > return value from DecodeFrameAsync() to decide whether decoder need to > be reinitialized. > > Signed-off-by Wenbin Chen <wenbin.chen@intel.com> > Signed-off-by Guangxin Xu <guangxin.xu@intel.com> > --- > libavcodec/qsvdec.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c > index 5f2e641373..88232f5d8d 100644 > --- a/libavcodec/qsvdec.c > +++ b/libavcodec/qsvdec.c > @@ -481,6 +481,13 @@ static int qsv_decode(AVCodecContext *avctx, > QSVContext *q, > > } while (ret == MFX_WRN_DEVICE_BUSY || ret == > MFX_ERR_MORE_SURFACE); > > + if (ret == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) { > + q->reinit_flag = 1; > + av_log(avctx, AV_LOG_DEBUG, "Video parameter change\n"); > + av_freep(&sync); > + return 0; > + } > + > if (ret != MFX_ERR_NONE && > ret != MFX_ERR_MORE_DATA && > ret != MFX_WRN_VIDEO_PARAM_CHANGED && > @@ -632,9 +639,9 @@ static int qsv_process_data(AVCodecContext *avctx, > QSVContext *q, > > ret = qsv_decode_header(avctx, q, pkt, pix_fmt, ¶m); > > - if (ret >= 0 && (q->orig_pix_fmt != > ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) || > + if (q->reinit_flag || (ret >= 0 && (q->orig_pix_fmt != > ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) || > avctx->coded_width != param.mfx.FrameInfo.Width || > - avctx->coded_height != param.mfx.FrameInfo.Height)) { > + avctx->coded_height != param.mfx.FrameInfo.Height))) { > AVPacket zero_pkt = {0}; > > if (q->buffered_count) { > -- > 2.25.1
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 5f2e641373..88232f5d8d 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -481,6 +481,13 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, } while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE); + if (ret == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) { + q->reinit_flag = 1; + av_log(avctx, AV_LOG_DEBUG, "Video parameter change\n"); + av_freep(&sync); + return 0; + } + if (ret != MFX_ERR_NONE && ret != MFX_ERR_MORE_DATA && ret != MFX_WRN_VIDEO_PARAM_CHANGED && @@ -632,9 +639,9 @@ static int qsv_process_data(AVCodecContext *avctx, QSVContext *q, ret = qsv_decode_header(avctx, q, pkt, pix_fmt, ¶m); - if (ret >= 0 && (q->orig_pix_fmt != ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) || + if (q->reinit_flag || (ret >= 0 && (q->orig_pix_fmt != ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) || avctx->coded_width != param.mfx.FrameInfo.Width || - avctx->coded_height != param.mfx.FrameInfo.Height)) { + avctx->coded_height != param.mfx.FrameInfo.Height))) { AVPacket zero_pkt = {0}; if (q->buffered_count) {
From: "Chen,Wenbin" <wenbin.chen@intel.com> FFmpeg-qsv decoder reinit codec when width and height change, but there are not only resolution change need to reinit codec. I change it to use return value from DecodeFrameAsync() to decide whether decoder need to be reinitialized. Signed-off-by Wenbin Chen <wenbin.chen@intel.com> Signed-off-by Guangxin Xu <guangxin.xu@intel.com> --- libavcodec/qsvdec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)