Skip to content

Commit

Permalink
fix(vaapi): use VBR rate control mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman committed Oct 29, 2024
1 parent bd2e1dc commit b26dc3b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/platform/linux/vaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ namespace video {
{ "low_power"s, 1 },
{ "async_depth"s, 1 },
{ "idr_interval"s, std::numeric_limits<int>::max() },
{ "rc_mode"s, "VBR"s },
},
{}, // SDR-specific options
{}, // HDR-specific options
Expand All @@ -878,6 +879,7 @@ namespace video {
{ "async_depth"s, 1 },
{ "sei"s, 0 },
{ "idr_interval"s, std::numeric_limits<int>::max() },
{ "rc_mode"s, "VBR"s },
},
{}, // SDR-specific options
{}, // HDR-specific options
Expand All @@ -897,6 +899,7 @@ namespace video {
{ "async_depth"s, 1 },
{ "sei"s, 0 },
{ "idr_interval"s, std::numeric_limits<int>::max() },
{ "rc_mode"s, "VBR"s },
},
{}, // SDR-specific options
{}, // HDR-specific options
Expand All @@ -909,8 +912,7 @@ namespace video {
std::make_optional<encoder_t::option_t>("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

Expand Down

0 comments on commit b26dc3b

Please sign in to comment.