pub struct RansByteDecoder<Sr: Source<u8>> { /* private fields */ }Expand description
Raw rANS decoder.
Implementations§
Source§impl<Sr: Source<u8>> RansByteDecoder<Sr>
impl<Sr: Source<u8>> RansByteDecoder<Sr>
pub fn new(source: Sr) -> Self
Sourcepub fn from_state(source: Sr, state: u32) -> Self
pub fn from_state(source: Sr, state: u32) -> Self
Construct a decoder with a given state (used for persistent stream decoding where the state continues across calls).
pub fn source(&self) -> &Sr
pub fn source_mut(&mut self) -> &mut Sr
pub fn into_source(self) -> Sr
pub fn state(&self) -> u32
pub fn check_eof(&self) -> bool
Sourcepub fn init(&mut self) -> bool
pub fn init(&mut self) -> bool
Initialize the decoder by reading the initial state from the source.
Sourcepub fn get(&self, scale_bits: Freq) -> Freq
pub fn get(&self, scale_bits: Freq) -> Freq
Get the next symbol frequency (low scale_bits of state).
Panics if scale_bits >= 32 (overflow at 1u32 << scale_bits).
Use try_get for a Result-returning checked variant.
Sourcepub fn try_get(&self, scale_bits: Freq) -> Result<Freq, RawRansError>
pub fn try_get(&self, scale_bits: Freq) -> Result<Freq, RawRansError>
Get the next symbol frequency with bounds checking.
Sourcepub fn advance(&mut self, start: Freq, freq: Freq, scale_bits: Freq) -> bool
pub fn advance(&mut self, start: Freq, freq: Freq, scale_bits: Freq) -> bool
Advance the decoder past a symbol (public checked wrapper).
Uses transactional state: computes into a local variable and only
assigns to self.state after renormalization succeeds.
Panics if parameters are invalid. Use try_advance for a
Result-returning checked variant.
Equivalent to: RansDecoder::Advance(start, freq, scale_bits).
Sourcepub fn try_advance(
&mut self,
start: Freq,
freq: Freq,
scale_bits: Freq,
) -> Result<bool, RawRansError>
pub fn try_advance( &mut self, start: Freq, freq: Freq, scale_bits: Freq, ) -> Result<bool, RawRansError>
Advance the decoder with bounds checking on scale_bits.
Sourcepub fn advance_symbol(
&mut self,
symbol: &RansByteDecSymbol,
scale_bits: Freq,
) -> bool
pub fn advance_symbol( &mut self, symbol: &RansByteDecSymbol, scale_bits: Freq, ) -> bool
Advance using a prepared decoder symbol.