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, append to qtables
DHT -> nx_jpeg_dht_parse, append to htables
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 |
| 88 | const NX_JPEG_DEC_CTX_BYTES: i64 = 112 |
functions
| 62 | func nx_jpeg_dec_top_result_is_valid(v: i64) -> i64 |
| 92 | func nx_jpeg_dec_ctx_init(ctx: *NxJpegDecCtx) -> i64 |
| 122 | func nx_jpeg_decode(jpeg: *u8, jpeg_len: i64, |