nx_zstd_fse.nx
buildroot/runtime/nx_zstd_fse.nx
about
nx_zstd_fse.nx -- FSE (tANS) decoding-table construction for Zstandard.
FSE is the entropy engine underneath zstd: literal lengths, match lengths
and offsets are each FSE-coded, and the literals Huffman weights are too.
Nothing in the tree had it -- nx_rans.nx is the same FAMILY (asymmetric
numeral systems) but the range variant, not the table-driven one zstd uses.
THE SPREAD. A decoding table is built by walking a stride across the table
and dropping each symbol `count` times. The stride
step = (size>>1) + (size>>3) + 3
is chosen to be coprime with the table size so the walk visits every cell
exactly once. That coprimality FAILS for size 8 (step 8, 8&7 == 0, the walk
never advances) -- which is exactly why zstd's minimum accuracy log is 5.
We REFUSE a table_log below that rather than emit a table whose cells were
silently overwritten.
LOW-PROBABILITY SYMBOLS. A normalized count of -1 means "less than one in
this table" -- those symbols are placed from the TOP of the table downward
and start at state 1. They are not an error and must not be clamped to 0,
or the rarest symbols become undecodable.
genealogy_id: zstandard_rfc8878_fse
lineage_id: nx_zstd_fse_v1
license_tier: ORIGINAL
dependencies 1 imports · 9 importers
imports: nx_syscalls.nx
imported by: nx_zstd_block.nxnx_zstd_block_gate.nxnx_zstd_fse_dec.nxnx_zstd_fse_dec_gate.nxnx_zstd_fse_gate.nxnx_zstd_seqdec.nxnx_zstd_seqdec_gate.nxnx_zstd_seqtab.nxnx_zstd_seqtab_gate.nx
structs
| 33 | struct NxFseTable |
consts
| 28 | const NX_FSE_MIN_LOG: i64 = 5 |
| 29 | const NX_FSE_MAX_LOG: i64 = 12 |
| 30 | const NX_FSE_MAX_SYMBOL: i64 = 256 |
| 31 | const NX_FSE_TBL_BYTES: i64 = 48 |
functions
| 42 | func nx_fse_highbit(v: i64) -> i64 |
| 50 | func nx_fse_step(table_size: i64) -> i64 |
| 62 | func nx_fse_build_dtable(norm: *i64, max_symbol: i64, table_log: i64) -> *NxFseTable |
| 167 | func nx_fse_cell_symbol(t: *NxFseTable, state: i64) -> i64 |
| 175 | func nx_fse_cell_nbbits(t: *NxFseTable, state: i64) -> i64 |
| 183 | func nx_fse_cell_newstate(t: *NxFseTable, state: i64) -> i64 |