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>
impl<R: BufRead> LosslessDecoder<R>
Sourcepub(crate) fn decode_frame(
&mut self,
width: u32,
height: u32,
implicit_dimensions: bool,
buf: &mut [u8],
) -> Result<(), DecodingError>
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.
Sourcefn decode_image_stream(
&mut self,
xsize: u16,
ysize: u16,
is_argb_img: bool,
data: &mut [u8],
) -> Result<(), DecodingError>
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
Sourcefn read_transforms(&mut self) -> Result<u16, DecodingError>
fn read_transforms(&mut self) -> Result<u16, DecodingError>
Reads transforms and their data from the bitstream
Sourcefn adjust_color_map(color_map: &mut [u8])
fn adjust_color_map(color_map: &mut [u8])
Adjusts the color map since it’s subtraction coded
Sourcefn read_huffman_codes(
&mut self,
read_meta: bool,
xsize: u16,
ysize: u16,
color_cache: Option<ColorCache>,
) -> Result<HuffmanInfo, DecodingError>
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
Sourcefn read_huffman_code(
&mut self,
alphabet_size: u16,
) -> Result<HuffmanTree, DecodingError>
fn read_huffman_code( &mut self, alphabet_size: u16, ) -> Result<HuffmanTree, DecodingError>
Decodes and returns a single huffman tree
Sourcefn read_huffman_code_lengths(
&mut self,
code_length_code_lengths: Vec<u16>,
num_symbols: u16,
) -> Result<Vec<u16>, DecodingError>
fn read_huffman_code_lengths( &mut self, code_length_code_lengths: Vec<u16>, num_symbols: u16, ) -> Result<Vec<u16>, DecodingError>
Reads huffman code lengths
Sourcefn decode_image_data(
&mut self,
width: u16,
height: u16,
huffman_info: HuffmanInfo,
data: &mut [u8],
) -> Result<(), DecodingError>
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
Sourcefn read_color_cache(&mut self) -> Result<Option<u8>, DecodingError>
fn read_color_cache(&mut self) -> Result<Option<u8>, DecodingError>
Reads color cache data from the bitstream
Sourcefn get_copy_distance(
bit_reader: &mut BitReader<R>,
prefix_code: u16,
) -> Result<usize, DecodingError>
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
Sourcefn plane_code_to_distance(xsize: u16, plane_code: usize) -> usize
fn plane_code_to_distance(xsize: u16, plane_code: usize) -> usize
Gets distance to pixel