code wiki / (root) / nx_zstd_fse.nx

nx_zstd_fse.nx

buildroot/runtime/nx_zstd_fse.nx

6592 B189 linesdepth 2pulls 2 transitivereach 9 importersview sourcekind librarytopic zstd
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_zstd_fse.nx nx_zstd_block.nx nx_zstd_block_gate.nx nx_zstd_fse_dec.nx nx_zstd_fse_dec_gate.nx nx_zstd_fse_gate.nx nx_zstd_seqdec.nx nx_zstd_seqdec_gate.nx nx_zstd_seqtab.nx nx_zstd_seqtab_gate.nx

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

33struct NxFseTable

consts

28const NX_FSE_MIN_LOG: i64 = 5
29const NX_FSE_MAX_LOG: i64 = 12
30const NX_FSE_MAX_SYMBOL: i64 = 256
31const NX_FSE_TBL_BYTES: i64 = 48

functions

42func nx_fse_highbit(v: i64) -> i64
50func nx_fse_step(table_size: i64) -> i64
62func nx_fse_build_dtable(norm: *i64, max_symbol: i64, table_log: i64) -> *NxFseTable
167func nx_fse_cell_symbol(t: *NxFseTable, state: i64) -> i64
175func nx_fse_cell_nbbits(t: *NxFseTable, state: i64) -> i64
183func nx_fse_cell_newstate(t: *NxFseTable, state: i64) -> i64