code wiki / _hdl_build / nx_h264_iframe.nx

nx_h264_iframe.nx

buildroot/runtime/_hdl_build/nx_h264_iframe.nx

20764 B496 linesdepth 5pulls 22 transitivereach 2 importersview sourcekind librarytopic h264
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_h264_bits.nx nx_h264_slice.nx nx_h264_mb.nx nx_h264_mb_pred.nx nx_h264_coeff_token.nx nx_h264_cavlc_level.nx nx_h264_residual.nx nx_h264_nc.nx nx_h264_zigzag.nx nx_h264_iframe.nx nx_cam_poster.nx nx_ts_lumadiff.nx

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

29const SC_PRED: i64 = 0 // 256 (i16 pred) / 64 (chroma)
30const SC_TOP: i64 = 256 // up to 16
31const SC_LEFT: i64 = 288 // up to 16
32const SC_SCAN: i64 = 320 // 16
33const SC_RAST: i64 = 336 // 16
34const SC_DQ: i64 = 352 // 16
35const SC_DCY: i64 = 368 // 16 (I16 luma DC scaled)
36const SC_NA: i64 = 384 // 6
37const SC_CC: i64 = 392 // 4
38const SC_DCC: i64 = 400 // 4
39const SC_IDCT: i64 = 408 // 16 words: nx_idct4x4 scratch, hoisted 2026-08-01 (SC_WORDS=512, so 408+16 fits)
40const SC_WORDS: i64 = 512

functions

42func scp(sc: *i64, off: i64) -> *i64 { return ((sc as i64) + off * 8) as *i64 }
45func dec_luma(br: *BitReader, lumaTC: *i64, lbW: i64, bx: i64, by: i64, maxc: i64, coeff: *i64) -> i64
58func dec_chroma_ac(br: *BitReader, cTC: *i64, cbW: i64, cbx: i64, cby: i64, coeff: *i64) -> i64
71func chroma_qpc(qpL: i64, cqo: i64) -> i64
79func i16_dc_scale_h(dcblk: *i64, qp: i64, sc: *i64) -> i64
99func recon_i16_luma_h(yf: *u8, W: i64, px: i64, py: i64, predMode: i64, sc: *i64, acstore: *i64, qp: i64) -> i64
154func 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
199func 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
257func 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