Noise-fraction anchor summed core bands into a "whole-HF" ratio
Browse files at this commitdccdbb8091c2f44f82ae0ac6108666df847ca1b0Parent: 4aa4b5f- test
- noise-fraction anchor summed core bands into a "whole-HF" ratio
1 changed file +25 -2
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 | 3392 | #[test] |
| 3393 | 3393 | fn sbr_instrument_anchor_controls() { |
| 3394 | 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 | 3399 | return; |
| 3397 | 3400 | } |
| 3398 | 3401 | if !have_ffmpeg() { |
| @@ -3468,7 +3471,12 @@ fn sbr_instrument_anchor_controls() { | ||
| 3468 | 3471 | #[test] |
| 3469 | 3472 | fn sbr_actual_noise_fraction() { |
| 3470 | 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 | 3480 | return; |
| 3473 | 3481 | } |
| 3474 | 3482 | if !have_ffmpeg() { |
| @@ -3528,6 +3536,8 @@ fn sbr_actual_noise_fraction() { | ||
| 3528 | 3536 | // not a decoder coverage gap (verified: `noise_fraction_table()` itself |
| 3529 | 3537 | // has nonzero entries for QMF bands up to `k2`). |
| 3530 | 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 | 3541 | println!( |
| 3532 | 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 | 3563 | println!( |
| 3554 | 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 | 3579 | sum_on += e_on; |
| 3557 | 3580 | sum_delta += e_on - e_off; |
| 3558 | 3581 | } |