forge
Explore
Log in

Don't you dare go Hollow

Noise-fraction anchor summed core bands into a "whole-HF" ratio

Browse files at this commit

dccdbb8091c2f44f82ae0ac6108666df847ca1b0Ahmet Kaan GümüşParent: 4aa4b5f
  • test
    • noise-fraction anchor summed core bands into a "whole-HF" ratio
Show full message
test(aac/sbr): noise-fraction anchor summed core bands into a "whole-HF" ratio

`sbr_actual_noise_fraction` is env-gated (it sets process env vars mid-run,
which is unsound alongside parallel tests), so no default run executes it.
Run by hand it FAILED: "whole-HF realized noise fraction regressed to 0.0397
(round-44 fix floor is 0.17)".

Nothing regressed. Every band above the crossover realizes 0.15-0.27 of its
energy as injected noise, right where round-42/44 left it; the total was
diluted. `bin_level_conviction`'s rows start at `MIN_BAND` = 14 on ITS band
scale (rate/256, so ~2412 Hz), while this stream's crossover is QMF band 14
on the OTHER scale (rate/128, 4823 Hz) -- the same integer, two scales. The
dozen core-decoded rows that opens with carry an order of magnitude more
energy than the SBR-generated ones (6.4e4 vs ~5e3) and, by definition, zero
injected noise, so averaging them in dragged the ratio to 0.0397.

The total now starts at the stream's own crossover, taken from the lowest QMF
band the bookkeeping table holds (which IS `kx`), so a future QMF-mapping
change cannot silently invalidate it the way a constant did. It reads 0.1774
-- round-44 measured 0.1770 on this file -- and the assertion passes
untouched at its original 0.17 floor. Noise injection is also still doing
work: zeroing it costs 0.000847 of full-band correlation against the
reference.

Both anchors' SKIP lines now print the exact command that runs them, since
being invisible to default runs is what let a stale instrument sit unread.

`sbr_instrument_anchor_controls` was run too, and passes: ours-vs-ours 1.0000,
reference-vs-remux 1.0000, reference vs itself at a 64-sample offset 0.9317
mean / 0.3323 min (the coherence floor the instrument itself imposes).

Suite: 16 passed, 0 failed (54.1s).
crates/ec-aac/tests/sbr_real_library.rsmodified+25 -2
@@ -3392,7 +3392,10 @@ fn report_conviction(label: &str, rows: &[(f64, f64, f64, f64, f64, f64)]) {
3392 #[test]3392 #[test]
3393 fn sbr_instrument_anchor_controls() {3393 fn sbr_instrument_anchor_controls() {
3394 if std::env::var("EC_AAC_SBR_INSTRUMENT_ANCHOR").is_err() {3394 if std::env::var("EC_AAC_SBR_INSTRUMENT_ANCHOR").is_err() {
3395- eprintln!("SKIP: set EC_AAC_SBR_INSTRUMENT_ANCHOR=1 to run (round-41 Task 1)");3395+ eprintln!(
3396+ "SKIP (round-41 Task 1): EC_AAC_SBR_INSTRUMENT_ANCHOR=1 cargo test -p ec-aac \
3397+ --release --test sbr_real_library sbr_instrument_anchor_controls -- --nocapture"
3398+ );
3396 return;3399 return;
3397 }3400 }
3398 if !have_ffmpeg() {3401 if !have_ffmpeg() {
@@ -3468,7 +3471,12 @@ fn sbr_instrument_anchor_controls() {
3468 #[test]3471 #[test]
3469 fn sbr_actual_noise_fraction() {3472 fn sbr_actual_noise_fraction() {
3470 if std::env::var("EC_AAC_SBR_NOISE_ANCHOR").is_err() {3473 if std::env::var("EC_AAC_SBR_NOISE_ANCHOR").is_err() {
3471- eprintln!("SKIP: set EC_AAC_SBR_NOISE_ANCHOR=1 to run (round-41 Task 2)");3474+ eprintln!(
3475+ "SKIP (round-41 Task 2): EC_AAC_SBR_NOISE_ANCHOR=1 cargo test -p ec-aac \
3476+ --release --test sbr_real_library sbr_actual_noise_fraction -- \
3477+ --nocapture --test-threads=1 (env-gated because it sets process \
3478+ env vars mid-run, which is unsound alongside parallel tests)"
3479+ );
3472 return;3480 return;
3473 }3481 }
3474 if !have_ffmpeg() {3482 if !have_ffmpeg() {
@@ -3528,6 +3536,8 @@ fn sbr_actual_noise_fraction() {
3528 // not a decoder coverage gap (verified: `noise_fraction_table()` itself3536 // not a decoder coverage gap (verified: `noise_fraction_table()` itself
3529 // has nonzero entries for QMF bands up to `k2`).3537 // has nonzero entries for QMF bands up to `k2`).
3530 let band_hz = f64::from(rate) / 128.0;3538 let band_hz = f64::from(rate) / 128.0;
3539+ let kx_band = bookkept.iter().map(|(b, ..)| *b).min().unwrap_or(0);
3540+ println!(" (crossover: QMF band {kx_band}, {:.0} Hz -- rows below it are core-decoded and excluded from the total)", kx_band as f64 * band_hz);
3531 println!(3541 println!(
3532 " ACTUAL noise fraction (band_hz, energy_on, energy_off, actual_fraction, bookkept_fraction):"3542 " ACTUAL noise fraction (band_hz, energy_on, energy_off, actual_fraction, bookkept_fraction):"
3533 );3543 );
@@ -3553,6 +3563,19 @@ fn sbr_actual_noise_fraction() {
3553 println!(3563 println!(
3554 " {hz:>6.0}Hz: on {e_on:.3e} off {e_off:.3e} actual {actual:.4} bookkept {book:.4}"3564 " {hz:>6.0}Hz: on {e_on:.3e} off {e_off:.3e} actual {actual:.4} bookkept {book:.4}"
3555 );3565 );
3566+ // HF ONLY (round-61): `MIN_BAND` (14, ~2412 Hz at 44.1k) sits BELOW
3567+ // this stream's crossover (~4500 Hz), so the row list opens with a
3568+ // dozen core-decoded bands that carry an order of magnitude more
3569+ // energy than the SBR-generated ones (6.4e4 vs ~5e3) and, by
3570+ // definition, zero injected noise. Summing them into a "whole-HF"
3571+ // ratio dilutes it toward zero -- that is how this metric read
3572+ // 0.0397 while every band above the crossover was realizing
3573+ // 0.15-0.27. The crossover comes from the bookkeeping table itself
3574+ // (its lowest QMF band IS `kx`), so it tracks the stream instead of
3575+ // a constant that a QMF-mapping change can invalidate.
3576+ if band < kx_band {
3577+ continue;
3578+ }
3556 sum_on += e_on;3579 sum_on += e_on;
3557 sum_delta += e_on - e_off;3580 sum_delta += e_on - e_off;
3558 }3581 }