pub struct ANSEncodingHistogram {
pub counts: Vec<i32>,
pub alphabet_size: usize,
pub cost: f32,
pub method: u32,
pub omit_pos: usize,
/* private fields */
}Expand description
Normalized ANS histogram for encoding.
Contains frequency counts normalized to sum to ANS_TAB_SIZE (4096).
Fields§
§counts: Vec<i32>Normalized frequency counts.
alphabet_size: usizeAlphabet size (highest non-zero symbol + 1).
cost: f32Cost estimate (header + data bits).
method: u32Encoding method:
- 0: flat distribution
- 1: small code (1-2 symbols)
- 2-13: shift value + 1
omit_pos: usizePosition of the balancing bin (absorbs rounding error).
Implementations§
Source§impl ANSEncodingHistogram
impl ANSEncodingHistogram
Sourcepub fn from_histogram(
histo: &Histogram,
strategy: ANSHistogramStrategy,
) -> Result<Self>
pub fn from_histogram( histo: &Histogram, strategy: ANSHistogramStrategy, ) -> Result<Self>
Create from a Histogram with the best normalization.
Tries different shift values and picks the one with lowest cost.
Use from_histogram_cached with a precomputed AllowedCountsCache
when calling this in a loop to avoid repeated table construction.
Sourcepub fn from_histogram_cached(
histo: &Histogram,
strategy: ANSHistogramStrategy,
cache: &AllowedCountsCache,
) -> Result<Self>
pub fn from_histogram_cached( histo: &Histogram, strategy: ANSHistogramStrategy, cache: &AllowedCountsCache, ) -> Result<Self>
Create from a Histogram using precomputed allowed counts tables.
This is the fast path — call AllowedCountsCache::new() once and reuse
it across all histogram normalization calls to avoid repeated allocation
and sorting of allowed counts tables.
Trait Implementations§
Source§impl Clone for ANSEncodingHistogram
impl Clone for ANSEncodingHistogram
Source§fn clone(&self) -> ANSEncodingHistogram
fn clone(&self) -> ANSEncodingHistogram
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ANSEncodingHistogram
impl Debug for ANSEncodingHistogram
Auto Trait Implementations§
impl Freeze for ANSEncodingHistogram
impl RefUnwindSafe for ANSEncodingHistogram
impl Send for ANSEncodingHistogram
impl Sync for ANSEncodingHistogram
impl Unpin for ANSEncodingHistogram
impl UnsafeUnpin for ANSEncodingHistogram
impl UnwindSafe for ANSEncodingHistogram
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