nx_zstd_block.nx
buildroot/runtime/nx_zstd_block.nx
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
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
| 39 | const NX_BLK_ERR_MALFORMED: i64 = 0 - 1 |
| 40 | const NX_BLK_ERR_FSE_SEQ: i64 = 0 - 2 |
| 41 | const NX_BLK_ERR_FSE_WEIGHTS: i64 = 0 - 3 |
| 42 | const NX_BLK_ERR_STREAMS4: i64 = 0 - 4 |
functions
| 44 | func nx_blk_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 } called by 1: nx_zstd_block_tree |
| 53 | func nx_zstd_block_tree(d: *u8, n: i64, off: i64, out_t: *i64) -> i64 |
| 78 | func nx_zstd_block_decompress(d: *u8, n: i64, out: *u8, cap: i64) -> i64 called by 1: main calls 13: sys_mmapnx_zstd_lit_headernx_zstd_lit_rawnx_zstd_lit_rlenx_zstd_block_treenx_zstd_lit_huf+7 |