code wiki / _hdl_build / nx_jpeg_color_write.nx
nx_jpeg_color_write.nx
buildroot/runtime/_hdl_build/nx_jpeg_color_write.nx
about
nx_jpeg_color_write.nx -- SOVEREIGN baseline COLOR (YCbCr 4:4:4) JFIF writer. Extends the grayscale J3
writer (nx_jpeg_write) to 3 components so photo thumbnails encode as real .jpg (far smaller than lossless
PNG). 2 DQT (luma id0 + chroma id1, via nx_qt_luma/nx_qt_chroma), 3-component SOF0/SOS, interleaved MCUs
(one 8x8 block per component, no chroma subsampling). REUSES (DRY): jw_b/jw_u16/jw_qround + nx_dct8 +
nx_zigzag + nx_jpeg_block_enc + nx_jpeg_huff_enc, sharing the LUMA DC/AC Huffman tables across all three
components (valid baseline -- table choice is the encoder's; the chroma compression win is the quant table).
RGB->YCbCr is the standard 8-bit-integer fast transform (NO floats). W,H must be multiples of 8.
JPEG/Annex K public since 1992 -> patent-clean. license_tier: ORIGINAL
dependencies 8 imports · 7 importers
imports: nx_syscalls.nxnx_h264_bitwriter.nxnx_dct8.nxnx_quant_table.nxnx_zigzag.nxnx_jpeg_huff_enc.nxnx_jpeg_block_enc.nxnx_jpeg_write.nx
imported by: nx_cam_poster.nxnx_galx_thumb_oneshot.nxnx_jpeg_color_write_gate.nxnx_reader_panels_gate.nxnx_reader_tile.nxnx_reader_tile_gate.nxnx_reader_zoomserve_gate.nx
structs
| none |
consts
| 17 | const K_MAGIC_4096: i64 = 4096 |
functions
| 20 | func jcw_y(r: i64, g: i64, b: i64) -> i64 { var v: i64 = (77*r + 150*g + 29*b) >> 8; if v < 0 { v = 0 } if v > 255 { v = 255 } return v } called by 1: jcw_write_color |
| 21 | func jcw_cb(r: i64, g: i64, b: i64) -> i64 { var v: i64 = (((0-43)*r - 85*g + 128*b) >> 8) + 128; if v < 0 { v = 0 } if v > 255 { v = 255 } return v } called by 1: jcw_write_color |
| 22 | func jcw_cr(r: i64, g: i64, b: i64) -> i64 { var v: i64 = ((128*r - 107*g - 21*b) >> 8) + 128; if v < 0 { v = 0 } if v > 255 { v = 255 } return v } called by 1: jcw_write_color |
| 26 | func jcw_block(bw: *BitWriter, plane: *i64, W: i64, bx: i64, by: i64, qt: *i64, |
| 41 | func jcw_write_color(out: *u8, W: i64, H: i64, rgb: *u8, |