nx_h264_cabac_residual.nx
buildroot/runtime/nx_h264_cabac_residual.nx
about
nx_h264_cabac_residual.nx -- H.264 CABAC residual block decoding (clause 9.3.2.3 / 9.3.3.1.3).
STEP 2, built on the STEP-1 arithmetic engine in nx_h264_cabac.nx which is KAT-verified against
clause 9.3.1 (gate ALL-PASS). Decodes ONE residual block: the significance map, then the levels
in reverse scan order, then signs.
WHY THIS EXISTS: ~50% of the recording corpus is CABAC-coded and the poster/dead-air paths refuse
it outright (rc=10), which is the single largest measured blocker on gallery posters (117 of 236
files needing work, 2026-07-31). The arithmetic engine already existed and was never built on.
SCOPE + HONESTY: binarization and context routing follow the spec, and the teeth below check the
structure that can be checked without a reference decoder. END-TO-END CORRECTNESS IS NOT PROVEN
HERE -- that requires decoding a real CABAC stream and looking at the image. Do not claim CABAC
posters work until that runs.
license_tier: ORIGINAL
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_h264_cabac.nxnx_h264_cabac_ctxinc.nx
imported by: nx_h264_cabac_residual_gate.nx
structs
| none |
consts
| 19 | const CBR_MAXCOEFF: i64 = 64 // largest block we handle (8x8 luma); 4x4 uses 16 |
| 20 | const CBR_UNARY_MAX: i64 = 13 // coeff_abs_level_minus1 prefix cap before the EG0 suffix |
| 21 | const CBR_EG0_MAXK: i64 = 32 |
| 22 | const CBR_MAX_LEVEL: i64 = 32768 // a coefficient level beyond this cannot occur in 8-bit H.264; past it the stream is corrupt and we REFUSE rather than emit a value that overflows the coefficient arrays // bound on the Exp-Golomb suffix so a corrupt stream cannot spin |
functions
| 25 | func cbr_eg0_bypass(cab: *i64) -> i64 |
| 48 | func cbr_sigmap(cab: *i64, ctx: *i64, rlps: *i64, tlps: *i64, tmps: *i64, |
| 79 | func cbr_levels(cab: *i64, ctx: *i64, rlps: *i64, tlps: *i64, tmps: *i64, |