From b26dc3b5e8d09dbd49cb148ac0ec68ee6066fa5f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 28 Oct 2024 23:30:57 -0500 Subject: [PATCH] fix(vaapi): use VBR rate control mode --- src/platform/linux/vaapi.cpp | 10 ---------- src/video.cpp | 6 ++++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/platform/linux/vaapi.cpp b/src/platform/linux/vaapi.cpp index ada6370034a..cd1d81f61d4 100644 --- a/src/platform/linux/vaapi.cpp +++ b/src/platform/linux/vaapi.cpp @@ -129,16 +129,6 @@ namespace va { return 0; } - void - init_codec_options(AVCodecContext *ctx, AVDictionary *options) override { - // Don't set the RC buffer size when using H.264 on Intel GPUs. It causes - // major encoding quality degradation. - auto vendor = vaQueryVendorString(va_display); - if (ctx->codec_id != AV_CODEC_ID_H264 || (vendor && !strstr(vendor, "Intel"))) { - ctx->rc_buffer_size = ctx->bit_rate * ctx->framerate.den / ctx->framerate.num; - } - } - int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx_buf) override { this->hwframe.reset(frame); diff --git a/src/video.cpp b/src/video.cpp index 3824c295727..4a2c85d969e 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -859,6 +859,7 @@ namespace video { { "low_power"s, 1 }, { "async_depth"s, 1 }, { "idr_interval"s, std::numeric_limits::max() }, + { "rc_mode"s, "VBR"s }, }, {}, // SDR-specific options {}, // HDR-specific options @@ -878,6 +879,7 @@ namespace video { { "async_depth"s, 1 }, { "sei"s, 0 }, { "idr_interval"s, std::numeric_limits::max() }, + { "rc_mode"s, "VBR"s }, }, {}, // SDR-specific options {}, // HDR-specific options @@ -897,6 +899,7 @@ namespace video { { "async_depth"s, 1 }, { "sei"s, 0 }, { "idr_interval"s, std::numeric_limits::max() }, + { "rc_mode"s, "VBR"s }, }, {}, // SDR-specific options {}, // HDR-specific options @@ -909,8 +912,7 @@ namespace video { std::make_optional("qp"s, &config::video.qp), "h264_vaapi"s, }, - // RC buffer size will be set in platform code if supported - LIMITED_GOP_SIZE | PARALLEL_ENCODING | SINGLE_SLICE_ONLY | NO_RC_BUF_LIMIT + LIMITED_GOP_SIZE | PARALLEL_ENCODING | SINGLE_SLICE_ONLY }; #endif