12 kHz input caps bandwidth at Medium, not Narrow
Browse files at this commit6efce8183d4bd381ff75e969e5a25315c99e5b77Parent: b3bcc7e- fix
- 12 kHz input caps bandwidth at Medium, not Narrow
2 changed files +9 -4
crates/ec-opus/src/encoder.rsmodified+1 -0
| @@ -680,6 +680,7 @@ impl Encoder { | ||
| 680 | 680 | 48000 => Bandwidth::Full, |
| 681 | 681 | 24000 => Bandwidth::SuperWide, |
| 682 | 682 | 16000 => Bandwidth::Wide, |
| 683 | + 12000 => Bandwidth::Medium, | |
| 683 | 684 | _ => Bandwidth::Narrow, |
| 684 | 685 | }; |
| 685 | 686 | BWS[idx].min(ceiling) |
shims/opus-rs/src/lib.rsmodified+8 -4
| @@ -374,15 +374,19 @@ mod tests { | ||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /// Input below 48 kHz, which the shim used to refuse outright, and the |
| 377 | - /// `look_ahead` that goes with it (120 samples at 48 kHz, scaled). | |
| 377 | + /// `look_ahead` that goes with it. 48/24 kHz VoIP at 32 kbps run | |
| 378 | + /// hybrid (SWB/FB), so the delay is CELT's 120-sample overlap, scaled; | |
| 379 | + /// 16 kHz and below cap the bandwidth at WB or narrower, where hybrid | |
| 380 | + /// does not exist, so dispatch takes SILK and the delay is the SILK | |
| 381 | + /// resampler look-ahead (WB 50 / MB 54 / NB 58 at 48 kHz), scaled. | |
| 378 | 382 | #[test] |
| 379 | 383 | fn slower_input_rates_encode_and_report_their_own_delay() { |
| 380 | 384 | for &(rate, frame, look) in &[ |
| 381 | 385 | (48_000i32, 960usize, 120usize), |
| 382 | 386 | (24_000, 480, 60), |
| 383 | - (16_000, 320, 40), | |
| 384 | - (12_000, 240, 30), | |
| 385 | - (8_000, 160, 20), | |
| 387 | + (16_000, 320, 50 / 3), | |
| 388 | + (12_000, 240, 54 / 4), | |
| 389 | + (8_000, 160, 58 / 6), | |
| 386 | 390 | ] { |
| 387 | 391 | let mut enc = OpusEncoder::new(rate, 1, Application::Voip).unwrap(); |
| 388 | 392 | enc.bitrate_bps = 32_000; |