forge
Explore
Log in

Don't you dare go Hollow

ec-opus test: hybrid_fb LB-only run forces Mode::Hybrid too. Root cause: with Bandwidth::Full forced but no mode override, the auto mode pick (encoder.rs:1700-1717, equiv vs threshold) still chooses CELT-only for some 20 ms packets, so the forced-FB run left hybrid (conformance.rs:2314). Fix: hybrid_roundtrip takes an Option<Mode> passed to set_mode (encoder.rs:490); the LB-only run passes Some(Mode::Hybrid) and keeps Bandwidth::Full, so every packet is config 15 with the SILK layer present. Other call sites pass None (automatic, unchanged). Evidence: cargo check -p ec-opus --all-targets clean; test run left to orchestrator

Browse files at this commit

08538a8f2114740c936882437ffbe51a2b20c5a9Ahmet Kaan GümüşParent: d0ac1b7
crates/ec-opus/tests/conformance.rsmodified+23 -9
@@ -2225,11 +2225,13 @@ fn hybrid_roundtrip(
22252225 pcm: &[f32],
22262226 bps: u32,
22272227 bandwidth: Option<Bandwidth>,
2228+ mode: Option<Mode>,
22282229 mute: (bool, bool),
22292230 ) -> (Vec<f32>, Vec<Vec<u8>>) {
22302231 let mut enc = Encoder::new(48000, 1, Application::Voip).unwrap();
22312232 enc.set_bitrate(bps);
22322233 enc.set_bandwidth(bandwidth);
2234+ enc.set_mode(mode);
22332235 let mut dec = Decoder::new(48000, 1).unwrap();
22342236 dec.debug_mute_layers(mute.0, mute.1);
22352237 let mut out = vec![0u8; 1500];
@@ -2277,8 +2279,8 @@ fn hybrid_layers_align() {
22772279 .unwrap()
22782280 .0
22792281 };
2280- let (lb, _) = hybrid_roundtrip(&click, 32_000, None, (true, false));
2281- let (hb, _) = hybrid_roundtrip(&click, 32_000, None, (false, true));
2282+ let (lb, _) = hybrid_roundtrip(&click, 32_000, None, None, (true, false));
2283+ let (hb, _) = hybrid_roundtrip(&click, 32_000, None, None, (false, true));
22822284 let delay = hybrid_delay(32_000) as i64;
22832285 let (plb, phb) = (peak(&lb) as i64 - at as i64, peak(&hb) as i64 - at as i64);
22842286 eprintln!("hybrid click: LB peak +{plb}, HB peak +{phb}, look_ahead {delay}");
@@ -2305,14 +2307,21 @@ fn hybrid_layers_align() {
23052307 #[test]
23062308 fn hybrid_fb_roundtrip() {
23072309 for (name, pcm) in silk_sources() {
2308- let (decoded, packets) = hybrid_roundtrip(&pcm, 32_000, None, (false, false));
2310+ let (decoded, packets) = hybrid_roundtrip(&pcm, 32_000, None, None, (false, false));
23092311 let toc = ec_opus::Toc::new(packets[0][0]);
23102312 assert_eq!(toc.config, 15, "{name}: TOC config {}", toc.config);
23112313 let (corr, lag) = aligned_corr(&pcm, &decoded, 400);
2312- let (lb_only, lb_packets) =
2313- hybrid_roundtrip(&pcm, 32_000, Some(Bandwidth::Full), (true, false));
2314+ let (lb_only, lb_packets) = hybrid_roundtrip(
2315+ &pcm,
2316+ 32_000,
2317+ Some(Bandwidth::Full),
2318+ Some(Mode::Hybrid),
2319+ (true, false),
2320+ );
23142321 assert!(
2315- lb_packets.iter().all(|p| ec_opus::Toc::new(p[0]).config == 15),
2322+ lb_packets
2323+ .iter()
2324+ .all(|p| ec_opus::Toc::new(p[0]).config == 15),
23162325 "{name}: forced-FB run left hybrid"
23172326 );
23182327 let lb_ref = lowpass(&pcm, 7000.0);
@@ -2344,11 +2353,16 @@ fn hybrid_fb_roundtrip() {
23442353 // SWB when asked for it, and the rest of the automatic hybrid range
23452354 // (SILK's share leaves CELT least at the bottom of it).
23462355 let speech = speech_like();
2347- let (_, packets) =
2348- hybrid_roundtrip(&speech, 24_000, Some(Bandwidth::SuperWide), (false, false));
2356+ let (_, packets) = hybrid_roundtrip(
2357+ &speech,
2358+ 24_000,
2359+ Some(Bandwidth::SuperWide),
2360+ None,
2361+ (false, false),
2362+ );
23492363 assert_eq!(ec_opus::Toc::new(packets[0][0]).config, 13);
23502364 for bps in [20_000u32, 24_000, 39_000] {
2351- let (decoded, packets) = hybrid_roundtrip(&speech, bps, None, (false, false));
2365+ let (decoded, packets) = hybrid_roundtrip(&speech, bps, None, None, (false, false));
23522366 let (corr, _) = aligned_corr(&speech, &decoded, 400);
23532367 let kbps = packets.iter().map(Vec::len).sum::<usize>() as f64 * 8.0
23542368 / (packets.len() as f64 * 20.0);