nx_jpeg_decode.nx
buildroot/runtime/nx_jpeg_decode.nx
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
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
| 70 | struct NxJpegDecCtx |
consts
| 50 | const NX_JPEG_DEC_TOP_OK: i64 = 0 |
| 51 | const NX_JPEG_DEC_TOP_NO_SOI: i64 = 1 |
| 52 | const NX_JPEG_DEC_TOP_NO_SOF: i64 = 2 |
| 53 | const NX_JPEG_DEC_TOP_NO_SOS: i64 = 3 |
| 54 | const NX_JPEG_DEC_TOP_BAD_DQT: i64 = 4 |
| 55 | const NX_JPEG_DEC_TOP_BAD_DHT: i64 = 5 |
| 56 | const NX_JPEG_DEC_TOP_BAD_SOF: i64 = 6 |
| 57 | const NX_JPEG_DEC_TOP_BAD_SOS: i64 = 7 |
| 58 | const NX_JPEG_DEC_TOP_NOT_BASELINE: i64 = 8 |
| 59 | const NX_JPEG_DEC_TOP_IMAGE_FAIL: i64 = 9 // resolve / walk_mcus error |
| 60 | const NX_JPEG_DEC_TOP_RESULT_N: i64 = 10 |
| 94 | const NX_JPEG_DEC_CTX_BYTES: i64 = 120 |
| 106 | const NX_JPEG_TC_CLASSES: i64 = 2 |
| 107 | const NX_JPEG_TH_PER_CLASS: i64 = 4 |
| 108 | const NX_JPEG_HSLOTS: i64 = 8 |
| 109 | const NX_JPEG_HSCRATCH: i64 = 4 |
| 110 | const NX_JPEG_QSLOTS: i64 = 4 |
| 111 | const NX_JPEG_QSCRATCH: i64 = 4 |
| 112 | const NX_JPEG_COMP_SLOTS: i64 = 4 |
| 113 | const NX_JPEG_HBITS_N: i64 = 17 |
| 114 | const NX_JPEG_HVAL_N: i64 = 256 |
| 115 | const NX_JPEG_QVAL_N: i64 = 64 |
| 116 | const NX_JPEG_TSLOT_FREE: i64 = 0 - 1 |
| 117 | const NX_JPEG_I64: i64 = 8 |
functions
| 62 | func nx_jpeg_dec_top_result_is_valid(v: i64) -> i64 |
| 119 | func nx_jpeg_ctx_htable_at(ctx: *NxJpegDecCtx, slot: i64) -> *NxJpegHTable |
| 122 | func nx_jpeg_ctx_qtable_at(ctx: *NxJpegDecCtx, slot: i64) -> *NxJpegQTable |
| 126 | func nx_jpeg_ctx_htable_bind(ctx: *NxJpegDecCtx, slot: i64) -> i64 |
| 136 | func nx_jpeg_ctx_tables_reset(ctx: *NxJpegDecCtx) -> i64 |
| 159 | func nx_jpeg_ctx_htable(ctx: *NxJpegDecCtx, tc: i64, th: i64) -> *NxJpegHTable |
| 168 | func nx_jpeg_ctx_qtable(ctx: *NxJpegDecCtx, tq: i64) -> *NxJpegQTable |
| 175 | func nx_jpeg_copy_i64(dst: *i64, src: *i64, n: i64) -> i64 |
| 182 | func nx_jpeg_ctx_parse_dht(ctx: *NxJpegDecCtx, payload: *u8, payload_len: i64) -> i64 |
| 210 | func nx_jpeg_ctx_parse_dqt(ctx: *NxJpegDecCtx, payload: *u8, payload_len: i64) -> i64 |
| 231 | func nx_jpeg_dec_ctx_init(ctx: *NxJpegDecCtx) -> i64 |
| 262 | func nx_jpeg_decode(jpeg: *u8, jpeg_len: i64, |