pub struct EntropyEncoder<S: EncoderVariantForS> { /* private fields */ }Expand description
High-level entropy encoder using PMF distributions with bypass support.
Generic over S: RansParams (RansByte or Rans64).
§Example
ⓘ
use msrtc_rans::entropy::EntropyEncoder;
use msrtc_rans::RansByte;
let mut enc: EntropyEncoder<RansByte> = EntropyEncoder::new();
enc.initialize(
&[4, 6], // pmf_lengths
&[1, 2], // pmf_offsets
&[1, 3, 1, 1, 1, 3, 5, 3, 1, 1], // pmf_table
16, // symbol_bits
4, // bypass_bits
).unwrap();
let mut buffer = Vec::new();
enc.encode(&[0, 1], &[1, 1], &mut buffer).unwrap();Implementations§
Source§impl<S: EncoderVariantForS> EntropyEncoder<S>
impl<S: EncoderVariantForS> EntropyEncoder<S>
Sourcepub fn initialize(
&mut self,
pmf_lengths: &[i32],
pmf_offsets: &[i32],
pmf_table: &[i32],
symbol_bits: u32,
bypass_bits: u32,
) -> Result<(), EntropyError>
pub fn initialize( &mut self, pmf_lengths: &[i32], pmf_offsets: &[i32], pmf_table: &[i32], symbol_bits: u32, bypass_bits: u32, ) -> Result<(), EntropyError>
Initialize the encoder with PMF distribution data.
pmf_lengths— number of symbols per distribution (including bypass sentinel)pmf_offsets— value offsets per distributionpmf_table— flat array of symbol frequencies for all distributionssymbol_bits— number of bits for symbol encoding (e.g. 16)bypass_bits— number of bits for bypass encoding (e.g. 4)
Sourcepub fn encode_batch(
&self,
indices: &[i32],
values: &[i32],
encoder: &mut <S as EncoderVariantForS>::RawEnc,
) -> Result<(), EntropyError>
pub fn encode_batch( &self, indices: &[i32], values: &[i32], encoder: &mut <S as EncoderVariantForS>::RawEnc, ) -> Result<(), EntropyError>
Encode symbols onto an existing raw encoder for persistent streaming.
Unlike encode(), this does NOT flush the encoder or finalize output.
Call encoder.flush() and extract units after all batches are pushed.
Trait Implementations§
Source§impl<S: EncoderVariantForS> Default for EntropyEncoder<S>
impl<S: EncoderVariantForS> Default for EntropyEncoder<S>
Auto Trait Implementations§
impl<S> Freeze for EntropyEncoder<S>
impl<S> RefUnwindSafe for EntropyEncoder<S>
impl<S> Send for EntropyEncoder<S>
impl<S> Sync for EntropyEncoder<S>
impl<S> Unpin for EntropyEncoder<S>
impl<S> UnsafeUnpin for EntropyEncoder<S>
impl<S> UnwindSafe for EntropyEncoder<S>
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