doc+test(opus-rs shim): SILK now reachable through the existing Application/bitrate surface
Browse files at this commitaf6881e2e1c3430c41546017637646c6d1527e0fParent: 7f710e51 changed file +19 -4
- shims/opus-rs/src/lib.rs +19 -4
shims/opus-rs/src/lib.rsmodified+19 -4
| @@ -15,10 +15,10 @@ | |||
| 15 | //! `complexity` is accepted for drop-in compatibility and ignored: this | 15 | //! `complexity` is accepted for drop-in compatibility and ignored: this |
| 16 | //! encoder has one (fast) analysis path, not a ladder. | 16 | //! encoder has one (fast) analysis path, not a ladder. |
| 17 | //! | 17 | //! |
| 18 | -//! One behaviour is genuinely narrower and is stated rather than hidden: this | 18 | +//! [`Application::Voip`] below 20 kbps, mono, 20 ms frames picks the SILK |
| 19 | -//! encoder is **CELT-only**, so [`Application::Voip`] selects a narrower | 19 | +//! layer, as the reference does; every other combination stays CELT. Stereo |
| 20 | -//! bandwidth at a given rate but not the SILK layer the name implies. Speech | 20 | +//! SILK and SILK at other frame sizes fall back to CELT rather than |
| 21 | -//! below about 32 kbps is where that costs the most. | 21 | +//! silently approximating it. |
| 22 | 22 | ||
| 23 | #![forbid(unsafe_code)] | 23 | #![forbid(unsafe_code)] |
| 24 | #![warn(missing_docs)] | 24 | #![warn(missing_docs)] |
| @@ -439,4 +439,19 @@ mod tests { | |||
| 439 | } | 439 | } |
| 440 | assert!(MultistreamEncoder::surround(48_000, 9, Application::Audio).is_err()); | 440 | assert!(MultistreamEncoder::surround(48_000, 9, Application::Audio).is_err()); |
| 441 | } | 441 | } |
| 442 | + | ||
| 443 | + /// `Application::Voip` under 20 kbps, mono, 20 ms frames reaches the | ||
| 444 | + /// SILK layer through this shim's existing surface — no new API, just | ||
| 445 | + /// the application and bitrate the incumbent already exposed. TOC | ||
| 446 | + /// configs 0..=11 are SILK (RFC 6716 Table 2). | ||
| 447 | + #[test] | ||
| 448 | + fn voip_below_20kbps_reaches_silk() { | ||
| 449 | + let mut enc = OpusEncoder::new(48_000, 1, Application::Voip).unwrap(); | ||
| 450 | + enc.bitrate_bps = 12_000; | ||
| 451 | + let pcm = tone(960, 1); | ||
| 452 | + let mut out = vec![0u8; 1500]; | ||
| 453 | + let len = enc.encode(&pcm, 960, &mut out).unwrap(); | ||
| 454 | + assert!(len > 1); | ||
| 455 | + assert!(out[0] >> 3 <= 11, "TOC config {} is not SILK", out[0] >> 3); | ||
| 456 | + } | ||
| 442 | } | 457 | } |