ffmpeg-encoder/nvenc: Test for "h264_nvenc" in for "Adaptive B-Frames"

Fixes the bug where "Adaptive B-Frames" would not be applied in the way it was expected to be applied.

Related: #191
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-04-25 00:59:27 +02:00
parent fb024cad73
commit 0966b61f76

View file

@ -584,25 +584,18 @@ void nvenc::update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* c
av_opt_set_int(context->priv_data, "rc-lookahead", la, AV_OPT_SEARCH_CHILDREN);
}
if (la > 0) {
// Adaptive I-Frames
if (int64_t adapt_i = obs_data_get_int(settings, KEY_RATECONTROL_ADAPTIVEI);
!util::is_tristate_default(adapt_i)) {
av_opt_set_int(context->priv_data, "no-scenecut", adapt_i, AV_OPT_SEARCH_CHILDREN);
}
// Adaptive I-Frames
if (int64_t adapt_i = obs_data_get_int(settings, KEY_RATECONTROL_ADAPTIVEI);
!util::is_tristate_default(adapt_i) && (la != 0)) {
av_opt_set_int(context->priv_data, "no-scenecut", adapt_i, AV_OPT_SEARCH_CHILDREN);
}
// Adaptive B-Frames
if (strcmp(codec->name, "h264_nvenc")) {
if (int64_t adapt_b = obs_data_get_int(settings, KEY_RATECONTROL_ADAPTIVEB);
!util::is_tristate_default(adapt_b)) {
av_opt_set_int(context->priv_data, "b_adapt", adapt_b, AV_OPT_SEARCH_CHILDREN);
}
}
} else {
// These two do not work if lookahead is set to 0 frames (disabled).
av_opt_set_int(context->priv_data, "no-scenecut", 0, AV_OPT_SEARCH_CHILDREN);
if (strcmp(codec->name, "h264_nvenc")) {
av_opt_set_int(context->priv_data, "b_adapt", 0, AV_OPT_SEARCH_CHILDREN);
// Adaptive B-Frames
constexpr std::string_view h264_encoder_name = "h264_nvenc";
if (h264_encoder_name == codec->name) {
if (int64_t adapt_b = obs_data_get_int(settings, KEY_RATECONTROL_ADAPTIVEB);
!util::is_tristate_default(adapt_b) && (la != 0)) {
av_opt_set_int(context->priv_data, "b_adapt", adapt_b, AV_OPT_SEARCH_CHILDREN);
}
}