pub struct SymbolEncoder { /* private fields */ }Expand description
Encoder for the AV1 symbol (range) coder.
Feed symbols with SymbolEncoder::encode_symbol (CDF-coded) and equiprobable bits with
SymbolEncoder::encode_literal, then call SymbolEncoder::finish to flush and obtain the
coded bytes. Those bytes are exactly what a decoder consumes via init_symbol(sz) (AV1 §8.2.2)
where sz is the returned length.
Implementations§
Source§impl SymbolEncoder
impl SymbolEncoder
Sourcepub fn encode_symbol(&mut self, symbol: usize, cdf: &[u16])
pub fn encode_symbol(&mut self, symbol: usize, cdf: &[u16])
Encodes symbol against a static cumulative cdf (cdf.len() symbols, cdf[last] == 32768).
§Panics
Debug builds assert symbol < cdf.len() and the CDF normalisation invariants.
Sourcepub fn encode_symbol_adapt(
&mut self,
symbol: usize,
cdf: &mut [u16],
count: &mut u16,
)
pub fn encode_symbol_adapt( &mut self, symbol: usize, cdf: &mut [u16], count: &mut u16, )
Encodes symbol against an adapting cumulative cdf, then applies the §8.2.6 CDF
adaptation in place (disable_cdf_update = 0). count is the spec’s trailing cdf[N]
adaptation counter (start it at 0 for a freshly initialised context); it is bumped here, up to
a maximum of 32. A decoder must apply the identical §8.2.6 update (decode the symbol, then the
same adaptation) with the same count so its CDF tracks the encoder’s exactly.
§Panics
Debug builds assert symbol < cdf.len() and the CDF normalisation invariants.
Sourcepub fn encode_literal(&mut self, value: u32, n: u32)
pub fn encode_literal(&mut self, value: u32, n: u32)
Encodes the low n bits of value as equiprobable bits, most-significant bit first.
This is the inverse of the decoder’s read_literal(n) (AV1 §8.2.5), which itself calls
read_bool() (§8.2.3) with the fixed CDF {1 << 14, 1 << 15}.
Trait Implementations§
Source§impl Clone for SymbolEncoder
impl Clone for SymbolEncoder
Source§fn clone(&self) -> SymbolEncoder
fn clone(&self) -> SymbolEncoder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more