Message ID | 1519961050-512-1-git-send-email-zhong.li@intel.com |
---|---|
State | Accepted |
Commit | 2d6b3f3a9dce409ca51d70ef4b85c0593bb4b109 |
Headers | show |
On Fri, Mar 02, 2018 at 11:24:10 +0800, Zhong Li wrote: > ret = MFXVideoENCODE_Query(q->session, &q->param, ¶m_out); > - if (ret < 0 || > - param_out.mfx.RateControlMethod != q->param.mfx.RateControlMethod) This original code gave the impression that a mismatch of RateControlMethod was not reported by MFXVideoENCODE_Query(), and therefore checked separately. You are not doing that anymore. > + if (UNMATCH(FrameInfo.FrameRateExtN) || UNMATCH(FrameInfo.FrameRateExtN)) Typo? (Both macro arguments are identical.) Moritz
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Moritz Barsnick > Sent: Tuesday, March 13, 2018 6:13 PM > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvenc: provide detail error > message if parameters invalid > > On Fri, Mar 02, 2018 at 11:24:10 +0800, Zhong Li wrote: > > ret = MFXVideoENCODE_Query(q->session, &q->param, > ¶m_out); > > - if (ret < 0 || > > - param_out.mfx.RateControlMethod != > q->param.mfx.RateControlMethod) > > This original code gave the impression that a mismatch of > RateControlMethod was not reported by MFXVideoENCODE_Query(), and > therefore checked separately. You are not doing that anymore. That is an intentional behavior. If current bit rate control mode is not supported. MFXVideoENCODE_Query() should return an invalid value as MSDK documentation. > > > + if (UNMATCH(FrameInfo.FrameRateExtN) || > > + UNMATCH(FrameInfo.FrameRateExtN)) > > Typo? (Both macro arguments are identical.) Yes, it is should be "FrameInfo.FrameRateExtD", I have a patch to fix it and will send soon. > > Moritz
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 74c273c..9710f5b 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -348,15 +348,34 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) return 0; } -static int rc_supported(QSVEncContext *q) +static int check_enc_param(AVCodecContext *avctx, QSVEncContext *q) { mfxVideoParam param_out = { .mfx.CodecId = q->param.mfx.CodecId }; mfxStatus ret; +#define UNMATCH(x) (param_out.mfx.x != q->param.mfx.x) + ret = MFXVideoENCODE_Query(q->session, &q->param, ¶m_out); - if (ret < 0 || - param_out.mfx.RateControlMethod != q->param.mfx.RateControlMethod) + + if (ret < 0) { + if (UNMATCH(CodecId)) + av_log(avctx, AV_LOG_ERROR, "Current codec type is unsupported\n"); + if (UNMATCH(CodecProfile)) + av_log(avctx, AV_LOG_ERROR, "Current profile is unsupported\n"); + if (UNMATCH(RateControlMethod)) + av_log(avctx, AV_LOG_ERROR, "Selected ratecontrol mode is unsupported\n"); + if (UNMATCH(LowPower)) + av_log(avctx, AV_LOG_ERROR, "Low power mode is unsupported\n"); + if (UNMATCH(FrameInfo.FrameRateExtN) || UNMATCH(FrameInfo.FrameRateExtN)) + av_log(avctx, AV_LOG_ERROR, "Current frame rate is unsupported\n"); + if (UNMATCH(FrameInfo.PicStruct)) + av_log(avctx, AV_LOG_ERROR, "Current picture structure is unsupported\n"); + if (UNMATCH(FrameInfo.Width) || UNMATCH(FrameInfo.Height)) + av_log(avctx, AV_LOG_ERROR, "Current resolution is unsupported\n"); + if (UNMATCH(FrameInfo.FourCC)) + av_log(avctx, AV_LOG_ERROR, "Current pixel format is unsupported\n"); return 0; + } return 1; } @@ -634,10 +653,10 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif } - if (!rc_supported(q)) { + if (!check_enc_param(avctx,q)) { av_log(avctx, AV_LOG_ERROR, - "Selected ratecontrol mode is not supported by the QSV " - "runtime. Choose a different mode.\n"); + "some encoding parameters are not supported by the QSV " + "runtime. Please double check the input parameters.\n"); return AVERROR(ENOSYS); }
Currently always shows "Selected ratecontrol mode is not supported by the QSV runtime. Choose a different mode", but sometimes it is not accurate. Signed-off-by: Zhong Li <zhong.li@intel.com> --- libavcodec/qsvenc.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)