pub struct Codebook {
pub entries: usize,
pub table: Vec<CodebookEntry>,
pub dimensions: usize,
}Expand description
A Vorbis codebook.
Fields§
§entries: usizeNumber of entries.
table: Vec<CodebookEntry>Entry descriptors.
dimensions: usizeVector dimension (1 for scalar books).
Implementations§
Source§impl Codebook
impl Codebook
Sourcepub fn from_lengths_and_values(lengths: &[u8], values: &[f32]) -> Self
pub fn from_lengths_and_values(lengths: &[u8], values: &[f32]) -> Self
Build a codebook from entry lengths and associated scalar values.
lengths[i] is the Huffman code length for entry i.
values[i] is the decoded scalar value for entry i (dimension=1).
Sourcepub fn lookup(&self, index: usize) -> Option<&[f32]>
pub fn lookup(&self, index: usize) -> Option<&[f32]>
Look up the value for the entry with the given index.
Returns None if the index is out of range or the entry is unused (length=0).
Sourcepub fn average_code_length(&self) -> f64
pub fn average_code_length(&self) -> f64
Compute the average code length (entropy estimate).
Sourcepub fn kraft_inequality_satisfied(&self) -> bool
pub fn kraft_inequality_satisfied(&self) -> bool
Kraft inequality check: returns true if code lengths satisfy Kraft’s inequality.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Codebook
impl RefUnwindSafe for Codebook
impl Send for Codebook
impl Sync for Codebook
impl Unpin for Codebook
impl UnsafeUnpin for Codebook
impl UnwindSafe for Codebook
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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