code wiki / (root) / nx_jpeg_decode.nx

nx_jpeg_decode.nx

buildroot/runtime/nx_jpeg_decode.nx

16816 B337 linesdepth 6pulls 13 transitivereach 119 importersview sourcekind librarytopic jpeg
docsdependenciesstructsconstsfunctions

about

nx_jpeg_decode.nx -- top-level baseline-JPEG decoder. The marker-walking front-end that ties every brick in the JPEG arc into a bytes-in / sample-planes-out API. Pipeline: jpeg_bytes -> nx_jpeg_seg_next (marker scan) for each segment: DQT -> nx_jpeg_dqt_parse into scratch, then PLACED by Tq (a redefinition replaces) DHT -> nx_jpeg_dht_parse into scratch, then PLACED by (Tc,Th) (a redefinition replaces) SOF0 -> nx_jpeg_sof_parse, store frame SOS -> nx_jpeg_sos_parse, store scan + record entropy_off (entropy bytes run from segment end to EOI) else -> skip (APP / COM / etc.) -> nx_jpeg_decode_image_resolve (per-component table lookup) -> nx_jpeg_decode_image_walk_mcus (MCU grid driver) Output: per-component sample planes filled. Caller upsamples + YCbCr->RGB to produce the final RGB framebuffer. Caller supplies all the storage (frame + scan + qtables + htables + per-component planes). Substrate adds no malloc beyond the scratch arenas internal to per-block primitives. nx_safety_envelope: intended_use: "Top-level baseline-JPEG decode -- bytes-in, sample-planes-out. Last brick before YCbCr->RGB upsample step." sil_target: SIL1 evidence: [composes_marker_dqt_dht_sof_sos_decode_image, sealed_verdicts_per_segment_kind, bounded_iteration] hazard_register: [bug-tape-progressive-mistaken-baseline, bug-tape-restart-marker-not-honored, bug-tape-app-segment-length-overrun] residual_risk: "Baseline (SOF0) only. Progressive (SOF2), extended-sequential (SOF1), and arithmetic- coded variants reject with NOT_BASELINE." verdict: NOT_YET_EVALUATED

dependencies 8 imports · 3 importers

nx_syscalls.nx nx_jpeg_marker.nx nx_jpeg_dqt.nx nx_jpeg_dht.nx nx_jpeg_sof.nx nx_jpeg_sos.nx nx_jpeg_mcu.nx nx_jpeg_decode_image.nx nx_jpeg_decode.nx nx_jpeg_ascii.nx nx_jpeg_decode_test.nx nx_jpeg_progressive.nx

imports: nx_syscalls.nxnx_jpeg_marker.nxnx_jpeg_dqt.nxnx_jpeg_dht.nxnx_jpeg_sof.nxnx_jpeg_sos.nxnx_jpeg_mcu.nxnx_jpeg_decode_image.nx

imported by: nx_jpeg_ascii.nxnx_jpeg_decode_test.nxnx_jpeg_progressive.nx

structs

70struct NxJpegDecCtx

consts

50const NX_JPEG_DEC_TOP_OK: i64 = 0
51const NX_JPEG_DEC_TOP_NO_SOI: i64 = 1
52const NX_JPEG_DEC_TOP_NO_SOF: i64 = 2
53const NX_JPEG_DEC_TOP_NO_SOS: i64 = 3
54const NX_JPEG_DEC_TOP_BAD_DQT: i64 = 4
55const NX_JPEG_DEC_TOP_BAD_DHT: i64 = 5
56const NX_JPEG_DEC_TOP_BAD_SOF: i64 = 6
57const NX_JPEG_DEC_TOP_BAD_SOS: i64 = 7
58const NX_JPEG_DEC_TOP_NOT_BASELINE: i64 = 8
59const NX_JPEG_DEC_TOP_IMAGE_FAIL: i64 = 9 // resolve / walk_mcus error
60const NX_JPEG_DEC_TOP_RESULT_N: i64 = 10
94const NX_JPEG_DEC_CTX_BYTES: i64 = 120
106const NX_JPEG_TC_CLASSES: i64 = 2
107const NX_JPEG_TH_PER_CLASS: i64 = 4
108const NX_JPEG_HSLOTS: i64 = 8
109const NX_JPEG_HSCRATCH: i64 = 4
110const NX_JPEG_QSLOTS: i64 = 4
111const NX_JPEG_QSCRATCH: i64 = 4
112const NX_JPEG_COMP_SLOTS: i64 = 4
113const NX_JPEG_HBITS_N: i64 = 17
114const NX_JPEG_HVAL_N: i64 = 256
115const NX_JPEG_QVAL_N: i64 = 64
116const NX_JPEG_TSLOT_FREE: i64 = 0 - 1
117const NX_JPEG_I64: i64 = 8

functions

62func nx_jpeg_dec_top_result_is_valid(v: i64) -> i64
119func nx_jpeg_ctx_htable_at(ctx: *NxJpegDecCtx, slot: i64) -> *NxJpegHTable
122func nx_jpeg_ctx_qtable_at(ctx: *NxJpegDecCtx, slot: i64) -> *NxJpegQTable
126func nx_jpeg_ctx_htable_bind(ctx: *NxJpegDecCtx, slot: i64) -> i64
136func nx_jpeg_ctx_tables_reset(ctx: *NxJpegDecCtx) -> i64
159func nx_jpeg_ctx_htable(ctx: *NxJpegDecCtx, tc: i64, th: i64) -> *NxJpegHTable
168func nx_jpeg_ctx_qtable(ctx: *NxJpegDecCtx, tq: i64) -> *NxJpegQTable
called by 1: main calls 1: nx_jpeg_ctx_qtable_at
175func nx_jpeg_copy_i64(dst: *i64, src: *i64, n: i64) -> i64
182func nx_jpeg_ctx_parse_dht(ctx: *NxJpegDecCtx, payload: *u8, payload_len: i64) -> i64
210func nx_jpeg_ctx_parse_dqt(ctx: *NxJpegDecCtx, payload: *u8, payload_len: i64) -> i64
231func nx_jpeg_dec_ctx_init(ctx: *NxJpegDecCtx) -> i64
262func nx_jpeg_decode(jpeg: *u8, jpeg_len: i64,