Struct arithmetic_coding::Decoder
source · [−]Expand description
An arithmetic decoder
An arithmetic decoder converts a stream of bytes into a stream of some
output symbol, using a predictive Model
.
Implementations
sourceimpl<M, R> Decoder<M, R> where
M: Model,
R: BitRead,
impl<M, R> Decoder<M, R> where
M: Model,
R: BitRead,
sourcepub fn new(model: M, input: R) -> Result<Self>
pub fn new(model: M, input: R) -> Result<Self>
Construct a new Decoder
The ‘precision’ of the encoder is maximised, based on the number of bits
needed to represent the Model::denominator
. ‘precision’ bits is
equal to u32::BITS
- Model::denominator
bits.
Errors
This method can fail if the underlying BitRead
cannot be read from.
Panics
The calculation of the number of bits used for ‘precision’ is subject to the following constraints:
- The total available bits is
u32::BITS
- The precision must use at least 2 more bits than that needed to
represent
Model::denominator
If these constraints cannot be satisfied this method will panic in debug builds
sourcepub fn with_precision(model: M, input: R, precision: u32) -> Result<Self>
pub fn with_precision(model: M, input: R, precision: u32) -> Result<Self>
Construct a new Decoder
with a custom precision
Errors
This method can fail if the underlying BitRead
cannot be read from.
Panics
The calculation of the number of bits used for ‘precision’ is subject to the following constraints:
- The total available bits is
BitStore::BITS
- The precision must use at least 2 more bits than that needed to
represent
Model::denominator
If these constraints cannot be satisfied this method will panic in debug builds
sourcepub fn decode_symbol(
&mut self
) -> Result<Option<M::Symbol>, Error<M::ValueError>>
pub fn decode_symbol(
&mut self
) -> Result<Option<M::Symbol>, Error<M::ValueError>>
Trait Implementations
Auto Trait Implementations
impl<M, R> RefUnwindSafe for Decoder<M, R> where
M: RefUnwindSafe,
R: RefUnwindSafe,
<M as Model>::B: RefUnwindSafe,
impl<M, R> Send for Decoder<M, R> where
M: Send,
R: Send,
<M as Model>::B: Send,
impl<M, R> Sync for Decoder<M, R> where
M: Sync,
R: Sync,
<M as Model>::B: Sync,
impl<M, R> Unpin for Decoder<M, R> where
M: Unpin,
R: Unpin,
<M as Model>::B: Unpin,
impl<M, R> UnwindSafe for Decoder<M, R> where
M: UnwindSafe,
R: UnwindSafe,
<M as Model>::B: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more