ProjectionDecoder

Struct ProjectionDecoder 

Source
pub struct ProjectionDecoder { /* private fields */ }
Expand description

Safe wrapper around OpusProjectionDecoder.

Implementations§

Source§

impl ProjectionDecoder

Source

pub fn size(channels: u8, streams: u8, coupled_streams: u8) -> Result<usize>

Size in bytes of a projection decoder state for external allocation.

§Errors

Returns Error::BadArg if the channel/stream configuration is invalid.

Source

pub unsafe fn init_in_place( ptr: *mut OpusProjectionDecoder, sample_rate: SampleRate, channels: u8, streams: u8, coupled_streams: u8, demixing_matrix: &[u8], ) -> Result<()>

Initialize a previously allocated projection decoder state.

§Safety

The caller must provide a valid pointer to ProjectionDecoder::size() bytes, aligned to at least align_of::<usize>() (malloc-style alignment).

§Errors

Returns Error::BadArg for invalid inputs or a mapped libopus error.

Source

pub fn new( sample_rate: SampleRate, channels: u8, streams: u8, coupled_streams: u8, demixing_matrix: &[u8], ) -> Result<Self>

Create a projection decoder given the demixing matrix provided by the encoder.

§Errors

Returns Error::BadArg for invalid inputs, Error::from_code for libopus failures, or Error::AllocFail if libopus returns a null handle.

Source

pub fn decode( &mut self, packet: &[u8], out: &mut [i16], frame_size_per_ch: usize, fec: bool, ) -> Result<usize>

Decode into interleaved i16 PCM.

§Errors

Returns Error::InvalidState if the decoder handle was freed, Error::BadArg for buffer/layout issues, a mapped libopus error, or Error::InternalError if libopus reports an impossible decoded sample count.

Source

pub fn decode_float( &mut self, packet: &[u8], out: &mut [f32], frame_size_per_ch: usize, fec: bool, ) -> Result<usize>

Decode into interleaved f32 PCM.

§Errors

Returns Error::InvalidState if the decoder handle was freed, Error::BadArg for buffer/layout issues, a mapped libopus error, or Error::InternalError if libopus reports an impossible decoded sample count.

Source

pub const fn channels(&self) -> u8

Output channel count.

Source

pub const fn streams(&self) -> u8

Number of coded streams expected in the input bitstream.

Source

pub const fn coupled_streams(&self) -> u8

Number of coupled coded streams expected in the input bitstream.

Source

pub const fn sample_rate(&self) -> SampleRate

Decoder sample rate.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.