[FFmpeg-devel] [PATCH] lavc/qsvenc_hevc: add qmax/qmin support for HEVC encoding

Fu, Linjie linjie.fu at intel.com
Tue Jun 30 09:30:55 EEST 2020


> From: Zhong Li <lizhong1008 at gmail.com>
> Sent: Thursday, March 12, 2020 10:07
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Cc: Rogozhkin, Dmitry V <dmitry.v.rogozhkin at intel.com>; Fu, Linjie
> <linjie.fu at intel.com>
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvenc_hevc: add qmax/qmin
> support for HEVC encoding
> 
> Linjie Fu <linjie.fu at intel.com> 于2020年3月11日周三 下午6:44写道:
> >
> > Add qmax/qmin support for HEVC software bitrate control(SWBRC).
> >
> > Limitations:
> >     - RateControlMethod != MFX_RATECONTROL_CQP
> >     - with EXTBRC ON
> >
> > Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin at intel.com>
> > Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> > ---
> >
> > Relative code in MSDK for the limitation:
> > https://github.com/Intel-Media-
> SDK/MediaSDK/blob/master/_studio/mfx_lib/encode_hw/hevc/agnostic/g9
> /hevcehw_g9_legacy.cpp#L4267
> >
> >  libavcodec/qsvenc.c      | 11 +++++------
> >  libavcodec/qsvenc_hevc.c |  2 ++
> >  2 files changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> > index 52b4e43..2c22eb7 100644
> > --- a/libavcodec/qsvenc.c
> > +++ b/libavcodec/qsvenc.c
> > @@ -732,6 +732,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >              if (q->adaptive_b >= 0)
> >                  q->extco2.AdaptiveB = q->adaptive_b ?
> MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
> >  #endif
> > +        }
> > +
> > +        if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id ==
> AV_CODEC_ID_HEVC) {
> > +            if (q->extbrc >= 0)
> > +                q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON :
> MFX_CODINGOPTION_OFF;
> >
> >  #if QSV_VERSION_ATLEAST(1, 9)
> >              if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx-
> >qmax) {
> > @@ -747,12 +752,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >                  q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI;
> >              }
> >  #endif
> > -        }
> > -
> > -        if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id ==
> AV_CODEC_ID_HEVC) {
> > -            if (q->extbrc >= 0)
> > -                q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON :
> MFX_CODINGOPTION_OFF;
> > -
> >              q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
> >              q->extco2.Header.BufferSz = sizeof(q->extco2);
> >
> > diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
> > index 27e2232..3bdca7d 100644
> > --- a/libavcodec/qsvenc_hevc.c
> > +++ b/libavcodec/qsvenc_hevc.c
> > @@ -262,6 +262,8 @@ static const AVCodecDefault qsv_enc_defaults[] = {
> >      // same as the x264 default
> >      { "g",         "248"   },
> >      { "bf",        "8"     },
> > +    { "qmin",      "-1"    },
> > +    { "qmax",      "-1"    },
> >      { "trellis",   "-1"    },
> >      { "flags",     "+cgop" },
> >  #if FF_API_PRIVATE_OPT
> > --
> > 2.7.4
> 
> LGTM, will apply
A kind ping.

- Linjie


More information about the ffmpeg-devel mailing list