Struct LosslessDecoder

Source
pub(crate) struct LosslessDecoder<R> {
    bit_reader: BitReader<R>,
    transforms: [Option<TransformType>; 4],
    transform_order: Vec<u8>,
    width: u16,
    height: u16,
}

Fields§

§bit_reader: BitReader<R>§transforms: [Option<TransformType>; 4]§transform_order: Vec<u8>§width: u16§height: u16

Implementations§

Source§

impl<R: BufRead> LosslessDecoder<R>

Source

pub(crate) const fn new(r: R) -> Self

Create a new decoder

Source

pub(crate) fn decode_frame( &mut self, width: u32, height: u32, implicit_dimensions: bool, buf: &mut [u8], ) -> Result<(), DecodingError>

Decodes a frame.

In an alpha chunk the width and height are not included in the header, so they should be provided by setting the implicit_dimensions argument. Otherwise that argument should be None and the frame dimensions will be determined by reading the VP8L header.

Source

fn decode_image_stream( &mut self, xsize: u16, ysize: u16, is_argb_img: bool, data: &mut [u8], ) -> Result<(), DecodingError>

Reads Image data from the bitstream

Can be in any of the 5 roles described in the Specification. ARGB Image role has different behaviour to the other 4. xsize and ysize describe the size of the blocks where each block has its own entropy code

Source

fn read_transforms(&mut self) -> Result<u16, DecodingError>

Reads transforms and their data from the bitstream

Source

fn adjust_color_map(color_map: &mut [u8])

Adjusts the color map since it’s subtraction coded

Source

fn read_huffman_codes( &mut self, read_meta: bool, xsize: u16, ysize: u16, color_cache: Option<ColorCache>, ) -> Result<HuffmanInfo, DecodingError>

Reads huffman codes associated with an image

Source

fn read_huffman_code( &mut self, alphabet_size: u16, ) -> Result<HuffmanTree, DecodingError>

Decodes and returns a single huffman tree

Source

fn read_huffman_code_lengths( &mut self, code_length_code_lengths: Vec<u16>, num_symbols: u16, ) -> Result<Vec<u16>, DecodingError>

Reads huffman code lengths

Source

fn decode_image_data( &mut self, width: u16, height: u16, huffman_info: HuffmanInfo, data: &mut [u8], ) -> Result<(), DecodingError>

Decodes the image data using the huffman trees and either of the 3 methods of decoding

Source

fn read_color_cache(&mut self) -> Result<Option<u8>, DecodingError>

Reads color cache data from the bitstream

Source

fn get_copy_distance( bit_reader: &mut BitReader<R>, prefix_code: u16, ) -> Result<usize, DecodingError>

Gets the copy distance from the prefix code and bitstream

Source

fn plane_code_to_distance(xsize: u16, plane_code: usize) -> usize

Gets distance to pixel

Trait Implementations§

Source§

impl<R: Debug> Debug for LosslessDecoder<R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for LosslessDecoder<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for LosslessDecoder<R>
where R: RefUnwindSafe,

§

impl<R> Send for LosslessDecoder<R>
where R: Send,

§

impl<R> Sync for LosslessDecoder<R>
where R: Sync,

§

impl<R> Unpin for LosslessDecoder<R>
where R: Unpin,

§

impl<R> UnwindSafe for LosslessDecoder<R>
where R: UnwindSafe,

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.