Struct ArithmeticDecoder

Source
pub(crate) struct ArithmeticDecoder {
    chunks: Box<[[u8; 4]]>,
    state: State,
    final_bytes: [u8; 3],
    final_bytes_remaining: i8,
}

Fields§

§chunks: Box<[[u8; 4]]>§state: State§final_bytes: [u8; 3]§final_bytes_remaining: i8

Implementations§

Source§

impl ArithmeticDecoder

Source

const FINAL_BYTES_REMAINING_EOF: i8 = -14i8

Source

pub(crate) fn new() -> ArithmeticDecoder

Source

pub(crate) fn init( &mut self, buf: Vec<[u8; 4]>, len: usize, ) -> Result<(), DecodingError>

Source

pub(crate) fn start_accumulated_result(&mut self) -> BitResultAccumulator

Start a span of reading operations from the buffer, without stopping when the buffer runs out. For all valid webp images, the buffer will not run out prematurely. Conversely if the buffer ends early, the webp image cannot be correctly decoded and any intermediate results need to be discarded anyway.

Each call to start_accumulated_result must be followed by a call to check on the same ArithmeticDecoder.

Source

pub(crate) fn check<T>( &self, acc: BitResultAccumulator, value_if_not_past_eof: T, ) -> Result<T, DecodingError>

Check that the read operations done so far were all valid.

Source

fn keep_accumulating<T>( &self, acc: BitResultAccumulator, value_if_not_past_eof: T, ) -> BitResult<T>

Source

pub(crate) fn read_bool(&mut self, probability: u8) -> BitResult<bool>

Source

pub(crate) fn read_flag(&mut self) -> BitResult<bool>

Source

pub(crate) fn read_literal(&mut self, n: u8) -> BitResult<u8>

Source

pub(crate) fn read_optional_signed_value(&mut self, n: u8) -> BitResult<i32>

Source

pub(crate) fn read_with_tree<const N: usize>( &mut self, tree: &[TreeNode; N], ) -> BitResult<i8>

Source

pub(crate) fn read_with_tree_with_first_node( &mut self, tree: &[TreeNode], first_node: TreeNode, ) -> BitResult<i8>

Source

fn fast(&mut self) -> FastDecoder<'_>

Source

fn load_from_final_bytes(&mut self)

Source

fn is_past_eof(&self) -> bool

Source

fn cold_read_bit(&mut self, probability: u8) -> BitResult<bool>

Source

fn cold_read_bool(&mut self, probability: u8) -> BitResult<bool>

Source

fn cold_read_flag(&mut self) -> BitResult<bool>

Source

fn cold_read_literal(&mut self, n: u8) -> BitResult<u8>

Source

fn cold_read_optional_signed_value(&mut self, n: u8) -> BitResult<i32>

Source

fn cold_read_with_tree( &mut self, tree: &[TreeNode], start: usize, ) -> BitResult<i8>

Auto Trait Implementations§

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