Skip to main content

CeltEncoder

Struct CeltEncoder 

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

A CELT encoder at 48 kHz (mono or stereo).

Implementations§

Source§

impl CeltEncoder

Source

pub fn new() -> Self

Creates a mono 48 kHz encoder.

Source

pub fn with_channels(channels: usize) -> Self

Creates a 48 kHz encoder with 1 or 2 channels.

§Panics

Panics unless channels is 1 or 2.

Source

pub const fn set_complexity(&mut self, complexity: u8)

Sets the encode complexity 0-10 (clamped), gating the analysis stages.

Source

pub fn encode_frame(&mut self, pcm: &[f32], nb_bytes: usize) -> Vec<u8>

Encodes one fullband frame of pcm (interleaved f32 in [-1, 1]; 120, 240, 480 or 960 samples per channel at 48 kHz) into nb_bytes.

§Panics

Panics on invalid frame sizes or byte budgets outside 2..=1275.

Source

pub fn encode_frame_bw( &mut self, pcm: &[f32], nb_bytes: usize, end: usize, ) -> Vec<u8>

Encodes one frame coding bands 0..end (end selects the CELT bandwidth: 13 = narrowband, 17 = wideband, 19 = super-wideband, 21 = fullband). The bands above end are left for the decoder to fill with folded noise.

§Panics

Panics on invalid frame sizes, byte budgets outside 2..=1275, or end outside 1..=21.

Source

pub const fn final_range(&self) -> u32

The range state after the last encoded frame; a conformant decoder finishes the frame with this exact value.

Source

pub const fn set_target_bitrate(&mut self, bitrate: Option<u32>)

Sets the VBR target bitrate in bits/s (None restores CBR, which fills the nb_bytes budget exactly). In VBR the nb_bytes passed to encode_frame* is an upper bound; each frame is shrunk to its own target.

Source

pub const fn last_transient(&self) -> bool

Whether the last frame was detected as a transient and coded with short blocks.

Source

pub const fn last_pitch(&self) -> (usize, f32)

The pitch period (samples) and gain the pre-filter analysis chose for the last frame. Currently informational - the comb filter and its post-filter bitstream coding are not yet applied.

Trait Implementations§

Source§

impl Default for CeltEncoder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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