[FFmpeg-devel] [PATCH 1/2] vaapi_hevc: Add an option to set quality level

Li, Zhong zhong.li at intel.com
Mon Aug 21 09:28:29 EEST 2017


> -----Original Message-----
> From: Jun Zhao [mailto:mypopydev at gmail.com]
> Sent: Monday, August 21, 2017 11:27 AM
> To: FFmpeg development discussions and patches
> <ffmpeg-devel at ffmpeg.org>; Li, Zhong <zhong.li at intel.com>
> Cc: sw at jkqxz.net; Zhao, Jun <jun.zhao at intel.com>; nfxjfg at googlemail.com
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] vaapi_hevc: Add an option to set
> quality level
> 
> 
> 
> On 2017/8/21 11:04, Zhong Li wrote:
> > Just like vaapi_h264 encoder, quality_level is set for tradeoff
> > quality and performance.
> >
> > Signed-off-by: Zhong Li <zhong.li at intel.com>
> > ---
> >  libavcodec/vaapi_encode_h265.c | 27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> >
> > diff --git a/libavcodec/vaapi_encode_h265.c
> > b/libavcodec/vaapi_encode_h265.c index cf6b9388d1..86bda4a27b
> 100644
> > --- a/libavcodec/vaapi_encode_h265.c
> > +++ b/libavcodec/vaapi_encode_h265.c
> > @@ -191,10 +191,19 @@ typedef struct VAAPIEncodeH265Context {
> >          VAEncMiscParameterBuffer misc;
> >          VAEncMiscParameterHRD hrd;
> >      } hrd_params;
> > +
> > +#if VA_CHECK_VERSION(0, 36, 0)
> > +    // Speed-quality tradeoff setting.
> > +    struct {
> > +        VAEncMiscParameterBuffer misc;
> > +        VAEncMiscParameterBufferQualityLevel quality;
> > +    } quality_params;
> > +#endif
> >  } VAAPIEncodeH265Context;
> >
> >  typedef struct VAAPIEncodeH265Options {
> >      int qp;
> > +    int quality;
> >  } VAAPIEncodeH265Options;
> >
> I think now use avctx->compression_level for video quality, not private
> option, please check 9c878651dbc8c795894740af74670b591551f619
> (https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/9c878651dbc8c7958947
> 40af74670b591551f619)

Yes, thanks for remind. This patch can be ignored now since hevc encoder can set quality level now by compression_level.

> >
> > @@ -1198,6 +1207,22 @@ static av_cold int
> vaapi_encode_h265_configure(AVCodecContext *avctx)
> >          av_assert0(0 && "Invalid RC mode.");
> >      }
> >
> > +    if (opt->quality > 0) {
> > +#if VA_CHECK_VERSION(0, 36, 0)
> > +        priv->quality_params.misc.type =
> > +            VAEncMiscParameterTypeQualityLevel;
> > +        priv->quality_params.quality.quality_level = opt->quality;
> > +
> > +        ctx->global_params[ctx->nb_global_params] =
> > +            &priv->quality_params.misc;
> > +        ctx->global_params_size[ctx->nb_global_params++] =
> > +            sizeof(priv->quality_params); #else
> > +        av_log(avctx, AV_LOG_WARNING, "The encode quality option is
> not "
> > +               "supported with this VAAPI version.\n"); #endif
> > +    }
> > +
> >      return 0;
> >  }
> >
> > @@ -1272,6 +1297,8 @@ static av_cold int
> > vaapi_encode_h265_init(AVCodecContext *avctx)  static const AVOption
> vaapi_encode_h265_options[] = {
> >      { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for
> I/B)",
> >        OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, 52, FLAGS },
> > +    { "quality", "Set encode quality (trades off against speed, higher is
> faster)",
> > +      OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 7, FLAGS },
> >      { NULL },
> >  };
> >
> >


More information about the ffmpeg-devel mailing list