code wiki / _hdl_build / nx_vcodec_ffv1_entropy_gate.nx
nx_vcodec_ffv1_entropy_gate.nx
buildroot/runtime/_hdl_build/nx_vcodec_ffv1_entropy_gate.nx
about
nx_vcodec_ffv1_entropy_gate.nx -- MEASURE an FFV1/RFC-9043-style integer entropy-coding improvement on REAL
quantized residuals, BEFORE any wire change. The shipped range coder (nx_rangecoder) adapts each per-context
12-bit probability with a FIXED shift-5 multiplicative step (rc_p_update). FFV1's edge is a NON-UNIFORM,
extreme-reaching adaptation rate (fast while uncertain, tiny steps once confidently skewed) -> lower steady-
state variance + probabilities that reach the true extremes. rc_p_update_adv (nx_rangecoder.nx) is that idea
in pure integers, parameterised by cfg=[s_start,s_floor,minstep,lo,hi]. This gate builds real 8x8 DCT+quant
residual blocks (frame diffs of bframe_test_decoded.yuv, the exact source the other entropy gates use) and
A/Bs the shipped shift-5 coder vs the _adv sweep on BOTH the LIVE run-length path (rc_block64) AND the sig-map
path (rc_sig), reporting bytes + permille saved, the per-frame Shannon headroom (the ceiling any adaptation
can reach), and a BIT-EXACT roundtrip verdict (mism count). MEASURE-FIRST: honest number, negative allowed.
license_tier: ORIGINAL
dependencies 6 imports · 0 importers
imports: nx_syscalls.nxnx_dct8.nxnx_vcodec.nxnx_rangecoder.nxnx_rangecoder_sig.nxnx_quality_metric.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 19 | const NW: i64 = 576 |
| 20 | const NH: i64 = 1024 |
| 21 | const BPF: i64 = 9216 // 8x8 luma blocks per frame = (576/8)*(1024/8) |
functions
| 23 | func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 24 | func gn(v: i64) -> i64 |
| 30 | func fill_frame(yuv: *u8, f: i64, qp: i64, M: *i64, scr: *i64, ti: *i64, to: *i64, dst: *i64) -> i64 |
| 50 | func cond_bits(h: *i64, C: i64) -> i64 |
| 64 | func tally_rl(blocks: *i64, nb: i64, zz8: *i64, h: *i64) -> i64 |
| 86 | func tally_sig(blocks: *i64, nb: i64, sigmap: *i64, h: *i64) -> i64 |
| 117 | func rlbytes_base(blocks: *i64, nb: i64, zz8: *i64, est: *i64, probs: *i64, out: *u8) -> i64 |
| 123 | func rlbytes_adv(blocks: *i64, nb: i64, cfg: *i64, zz8: *i64, est: *i64, probs: *i64, cnt: *i64, out: *u8) -> i64 |
| 129 | func sigbytes_base(blocks: *i64, nb: i64, est: *i64, probs: *i64, sigmap: *i64, out: *u8) -> i64 |
| 135 | func sigbytes_adv(blocks: *i64, nb: i64, cfg: *i64, est: *i64, probs: *i64, cnt: *i64, sigmap: *i64, out: *u8) -> i64 |
| 143 | func rlverify_adv(blocks: *i64, nb: i64, cfg: *i64, zz8: *i64, est: *i64, probs: *i64, cnt: *i64, out: *u8, |
| 161 | func sigverify_adv(blocks: *i64, nb: i64, cfg: *i64, est: *i64, probs: *i64, cnt: *i64, sigmap: *i64, out: *u8, |
| 180 | func setcfg(c: *i64, a: i64, b: i64, d: i64, e: i64, f: i64) -> i64 { c[0]=a; c[1]=b; c[2]=d; c[3]=e; c[4]=f; return 0 } called by 1: main |
| 181 | func row(lbl: *u8, bytes: i64, base: i64) -> i64 |
| 184 | func main() -> i64 |