Struct miniz_oxide::inflate::core::HuffmanTable
source · struct HuffmanTable {
pub code_size: [u8; 288],
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§
§code_size: [u8; 288]
Length of the code at each index.
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: u32,
) -> (i32, u32)
fn tree_lookup( &self, fast_symbol: i32, bit_buf: u64, code_len: u32, ) -> (i32, u32)
Get the symbol and the code length from the huffman tree.
sourcefn lookup(&self, bit_buf: u64) -> Option<(i32, u32)>
fn lookup(&self, bit_buf: u64) -> Option<(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.