pub struct OpusFrameRouting {
pub operating_mode: OperatingMode,
pub toc_bandwidth: Bandwidth,
pub frame_size_tenths_ms: u16,
pub channels: ChannelMapping,
pub silk_layer: bool,
pub celt_layer: bool,
pub silk_bandwidth: Option<SilkBandwidth>,
pub silk_frames_per_channel: Option<u8>,
}Expand description
Routing decision for one Opus frame, derived purely from the TOC byte.
Holds every dispatch-level fact a §4 decoder needs before it
touches the range coder. Every field is derivable from
OpusTocByte; bundling them here keeps the dispatch logic
in one place (and one set of tests) instead of duplicated across
every caller that constructs a SILK or CELT context.
Fields§
§operating_mode: OperatingMode§3.1 Table 2 mode (SILK / Hybrid / CELT-only).
toc_bandwidth: Bandwidth§3.1 Table 2 audio bandwidth as signalled by the TOC. For a
Hybrid frame this is the SWB / FB the output covers, not the
(always-WB) internal SILK bandwidth — use Self::silk_bandwidth
when feeding the SILK decoder.
frame_size_tenths_ms: u16§3.1 Table 2 Opus-frame duration, in tenths of a millisecond (25, 50, 100, 200, 400, 600).
channels: ChannelMapping§3.1 s bit (mono vs stereo).
silk_layer: boolSILK-bearing flag (true for SILK-only or Hybrid).
celt_layer: boolCELT-bearing flag (true for Hybrid or CELT-only).
silk_bandwidth: Option<SilkBandwidth>Internal SILK bandwidth (Some when silk_layer is true; None
for CELT-only). For Hybrid this is always SilkBandwidth::Wb
per RFC 6716 §4.2 first paragraph.
silk_frames_per_channel: Option<u8>Number of regular SILK frames per channel per Opus frame
(Some when silk_layer is true; None otherwise). Per §4.2.2:
1 for 10 / 20 ms Opus frames, 2 for 40 ms, 3 for 60 ms.
Implementations§
Source§impl OpusFrameRouting
impl OpusFrameRouting
Sourcepub fn from_toc(toc: OpusTocByte) -> Self
pub fn from_toc(toc: OpusTocByte) -> Self
Derive the routing for one Opus frame from its TOC byte.
Total function — every OpusTocByte value produces a valid
routing, because the TOC byte parser has already constrained
(mode, bandwidth, frame_size, channels) to the §3.1 Table 2
- Table 3 legal grid.
Sourcepub fn channel_count(&self) -> u8
pub fn channel_count(&self) -> u8
Number of audio channels (1 for mono, 2 for stereo).
Sourcepub fn total_silk_frames(&self) -> u8
pub fn total_silk_frames(&self) -> u8
Total regular-SILK-frame count for this Opus frame across both
channels (mono × frames_per_channel, or stereo × 2 ×
frames_per_channel). Returns 0 for CELT-only frames.
Sourcepub fn has_per_frame_lbrr_bits(&self) -> bool
pub fn has_per_frame_lbrr_bits(&self) -> bool
true iff this Opus frame is long enough to potentially carry
§4.2.4 per-frame LBRR flag bytes (i.e. 40 ms or 60 ms). Per
§4.2.4 the per-frame flags are only present when the global
LBRR flag is set, but the duration gate alone is a routing
concern.
Trait Implementations§
Source§impl Clone for OpusFrameRouting
impl Clone for OpusFrameRouting
Source§fn clone(&self) -> OpusFrameRouting
fn clone(&self) -> OpusFrameRouting
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for OpusFrameRouting
Source§impl Debug for OpusFrameRouting
impl Debug for OpusFrameRouting
impl Eq for OpusFrameRouting
Source§impl PartialEq for OpusFrameRouting
impl PartialEq for OpusFrameRouting
Source§fn eq(&self, other: &OpusFrameRouting) -> bool
fn eq(&self, other: &OpusFrameRouting) -> bool
self and other values to be equal, and is used by ==.