Skip to main content

EntropyDecoder

Struct EntropyDecoder 

Source
pub struct EntropyDecoder<S: RansParams> { /* private fields */ }
Expand description

High-level entropy decoder using CDF tables for symbol lookup.

Generic over S: RansParams (RansByte or Rans64).

Implementations§

Source§

impl<S: RansParams> EntropyDecoder<S>

Source

pub fn new() -> Self

Create a new uninitialized entropy decoder.

Source

pub fn initialize( &mut self, pmf_lengths: &[i32], pmf_offsets: &[i32], pmf_table: &[i32], symbol_bits: u32, bypass_bits: u32, ) -> Result<(), EntropyError>

Initialize the decoder with PMF distribution data.

  • pmf_lengths — number of symbols per distribution (including bypass sentinel)
  • pmf_offsets — value offsets per distribution
  • pmf_table — flat array of symbol frequencies for all distributions
  • symbol_bits — number of bits for symbol encoding (e.g. 16)
  • bypass_bits — number of bits for bypass encoding (e.g. 4)
Source

pub fn decode( &self, values: &mut [i32], indices: &[i32], data: &[u8], ) -> Result<(), EntropyError>

One-shot decode: decode from data into values.

  • values — output buffer (must be same length as indices)
  • indices — distribution indices for each value to decode
  • data — encoded byte stream
Source

pub fn decode_partial( &self, values: &mut [i32], indices: &[i32], data: &[u8], ) -> Result<usize, EntropyError>

Decode from a slice but do NOT require the source to be fully exhausted.

This is used when decoding from a RansDecoderStream where multiple encoded segments are concatenated. The method decodes values/indices from the beginning of data and returns the number of bytes consumed.

  • values — output buffer (must be same length as indices)
  • indices — distribution indices for each value to decode
  • data — encoded byte stream (may contain extra trailing data)

Returns the number of bytes consumed from data on success.

Source

pub fn decode_batch( &self, values: &mut [i32], indices: &[i32], data: &[u8], ) -> Result<usize, EntropyError>

Decode a batch of symbols from data without requiring EOF.

This is used for multipart stream decoding, where the stream contains multiple messages concatenated. The first decoder reads its symbols and returns the bytes consumed, leaving the rest for subsequent decoders.

Returns the number of bytes consumed.

Source

pub fn decode_stream( &self, values: &mut [i32], indices: &[i32], data: &[u8], ) -> Result<usize, EntropyError>

Decode a batch of symbols from a sub-slice of data, returning bytes consumed.

This is an alias for decode_batch used by the Python stream decoder.

Trait Implementations§

Source§

impl<S: RansParams> Default for EntropyDecoder<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for EntropyDecoder<S>

§

impl<S> RefUnwindSafe for EntropyDecoder<S>
where S: RefUnwindSafe,

§

impl<S> Send for EntropyDecoder<S>
where S: Send,

§

impl<S> Sync for EntropyDecoder<S>
where S: Sync,

§

impl<S> Unpin for EntropyDecoder<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for EntropyDecoder<S>

§

impl<S> UnwindSafe for EntropyDecoder<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.