forge
Explore
Log in

Don't you dare go Hollow

probe(sbr): parity-split direct-coherence instrument, even-gap vs odd-gap territory

Browse files at this commit

c39572eec7b33fbeef548d3028d638aa19e1bba9Ahmet Kaan GümüşParent: 2f5c8e2
EC_AAC_SBR_PARITY_SPLIT reports bin_level_conviction's direct-coherence mean
separately for header A's even-gap patch territory (bands 14..28, from
(0,14,14), already exact before round-35) and its odd-gap territory (bands
28..43, from (3,28,11)/(0,39,3)/(13,42,1), where round-35's Synthesis
phase-intercept correction landed) -- the region split the full-band/HF
"direct" numbers can't see (odd-gap bands are ~15 of ~100 total HF bands,
swamped by even-gap's dominant energy in any energy-weighted metric).

Round-36 before/after (git-checked-out src at HEAD~1 vs HEAD, same real
file): odd-gap direct coherence REGRESSES sharply after round-35's fix
(ch0 0.1907->0.0714, ch1 0.2461->0.0741) while even-gap stays flat (ch0
0.1526->0.1510, ch1 0.1848->0.1749) -- the opposite of the charter's
"odd-gap improves" expectation. bw=0 (EC_AAC_SBR_BW_SCALE=0) moves neither
region (ch0 even 0.1517/odd 0.0707, ch1 even 0.1745/odd 0.0727, both
indistinguishable from bw=1), exonerating the chirp/whitening IIR as the
cause of either number.
crates/ec-aac/tests/sbr_real_library.rsmodified+38 -0
@@ -1426,6 +1426,44 @@ fn sbr_real_library_matches_reference() {
14261426 );
14271427 }
14281428 }
1429+ // (Round-36, Task 2) parity-split coherence: round-35 fixed the
1430+ // Synthesis phase-intercept bug only for ODD (target-source)
1431+ // patch gaps, at the patch-copy site. On header A (the real
1432+ // file's own header) that fix can only be SEEN in the odd-gap
1433+ // territory those patches cover (bands 28..42, from patches
1434+ // (3,28,11)/(0,39,3)/(13,42,1)); the even-gap patch (0,14,14)
1435+ // covers bands 14..27 and was already exact before round-35, so
1436+ // it is the control range the fix must NOT move. Reuses
1437+ // `bin_level_conviction`'s per-bin direct-coherence measurement
1438+ // over every HF band in [14, 43) (min_band=14, top_n wide enough
1439+ // to keep every band, not just the top-energy handful), then
1440+ // averages `direct` within each region separately.
1441+ if std::env::var("EC_AAC_SBR_PARITY_SPLIT").is_ok() && n >= 4_096 {
1442+ let band_hz = f64::from(rate) / 256.0;
1443+ let win = &o[oa..oa + n];
1444+ let twin = &t[ob..ob + n];
1445+ let rows = bin_level_conviction(win, twin, rate, 14, 29);
1446+ let mean_in = |lo: usize, hi: usize| {
1447+ let vals: Vec<f64> = rows
1448+ .iter()
1449+ .filter(|(hz, ..)| {
1450+ let band = (hz / band_hz).round() as usize;
1451+ band >= lo && band < hi
1452+ })
1453+ .map(|(_, _, direct, ..)| *direct)
1454+ .collect();
1455+ if vals.is_empty() {
1456+ (0.0, 0)
1457+ } else {
1458+ (vals.iter().sum::<f64>() / vals.len() as f64, vals.len())
1459+ }
1460+ };
1461+ let (even_mean, even_n) = mean_in(14, 28);
1462+ let (odd_mean, odd_n) = mean_in(28, 43);
1463+ println!(
1464+ " ch{ch} PARITY-SPLIT direct-coherence mean: even-gap[14,28)={even_mean:.4} (n={even_n}) odd-gap[28,43)={odd_mean:.4} (n={odd_n})"
1465+ );
1466+ }
14291467 println!(
14301468 " ch{ch}: lag {lag}, full {full:.6}, below {:.0}Hz {low:.6}, above {:.0}Hz {high:.6}",
14311469 c.crossover_hz, c.crossover_hz