code wiki / (root) / nx_zstd_fse_dec.nx

nx_zstd_fse_dec.nx

buildroot/runtime/nx_zstd_fse_dec.nx

3797 B91 linesdepth 3pulls 4 transitivereach 5 importersview sourcekind librarytopic zstd
docsdependenciesstructsconstsfunctions

about

nx_zstd_fse_dec.nx -- the FSE decoding state machine for zstd sequences. nx_zstd_fse.nx builds the table; this drives it. An FSE decoder is a state that indexes the table: the entry names the symbol, and the NEXT state is that entry's baseline plus a few freshly-read bits. Literal lengths, match lengths and offsets each run their own independent state over the SAME backward bitstream. THE SYMBOL COMES BEFORE THE UPDATE. Read the symbol at the CURRENT state, then consume bits to move to the next. Doing it the other way round yields a stream that is off by one symbol from the first sequence onward -- it decodes, it is the right length, and every value is wrong. THE THREE STATES INTERLEAVE IN A FIXED ORDER. zstd initialises literal length, then offset, then match length; and on each sequence it updates them in the reverse order. They share one bit reader, so any deviation shifts every subsequent read. This module exposes init/symbol/next as separate operations precisely so the caller can express that ordering explicitly rather than burying it in a loop. WHAT IS PROVEN HERE: the state machine's mechanics and invariants. The PREDEFINED distribution tables for the three sequence alphabets are spec DATA, not derivable, and are deliberately NOT included -- transcribing them from memory would produce a decoder that looks right and disagrees with every other implementation. They need to come from the specification text. genealogy_id: zstandard_rfc8878_fse_decoding lineage_id: nx_zstd_fse_dec_v1 license_tier: ORIGINAL

dependencies 3 imports · 5 importers

nx_syscalls.nx nx_zstd_fse.nx nx_zstd_bits.nx nx_zstd_fse_dec.nx nx_zstd_block.nx nx_zstd_block_gate.nx nx_zstd_fse_dec_gate.nx nx_zstd_seqdec.nx nx_zstd_seqdec_gate.nx

imports: nx_syscalls.nxnx_zstd_fse.nxnx_zstd_bits.nx

imported by: nx_zstd_block.nxnx_zstd_block_gate.nxnx_zstd_fse_dec_gate.nxnx_zstd_seqdec.nxnx_zstd_seqdec_gate.nx

structs

none

consts

none

functions

40func nx_zstd_fse_state_init(t: *NxFseTable, b: *NxZstdBits) -> i64
55func nx_zstd_fse_state_symbol(t: *NxFseTable, state: i64) -> i64
65func nx_zstd_fse_state_next(t: *NxFseTable, b: *NxZstdBits, state: i64) -> i64
89func nx_zstd_fse_state_cost(t: *NxFseTable, state: i64) -> i64
called by 1: main calls 1: nx_fse_cell_nbbits