pub struct AnsDistribution {
pub symbols: Vec<AnsEncSymbolInfo>,
pub log_alpha_size: u32,
pub total: u32,
}Expand description
A complete ANS distribution with encoding info for all symbols.
Fields§
§symbols: Vec<AnsEncSymbolInfo>Symbol encoding information.
log_alpha_size: u32Log2 of distribution size (typically 12).
total: u32Total of normalized frequencies (should be ANS_TAB_SIZE).
Implementations§
Source§impl AnsDistribution
impl AnsDistribution
Sourcepub fn from_frequencies(freqs: &[u32]) -> Result<Self>
pub fn from_frequencies(freqs: &[u32]) -> Result<Self>
Creates a distribution from raw frequencies.
Normalizes frequencies to sum to ANS_TAB_SIZE.
Sourcepub fn from_normalized_counts(counts: &[i32]) -> Result<Self>
pub fn from_normalized_counts(counts: &[i32]) -> Result<Self>
Creates a distribution from pre-normalized counts.
The counts must already sum to ANS_TAB_SIZE (4096). This is used when building distributions from ANSEncodingHistogram which has already done the normalization.
Sourcepub fn from_normalized_counts_with_log_alpha(
counts: &[i32],
log_alpha_size: usize,
) -> Result<Self>
pub fn from_normalized_counts_with_log_alpha( counts: &[i32], log_alpha_size: usize, ) -> Result<Self>
Creates a distribution from pre-normalized counts with explicit log_alpha_size.
Use this when multiple distributions share a single header (e.g., multi-histogram
ANS). The log_alpha_size must match the value written to the bitstream header,
NOT the per-distribution default. The decoder reads one global log_alpha_size
and uses it for all distributions in the group.
Sourcepub fn alphabet_size(&self) -> usize
pub fn alphabet_size(&self) -> usize
Returns the number of symbols in this distribution.
Sourcepub fn get(&self, symbol: usize) -> Option<&AnsEncSymbolInfo>
pub fn get(&self, symbol: usize) -> Option<&AnsEncSymbolInfo>
Gets the encoding info for a symbol.
Trait Implementations§
Source§impl Clone for AnsDistribution
impl Clone for AnsDistribution
Source§fn clone(&self) -> AnsDistribution
fn clone(&self) -> AnsDistribution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
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