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>
impl<S: RansParams> EntropyDecoder<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 decoder 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 decode(
&self,
values: &mut [i32],
indices: &[i32],
data: &[u8],
) -> Result<(), EntropyError>
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 asindices)indices— distribution indices for each value to decodedata— encoded byte stream
Sourcepub fn decode_partial(
&self,
values: &mut [i32],
indices: &[i32],
data: &[u8],
) -> Result<usize, EntropyError>
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 asindices)indices— distribution indices for each value to decodedata— encoded byte stream (may contain extra trailing data)
Returns the number of bytes consumed from data on success.
Sourcepub fn decode_batch(
&self,
values: &mut [i32],
indices: &[i32],
data: &[u8],
) -> Result<usize, EntropyError>
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.
Sourcepub fn decode_stream(
&self,
values: &mut [i32],
indices: &[i32],
data: &[u8],
) -> Result<usize, EntropyError>
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.