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(
2225 pcm: &[f32],2225 pcm: &[f32],
2226 bps: u32,2226 bps: u32,
2227 bandwidth: Option<Bandwidth>,2227 bandwidth: Option<Bandwidth>,
2228+ mode: Option<Mode>,
2228 mute: (bool, bool),2229 mute: (bool, bool),
2229 ) -> (Vec<f32>, Vec<Vec<u8>>) {2230 ) -> (Vec<f32>, Vec<Vec<u8>>) {
2230 let mut enc = Encoder::new(48000, 1, Application::Voip).unwrap();2231 let mut enc = Encoder::new(48000, 1, Application::Voip).unwrap();
2231 enc.set_bitrate(bps);2232 enc.set_bitrate(bps);
2232 enc.set_bandwidth(bandwidth);2233 enc.set_bandwidth(bandwidth);
2234+ enc.set_mode(mode);
2233 let mut dec = Decoder::new(48000, 1).unwrap();2235 let mut dec = Decoder::new(48000, 1).unwrap();
2234 dec.debug_mute_layers(mute.0, mute.1);2236 dec.debug_mute_layers(mute.0, mute.1);
2235 let mut out = vec![0u8; 1500];2237 let mut out = vec![0u8; 1500];
@@ -2277,8 +2279,8 @@ fn hybrid_layers_align() {
2277 .unwrap()2279 .unwrap()
2278 .02280 .0
2279 };2281 };
2280- let (lb, _) = hybrid_roundtrip(&click, 32_000, None, (true, false));2282+ let (lb, _) = hybrid_roundtrip(&click, 32_000, None, None, (true, false));
2281- let (hb, _) = hybrid_roundtrip(&click, 32_000, None, (false, true));2283+ let (hb, _) = hybrid_roundtrip(&click, 32_000, None, None, (false, true));
2282 let delay = hybrid_delay(32_000) as i64;2284 let delay = hybrid_delay(32_000) as i64;
2283 let (plb, phb) = (peak(&lb) as i64 - at as i64, peak(&hb) as i64 - at as i64);2285 let (plb, phb) = (peak(&lb) as i64 - at as i64, peak(&hb) as i64 - at as i64);
2284 eprintln!("hybrid click: LB peak +{plb}, HB peak +{phb}, look_ahead {delay}");2286 eprintln!("hybrid click: LB peak +{plb}, HB peak +{phb}, look_ahead {delay}");
@@ -2305,14 +2307,21 @@ fn hybrid_layers_align() {
2305 #[test]2307 #[test]
2306 fn hybrid_fb_roundtrip() {2308 fn hybrid_fb_roundtrip() {
2307 for (name, pcm) in silk_sources() {2309 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));
2309 let toc = ec_opus::Toc::new(packets[0][0]);2311 let toc = ec_opus::Toc::new(packets[0][0]);
2310 assert_eq!(toc.config, 15, "{name}: TOC config {}", toc.config);2312 assert_eq!(toc.config, 15, "{name}: TOC config {}", toc.config);
2311 let (corr, lag) = aligned_corr(&pcm, &decoded, 400);2313 let (corr, lag) = aligned_corr(&pcm, &decoded, 400);
2312- let (lb_only, lb_packets) =2314+ let (lb_only, lb_packets) = hybrid_roundtrip(
2313- hybrid_roundtrip(&pcm, 32_000, Some(Bandwidth::Full), (true, false));2315+ &pcm,
2316+ 32_000,
2317+ Some(Bandwidth::Full),
2318+ Some(Mode::Hybrid),
2319+ (true, false),
2320+ );
2314 assert!(2321 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),
2316 "{name}: forced-FB run left hybrid"2325 "{name}: forced-FB run left hybrid"
2317 );2326 );
2318 let lb_ref = lowpass(&pcm, 7000.0);2327 let lb_ref = lowpass(&pcm, 7000.0);
@@ -2344,11 +2353,16 @@ fn hybrid_fb_roundtrip() {
2344 // SWB when asked for it, and the rest of the automatic hybrid range2353 // SWB when asked for it, and the rest of the automatic hybrid range
2345 // (SILK's share leaves CELT least at the bottom of it).2354 // (SILK's share leaves CELT least at the bottom of it).
2346 let speech = speech_like();2355 let speech = speech_like();
2347- let (_, packets) =2356+ let (_, packets) = hybrid_roundtrip(
2348- hybrid_roundtrip(&speech, 24_000, Some(Bandwidth::SuperWide), (false, false));2357+ &speech,
2358+ 24_000,
2359+ Some(Bandwidth::SuperWide),
2360+ None,
2361+ (false, false),
2362+ );
2349 assert_eq!(ec_opus::Toc::new(packets[0][0]).config, 13);2363 assert_eq!(ec_opus::Toc::new(packets[0][0]).config, 13);
2350 for bps in [20_000u32, 24_000, 39_000] {2364 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));
2352 let (corr, _) = aligned_corr(&speech, &decoded, 400);2366 let (corr, _) = aligned_corr(&speech, &decoded, 400);
2353 let kbps = packets.iter().map(Vec::len).sum::<usize>() as f64 * 8.02367 let kbps = packets.iter().map(Vec::len).sum::<usize>() as f64 * 8.0
2354 / (packets.len() as f64 * 20.0);2368 / (packets.len() as f64 * 20.0);