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

20590 B344 linesdepth 5pulls 15 transitivereach 0 importersview sourcekind gate/prooftopic vcodec
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_dct8.nx nx_vcodec.nx nx_rangecoder.nx nx_rangecoder_sig.nx nx_quality_metric.nx nx_vcodec_ffv1_entropy_gate.nx

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

main gw sys_write sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_dct8_init vc_t8_init nx_dct8_init ↻ vc_t8p vc_t8p ↻ setcfg fill_frame nx_dct8_forward_2d nx_dct8_forward_1d vc_quant8 rlbytes_base rc_enc_init rc_block64_encode rc_enc_ctx rc_enc_bit rc_shift_low rc_p_update ve_zze ve_blen rc_enc_flush rc_shift_low ↻ rlbytes_adv rc_enc_init ↻ rc_enc_flush ↻ sigbytes_base rc_enc_init ↻ rc_sig_encode rc_enc_ctx ↻ rcs_nb rcs_sigctx

structs

none

consts

19const NW: i64 = 576
20const NH: i64 = 1024
21const BPF: i64 = 9216 // 8x8 luma blocks per frame = (576/8)*(1024/8)

functions

23func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: rowmain calls 1: sys_write
24func gn(v: i64) -> i64
called by 2: rowmain calls 2: sys_mmapsys_write
30func fill_frame(yuv: *u8, f: i64, qp: i64, M: *i64, scr: *i64, ti: *i64, to: *i64, dst: *i64) -> i64
called by 1: main calls 2: nx_dct8_forward_2dvc_quant8
50func cond_bits(h: *i64, C: i64) -> i64
called by 1: main calls 1: qm_log2_q16
64func tally_rl(blocks: *i64, nb: i64, zz8: *i64, h: *i64) -> i64
called by 1: main calls 2: ve_zzeve_blen
86func tally_sig(blocks: *i64, nb: i64, sigmap: *i64, h: *i64) -> i64
called by 1: main calls 3: rcs_nbrcs_sigctxve_blen
117func rlbytes_base(blocks: *i64, nb: i64, zz8: *i64, est: *i64, probs: *i64, out: *u8) -> i64
123func rlbytes_adv(blocks: *i64, nb: i64, cfg: *i64, zz8: *i64, est: *i64, probs: *i64, cnt: *i64, out: *u8) -> i64
called by 1: main calls 2: rc_enc_initrc_enc_flush
129func sigbytes_base(blocks: *i64, nb: i64, est: *i64, probs: *i64, sigmap: *i64, out: *u8) -> i64
135func sigbytes_adv(blocks: *i64, nb: i64, cfg: *i64, est: *i64, probs: *i64, cnt: *i64, sigmap: *i64, out: *u8) -> i64
called by 1: main calls 2: rc_enc_initrc_enc_flush
143func rlverify_adv(blocks: *i64, nb: i64, cfg: *i64, zz8: *i64, est: *i64, probs: *i64, cnt: *i64, out: *u8,
161func sigverify_adv(blocks: *i64, nb: i64, cfg: *i64, est: *i64, probs: *i64, cnt: *i64, sigmap: *i64, out: *u8,
180func 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
181func row(lbl: *u8, bytes: i64, base: i64) -> i64
called by 1: main calls 2: gwgn
184func main() -> i64