Dred

Struct Dred 

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

OPUS DRED Decoder

Implementations§

Source§

impl Dred

Source

pub fn new(decoder: Decoder) -> Result<Self, ErrorCode>

Creates new decoder instance

Source

pub fn decoder(&mut self) -> &Decoder

Access underlying decoder

Source

pub fn decoder_mut(&mut self) -> &mut Decoder

Access underlying decoder

Source

pub fn decode_to( &mut self, input: &[u8], output: &mut [MaybeUninit<i16>], ) -> Result<usize, ErrorCode>

Decodes input packet, returning number of decoded samples.

Output size must correspond to sampling rate. For example, at 48 kHz allowed frame sizes are 120, 240, 480, 960, 1920, and 2880.

Maximum packet duration is 120ms therefore maximum frame size must be frame_bytes_size(SampleRate::Hz48000, Channels::Stereo, 120)

Source

pub fn decode_to_slice( &mut self, input: &[u8], output: &mut [u16], ) -> Result<usize, ErrorCode>

Decodes input packet, returning number of decoded samples.

Refer to decode_to for details

Source

pub fn decode_float_to( &mut self, input: &[u8], output: &mut [MaybeUninit<f32>], ) -> Result<usize, ErrorCode>

Decodes input packet, returning number of decoded samples.

Output size must correspond to sampling rate. For example, at 48 kHz allowed frame sizes are 120, 240, 480, 960, 1920, and 2880.

Maximum packet duration is 120ms therefore maximum frame size must be frame_bytes_size(SampleRate::Hz48000, Channels::Stereo, 120)

Source

pub fn decode_float_to_slice( &mut self, input: &[u8], output: &mut [f32], ) -> Result<usize, ErrorCode>

Decodes input packet, returning number of decoded samples.

Refer to decode_to for details

Source

pub fn reset(&mut self) -> Result<(), ErrorCode>

Resets state to initial

Source

pub fn get_pitch(&mut self) -> Result<Option<NonZeroU32>, ErrorCode>

Gets the pitch of the last decoded frame, if available.

This can be used for any post-processing algorithm requiring the use of pitch, e.g. time stretching/shortening. If the last frame was not voiced, or if the pitch was not coded in the frame, then zero is returned.

Source

pub fn get_last_packet_duration(&mut self) -> Result<u32, ErrorCode>

Gets the duration (in samples) of the last packet successfully decoded or concealed.

Source

pub fn get_gain(&mut self) -> Result<i32, ErrorCode>

Gets the decoder’s gain configuration

Source

pub fn set_gain(&mut self, value: i32) -> Result<(), ErrorCode>

Configures decoder gain adjustment.

Scales the decoded output by a factor specified in Q8 dB units. This has a maximum range of -32768 to 32767 inclusive, and returns BadArg otherwise.

The default is zero indicating no adjustment.

This setting survives decoder reset.

Formula:

gain = pow(10, x/(20.0*256))

Source

pub fn get_bandwidth(&mut self) -> Result<Bandwidth, ErrorCode>

Gets the decoder’s last bandpass

Source

pub fn get_sample_rate(&mut self) -> Result<SampleRate, ErrorCode>

Gets configured sample rate of this instance

Source

pub fn get_phase_inversion_disabled(&mut self) -> Result<bool, ErrorCode>

Gets the decoder’s configured phase inversion status.

Source

pub fn set_phase_inversion_disabled( &mut self, value: bool, ) -> Result<(), ErrorCode>

Configures phase inversion.

If set to true, disables the use of phase inversion for intensity stereo, improving the quality of mono downmixes, but slightly reducing normal stereo quality.

Disabling phase inversion in the decoder does not comply with RFC 6716, although it does not cause any interoperability issue and is expected to become part of the Opus standard once RFC 6716 is updated by draft-ietf-codec-opus-update.

Trait Implementations§

Auto Trait Implementations§

§

impl Freeze for Dred

§

impl RefUnwindSafe for Dred

§

impl !Sync for Dred

§

impl Unpin for Dred

§

impl UnwindSafe for Dred

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