code wiki / (root) / nx_zstd_seq.nx

nx_zstd_seq.nx

buildroot/runtime/nx_zstd_seq.nx

8711 B262 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind librarytopic zstd
docsdependenciesstructsconstsfunctions

about

nx_zstd_seq.nx -- Zstandard sequences: header, code tables, execution. The last zstd layer. A sequence is a triple (literal_length, match_length, offset): copy N literals, then copy M bytes from earlier in the OUTPUT. The literals come from nx_zstd_lit; this turns them plus the sequence list into the decompressed bytes. THE MATCH COPY MUST BE BYTE BY BYTE. An offset SMALLER than the match length is legal and extremely common -- it is how zstd encodes runs, and the copy deliberately reads bytes it wrote moments earlier in the same operation. A bulk move that reads the whole source region up front produces the wrong bytes for every position past the first `offset` of them. offset=1 with match_length=100 is a 100-byte run of one value; a bulk copy gives one byte and 99 of whatever was already there. THE SEQUENCE COUNT IS 1, 2 OR 3 BYTES with a discontinuous encoding: below 128 it is the byte itself, below 255 it is a two-byte form biased by 0x8000, and exactly 255 escapes to a three-byte form biased by 0x7F00. Treating it as a plain varint mis-sizes the header and every table after it. THE LITERAL AND MATCH LENGTH CODES ARE BASELINE PLUS EXTRA BITS, and the baselines are NOT uniform -- the first 16 literal-length codes are the value itself, then the table jumps. Match lengths start at 3, not 0, because a match shorter than 3 is never worth encoding. genealogy_id: zstandard_rfc8878_sequences lineage_id: nx_zstd_seq_v1 license_tier: ORIGINAL

dependencies 1 imports · 5 importers

nx_syscalls.nx nx_zstd_seq.nx nx_zstd_block.nx nx_zstd_block_gate.nx nx_zstd_seq_gate.nx nx_zstd_seqdec.nx nx_zstd_seqdec_gate.nx

imports: nx_syscalls.nx

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

structs

none

consts

32const NX_SEQ_MODE_PREDEFINED: i64 = 0
33const NX_SEQ_MODE_RLE: i64 = 1
34const NX_SEQ_MODE_FSE: i64 = 2
35const NX_SEQ_MODE_REPEAT: i64 = 3
37const NX_SEQ_FLD_COUNT: i64 = 0
38const NX_SEQ_FLD_LLMODE: i64 = 1
39const NX_SEQ_FLD_OFMODE: i64 = 2
40const NX_SEQ_FLD_MLMODE: i64 = 3
41const NX_SEQ_FLD_HDRLEN: i64 = 4

functions

43func nx_seq_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 }
called by 1: nx_zstd_seq_header
47func nx_zstd_seq_header(d: *u8, n: i64, off: i64, fld: *i64) -> i64
93func nx_zstd_ll_base(code: i64) -> i64
called by 2: mainnx_zstd_seq_one
119func nx_zstd_ll_extra(code: i64) -> i64
called by 2: mainnx_zstd_seq_one
144func nx_zstd_ml_base(code: i64) -> i64
called by 2: mainnx_zstd_seq_one
171func nx_zstd_ml_extra(code: i64) -> i64
called by 2: mainnx_zstd_seq_one
197func nx_zstd_of_base(code: i64) -> i64
called by 2: mainnx_zstd_seq_one
203func nx_zstd_of_extra(code: i64) -> i64
called by 2: mainnx_zstd_seq_one
216func nx_zstd_seq_execute(lit: *u8, lit_len: i64, seqs: *i64, nseq: i64,