code wiki / _hdl_build / nx_jpeg_write.nx

nx_jpeg_write.nx

buildroot/runtime/_hdl_build/nx_jpeg_write.nx

9068 B187 linesdepth 5pulls 7 transitivereach 11 importersview sourcekind librarytopic jpeg
docsdependenciesstructsconstsfunctions

about

nx_jpeg_write.nx -- SOVEREIGN baseline grayscale JFIF writer (J3). Assembles a complete, standards- compliant baseline JPEG file (a real .jpg any decoder opens) from an 8-bit luma image: SOI, APP0/JFIF, DQT (quant table in zigzag order), SOF0 (8-bit, 1 component), DHT (luma DC + AC standard Annex-K tables), SOS, the entropy-coded scan (per-8x8-block DC-diff + AC-RLE via nx_jpeg_block_enc, final byte 1-padded, 0xFF byte-stuffed), EOI. Composes the audited nx_dct8 / nx_quant_table / nx_zigzag + nx_jpeg_huff_enc (J1) + nx_jpeg_block_enc (J2). W,H must be multiples of 8. JPEG/Annex K is public since 1992 -> patent-clean. license_tier: ORIGINAL

dependencies 6 imports · 5 importers

nx_syscalls.nx nx_h264_bitwriter.nx nx_dct8.nx nx_zigzag.nx nx_jpeg_huff_enc.nx nx_jpeg_block_enc.nx nx_jpeg_write.nx nx_cam_poster.nx nx_jpeg_color_write.nx nx_jpeg_color_write_gate.nx nx_jpeg_rst_gate.nx nx_jpeg_write_gate.nx

imports: nx_syscalls.nxnx_h264_bitwriter.nxnx_dct8.nxnx_zigzag.nxnx_jpeg_huff_enc.nxnx_jpeg_block_enc.nx

imported by: nx_cam_poster.nxnx_jpeg_color_write.nxnx_jpeg_color_write_gate.nxnx_jpeg_rst_gate.nxnx_jpeg_write_gate.nx

structs

none

consts

14const K_MAGIC_1024: i64 = 1024

functions

16func jw_b(out: *u8, off: i64, v: i64) -> i64 { out[off]=(v & 0xff) as u8; return off+1 }
17func jw_u16(out: *u8, off: i64, v: i64) -> i64 { out[off]=((v>>8)&0xff) as u8; out[off+1]=(v&0xff) as u8; return off+2 }
18func jw_qround(v: i64, q: i64) -> i64 { if v>=0 { return (v + q/2)/q } return 0 - (((0-v) + q/2)/q) }
23func jw_write_jpeg(out: *u8, W: i64, H: i64, qt: *i64,
96func jw_flush_interval(out: *u8, o: i64, bw: *BitWriter, ebuf: *u8, ecap: i64) -> i64
119func jw_write_jpeg_ri(out: *u8, W: i64, H: i64, qt: *i64,