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
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.
Trait Implementations§
Auto Trait Implementations§
impl<Sr> Freeze for RansByteDecoder<Sr>where
Sr: Freeze,
impl<Sr> RefUnwindSafe for RansByteDecoder<Sr>where
Sr: RefUnwindSafe,
impl<Sr> Send for RansByteDecoder<Sr>where
Sr: Send,
impl<Sr> Sync for RansByteDecoder<Sr>where
Sr: Sync,
impl<Sr> Unpin for RansByteDecoder<Sr>where
Sr: Unpin,
impl<Sr> UnsafeUnpin for RansByteDecoder<Sr>where
Sr: UnsafeUnpin,
impl<Sr> UnwindSafe for RansByteDecoder<Sr>where
Sr: UnwindSafe,
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