pub struct InterleavedTansEncoder { /* private fields */ }Expand description
Interleaved tANS encoder for Zstd sequences (LL, OF, ML).
Implementations§
Source§impl InterleavedTansEncoder
impl InterleavedTansEncoder
Sourcepub fn new(
ll_table: &FseTable,
of_table: &FseTable,
ml_table: &FseTable,
) -> Self
pub fn new( ll_table: &FseTable, of_table: &FseTable, ml_table: &FseTable, ) -> Self
Create encoder from three FSE tables.
Note: For predefined tables, prefer new_predefined() which uses
cached encoders for better performance.
Sourcepub fn new_predefined() -> Self
pub fn new_predefined() -> Self
Create encoder using cached predefined tANS encoders.
This is the fast path for encoding with predefined FSE tables. Cloning cached encoders is much faster than building from scratch.
Sourcepub fn from_encoders(
ll_encoder: TansEncoder,
of_encoder: TansEncoder,
ml_encoder: TansEncoder,
) -> Self
pub fn from_encoders( ll_encoder: TansEncoder, of_encoder: TansEncoder, ml_encoder: TansEncoder, ) -> Self
Create encoder from pre-built tANS encoders.
This allows using custom FSE tables by building encoders separately.
Sourcepub fn init_states(&mut self, ll: u8, of: u8, ml: u8)
pub fn init_states(&mut self, ll: u8, of: u8, ml: u8)
Initialize all three encoders with their first symbols.
These should be the LAST symbols in the sequence (encoding is reversed).
Sourcepub fn encode_sequence(&mut self, ll: u8, of: u8, ml: u8) -> [(u32, u8); 3]
pub fn encode_sequence(&mut self, ll: u8, of: u8, ml: u8) -> [(u32, u8); 3]
Encode one sequence (LL, OF, ML) and return bits for each.
Returns [(ll_bits, ll_nbits), (of_bits, of_nbits), (ml_bits, ml_nbits)]
Note: tANS encoding order matters! We encode in reverse of decode order. Decoder reads FSE updates: LL, ML, OF So we encode: OF, ML, LL (reverse order for correct state transitions)
Sourcepub fn get_states(&self) -> (u32, u32, u32)
pub fn get_states(&self) -> (u32, u32, u32)
Get final states for all three encoders.
These become the decoder’s initial states.
Sourcepub fn accuracy_logs(&self) -> (u8, u8, u8)
pub fn accuracy_logs(&self) -> (u8, u8, u8)
Get accuracy logs for all three encoders.