Skip to content

Commit

Permalink
Don't fall back to undefined ref frame count on HEVC/AV1 if H.264 suc…
Browse files Browse the repository at this point in the history
…ceded with ref frame count specified

I don't think there are any encoders out there that support this for some codecs and not others.
  • Loading branch information
cgutman committed Feb 7, 2024
1 parent 38d45b3 commit aee88f3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,13 @@ namespace video {
if (disp->is_codec_supported(encoder.hevc.name, config_autoselect)) {
retry_hevc:
auto max_ref_frames_hevc = validate_config(disp, encoder, config_max_ref_frames);
auto autoselect_hevc = max_ref_frames_hevc >= 0 ? max_ref_frames_hevc : validate_config(disp, encoder, config_autoselect);

// If H.264 succeeded with max ref frames specified, assume that we can count on
// HEVC to also succeed with max ref frames specified if HEVC is supported.
auto autoselect_hevc = (max_ref_frames_hevc >= 0 || max_ref_frames_h264 >= 0) ?
max_ref_frames_hevc :
validate_config(disp, encoder, config_autoselect);

if (autoselect_hevc < 0 && encoder.hevc.qp && encoder.hevc[encoder_t::CBR]) {
// It's possible the encoder isn't accepting Constant Bit Rate. Turn off CBR and make another attempt
encoder.hevc.capabilities.set();
Expand Down Expand Up @@ -2511,7 +2517,13 @@ namespace video {
if (disp->is_codec_supported(encoder.av1.name, config_autoselect)) {
retry_av1:
auto max_ref_frames_av1 = validate_config(disp, encoder, config_max_ref_frames);
auto autoselect_av1 = max_ref_frames_av1 >= 0 ? max_ref_frames_av1 : validate_config(disp, encoder, config_autoselect);

// If H.264 succeeded with max ref frames specified, assume that we can count on
// AV1 to also succeed with max ref frames specified if AV1 is supported.
auto autoselect_av1 = (max_ref_frames_av1 >= 0 || max_ref_frames_h264 >= 0) ?
max_ref_frames_av1 :
validate_config(disp, encoder, config_autoselect);

if (autoselect_av1 < 0 && encoder.av1.qp && encoder.av1[encoder_t::CBR]) {
// It's possible the encoder isn't accepting Constant Bit Rate. Turn off CBR and make another attempt
encoder.av1.capabilities.set();
Expand Down

0 comments on commit aee88f3

Please sign in to comment.