nx_zstd_fse_dec.nx
buildroot/runtime/nx_zstd_fse_dec.nx
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
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
| 40 | func nx_zstd_fse_state_init(t: *NxFseTable, b: *NxZstdBits) -> i64 |
| 55 | func nx_zstd_fse_state_symbol(t: *NxFseTable, state: i64) -> i64 |
| 65 | func nx_zstd_fse_state_next(t: *NxFseTable, b: *NxZstdBits, state: i64) -> i64 |
| 89 | func nx_zstd_fse_state_cost(t: *NxFseTable, state: i64) -> i64 |