pub struct BoolDecoder<'a> { /* private fields */ }Expand description
VP8 boolean entropy decoder (RFC 6386 §7.3).
Reads the bools/literals/tree symbols written by a BoolEncoder, in the same order and with
the same probabilities. Reading past the end of the partition yields zero bits (matching the
reference decoders’ zero-padding) rather than panicking; BoolDecoder::is_past_end reports
whether that has happened, so the codec layer can reject a truncated stream.
Implementations§
Source§impl<'a> BoolDecoder<'a>
impl<'a> BoolDecoder<'a>
Sourcepub fn new(input: &'a [u8]) -> Self
pub fn new(input: &'a [u8]) -> Self
Creates a decoder over input, priming value with the first two bytes (zero-padded if
input is shorter), per RFC 6386 §7.3 init_bool_decoder.
Sourcepub fn get_bool(&mut self, prob: Prob) -> bool
pub fn get_bool(&mut self, prob: Prob) -> bool
Decodes one bool encoded at probability prob / 256 (RFC 6386 §7.3 read_bool).
Sourcepub fn get_flag(&mut self) -> bool
pub fn get_flag(&mut self) -> bool
Decodes a one-bit flag (a bool at probability 128) — the F / L(1) of §8.
Sourcepub fn get_literal(&mut self, num_bits: u32) -> u32
pub fn get_literal(&mut self, num_bits: u32) -> u32
Decodes an unsigned num_bits-bit literal L(num_bits), high-order bit first (RFC 6386 §7.3
read_literal). num_bits must be 0..=32.
Sourcepub fn get_signed_literal(&mut self, num_bits: u32) -> i32
pub fn get_signed_literal(&mut self, num_bits: u32) -> i32
Decodes a signed num_bits-bit literal (RFC 6386 §7.3 read_signed_literal): a sign flag
followed by num_bits - 1 magnitude bits.
Sourcepub fn get_tree_start(
&mut self,
tree: &Tree,
probs: &[Prob],
start: usize,
) -> usize
pub fn get_tree_start( &mut self, tree: &Tree, probs: &[Prob], start: usize, ) -> usize
Decodes a tree-coded value from tree with interior-node probabilities probs, beginning
the descent at interior node start (RFC 6386 §8.1 treed_read).
Sourcepub fn get_tree(&mut self, tree: &Tree, probs: &[Prob]) -> usize
pub fn get_tree(&mut self, tree: &Tree, probs: &[Prob]) -> usize
Decodes a tree-coded value from the root (equivalent to
get_tree_start with start = 0).
Sourcepub fn is_past_end(&self) -> bool
pub fn is_past_end(&self) -> bool
Whether a read has consumed input beyond the end of the partition (zero-padded). A correct, untruncated stream never reads past its meaningful end by more than the coder’s lookahead, so the codec layer can use this to detect a malformed or truncated partition.
Trait Implementations§
Source§impl<'a> Clone for BoolDecoder<'a>
impl<'a> Clone for BoolDecoder<'a>
Source§fn clone(&self) -> BoolDecoder<'a>
fn clone(&self) -> BoolDecoder<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more