From 3ed86305350cf0c9494858f943e02cac22274d3d Mon Sep 17 00:00:00 2001 From: Matthew Jackson <1085847+MattJackson@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:31:39 -0700 Subject: [PATCH] Take a lone sample window from the middle of its extent A title cut into 50-odd clips gives each extent one window's worth of budget. At the extent's head, every clip is sampled at the same relative position and the first clip's window lands on the opening of the feature -- the one stretch with no subtitles in it. --- src/disc/pgs_forced_probe.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/disc/pgs_forced_probe.rs b/src/disc/pgs_forced_probe.rs index a7c3091..b6bd36d 100644 --- a/src/disc/pgs_forced_probe.rs +++ b/src/disc/pgs_forced_probe.rs @@ -176,7 +176,12 @@ fn plan_windows(sector_count: u32, share: u32) -> Vec { (0..windows) .map(|i| SampleWindow { offset: if windows == 1 { - 0 + // A title cut into many clips gives each extent a share worth one + // window. Putting that window at the extent's head samples every + // clip at the same relative position — and for the FIRST clip + // that position is the start of the feature, the one stretch a + // film reliably has no subtitles in. Take the middle instead. + align_down(span / 2) } else { // u64: `span * i` overflows u32 for a large extent. align_down((u64::from(span) * u64::from(i) / u64::from(windows - 1)) as u32) @@ -2508,4 +2513,22 @@ mod tests { "the run's final display set must still be observed" ); } + + /// A title cut into many clips gives each extent a single window's worth of + /// budget. That window must not sit at the extent's head: sampled at the head, + /// every clip is read at the same relative position, and for the first clip + /// that position is the opening of the feature — the one stretch that + /// reliably has no subtitles in it, which is the whole defect being fixed. + #[test] + fn a_single_window_sample_is_taken_from_the_middle_of_the_extent() { + let sectors = 524_288u32; + let share = 2_439u32; // the shape a 50-clip feature produces + let plan = plan_windows(sectors, share); + assert_eq!(plan.len(), 1, "one window's worth of share"); + let w = plan[0]; + assert!( + w.offset > sectors / 4 && w.offset + w.len < sectors / 4 * 3, + "the lone window must be taken from the middle, got {w:?} of {sectors}" + ); + } }