code wiki / _hdl_build / nx_h264_iframe.nx
nx_h264_iframe.nx
buildroot/runtime/_hdl_build/nx_h264_iframe.nx
about
nx_h264_iframe.nx -- reusable CAVLC I-slice -> YUV420 decode driver (STEP 3 core for the cam poster).
Lifts the proven full-frame reconstruction from nx_h264_decode_frame.nx into a callable function that
takes an already-extracted, de-emulated IDR slice RBSP + parsed SPS/PPS + output planes, decodes every
macroblock (I_4x4 / I_16x16 / I_PCM), and reconstructs Y/U/V. Two engineering fixes vs the original main:
(1) uses CODED MB dims (mbW=sps[4]+1, mbH=sps[5]+1) so non-16-aligned crops (e.g. 1080) decode fully;
(2) HOISTS all per-call scratch out of the recon kernels (the toolchain's sys_mmap has no munmap; a
per-MB mmap would exhaust the kernel map_count on a full-HD frame) -> bounded, constant map count.
Deblocking is intentionally omitted here (a downscaled poster averages block edges away); add for full res.
LIB (no main). license_tier: ORIGINAL genealogy_id: itu_t_h264_islice_cavlc_recon (lifted from decode_frame)
dependencies 17 imports · 2 importers
diagram shows first 10 each side; +7 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_h264_bits.nxnx_h264_slice.nxnx_h264_mb.nxnx_h264_mb_pred.nxnx_h264_coeff_token.nxnx_h264_cavlc_level.nxnx_h264_residual.nxnx_h264_nc.nxnx_h264_zigzag.nxnx_h264_hadamard.nxnx_h264_dequant.nxnx_h264_idct.nxnx_h264_intra16.nxnx_h264_intra.nxnx_h264_chroma_pred.nxnx_h264_chroma.nx
imported by: nx_cam_poster.nxnx_ts_lumadiff.nx
structs
| none |
consts
| 29 | const SC_PRED: i64 = 0 // 256 (i16 pred) / 64 (chroma) |
| 30 | const SC_TOP: i64 = 256 // up to 16 |
| 31 | const SC_LEFT: i64 = 288 // up to 16 |
| 32 | const SC_SCAN: i64 = 320 // 16 |
| 33 | const SC_RAST: i64 = 336 // 16 |
| 34 | const SC_DQ: i64 = 352 // 16 |
| 35 | const SC_DCY: i64 = 368 // 16 (I16 luma DC scaled) |
| 36 | const SC_NA: i64 = 384 // 6 |
| 37 | const SC_CC: i64 = 392 // 4 |
| 38 | const SC_DCC: i64 = 400 // 4 |
| 39 | const SC_IDCT: i64 = 408 // 16 words: nx_idct4x4 scratch, hoisted 2026-08-01 (SC_WORDS=512, so 408+16 fits) |
| 40 | const SC_WORDS: i64 = 512 |
functions
| 42 | func scp(sc: *i64, off: i64) -> *i64 { return ((sc as i64) + off * 8) as *i64 } |
| 45 | func dec_luma(br: *BitReader, lumaTC: *i64, lbW: i64, bx: i64, by: i64, maxc: i64, coeff: *i64) -> i64 |
| 58 | func dec_chroma_ac(br: *BitReader, cTC: *i64, cbW: i64, cbx: i64, cby: i64, coeff: *i64) -> i64 |
| 71 | func chroma_qpc(qpL: i64, cqo: i64) -> i64 calls 1: nx_h264_chroma_qp |
| 79 | func i16_dc_scale_h(dcblk: *i64, qp: i64, sc: *i64) -> i64 |
| 99 | func recon_i16_luma_h(yf: *u8, W: i64, px: i64, py: i64, predMode: i64, sc: *i64, acstore: *i64, qp: i64) -> i64 |
| 154 | func recon_i4_block_h(yf: *u8, W: i64, bpx: i64, bpy: i64, mode: i64, aT: i64, aL: i64, aTL: i64, aTR: i64, coeffscan: *i64, qp: i64, sc: *i64) -> i64 |
| 199 | func recon_chroma_comp_h(cf: *u8, cW: i64, cpx: i64, cpy: i64, predMode: i64, cdc: *i64, acstore: *i64, qpc: i64, availT: i64, availL: i64, sc: *i64) -> i64 |
| 257 | func nx_h264_decode_iframe(sl_dst: *u8, sl_rbsp: i64, ntype: i64, sps: *i64, pps: *i64, yf: *u8, uf: *u8, vf: *u8, mbW: i64, mbH: i64) -> i64 called by 2: mainmain calls 22: sys_mmapbr_initnx_h264_parse_slice_header_brnx_h264_mb_parse_itypenx_h264_mb_type_classbr_align+16 |