Struct arithmetic_coding_adder_dep::decoder::Decoder
source · pub struct Decoder<M, R>where
M: Model,
R: BitRead,{
pub model: M,
/* 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
.
Fields§
§model: M
The model used to predict the next symbol
Implementations§
source§impl<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) -> Self
pub fn new(model: M) -> 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, precision: u32) -> Self
pub fn with_precision(model: M, 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<'a>(&'a mut self, input: &'a mut R) -> DecodeIter<'_, M, R> ⓘ
pub fn decode_all<'a>(&'a mut self, input: &'a mut R) -> 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>where
X: Model<B = M::B>,
pub fn chain<X>(self, model: X) -> Decoder<X, R>where X: Model<B = M::B>,
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