pub struct CodecInfo {
pub sample_rate: u32,
pub frame_rate: f32,
pub hop_length: usize,
pub channels: usize,
pub max_quantizers: usize,
pub codebook_size: usize,
}Expand description
Static description of a codec — enough to reason about rate, framing, and bitrate without touching a concrete config struct.
Fields§
§sample_rate: u32Audio sample rate (Hz) the codec consumes/produces.
frame_rate: f32Codec frames per second (Hz) — e.g. Mimi 12.5, DAC sample_rate/hop.
hop_length: usizePCM samples per codec frame (sample_rate / frame_rate).
channels: usizeAudio channels (1 for the mono codecs here).
max_quantizers: usizeCodebooks (quantizers) available at full rate.
codebook_size: usizeEntries per codebook.
Implementations§
Source§impl CodecInfo
impl CodecInfo
Sourcepub fn bits_per_codebook(&self) -> f32
pub fn bits_per_codebook(&self) -> f32
Bits carried by one codebook index (log2(codebook_size)).
Sourcepub fn bits_per_second_per_codebook(&self) -> f32
pub fn bits_per_second_per_codebook(&self) -> f32
Bits/sec contributed by a single codebook at this frame rate.
Sourcepub fn bitrate_bps(&self, num_quantizers: Option<usize>) -> f32
pub fn bitrate_bps(&self, num_quantizers: Option<usize>) -> f32
Nominal bitrate (bits/sec) for num_quantizers codebooks (default: all).
Sourcepub fn quantizers_for_bitrate(&self, target_bps: f32) -> usize
pub fn quantizers_for_bitrate(&self, target_bps: f32) -> usize
The largest codebook count whose nominal bitrate stays at or below
target_bps, clamped to [1, max_quantizers]. Codec-agnostic bitrate
control: callers pass a bitrate, codecs pick the quantizer count.
Sourcepub fn frames_for_samples(&self, num_samples: usize) -> usize
pub fn frames_for_samples(&self, num_samples: usize) -> usize
Number of codec frames produced for num_samples PCM samples.
Trait Implementations§
impl Copy for CodecInfo
impl StructuralPartialEq for CodecInfo
Auto Trait Implementations§
impl Freeze for CodecInfo
impl RefUnwindSafe for CodecInfo
impl Send for CodecInfo
impl Sync for CodecInfo
impl Unpin for CodecInfo
impl UnsafeUnpin for CodecInfo
impl UnwindSafe for CodecInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more