Message ID | 20170821030403.14381-1-zhong.li@intel.com |
---|---|
State | New |
Headers | show |
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@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/9c878651dbc8c795894740af74670b591551f619) > > @@ -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 }, > }; > >
so, how to use avctx->compression_level option? ------------------ Original ------------------ From: "Jun Zhao";<mypopydev@gmail.com>; Send time: Monday, Aug 21, 2017 11:26 AM To: "FFmpeg development discussions and patches"<ffmpeg-devel@ffmpeg.org>; "Zhong Li"<zhong.li@intel.com>; Cc: "sw"<sw@jkqxz.net>; "jun.zhao"<jun.zhao@intel.com>; "nfxjfg"<nfxjfg@googlemail.com>; Subject: Re: [FFmpeg-devel] [PATCH 1/2] vaapi_hevc: Add an option to setquality 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@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/9c878651dbc8c795894740af74670b591551f619) > > @@ -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 }, > }; > > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> -----Original Message----- > From: Jun Zhao [mailto:mypopydev@gmail.com] > Sent: Monday, August 21, 2017 11:27 AM > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org>; Li, Zhong <zhong.li@intel.com> > Cc: sw@jkqxz.net; Zhao, Jun <jun.zhao@intel.com>; nfxjfg@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@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 }, > > }; > > > >
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; @@ -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 }, };
Just like vaapi_h264 encoder, quality_level is set for tradeoff quality and performance. Signed-off-by: Zhong Li <zhong.li@intel.com> --- libavcodec/vaapi_encode_h265.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)