Skip to main content

OpusFrameRouting

Struct OpusFrameRouting 

Source
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: bool

SILK-bearing flag (true for SILK-only or Hybrid).

§celt_layer: bool

CELT-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

Source

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.
Source

pub fn channel_count(&self) -> u8

Number of audio channels (1 for mono, 2 for stereo).

Source

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.

Source

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

Source§

fn clone(&self) -> OpusFrameRouting

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for OpusFrameRouting

Source§

impl Debug for OpusFrameRouting

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for OpusFrameRouting

Source§

impl PartialEq for OpusFrameRouting

Source§

fn eq(&self, other: &OpusFrameRouting) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for OpusFrameRouting

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.