V3: - Fix build error with old VAAPI version. V2: - Refine the name/value type to mb_rate_control/bool. - Only supported GEN9+ (SKL/APL/KBL/...) - i965 driver default use frame-level rate control algorithm (generate the QP for each frame), when enable mb_rate_control, it's will enable the MB-level RC algorithm (generate the QP for each MB). - enables MB-level bitrate control that generally improves subjective visual quality, but have negative impact on performance and objective visual quality metric.
From 219b06cec04a6c3f719ce80084a98b19456498e0 Mon Sep 17 00:00:00 2001 From: Jun Zhao <jun.z...@intel.com> Date: Tue, 9 May 2017 08:19:16 +0800 Subject: [PATCH V3] lavc/vaapi_encode_h264: Enable MB rate control.
Enables macroblock-level bitrate control that generally improves subjective visual quality. It may have a negative impact on performance and objective visual quality metrics. Default is off and can't compatible with Constant QP. Signed-off-by: Jun Zhao <jun.z...@intel.com> --- libavcodec/vaapi_encode_h264.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 92e29554ed..44223ada55 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -168,6 +168,7 @@ typedef struct VAAPIEncodeH264Options { int qp; int quality; int low_power; + int mb_rate_control; } VAAPIEncodeH264Options; @@ -1133,8 +1134,22 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx) priv->fixed_qp_p = 26; priv->fixed_qp_b = 26; - av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %"PRId64" bps.\n", + if (opt->mb_rate_control) { +#if VA_CHECK_VERSION(0, 39, 2) + ctx->rc_params.rc.rc_flags.bits.mb_rate_control = opt->mb_rate_control; +#else + av_log(avctx, AV_LOG_WARNING, "The MB rate control option is not " + "supported with this VAAPI version.\n"); +#endif + } + + av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate %s MB rate control = %"PRId64" bps.\n", ctx->va_rc_mode == VA_RC_CBR ? "constant" : "variable", +#if VA_CHECK_VERSION(0, 39, 2) + opt->mb_rate_control ? "with" : "without", +#else + "without", +#endif avctx->bit_rate); } else { @@ -1283,6 +1298,8 @@ static const AVOption vaapi_encode_h264_options[] = { { "low_power", "Use low-power encoding mode (experimental: only supported " "on some platforms, does not support all features)", OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, + { "mb_rate_control", "MB level bitrate control (only supported on GEN9+)", + OFFSET(mb_rate_control), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS, "mb_rate_control" }, { NULL }, }; -- 2.11.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel