pub struct ArithmeticDecoder<R: Read> { /* private fields */ }Expand description
Arithmetic decoder using 16-bit precision with E3 underflow prevention.
The decoder maintains an interval [low, high] and a code value read from the bitstream. As symbols are decoded, the interval narrows and bits are shifted out when the MSBs converge.
Implementations§
Source§impl<R: Read> ArithmeticDecoder<R>
impl<R: Read> ArithmeticDecoder<R>
Sourcepub fn new(reader: R) -> Result<Self>
pub fn new(reader: R) -> Result<Self>
Initialize decoder by reading the first 16 bits of encoded data.
Sourcepub fn threshold_val(&self, total: u16) -> u16
pub fn threshold_val(&self, total: u16) -> u16
Compute threshold for symbol lookup given total frequency.
Returns a value in [0, total-1] indicating where the current code falls within the frequency distribution.
Sourcepub fn decode_update(
&mut self,
cum_low: u16,
cum_high: u16,
total: u16,
) -> Result<()>
pub fn decode_update( &mut self, cum_low: u16, cum_high: u16, total: u16, ) -> Result<()>
Narrow interval after decoding a symbol and renormalize.
cum_low: cumulative frequency of all symbols before this onecum_high: cumulative frequency up to and including this symboltotal: sum of all symbol frequencies
Auto Trait Implementations§
impl<R> Freeze for ArithmeticDecoder<R>where
R: Freeze,
impl<R> RefUnwindSafe for ArithmeticDecoder<R>where
R: RefUnwindSafe,
impl<R> Send for ArithmeticDecoder<R>where
R: Send,
impl<R> Sync for ArithmeticDecoder<R>where
R: Sync,
impl<R> Unpin for ArithmeticDecoder<R>where
R: Unpin,
impl<R> UnsafeUnpin for ArithmeticDecoder<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for ArithmeticDecoder<R>where
R: 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