code wiki / (root) / nx_zstd_block.nx

nx_zstd_block.nx

buildroot/runtime/nx_zstd_block.nx

6801 B155 linesdepth 5pulls 10 transitivereach 1 importersview sourcekind librarytopic zstd
docsdependenciesstructsconstsfunctions

about

nx_zstd_block.nx -- Zstandard compressed-block decompression. The integration layer: literals section + sequences section -> plain bytes. This is what turns the six proven zstd layers into a decoder that actually handles a Compressed block instead of refusing it. WHAT IS WIRED. Raw, RLE and Huffman-coded literals (with a directly-encoded weight table), plus the zero-sequence case where the block's output IS its literals. That is a complete, legal zstd block -- it is what an encoder emits for data it could not match, which is common for already-compressed or high-entropy input. WHAT IS NOT, AND SAYS SO. FSE-coded sequences and FSE-compressed Huffman weights each return their own distinct refusal code. A decoder that quietly emitted the literals for a block that also carried sequences would produce output that is the right LENGTH and the wrong BYTES -- the worst possible failure, because a length check would pass it. THE HUFFMAN TREE DESCRIPTION IS INSIDE THE COMPRESSED SIZE. compressed_size from the literals header covers the tree description AND the stream(s), so the stream length is compressed_size minus the description. Treating compressed_size as the stream alone over-reads by the description length and desynchronises the sequences section that follows. genealogy_id: zstandard_rfc8878_block lineage_id: nx_zstd_block_v1 license_tier: ORIGINAL

dependencies 9 imports · 1 importers

nx_syscalls.nx nx_zstd_fse.nx nx_zstd_bits.nx nx_zstd_huf.nx nx_zstd_lit.nx nx_zstd_seq.nx nx_zstd_fse_dec.nx nx_zstd_seqtab.nx nx_zstd_seqdec.nx nx_zstd_block.nx nx_zstd_block_gate.nx

imports: nx_syscalls.nxnx_zstd_fse.nxnx_zstd_bits.nxnx_zstd_huf.nxnx_zstd_lit.nxnx_zstd_seq.nxnx_zstd_fse_dec.nxnx_zstd_seqtab.nxnx_zstd_seqdec.nx

imported by: nx_zstd_block_gate.nx

structs

none

consts

39const NX_BLK_ERR_MALFORMED: i64 = 0 - 1
40const NX_BLK_ERR_FSE_SEQ: i64 = 0 - 2
41const NX_BLK_ERR_FSE_WEIGHTS: i64 = 0 - 3
42const NX_BLK_ERR_STREAMS4: i64 = 0 - 4

functions

44func nx_blk_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 }
called by 1: nx_zstd_block_tree
53func nx_zstd_block_tree(d: *u8, n: i64, off: i64, out_t: *i64) -> i64
78func nx_zstd_block_decompress(d: *u8, n: i64, out: *u8, cap: i64) -> i64