[FFmpeg-devel] [PATCH v2 1/2] vaapi_encode: ensure correct VBR bitrate is used in h264 SPS
Mark Thompson
sw at jkqxz.net
Wed Aug 21 00:05:36 EEST 2019
On 13/08/2019 02:04, Aman Gupta wrote:
> From: Aman Gupta <aman at tmm1.net>
>
> This is a regression from 2562dd9e7831743ba6dc5680501fb7d26a2ec62c
> which surfaces a pathological bug in some Intel hardware encoders,
> causing very low bitrates to be generated whenever VBR mode is used.
>
> /cc intel/intel-vaapi-driver#480
>
> Signed-off-by: Aman Gupta <aman at tmm1.net>
> ---
> libavcodec/vaapi_encode.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index e69b59fa37..231efba6cc 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1665,6 +1665,9 @@ rc_mode_found:
> ctx->va_rc_mode = rc_mode->va_mode;
> ctx->va_bit_rate = rc_bits_per_second;
>
> + if (ctx->va_rc_mode == VA_RC_VBR)
> + ctx->va_bit_rate = rc_bits_per_second * rc_target_percentage / 100;
> +
> av_log(avctx, AV_LOG_VERBOSE, "RC mode: %s.\n", rc_mode->name);
> if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
> // This driver does not want the RC mode attribute to be set.
>
The bits_per_second value in the sequence parameters has to match the one in the rate control parameters. That's the max rate value, not the target as modified by target_percentage.
For i965, see <https://github.com/intel/intel-vaapi-driver/blob/master/src/i965_encoder.c> (lines 392, 584, 743). When they don't match, it will repeatedly try to change the target bitrate and reset everything.
On 13/08/2019 03:42, Fu, Linjie wrote:
>
> If it's a driver related issue, IMHO we'd better have it fixed in specific driver.
This.
Thanks,
- Mark
More information about the ffmpeg-devel
mailing list