diff --git a/crates/ec-opus/src/encoder.rs b/crates/ec-opus/src/encoder.rs index 2a1edcd3..59312009 100644 --- a/crates/ec-opus/src/encoder.rs +++ b/crates/ec-opus/src/encoder.rs @@ -272,6 +272,11 @@ impl Encoder { /// | + continuous 1.3 `alloc_trim` (`-r3`) | 5 | same 7, and corr worse by >.0005 on 9 rows | /// | + tf boost k=1.25 (`-r4`) | 5 | same 7 | /// | + tf boost k=1.5 (`-r5`) | 5 | same 7 | + /// | + two-pass *and* k=1.25, the combined best (`-r7`) | 5 | same 7: nik@64 .773, nik@96 1.801, her@96 1.114, dl8a@64 1.181, dl8a@96 1.014, hein@64 .977, hein@96 1.398 | + /// + /// The best aligned arm on the KEEP rule is the delay alone without + /// `dc_reject` (5 rows worse); every arm that adds `dc_reject` puts dl8a + /// in the blocking set too. /// /// The blocking set (nik, her@96, dl8a, hein) is the same in every arm and /// no arm moves any of those rows back towards its shipped value, so the diff --git a/crates/ec-opus/tests/conformance.rs b/crates/ec-opus/tests/conformance.rs index ab909296..a95d04ad 100644 --- a/crates/ec-opus/tests/conformance.rs +++ b/crates/ec-opus/tests/conformance.rs @@ -2109,7 +2109,7 @@ fn silk_mediumband_and_10ms_roundtrip() { frame_ms == 10 || voiced > 0, "{tag}: no frame coded with LTP" ); - if let Some(oracle) = oracle_decode(&format!("silk-{tag}"), &packets, pcm.len()) { + if let Some(oracle) = oracle_decode(&format!("silk-{tag}"), &packets, pcm.len(), 120) { let (c, _) = aligned_corr(&oracle, &decoded, 2000); assert!(c >= 0.99, "{tag}: our decode vs oracle decode corr {c:.4}"); } @@ -2159,7 +2159,7 @@ fn silk_multiframe_packets_roundtrip() { ); assert!(corr >= floor, "{tag}: corr {corr:.4} below {floor:.4}"); assert!(voiced > 0, "{tag}: no frame coded with LTP"); - if let Some(oracle) = oracle_decode(&format!("silk-{tag}"), &packets, pcm.len()) { + if let Some(oracle) = oracle_decode(&format!("silk-{tag}"), &packets, pcm.len(), 120) { let (c, _) = aligned_corr(&oracle, &decoded, 2500); assert!( c >= 0.99, @@ -2366,12 +2366,21 @@ fn silk_compares_to_celt_on_speech_at_speech_rates() { } /// Reference oracle decode of `packets` as Ogg-Opus, or `None` without ffmpeg. -fn oracle_decode(name: &str, packets: &[Vec], samples: usize) -> Option> { +/// `pre_skip` must be the encoder's advertised [`Encoder::look_ahead`] for +/// these packets: it is what the oracle trims off the front, so a caller that +/// compares sample-for-sample against its own decode at that same offset only +/// lines up when the two agree. +fn oracle_decode( + name: &str, + packets: &[Vec], + samples: usize, + pre_skip: usize, +) -> Option> { if Command::new("ffmpeg").arg("-version").output().is_err() { return None; } let path = temp_path(&format!("{name}.opus")); - write_ogg_opus(&path, packets, opus_head(1, 120, None), 1, samples, 120); + write_ogg_opus(&path, packets, opus_head(1, pre_skip as u16, None), 1, samples, pre_skip as i64); let out = Command::new("ffmpeg") .args(["-v", "warning", "-c:a", "libopus", "-i"]) .arg(&path) @@ -2418,7 +2427,7 @@ fn silk_nsq_improves_quality_at_equal_rate() { "{name}: corr {corr:.4} (floor {floor}) at {kbps:.1} kbps" )); } - if let Some(oracle) = oracle_decode(&format!("silk-nsq-{name}"), &packets, pcm.len()) { + if let Some(oracle) = oracle_decode(&format!("silk-nsq-{name}"), &packets, pcm.len(), 120) { let (c, _) = aligned_corr(&oracle, &decoded, 2000); assert!(c >= 0.99, "{name}: our decode vs oracle decode corr {c:.4}"); } @@ -2584,7 +2593,7 @@ fn hybrid_fb_roundtrip() { (28.0..=36.0).contains(&kbps), "{name}: {kbps:.1} kbps for a 32 kbps CBR target" ); - if let Some(oracle) = oracle_decode(&format!("hybrid-{name}"), &packets, pcm.len()) { + if let Some(oracle) = oracle_decode(&format!("hybrid-{name}"), &packets, pcm.len(), delay) { let n = oracle.len().min(decoded.len() - delay); let c = correlation(&oracle[..n], &decoded[delay..delay + n]); eprintln!("hybrid FB {name}: oracle vs ours corr {c:.4}"); diff --git a/lanes/opus-opusx2-r7.sweep.txt b/lanes/opus-opusx2-r7.sweep.txt new file mode 100644 index 00000000..f039d1af --- /dev/null +++ b/lanes/opus-opusx2-r7.sweep.txt @@ -0,0 +1,16 @@ +# lane-opusx2 r7: aligned tree + two-pass coarse energy + tf boost k=1.25 (combined winners) +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref +nik 64 69.1 69.2 -0.1 0.9883 0.9864 -0.0020 -109.28 -154.78 0.773 0.9766 0.9745 0 0 +nik 96 100.9 101.0 -0.1 0.9943 0.9940 -0.0003 -113.00 -31.55 1.801 0.9889 0.9888 0 0 +reelo 64 63.5 63.6 -0.1 0.9887 0.9866 -0.0020 -177.31 -123.36 1.335 0.9701 0.9686 0 0 +reelo 96 93.3 93.9 -0.6 0.9943 0.9937 -0.0005 -89.23 -125.18 0.801 0.9870 0.9854 0 0 +her 64 67.6 67.9 -0.5 0.9827 0.9794 -0.0033 -309.55 -339.00 0.894 0.9475 0.9406 0 0 +her 96 100.7 101.5 -0.7 0.9915 0.9902 -0.0012 -214.59 -191.50 1.114 0.9768 0.9728 0 0 +reell 64 71.3 71.3 -0.0 0.9904 0.9880 -0.0024 -271.04 -128.39 1.975 0.9712 0.9644 0 0 +reell 96 105.3 105.4 -0.0 0.9952 0.9948 -0.0004 -262.90 -29.16 3.846 0.9852 0.9804 0 0 +dl8a 64 65.7 65.8 -0.2 0.9885 0.9865 -0.0020 -426.86 -378.84 1.181 0.9789 0.9723 0 0 +dl8a 96 96.4 96.8 -0.4 0.9937 0.9934 -0.0003 -427.68 -423.47 1.014 0.9871 0.9864 0 0 +hein 64 64.7 64.9 -0.3 0.9884 0.9874 -0.0010 -381.78 -388.31 0.977 0.9320 0.9148 0 0 +hein 96 86.7 86.9 -0.3 0.9942 0.9930 -0.0012 -330.35 -246.46 1.398 0.9681 0.9499 0 0