diff --git a/crates/ec-opus/tests/conformance.rs b/crates/ec-opus/tests/conformance.rs index 27dc8956..ab909296 100644 --- a/crates/ec-opus/tests/conformance.rs +++ b/crates/ec-opus/tests/conformance.rs @@ -2513,6 +2513,15 @@ fn hybrid_roundtrip( /// The two layers of a hybrid packet reach the decoder's output at the same /// delay: a click's low-band-only and high-band-only peaks coincide at the /// encoder's documented look-ahead. +/// The delay [`hybrid_roundtrip`]'s encoder advertises for a 20 ms frame — +/// [`Encoder::look_ahead`] of that same configuration, so the lag assertions +/// track the layer's real delay instead of a constant. +fn hybrid_delay(bps: u32) -> usize { + let mut enc = Encoder::new(48000, 1, Application::Voip).unwrap(); + enc.set_bitrate(bps); + enc.look_ahead(960) +} + #[test] fn hybrid_layers_align() { let mut click = vec![0f32; 48000]; @@ -2528,25 +2537,18 @@ fn hybrid_layers_align() { }; let (lb, _) = hybrid_roundtrip(&click, 32_000, None, (true, false)); let (hb, _) = hybrid_roundtrip(&click, 32_000, None, (false, true)); - let enc = Encoder::new(48000, 1, Application::Voip).unwrap(); + let delay = hybrid_delay(32_000) as i64; let (plb, phb) = (peak(&lb) as i64 - at as i64, peak(&hb) as i64 - at as i64); - eprintln!( - "hybrid click: LB peak +{plb}, HB peak +{phb}, look_ahead {}", - { - let mut e = enc.clone(); - e.set_bitrate(32_000); - e.look_ahead(960) - } - ); - // A fullband CELT click lands at exactly +312 (`celt_click_peak_offset`: - // the MDCT overlap plus the 192-sample input delay compensation); - // the band-limited HB layer's main lobe sits up to 2 samples early once - // transient frames keep their short blocks, and SILK lands at +121. + eprintln!("hybrid click: LB peak +{plb}, HB peak +{phb}, look_ahead {delay}"); + // A fullband CELT click lands at exactly the encoder's advertised delay + // (`celt_click_peak_offset`); the band-limited HB layer's main lobe sits + // up to 2 samples early once transient frames keep their short blocks, + // and SILK lands one sample late. assert!( (plb - phb).abs() <= 3, "layers misaligned: LB +{plb} vs HB +{phb}" ); - assert!((phb - 312).abs() <= 2, "HB peak +{phb}, look_ahead 312"); + assert!((phb - delay).abs() <= 2, "HB peak +{phb}, look_ahead {delay}"); } /// 20 ms FB hybrid at 32 kbps: decodes in our decoder range-exactly, tracks @@ -2572,11 +2574,7 @@ fn hybrid_fb_roundtrip() { ); assert!(corr >= 0.95, "{name}: full-band corr {corr:.4}"); // +-3: the wav16 fixture is a pure tone, whose phase moves the peak. - let delay = { - let mut e = Encoder::new(48000, 1, Application::Voip).unwrap(); - e.set_bitrate(32_000); - e.look_ahead(960) - }; + let delay = hybrid_delay(32_000); assert!( (delay - 3..=delay + 3).contains(&lag), "{name}: aligned at lag {lag}, not the advertised {delay}" diff --git a/lanes/opus-gate-r1.sweep.txt b/lanes/opus-gate-r1.sweep.txt index 46918f2a..b5cd9117 100644 --- a/lanes/opus-gate-r1.sweep.txt +++ b/lanes/opus-gate-r1.sweep.txt @@ -1,15 +1,15 @@ # 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.2 0.9883 0.9864 -0.0019 -155.70 -154.78 1.005 0.9765 0.9745 0 0 -nik 96 100.8 101.0 -0.2 0.9943 0.9940 -0.0003 -111.16 -31.55 1.781 0.9888 0.9888 0 0 -reelo 64 63.5 63.6 -0.2 0.9886 0.9866 -0.0020 -179.06 -123.36 1.347 0.9699 0.9686 0 0 -reelo 96 93.2 93.9 -0.7 0.9942 0.9937 -0.0004 -89.99 -125.18 0.805 0.9869 0.9854 0 0 -her 64 67.5 67.9 -0.7 0.9825 0.9794 -0.0030 -347.44 -339.00 1.032 0.9466 0.9406 0 0 -her 96 100.7 101.5 -0.8 0.9913 0.9902 -0.0011 -247.70 -191.50 1.289 0.9760 0.9728 0 0 -reell 64 71.3 71.3 -0.0 0.9904 0.9880 -0.0024 -272.52 -128.39 1.987 0.9710 0.9644 0 0 -reell 96 105.3 105.4 -0.0 0.9952 0.9948 -0.0004 -261.59 -29.16 3.825 0.9849 0.9804 0 0 -dl8a 64 65.5 65.8 -0.4 0.9883 0.9865 -0.0019 -394.10 -378.84 1.055 0.9784 0.9723 0 0 -dl8a 96 96.3 96.8 -0.5 0.9936 0.9934 -0.0002 -406.85 -423.47 0.945 0.9865 0.9864 0 0 -hein 64 64.6 64.9 -0.4 0.9876 0.9874 -0.0003 -374.22 -388.31 0.951 0.9258 0.9148 0 0 -hein 96 86.5 86.9 -0.4 0.9938 0.9930 -0.0007 -373.59 -246.46 1.638 0.9651 0.9499 0 0 +nik 64 69.1 69.2 -0.1 0.9887 0.9864 -0.0024 -95.23 -154.78 0.708 0.9766 0.9745 0 0 +nik 96 100.9 101.0 -0.1 0.9947 0.9940 -0.0007 -29.86 -31.55 0.985 0.9889 0.9888 0 0 +reelo 64 63.6 63.6 -0.0 0.9893 0.9866 -0.0027 -202.82 -123.36 1.510 0.9702 0.9686 0 0 +reelo 96 93.4 93.9 -0.5 0.9947 0.9937 -0.0009 -114.74 -125.18 0.940 0.9862 0.9854 0 0 +her 64 67.7 67.9 -0.4 0.9834 0.9794 -0.0040 -365.72 -339.00 1.103 0.9477 0.9406 0 0 +her 96 101.0 101.5 -0.5 0.9914 0.9902 -0.0012 -202.07 -191.50 1.051 0.9728 0.9728 0 0 +reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0029 -351.70 -128.39 2.697 0.9721 0.9644 0 0 +reell 96 105.3 105.4 -0.0 0.9956 0.9948 -0.0008 -301.83 -29.16 4.499 0.9856 0.9804 0 0 +dl8a 64 65.7 65.8 -0.1 0.9889 0.9865 -0.0025 -227.54 -378.84 0.552 0.9787 0.9723 0 0 +dl8a 96 96.5 96.8 -0.3 0.9942 0.9934 -0.0009 -177.70 -423.47 0.374 0.9881 0.9864 0 0 +hein 64 64.8 64.9 -0.2 0.9888 0.9874 -0.0014 -344.06 -388.31 0.853 0.9318 0.9148 0 0 +hein 96 86.8 86.9 -0.2 0.9946 0.9930 -0.0016 -117.91 -246.46 0.528 0.9689 0.9499 0 0 diff --git a/lanes/opus-opusx2-r6.sweep.txt b/lanes/opus-opusx2-r6.sweep.txt new file mode 100644 index 00000000..f50edb33 --- /dev/null +++ b/lanes/opus-opusx2-r6.sweep.txt @@ -0,0 +1,16 @@ +# lane-opusx2 r6: DEFAULTS (alignment knob off) -- regression check that the shipped path is untouched +# 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.9887 0.9864 -0.0024 -95.23 -154.78 0.708 0.9766 0.9745 0 0 +nik 96 100.9 101.0 -0.1 0.9947 0.9940 -0.0007 -29.86 -31.55 0.985 0.9889 0.9888 0 0 +reelo 64 63.6 63.6 -0.0 0.9893 0.9866 -0.0027 -202.82 -123.36 1.510 0.9702 0.9686 0 0 +reelo 96 93.4 93.9 -0.5 0.9947 0.9937 -0.0009 -114.74 -125.18 0.940 0.9862 0.9854 0 0 +her 64 67.7 67.9 -0.4 0.9834 0.9794 -0.0040 -365.72 -339.00 1.103 0.9477 0.9406 0 0 +her 96 101.0 101.5 -0.5 0.9914 0.9902 -0.0012 -202.07 -191.50 1.051 0.9728 0.9728 0 0 +reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0029 -351.70 -128.39 2.697 0.9721 0.9644 0 0 +reell 96 105.3 105.4 -0.0 0.9956 0.9948 -0.0008 -301.83 -29.16 4.499 0.9856 0.9804 0 0 +dl8a 64 65.7 65.8 -0.1 0.9889 0.9865 -0.0025 -227.54 -378.84 0.552 0.9787 0.9723 0 0 +dl8a 96 96.5 96.8 -0.3 0.9942 0.9934 -0.0009 -177.70 -423.47 0.374 0.9881 0.9864 0 0 +hein 64 64.8 64.9 -0.2 0.9888 0.9874 -0.0014 -344.06 -388.31 0.853 0.9318 0.9148 0 0 +hein 96 86.8 86.9 -0.2 0.9946 0.9930 -0.0016 -117.91 -246.46 0.528 0.9689 0.9499 0 0