From dd00c7cff2bb2ab8d73ef6cc7d8ffc0bae97d757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 20 Aug 2026 10:32:30 +0300 Subject: [PATCH] fix(aac-sbr-test): whole-file windowed corr mean was double-applying the alignment lag 197cd44's cheap default path (no per-window search) added the global `lag` on top of `oa`/`ob`, which already encode that same shift via their differing base offsets -- every window ended up an extra `lag` samples out of alignment. That collapsed reeln's reported WHOLE-FILE windowed corr mean from ~0.95 to 0.14/0.21 while the single-WINDOW full/low numbers (which don't go through this path) stayed at 0.96-0.97, making it look like a real late-file collapse. Corrected mean: ch0 0.953189, ch1 0.949116 -- in line with round 41's 0.9565/0.9512, decode itself never regressed. Round 48's feed-forward FIR verdict is unaffected: it was based on `full`/`low`/QMF-witness numbers, none of which go through this buggy path. --- crates/ec-aac/tests/sbr_real_library.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ec-aac/tests/sbr_real_library.rs b/crates/ec-aac/tests/sbr_real_library.rs index 6852f001..fe379649 100644 --- a/crates/ec-aac/tests/sbr_real_library.rs +++ b/crates/ec-aac/tests/sbr_real_library.rs @@ -2383,7 +2383,14 @@ fn sbr_real_library_matches_reference() { } else { (0..windows) .filter_map(|w| { - let base_o = (oa as i64 + lag + (w * 4_096) as i64).try_into().ok()?; + // `oa`/`ob` (computed above from `lag`) already encode the + // alignment shift via their differing base offsets -- do NOT + // add `lag` again here, that double-applies it and shifts + // every window an extra `lag` samples out of alignment + // (this collapsed the whole-file mean from ~0.96 to ~0.14 + // while leaving the single-WINDOW `full`/`low` numbers, + // which don't go through this path, unaffected). + let base_o = oa + w * 4_096; let base_t = ob + w * 4_096; if base_o + 4_096 > o.len() || base_t + 4_096 > t.len() { return None;