diff --git a/crates/ec-opus/tests/conformance.rs b/crates/ec-opus/tests/conformance.rs index 0ca4ef51..3c991770 100644 --- a/crates/ec-opus/tests/conformance.rs +++ b/crates/ec-opus/tests/conformance.rs @@ -3427,11 +3427,16 @@ fn spectral_divergence_vs_libopus() { const FRAME: usize = 960; const CHANNELS: usize = 2; const MAX_LAG: usize = 2000; - const KBPS: u32 = 96; + let kbps_env: u32 = std::env::var("SWEEP_KBPS").ok().and_then(|v| v.parse().ok()).unwrap_or(96); + #[allow(non_snake_case)] + let KBPS: u32 = kbps_env; let all: &[(&str, &str)] = &[ ("reell", "~/Music/reell.mp4"), ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), + ("her", "~/Music/reeli.mp3"), + ("reelm", "~/Music/reelm.wav"), + ("hein", "~/Downloads/reelm.mp3"), ]; let only: Vec = std::env::var("SWEEP_ONLY") .unwrap_or_else(|_| "reell,dl8a".to_owned()) @@ -3500,6 +3505,24 @@ fn spectral_divergence_vs_libopus() { diags.push(enc.last_celt_diag().clone()); } let ours_kbps = ours_bytes as f64 * 8.0 / seconds / 1000.0; + // Transient-frame counts as the decoder sees them: libopus vs ours. + let count_transients = |pkts: &[Vec]| -> (usize, usize) { + let mut d = Decoder::new(48000, CHANNELS).unwrap(); + let mut buf = vec![0.0f32; 5760 * CHANNELS]; + let mut t = 0usize; + for p in pkts { + if d.decode_float(p, &mut buf).is_ok() && d.last_celt_diag().transient { + t += 1; + } + } + (t, pkts.len()) + }; + let (ref_tr, ref_n) = count_transients(&ref_pkts); + let ours_tr = diags.iter().filter(|d| d.is_transient).count(); + eprintln!( + "{tag}@{KBPS}k transient frames: ours {ours_tr}/{} ref {ref_tr}/{ref_n}", + diags.len() + ); let ours_trim: Vec = ours_dec.into_iter().take(source_frames * CHANNELS).collect(); let (_, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); let ours_i16 = to_i16(&ours_aligned); diff --git a/lanes/opus-64-r5.report.md b/lanes/opus-64-r5.report.md new file mode 100644 index 00000000..a3924496 --- /dev/null +++ b/lanes/opus-64-r5.report.md @@ -0,0 +1,23 @@ +# lane-opus-64 r5 — transient_analysis port shipped; tf_estimate consumers rejected by measurement + +State shipped: r4 `transient_analysis` port (tf_estimate/tf_chan computed, `TF_ANALYSIS=false`). + +## 14-row gate (lanes/opus-64-r5.sweep.txt) vs lanes/opus-reell-r2.sweep.txt +- her@96 err_ratio 10.13 -> 1.18 (Q -900 -> -234), her@64 4.65 -> 0.76. Residue (b) closed. +- reelm@64 gap +.0043 -> +.0046 (minsec .9151 -> .9085); hein@64 gap +.0020 -> +.0031 (corr -.0011). +- All other rows within +-.0005; RATE GATE all within +-5%; DROPOUT GATE passed. + +## Ablations on reelm/hein@64 (logs opus-64-r5.*.log) +- libopus VBR `target += 2*(tf_estimate-0.044)*target` replacing the 7/4 stand-in: rate -1.8%, + gap +.0074/+.0052, 1 s dropouts each -> rejected. +- libopus trim `-= 2*tf_estimate`: gap +.0049/+.0034 (= baseline noise) -> rejected. +- Both: gap +.0077/+.0056, drops -> rejected. + +## Cause narrowed (spectral_divergence_vs_libopus, new transient count, SWEEP_KBPS=64) +transient frames ours/ref: her 529/533, reelm 1807/1788, hein 2028/2054 (<=1.5%). +Detector parity holds; the reelm/hein 64k residue is how short-block frames are coded +(~30% of frames on those sources), not how many are declared. tf_analysis ON was neutral. + +## Test surface +- `spectral_divergence_vs_libopus`: `SWEEP_KBPS` env, sources her/reelm/hein, prints + decoder-seen transient counts ours vs libopus. diff --git a/lanes/opus-64-r5.sweep.txt b/lanes/opus-64-r5.sweep.txt new file mode 100644 index 00000000..7e97b2d7 --- /dev/null +++ b/lanes/opus-64-r5.sweep.txt @@ -0,0 +1,16 @@ +nik@64k: ref 69.2 ours 69.2 kbps (+0.0%), corr o=0.9876 r=0.9864 gap=-0.0012, Q o=-399.22 r=-154.78, err_ratio 2.764, minsec o=0.9759 r=0.9745, drop o=0 r=0 +nik@96k: ref 101.0 ours 100.8 kbps (-0.2%), corr o=0.9944 r=0.9940 gap=-0.0003, Q o=-227.79 r=-31.55, err_ratio 3.239, minsec o=0.9881 r=0.9888, drop o=0 r=0 +reelo@64k: ref 63.6 ours 63.5 kbps (-0.0%), corr o=0.9883 r=0.9866 gap=-0.0017, Q o=-335.73 r=-123.36, err_ratio 2.618, minsec o=0.9644 r=0.9686, drop o=0 r=0 +reelo@96k: ref 93.9 ours 93.8 kbps (-0.0%), corr o=0.9946 r=0.9937 gap=-0.0009, Q o=-265.38 r=-125.18, err_ratio 1.966, minsec o=0.9862 r=0.9854, drop o=0 r=0 +her@64k: ref 67.9 ours 67.3 kbps (-0.9%), corr o=0.9827 r=0.9794 gap=-0.0033, Q o=-839.84 r=-339.00, err_ratio 4.650, minsec o=0.9472 r=0.9406, drop o=0 r=0 +her@96k: ref 101.5 ours 100.9 kbps (-0.6%), corr o=0.9913 r=0.9902 gap=-0.0011, Q o=-899.99 r=-191.50, err_ratio 10.126, minsec o=0.9730 r=0.9728, drop o=0 r=0 +reell@64k: ref 71.3 ours 71.3 kbps (-0.0%), corr o=0.9903 r=0.9880 gap=-0.0024, Q o=-222.24 r=-128.39, err_ratio 1.603, minsec o=0.9700 r=0.9644, drop o=0 r=0 +reell@96k: ref 105.4 ours 105.3 kbps (-0.0%), corr o=0.9954 r=0.9948 gap=-0.0007, Q o=-229.13 r=-29.16, err_ratio 3.328, minsec o=0.9852 r=0.9804, drop o=0 r=0 +reelm@64k: ref 63.3 ours 62.6 kbps (-1.1%), corr o=0.9816 r=0.9859 gap=+0.0043, Q o=-389.15 r=-392.46, err_ratio 0.988, minsec o=0.9151 r=0.9100, drop o=0 r=0 +reelm@96k: ref 84.8 ours 84.0 kbps (-1.0%), corr o=0.9920 r=0.9920 gap=-0.0001, Q o=-303.07 r=-231.16, err_ratio 1.346, minsec o=0.9661 r=0.9511, drop o=0 r=0 +dl8a@64k: ref 65.8 ours 65.4 kbps (-0.6%), corr o=0.9879 r=0.9865 gap=-0.0015, Q o=-386.87 r=-378.84, err_ratio 1.029, minsec o=0.9744 r=0.9723, drop o=0 r=0 +dl8a@96k: ref 96.8 ours 96.0 kbps (-0.9%), corr o=0.9939 r=0.9934 gap=-0.0006, Q o=-340.97 r=-423.47, err_ratio 0.747, minsec o=0.9858 r=0.9864, drop o=0 r=0 +hein@64k: ref 64.9 ours 64.5 kbps (-0.6%), corr o=0.9853 r=0.9874 gap=+0.0020, Q o=-426.68 r=-388.31, err_ratio 1.141, minsec o=0.9209 r=0.9148, drop o=0 r=0 +hein@96k: ref 86.9 ours 86.3 kbps (-0.7%), corr o=0.9937 r=0.9930 gap=-0.0006, Q o=-376.12 r=-246.46, err_ratio 1.653, minsec o=0.9675 r=0.9499, drop o=0 r=0 +RATE GATE: all rows within ±5% +DROPOUT GATE: passed (no ours-only dropouts)