pub(crate) struct BitStream {
pub buffer: u64,
aligned_buffer: u64,
pub(crate) bits_left: u8,
pub marker: Option<Marker>,
pub successive_high: u8,
pub successive_low: u8,
spec_start: u8,
spec_end: u8,
pub eob_run: i32,
pub overread_by: usize,
pub seen_eoi: bool,
}
Expand description
A BitStream
struct, a bit by bit reader with super powers
Fields§
§buffer: u64
A MSB type buffer that is used for some certain operations
aligned_buffer: u64
A TOP aligned MSB type buffer that is used to accelerate some operations like peek_bits and get_bits.
By top aligned, I mean the top bit (63) represents the top bit in the buffer.
bits_left: u8
Tell us the bits left the two buffer
marker: Option<Marker>
Did we find a marker(RST/EOF) during decoding?
successive_high: u8
Progressive decoding
successive_low: u8
§spec_start: u8
§spec_end: u8
§eob_run: i32
§overread_by: usize
§seen_eoi: bool
True if we have seen end of image marker. Don’t read anything after that.
Implementations§
Source§impl BitStream
impl BitStream
Sourcepub(crate) fn new_progressive(
ah: u8,
al: u8,
spec_start: u8,
spec_end: u8,
) -> BitStream
pub(crate) fn new_progressive( ah: u8, al: u8, spec_start: u8, spec_end: u8, ) -> BitStream
Create a new Bitstream for progressive decoding
Sourcepub(crate) fn refill<T>(
&mut self,
reader: &mut ZByteReader<T>,
) -> Result<bool, DecodeErrors>where
T: ZReaderTrait,
pub(crate) fn refill<T>(
&mut self,
reader: &mut ZByteReader<T>,
) -> Result<bool, DecodeErrors>where
T: ZReaderTrait,
Refill the bit buffer by (a maximum of) 32 bits
§Arguments
reader
:&mut BufReader<R>
: A mutable reference to an underlying File/Memory buffer containing a valid JPEG stream
This function will only refill if self.count
is less than 32
Sourcefn decode_dc<T>(
&mut self,
reader: &mut ZByteReader<T>,
dc_table: &HuffmanTable,
dc_prediction: &mut i32,
) -> Result<bool, DecodeErrors>where
T: ZReaderTrait,
fn decode_dc<T>(
&mut self,
reader: &mut ZByteReader<T>,
dc_table: &HuffmanTable,
dc_prediction: &mut i32,
) -> Result<bool, DecodeErrors>where
T: ZReaderTrait,
Decode the DC coefficient in a MCU block.
The decoded coefficient is written to dc_prediction
Sourcepub fn decode_mcu_block<T>(
&mut self,
reader: &mut ZByteReader<T>,
dc_table: &HuffmanTable,
ac_table: &HuffmanTable,
qt_table: &[i32; 64],
block: &mut [i32; 64],
dc_prediction: &mut i32,
) -> Result<(), DecodeErrors>where
T: ZReaderTrait,
pub fn decode_mcu_block<T>(
&mut self,
reader: &mut ZByteReader<T>,
dc_table: &HuffmanTable,
ac_table: &HuffmanTable,
qt_table: &[i32; 64],
block: &mut [i32; 64],
dc_prediction: &mut i32,
) -> Result<(), DecodeErrors>where
T: ZReaderTrait,
Decode a Minimum Code Unit(MCU) as quickly as possible
§Arguments
- reader: The bitstream from where we read more bits.
- dc_table: The Huffman table used to decode the DC coefficient
- ac_table: The Huffman table used to decode AC values
- block: A memory region where we will write out the decoded values
- DC prediction: Last DC value for this component
Sourceconst fn peek_bits<const LOOKAHEAD: u8>(&self) -> i32
const fn peek_bits<const LOOKAHEAD: u8>(&self) -> i32
Peek look_ahead
bits ahead without discarding them from the buffer
Sourcepub(crate) fn decode_prog_dc_first<T>(
&mut self,
reader: &mut ZByteReader<T>,
dc_table: &HuffmanTable,
block: &mut i16,
dc_prediction: &mut i32,
) -> Result<(), DecodeErrors>where
T: ZReaderTrait,
pub(crate) fn decode_prog_dc_first<T>(
&mut self,
reader: &mut ZByteReader<T>,
dc_table: &HuffmanTable,
block: &mut i16,
dc_prediction: &mut i32,
) -> Result<(), DecodeErrors>where
T: ZReaderTrait,
Decode a DC block