From 11270e5df98fcbb67bdb32b06a89b21aa3da8f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 02:15:31 +0300 Subject: [PATCH] test(aac-sbr): full_chain_low_band uses top-K lag refinement and widens on a sub-bar winner (FMJ true lag 21566 sat outside the 20k bound) --- crates/ec-aac/tests/sbr_real_library.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/ec-aac/tests/sbr_real_library.rs b/crates/ec-aac/tests/sbr_real_library.rs index da9eeae4..e590e93b 100644 --- a/crates/ec-aac/tests/sbr_real_library.rs +++ b/crates/ec-aac/tests/sbr_real_library.rs @@ -2262,10 +2262,26 @@ fn full_chain_low_band_matches_own_core() { // without exposing the well-behaved one to the wider bound's // noise floor. const WIDE_LAG_MAX: i64 = 20_000; - // `_ex` itself widens to `SEARCH_LAG_MAX` and asserts when the - // winner sits at the bound. - let (lag, corr, _) = best_lag_correlation_ex(&ol, &ul, WIDE_LAG_MAX); + // Top-K refinement, not the single coarse winner: FMJ's single + // coarse pick landed on an in-bounds noise peak (lag 18995, + // corr 0.10) while its true alignment scores >0.99 on refine. + // A winner at the bound widens once, then is asserted off it. + let (mut lag, mut corr, mut at_edge) = + robust_lag_topk(&ol, &ul, WIDE_LAG_MAX, core_rate, 8); + let mut bound = WIDE_LAG_MAX; + // A sub-bar winner inside the narrow bound is the same symptom + // (true peak outside the search), so it widens too. + if at_edge || corr < 0.99 { + bound = SEARCH_LAG_MAX; + (lag, corr, at_edge) = robust_lag_topk(&ol, &ul, SEARCH_LAG_MAX, core_rate, 8); + } println!(" ch{ch}: measured best lag {lag}, corr {corr:.6}"); + assert!( + !at_edge, + "{} ch{ch}: winning lag {lag} sits at the +/-{bound} \ + search bound -- corr {corr:.6} is noise, not a measurement", + c.path.display() + ); assert!( corr >= 0.99, "{} ch{ch}: full-chain low band vs our own core-only decode \