Skip to main content

BoolDecoder

Struct BoolDecoder 

Source
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>

Source

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.

Source

pub fn get_bool(&mut self, prob: Prob) -> bool

Decodes one bool encoded at probability prob / 256 (RFC 6386 §7.3 read_bool).

Source

pub fn get_flag(&mut self) -> bool

Decodes a one-bit flag (a bool at probability 128) — the F / L(1) of §8.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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>

Source§

fn clone(&self) -> BoolDecoder<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for BoolDecoder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BoolDecoder<'a>

§

impl<'a> RefUnwindSafe for BoolDecoder<'a>

§

impl<'a> Send for BoolDecoder<'a>

§

impl<'a> Sync for BoolDecoder<'a>

§

impl<'a> Unpin for BoolDecoder<'a>

§

impl<'a> UnsafeUnpin for BoolDecoder<'a>

§

impl<'a> UnwindSafe for BoolDecoder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.