nx_jpeg_decode_image.nx
buildroot/runtime/nx_jpeg_decode_image.nx
about
nx_jpeg_decode_image.nx -- full-image driver for the bits-up
baseline JPEG decoder. Per ITU-T Rec. T.81 sec A + F.
Takes:
- Pre-parsed frame descriptor (NxJpegFrame from nx_jpeg_sof_parse)
- Pre-parsed scan header (NxJpegScan from nx_jpeg_sos_parse)
- 4-entry quantization tables array (indexed by sof_component.tqi)
- 4-entry DC + AC Huffman tables (indexed by scan_component.td/ta)
- Entropy-coded byte buffer (the bytes after the SOS header)
- Per-component caller-allocated sample planes + their strides
Loops over the MCU grid (rows x cols from the frame's max-h/max-v).
For each MCU, iterates scan components in order, dispatching to
nx_jpeg_mcu_decode_one_component which handles the Hi*Vi block grid.
Per-component prev_dc tracking: each scan starts with prev_dc = 0
for every component; the MCU walker updates it across blocks.
nx_safety_envelope:
intended_use: "Top-level baseline-JPEG image decoder, sample
planes out. Caller adds YCbCr->RGB upsample."
sil_target: SIL1
evidence: [t81_section_a_canonical_basis,
composes_marker_dqt_dht_sof_sos_entropy_mcu]
hazard_register: [bug-tape-component-id-vs-array-index-confusion,
bug-tape-restart-interval-not-honored,
bug-tape-mcu-grid-cell-stride-mismatch]
residual_risk: "Restart-marker (DRI / RSTn) intervals NOT yet
honored. Bitstream-with-restart-markers
decode requires a follow-on stone."
verdict: NOT_YET_EVALUATED
dependencies 6 imports · 2 importers
imports: nx_syscalls.nxnx_jpeg_sof.nxnx_jpeg_sos.nxnx_jpeg_dht.nxnx_jpeg_dequant.nxnx_jpeg_mcu.nx
imported by: nx_jpeg_decode.nxnx_jpeg_decode_image_test.nx
structs
| 84 | struct NxJpegDecCompState |
consts
| 40 | const NX_JPEG_DEC_OK: i64 = 0 |
| 41 | const NX_JPEG_DEC_BAD_COMP: i64 = 1 // scan component selector doesn't match SOF |
| 42 | const NX_JPEG_DEC_BAD_TQ: i64 = 2 // SOF component points at unknown qtable |
| 43 | const NX_JPEG_DEC_BAD_TD: i64 = 3 // scan component DC table id not present |
| 44 | const NX_JPEG_DEC_BAD_TA: i64 = 4 // scan component AC table id not present |
| 45 | const NX_JPEG_DEC_MCU_FAIL: i64 = 5 // MCU decode propagated an entropy / mcu error |
| 46 | const NX_JPEG_DEC_RESULT_N: i64 = 6 |
| 94 | const NX_JPEG_DEC_COMPSTATE_BYTES: i64 = 56 |
functions
| 48 | func nx_jpeg_dec_result_is_valid(v: i64) -> i64 |
| 57 | func _decoder_sof_for_scan_comp(frame: *NxJpegFrame, called by 1: nx_jpeg_decode_image_resolve |
| 70 | func _decoder_lookup_huffman(tables: *NxJpegHTable, n_tables: i64, called by 1: nx_jpeg_decode_image_resolve |
| 99 | func nx_jpeg_decode_image_resolve(frame: *NxJpegFrame, scan: *NxJpegScan, |
| 143 | func nx_jpeg_decode_image_walk_mcus(frame: *NxJpegFrame, scan: *NxJpegScan, |
| 156 | func _decoder_consume_rst(scan: *NxJpegScan, state: *NxJpegDecCompState, called by 1: nx_jpeg_decode_image_walk_mcus_ri |
| 194 | func nx_jpeg_decode_image_walk_mcus_ri(frame: *NxJpegFrame, scan: *NxJpegScan, |