Leave reference frames unspecified if REF_FRAMES_RESTRICT is not supported

FFmpeg codecs specify their own defaults that we shouldn't override.
This commit is contained in:
Cameron Gutman 2023-04-14 18:08:53 -05:00
parent 808187397d
commit 8f74c3b482

View File

@ -1106,12 +1106,14 @@ namespace video {
ctx->keyint_min = std::numeric_limits<int>::max();
if (config.numRefFrames == 0) {
ctx->refs = video_format[encoder_t::REF_FRAMES_AUTOSELECT] ? 0 : 16;
}
else {
// Some client decoders have limits on the number of reference frames
ctx->refs = video_format[encoder_t::REF_FRAMES_RESTRICT] ? config.numRefFrames : 0;
// Some client decoders have limits on the number of reference frames
if (config.numRefFrames) {
if (video_format[encoder_t::REF_FRAMES_RESTRICT]) {
ctx->refs = config.numRefFrames;
}
else {
BOOST_LOG(warning) << "Client requested reference frame limit, but encoder doesn't support it!"sv;
}
}
ctx->flags |= (AV_CODEC_FLAG_CLOSED_GOP | AV_CODEC_FLAG_LOW_DELAY);