Struct miniz_oxide::inflate::core::HuffmanTable
source · struct HuffmanTable {
pub look_up: [i16; 1024],
pub tree: [i16; 576],
}
Expand description
A struct containing huffman code lengths and the huffman code tree used by the decompressor.
Fields§
§look_up: [i16; 1024]
Fast lookup table for shorter huffman codes.
See HuffmanTable::fast_lookup
.
tree: [i16; 576]
Full huffman tree.
Positive values are edge nodes/symbols, negative values are parent nodes/references to other nodes.
Implementations§
source§impl HuffmanTable
impl HuffmanTable
const fn new() -> HuffmanTable
sourcefn fast_lookup(&self, bit_buf: u64) -> i16
fn fast_lookup(&self, bit_buf: u64) -> i16
Look for a symbol in the fast lookup table. The symbol is stored in the lower 9 bits, the length in the next 6. If the returned value is negative, the code wasn’t found in the fast lookup table and the full tree has to be traversed to find the code.
sourcefn tree_lookup(
&self,
fast_symbol: i32,
bit_buf: u64,
code_len: u8,
) -> (i32, u32)
fn tree_lookup( &self, fast_symbol: i32, bit_buf: u64, code_len: u8, ) -> (i32, u32)
Get the symbol and the code length from the huffman tree.
sourcefn lookup(&self, bit_buf: u64) -> (i32, u32)
fn lookup(&self, bit_buf: u64) -> (i32, u32)
Look up a symbol and code length from the bits in the provided bit buffer.
Returns Some(symbol, length) on success, None if the length is 0.
It’s possible we could avoid checking for 0 if we can guarantee a sane table. TODO: Check if a smaller type for code_len helps performance.
Trait Implementations§
source§impl Clone for HuffmanTable
impl Clone for HuffmanTable
source§fn clone(&self) -> HuffmanTable
fn clone(&self) -> HuffmanTable
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for HuffmanTable
impl RefUnwindSafe for HuffmanTable
impl Send for HuffmanTable
impl Sync for HuffmanTable
impl Unpin for HuffmanTable
impl UnwindSafe for HuffmanTable
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)