wip(opus): aligned-spectrum re-sweep snapshot at the agent cap
Browse files at this commitd5ed04464cbfd02a255b9689347db535a91af02aParent: 02f91a23 changed files +45 -31
- crates/ec-opus/tests/conformance.rs +17 -19
- lanes/opus-gate-r1.sweep.txt +12 -12
- lanes/opus-opusx2-r6.sweep.txt +16 -0
crates/ec-opus/tests/conformance.rsmodified+17 -19
| @@ -2513,6 +2513,15 @@ fn hybrid_roundtrip( | |||
| 2513 | /// The two layers of a hybrid packet reach the decoder's output at the same | 2513 | /// The two layers of a hybrid packet reach the decoder's output at the same |
| 2514 | /// delay: a click's low-band-only and high-band-only peaks coincide at the | 2514 | /// delay: a click's low-band-only and high-band-only peaks coincide at the |
| 2515 | /// encoder's documented look-ahead. | 2515 | /// encoder's documented look-ahead. |
| 2516 | +/// The delay [`hybrid_roundtrip`]'s encoder advertises for a 20 ms frame — | ||
| 2517 | +/// [`Encoder::look_ahead`] of that same configuration, so the lag assertions | ||
| 2518 | +/// track the layer's real delay instead of a constant. | ||
| 2519 | +fn hybrid_delay(bps: u32) -> usize { | ||
| 2520 | + let mut enc = Encoder::new(48000, 1, Application::Voip).unwrap(); | ||
| 2521 | + enc.set_bitrate(bps); | ||
| 2522 | + enc.look_ahead(960) | ||
| 2523 | +} | ||
| 2524 | + | ||
| 2516 | #[test] | 2525 | #[test] |
| 2517 | fn hybrid_layers_align() { | 2526 | fn hybrid_layers_align() { |
| 2518 | let mut click = vec![0f32; 48000]; | 2527 | let mut click = vec![0f32; 48000]; |
| @@ -2528,25 +2537,18 @@ fn hybrid_layers_align() { | |||
| 2528 | }; | 2537 | }; |
| 2529 | let (lb, _) = hybrid_roundtrip(&click, 32_000, None, (true, false)); | 2538 | let (lb, _) = hybrid_roundtrip(&click, 32_000, None, (true, false)); |
| 2530 | let (hb, _) = hybrid_roundtrip(&click, 32_000, None, (false, true)); | 2539 | let (hb, _) = hybrid_roundtrip(&click, 32_000, None, (false, true)); |
| 2531 | - let enc = Encoder::new(48000, 1, Application::Voip).unwrap(); | 2540 | + let delay = hybrid_delay(32_000) as i64; |
| 2532 | let (plb, phb) = (peak(&lb) as i64 - at as i64, peak(&hb) as i64 - at as i64); | 2541 | let (plb, phb) = (peak(&lb) as i64 - at as i64, peak(&hb) as i64 - at as i64); |
| 2533 | - eprintln!( | 2542 | + eprintln!("hybrid click: LB peak +{plb}, HB peak +{phb}, look_ahead {delay}"); |
| 2534 | - "hybrid click: LB peak +{plb}, HB peak +{phb}, look_ahead {}", | 2543 | + // A fullband CELT click lands at exactly the encoder's advertised delay |
| 2535 | - { | 2544 | + // (`celt_click_peak_offset`); the band-limited HB layer's main lobe sits |
| 2536 | - let mut e = enc.clone(); | 2545 | + // up to 2 samples early once transient frames keep their short blocks, |
| 2537 | - e.set_bitrate(32_000); | 2546 | + // and SILK lands one sample late. |
| 2538 | - e.look_ahead(960) | ||
| 2539 | - } | ||
| 2540 | - ); | ||
| 2541 | - // A fullband CELT click lands at exactly +312 (`celt_click_peak_offset`: | ||
| 2542 | - // the MDCT overlap plus the 192-sample input delay compensation); | ||
| 2543 | - // the band-limited HB layer's main lobe sits up to 2 samples early once | ||
| 2544 | - // transient frames keep their short blocks, and SILK lands at +121. | ||
| 2545 | assert!( | 2547 | assert!( |
| 2546 | (plb - phb).abs() <= 3, | 2548 | (plb - phb).abs() <= 3, |
| 2547 | "layers misaligned: LB +{plb} vs HB +{phb}" | 2549 | "layers misaligned: LB +{plb} vs HB +{phb}" |
| 2548 | ); | 2550 | ); |
| 2549 | - assert!((phb - 312).abs() <= 2, "HB peak +{phb}, look_ahead 312"); | 2551 | + assert!((phb - delay).abs() <= 2, "HB peak +{phb}, look_ahead {delay}"); |
| 2550 | } | 2552 | } |
| 2551 | 2553 | ||
| 2552 | /// 20 ms FB hybrid at 32 kbps: decodes in our decoder range-exactly, tracks | 2554 | /// 20 ms FB hybrid at 32 kbps: decodes in our decoder range-exactly, tracks |
| @@ -2572,11 +2574,7 @@ fn hybrid_fb_roundtrip() { | |||
| 2572 | ); | 2574 | ); |
| 2573 | assert!(corr >= 0.95, "{name}: full-band corr {corr:.4}"); | 2575 | assert!(corr >= 0.95, "{name}: full-band corr {corr:.4}"); |
| 2574 | // +-3: the wav16 fixture is a pure tone, whose phase moves the peak. | 2576 | // +-3: the wav16 fixture is a pure tone, whose phase moves the peak. |
| 2575 | - let delay = { | 2577 | + let delay = hybrid_delay(32_000); |
| 2576 | - let mut e = Encoder::new(48000, 1, Application::Voip).unwrap(); | ||
| 2577 | - e.set_bitrate(32_000); | ||
| 2578 | - e.look_ahead(960) | ||
| 2579 | - }; | ||
| 2580 | assert!( | 2578 | assert!( |
| 2581 | (delay - 3..=delay + 3).contains(&lag), | 2579 | (delay - 3..=delay + 3).contains(&lag), |
| 2582 | "{name}: aligned at lag {lag}, not the advertised {delay}" | 2580 | "{name}: aligned at lag {lag}, not the advertised {delay}" |
lanes/opus-gate-r1.sweep.txtmodified+12 -12
| @@ -1,15 +1,15 @@ | |||
| 1 | # ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) | 1 | # ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) |
| 2 | # both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo | 2 | # both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo |
| 3 | # 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 | 3 | # 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 |
| 4 | -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 | 4 | +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 |
| 5 | -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 | 5 | +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 |
| 6 | -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 | 6 | +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 |
| 7 | -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 | 7 | +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 |
| 8 | -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 | 8 | +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 |
| 9 | -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 | 9 | +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 |
| 10 | -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 | 10 | +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 |
| 11 | -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 | 11 | +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 |
| 12 | -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 | 12 | +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 |
| 13 | -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 | 13 | +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 |
| 14 | -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 | 14 | +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 |
| 15 | -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 | 15 | +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 |
lanes/opus-opusx2-r6.sweep.txtadded+16 -0
| @@ -0,0 +1,16 @@ | |||
| 1 | +# lane-opusx2 r6: DEFAULTS (alignment knob off) -- regression check that the shipped path is untouched | ||
| 2 | +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) | ||
| 3 | +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo | ||
| 4 | +# 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 | ||
| 5 | +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 | ||
| 6 | +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 | ||
| 7 | +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 | ||
| 8 | +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 | ||
| 9 | +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 | ||
| 10 | +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 | ||
| 11 | +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 | ||
| 12 | +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 | ||
| 13 | +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 | ||
| 14 | +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 | ||
| 15 | +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 | ||
| 16 | +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 | ||