code wiki / (root) / nx_jpeg_dht.nx

nx_jpeg_dht.nx

buildroot/runtime/nx_jpeg_dht.nx

9491 B237 linesdepth 2pulls 2 transitivereach 82 importersview sourcekind librarytopic jpeg
docsdependenciesstructsconstsfunctions

about

nx_jpeg_dht.nx -- JPEG Huffman-table (DHT) parser per ITU-T Rec. T.81 sec B.2.4.2 + canonical decode-table builder per Annex C. DHT payload layout (one or more tables packed): Tc (4 bits) Th (4 bits) -- class (0=DC, 1=AC) + table-id (0..3) L1..L16 (16 bytes) -- BITS: count of codes of each length V1..Vn (sum-of-BITS) -- HUFFVAL: symbol assignments in increasing-code-value order Canonical decode table (T.81 Annex C, Fig C.1-C.3) consists of three 17-entry arrays (lengths 1..16, index 0 unused): MINCODE[L] -- smallest code of length L MAXCODE[L] -- largest code of length L (-1 if no codes of len L) VALPTR[L] -- index into HUFFVAL where codes of length L begin Decode algorithm (T.81 Fig F.16) -- DECODE: read 1 bit -> CODE for L = 1 to 16: if CODE <= MAXCODE[L]: return HUFFVAL[VALPTR[L] + CODE - MINCODE[L]] read 1 more bit; CODE = (CODE << 1) | bit error nx_safety_envelope: intended_use: "Huffman-table parsing + canonical decode-table construction for JPEG entropy decode." sil_target: SIL1 evidence: [t81_section_b_2_4_2_canonical_basis, t81_annex_c_canonical_table_algorithm, bounded_iteration] hazard_register: [bug-tape-dht-huffsize-table-overflow, bug-tape-dht-malformed-bits-length-sum, bug-tape-dht-tc-th-out-of-range] residual_risk: "Decode-table users must bound L<=16 per spec; substrate emits BAD_LENGTH if BITS sum >256." verdict: NOT_YET_EVALUATED

dependencies 1 imports · 9 importers

nx_syscalls.nx nx_jpeg_dht.nx nx_jpeg_decode.nx nx_jpeg_decode_image.nx nx_jpeg_decode_image_test.nx nx_jpeg_dht_test.nx nx_jpeg_entropy.nx nx_jpeg_entropy_test.nx nx_jpeg_mcu.nx nx_jpeg_mcu_test.nx nx_jpeg_progressive.nx

imports: nx_syscalls.nx

imported by: nx_jpeg_decode.nxnx_jpeg_decode_image.nxnx_jpeg_decode_image_test.nxnx_jpeg_dht_test.nxnx_jpeg_entropy.nxnx_jpeg_entropy_test.nxnx_jpeg_mcu.nxnx_jpeg_mcu_test.nxnx_jpeg_progressive.nx

structs

57struct NxJpegHTable

consts

41const NX_JPEG_DHT_OK: i64 = 0
42const NX_JPEG_DHT_TRUNC: i64 = 1
43const NX_JPEG_DHT_BAD_TC: i64 = 2 // Tc > 1
44const NX_JPEG_DHT_BAD_TH: i64 = 3 // Th > 3
45const NX_JPEG_DHT_TOO_MANY_SYM: i64 = 4 // sum-of-BITS > 256
46const NX_JPEG_DHT_OVERFLOW: i64 = 5 // more than 4 tables in payload
47const NX_JPEG_DHT_RESULT_N: i64 = 6
68const NX_JPEG_HTABLE_BYTES: i64 = 64

functions

49func nx_jpeg_dht_result_is_valid(v: i64) -> i64
73func nx_jpeg_dht_build_decode_tables(bits: *i64,
called by 1: nx_jpeg_dht_parse
122func nx_jpeg_dht_parse(payload: *u8, payload_len: i64,
200func nx_jpeg_huff_decode_symbol(table: *NxJpegHTable,