pub struct Decoder<M, R>{ /* private fields */ }
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§
Source§impl<M, R> Decoder<M, R>
impl<M, R> Decoder<M, R>
Sourcepub fn new(model: M, input: R) -> Self
pub fn new(model: M, input: R) -> 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.
§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) -> Self
pub fn with_precision(model: M, input: R, precision: u32) -> Self
Construct a new Decoder
with a custom precision
§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 const fn with_state(state: State<M::B, R>, model: M) -> Self
pub const fn with_state(state: State<M::B, R>, model: M) -> Self
todo
Sourcepub fn decode_all(&mut self) -> DecodeIter<'_, M, R> ⓘ
pub fn decode_all(&mut self) -> DecodeIter<'_, M, R> ⓘ
Return an iterator over the decoded symbols.
The iterator will continue returning symbols until EOF is reached
Sourcepub fn chain<X>(self, model: X) -> Decoder<X, R>
pub fn chain<X>(self, model: X) -> Decoder<X, R>
Reuse the internal state of the Decoder with a new model.
Allows for chaining multiple sequences of symbols from a single stream of bits
Sourcepub fn into_inner(self) -> (M, State<M::B, R>)
pub fn into_inner(self) -> (M, State<M::B, R>)
todo