From 8ebb43fe60f65066396db160616caadf288c2944 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 25 Oct 2026 19:28:26 -0400 Subject: [PATCH] fix(h264): restore the MMCO 6 long-term index range check --- crates/h264/src/dpb.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/h264/src/dpb.rs b/crates/h264/src/dpb.rs index 7f38a148..a74799d9 100644 --- a/crates/h264/src/dpb.rs +++ b/crates/h264/src/dpb.rs @@ -352,12 +352,19 @@ impl Dpb { had5 = true; } 6 => { - for e in &mut self.entries { - if e.mark == RefMark::Long && e.long_term_frame_idx == m.long_term_frame_idx { - e.mark = RefMark::Unused; + // Only an index within the allowed range may be assigned (8.2.5.4.6). + let allowed = match self.max_long_term_frame_idx { + Some(max) => m.long_term_frame_idx <= max, + None => false, + }; + if allowed { + for e in &mut self.entries { + if e.mark == RefMark::Long && e.long_term_frame_idx == m.long_term_frame_idx { + e.mark = RefMark::Unused; + } } + *cur_long = Some(m.long_term_frame_idx); } - *cur_long = Some(m.long_term_frame_idx); } _ => {} }