pub struct AnsDistribution {
pub symbols: Vec<u16>,
pub frequencies: Vec<u32>,
pub cumulative: Vec<u32>,
pub log_table_size: u8,
}Expand description
ANS probability distribution table.
Maps symbols to frequency counts. The sum of all frequencies must equal
1 << log_table_size (the table size).
Fields§
§symbols: Vec<u16>Symbol values in the distribution.
frequencies: Vec<u32>Frequency (probability count) for each symbol.
cumulative: Vec<u32>Cumulative frequency table (prefix sums of frequencies).
log_table_size: u8Log2 of the total frequency table size.
Implementations§
Source§impl AnsDistribution
impl AnsDistribution
Sourcepub fn new(
symbols: Vec<u16>,
frequencies: Vec<u32>,
log_table_size: u8,
) -> CodecResult<Self>
pub fn new( symbols: Vec<u16>, frequencies: Vec<u32>, log_table_size: u8, ) -> CodecResult<Self>
Create a new distribution from symbol frequencies.
Frequencies are normalized so they sum to 1 << log_table_size.
Sourcepub fn table_size(&self) -> u32
pub fn table_size(&self) -> u32
Total table size (sum of all frequencies).
Sourcepub fn num_symbols(&self) -> usize
pub fn num_symbols(&self) -> usize
Number of symbols in the distribution.
Trait Implementations§
Source§impl Clone for AnsDistribution
impl Clone for AnsDistribution
Source§fn clone(&self) -> AnsDistribution
fn clone(&self) -> AnsDistribution
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AnsDistribution
impl RefUnwindSafe for AnsDistribution
impl Send for AnsDistribution
impl Sync for AnsDistribution
impl Unpin for AnsDistribution
impl UnsafeUnpin for AnsDistribution
impl UnwindSafe for AnsDistribution
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