Skip to content

Commit

Permalink
fixup! nvenc: improve rfi logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ns6089 committed Aug 22, 2023
1 parent c2654dd commit 187e37c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/nvenc/nvenc_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,16 +458,21 @@ namespace nvenc {
nvenc_base::invalidate_ref_frames(uint64_t first_frame, uint64_t last_frame) {
if (!encoder || !encoder_params.rfi) return false;

if (first_frame == encoder_state.last_rfi_range.first &&
if (first_frame >= encoder_state.last_rfi_range.first &&
last_frame <= encoder_state.last_rfi_range.second) {
BOOST_LOG(debug) << "NvEnc: rfi request " << first_frame << "-" << last_frame << " already done";
return true;
}

if (last_frame < first_frame) {
BOOST_LOG(error) << "NvEnc: invaid rfi request " << first_frame << "-" << last_frame << ", generating IDR";
return false;
}

BOOST_LOG(debug) << "NvEnc: rfi request " << first_frame << "-" << last_frame << " expanding to last encoded frame " << encoder_state.last_encoded_frame_index;
last_frame = encoder_state.last_encoded_frame_index;

if (last_frame < first_frame || last_frame - first_frame + 1 >= encoder_params.ref_frames_in_dpb) {
if (last_frame - first_frame + 1 >= encoder_params.ref_frames_in_dpb) {
BOOST_LOG(debug) << "NvEnc: rfi request too large, generating IDR";
return false;
}
Expand Down

0 comments on commit 187e37c

Please sign in to comment.