Message ID | 20190430090343.11452-1-zhong.li@intel.com |
---|---|
State | Accepted |
Commit | 48627aaf646270a8c98337ee208574543e499bfd |
Headers | show |
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Zhong Li > Sent: Tuesday, April 30, 2019 5:04 PM > To: ffmpeg-devel@ffmpeg.org > Cc: Li, Zhong <zhong.li@intel.com> > Subject: [FFmpeg-devel] [PATCH 1/3] lavc/qsvdec: add query function and > provide error message > > It is helpful to know why some clips decoding failed. > Ticket#7330 is a good example, with this patch it is easily to know bitstream > codec level is out of support range. > > Signed-off-by: Zhong Li <zhong.li@intel.com> > --- > libavcodec/qsvdec.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index > 4a0be811fb..2a8a032111 100644 > --- a/libavcodec/qsvdec.c > +++ b/libavcodec/qsvdec.c > @@ -120,6 +120,33 @@ static inline unsigned int qsv_fifo_size(const > AVFifoBuffer* fifo) > return av_fifo_size(fifo) / qsv_fifo_item_size(); } > > +static int check_dec_param(AVCodecContext *avctx, QSVContext *q, > +mfxVideoParam *param_in) { > + mfxVideoParam param_out = { .mfx.CodecId = > param_in->mfx.CodecId }; > + mfxStatus ret; > + > +#define CHECK_MATCH(x) \ > + do { \ > + if (param_out.mfx.x != param_in->mfx.x) { \ > + av_log(avctx, AV_LOG_WARNING, "Required "#x" %d is > unsupported\n", \ > + param_in->mfx.x); \ > + } \ > + } while (0) > + > + ret = MFXVideoDECODE_Query(q->session, param_in, ¶m_out); > + > + if (ret < 0) { > + CHECK_MATCH(CodecId); > + CHECK_MATCH(CodecProfile); > + CHECK_MATCH(CodecLevel); > + CHECK_MATCH(FrameInfo.Width); > + CHECK_MATCH(FrameInfo.Height); > +#undef CHECK_MATCH > + return 0; > + } > + return 1; > +} > + > static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q) { > const AVPixFmtDescriptor *desc; > @@ -206,6 +233,12 @@ static int qsv_decode_init(AVCodecContext *avctx, > QSVContext *q) > param.ExtParam = q->ext_buffers; > param.NumExtParam = q->nb_ext_buffers; > > + if (!check_dec_param(avctx, q, ¶m)) { > + //Just give a warning instead of an error since it is still decodable > possibly. > + av_log(avctx, AV_LOG_WARNING, > + "Current input bitstream is not supported by QSV > decoder.\n"); > + } > + > ret = MFXVideoDECODE_Init(q->session, ¶m); > if (ret < 0) > return ff_qsv_print_error(avctx, ret, > -- > 2.17.1 Ping for comment of this patch set. Thanks
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 4a0be811fb..2a8a032111 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -120,6 +120,33 @@ static inline unsigned int qsv_fifo_size(const AVFifoBuffer* fifo) return av_fifo_size(fifo) / qsv_fifo_item_size(); } +static int check_dec_param(AVCodecContext *avctx, QSVContext *q, mfxVideoParam *param_in) +{ + mfxVideoParam param_out = { .mfx.CodecId = param_in->mfx.CodecId }; + mfxStatus ret; + +#define CHECK_MATCH(x) \ + do { \ + if (param_out.mfx.x != param_in->mfx.x) { \ + av_log(avctx, AV_LOG_WARNING, "Required "#x" %d is unsupported\n", \ + param_in->mfx.x); \ + } \ + } while (0) + + ret = MFXVideoDECODE_Query(q->session, param_in, ¶m_out); + + if (ret < 0) { + CHECK_MATCH(CodecId); + CHECK_MATCH(CodecProfile); + CHECK_MATCH(CodecLevel); + CHECK_MATCH(FrameInfo.Width); + CHECK_MATCH(FrameInfo.Height); +#undef CHECK_MATCH + return 0; + } + return 1; +} + static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q) { const AVPixFmtDescriptor *desc; @@ -206,6 +233,12 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q) param.ExtParam = q->ext_buffers; param.NumExtParam = q->nb_ext_buffers; + if (!check_dec_param(avctx, q, ¶m)) { + //Just give a warning instead of an error since it is still decodable possibly. + av_log(avctx, AV_LOG_WARNING, + "Current input bitstream is not supported by QSV decoder.\n"); + } + ret = MFXVideoDECODE_Init(q->session, ¶m); if (ret < 0) return ff_qsv_print_error(avctx, ret,
It is helpful to know why some clips decoding failed. Ticket#7330 is a good example, with this patch it is easily to know bitstream codec level is out of support range. Signed-off-by: Zhong Li <zhong.li@intel.com> --- libavcodec/qsvdec.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)