forge
Explore
Log in

Don't you dare go Hollow

Below-crossover band searches its own alignment lag, not the full-band winner

Browse files at this commit

226d6338eaa6bf34e63df6ecfb336af81fdd0c84Ahmet Kaan GümüşParent: f505821
  • test
    • below-crossover band searches its own alignment lag, not the full-band winner
Show full message
test(sbr): below-crossover band searches its own alignment lag, not the full-band winner

reeln ch1's full-band search lands on lag 65 while the below-crossover
(low-passed, core-only) content's own true alignment is lag 64 -- the two
differ by only 0.0015 in full-band correlation (broadband content barely
cares) but by 0.88 in below-crossover correlation, which is exactly what a
narrowband correlation surface reusing the wrong neighbour of a near-tied
full-band lag looks like. Below-crossover corr for ch1 moves 0.062 -> 0.945,
in line with ch0's own 0.993 -- the "ch1 below-crossover is worse than
full-band" anomaly was this measurement bug, not a second SBR defect.
crates/ec-aac/tests/sbr_real_library.rsmodified+24 -8
@@ -482,13 +482,30 @@ fn sbr_real_library_matches_reference() {
482 let n = WINDOW482 let n = WINDOW
483 .min(o.len().saturating_sub(oa))483 .min(o.len().saturating_sub(oa))
484 .min(t.len().saturating_sub(ob));484 .min(t.len().saturating_sub(ob));
485- let (o_low, t_low, low) = if n >= 1024 {485+ // The below-crossover band gets its OWN lag search rather than
486- let ol = lowpass(&o[oa..oa + n], rate, c.crossover_hz);486+ // reusing the full-band winning lag: a narrowband, slowly-varying
487- let tl = lowpass(&t[ob..ob + n], rate, c.crossover_hz);487+ // low-passed signal has a correlation surface that stays broad
488- let lc = correlation(&ol, &tl);488+ // and flat across many nearby lags, so a full-band search (whose
489- (ol, tl, lc)489+ // winner is decided mostly by the higher-energy/higher-bandwidth
490- } else {490+ // content) can land on a lag that is a genuine local optimum for
491- (Vec::new(), Vec::new(), 0.0)491+ // the whole signal yet a bad one for the low band alone -- on
492+ // reeln ch1, full-band lag 65 vs 64 differ by only 0.0015 in
493+ // full-band correlation but by 0.88 in below-crossover
494+ // correlation once the low band is measured at its own winning
495+ // lag instead. Both bands are still re-anchored at the SAME
496+ // `start` offset internally (see `best_lag_correlation`), so
497+ // this is genuinely comparing the low band against itself, not
498+ // drifting to an unrelated part of the file.
499+ let low = {
500+ let ol_full = lowpass(o, rate, c.crossover_hz);
501+ let tl_full = lowpass(t, rate, c.crossover_hz);
502+ let (low_lag, low_corr) = best_lag_correlation(&ol_full, &tl_full);
503+ if low_lag != lag {
504+ eprintln!(
505+ " ch{ch} below-crossover band's own best lag {low_lag} differs from full-band lag {lag}"
506+ );
507+ }
508+ low_corr
492 };509 };
493 let high = if n >= 1024 {510 let high = if n >= 1024 {
494 let oh = highpass(&o[oa..oa + n], rate, c.crossover_hz);511 let oh = highpass(&o[oa..oa + n], rate, c.crossover_hz);
@@ -501,7 +518,6 @@ fn sbr_real_library_matches_reference() {
501 " ch{ch}: lag {lag}, full {full:.6}, below {:.0}Hz {low:.6}, above {:.0}Hz {high:.6}",518 " ch{ch}: lag {lag}, full {full:.6}, below {:.0}Hz {low:.6}, above {:.0}Hz {high:.6}",
502 c.crossover_hz, c.crossover_hz519 c.crossover_hz, c.crossover_hz
503 );520 );
504- let _ = (&o_low, &t_low);
505 if std::env::var("EC_AAC_SBR_DRIFT").is_ok() && n >= 4_096 {521 if std::env::var("EC_AAC_SBR_DRIFT").is_ok() && n >= 4_096 {
506 let windows = (n / 4_096).min(20);522 let windows = (n / 4_096).min(20);
507 let drift = windowed_lag_drift(o, t, oa, ob, windows);523 let drift = windowed_lag_drift(o, t, oa, ob, windows);