code wiki / _hdl_build / nx_codec_rd2_gate.nx
nx_codec_rd2_gate.nx
buildroot/runtime/_hdl_build/nx_codec_rd2_gate.nx
about
nx_codec_rd2_gate.nx -- SOVEREIGN MODELED rate-distortion head-to-head: rANS vs JPEG-Huffman on the
IDENTICAL SYMBOL STREAM (DC-diff categories + AC run/size + EOB) with IDENTICAL magnitude bits, at
IDENTICAL quality. This is the architectural fix the first head-to-head (nx_codec_rd_gate) demanded:
give rANS the same DC-diff + RLE MODELING JPEG uses, so the comparison is the pure entropy-coder
question (rANS vs Huffman on the same symbols) -- the magnitude bits are byte-identical in both and
cancel. No python / 3rd party.
T1 JPEG entropy lossless T2 modeled encode/decode lossless (jsym round-trips the coeffs)
T3 rANS(symbols) lossless T4 the modeling fix BEATS naive rANS (was 5571B)
T5 grade matches measured sizes (honest) T6 liar-kill: more bytes can't be a win
GREEN iff 6/6. knowledge/status/codec_rd2_gate.log. license_tier: ORIGINAL
dependencies 10 imports · 0 importers
imports: nx_syscalls.nxnx_gate_emit_lib.nxnx_h264_bitwriter.nxnx_dct8.nxnx_quant_table.nxnx_zigzag.nxnx_jpeg_huff_enc.nxnx_jpeg_block_enc.nxnx_jpeg_sym.nxnx_rans.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
| 22 | const GRADE_BEHIND: i64 = 1 |
| 23 | const GRADE_PARITY: i64 = 2 |
| 24 | const GRADE_EXCEEDS: i64 = 4 |
functions
| 26 | func g_num(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=(48 as u8);k=1}; while m>0{t[k]=((48+(m%10)) as u8);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 } |
| 27 | func g_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 28 | func g_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=(48 as u8);k=1}; while m>0{t[k]=((48+(m%10)) as u8);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 29 | func qrnd(v: i64, q: i64) -> i64 { if v>=0 { return (v + q/2)/q } return 0 - (((0-v) + q/2)/q) } called by 1: main |
| 30 | func rd_grade(our: i64, ref: i64) -> i64 { if our < ref { return GRADE_EXCEEDS } if our > ref { return GRADE_BEHIND } return GRADE_PARITY } called by 1: main |
| 31 | func g_grade(gr: i64) -> i64 { if gr==4 { g_puts("EXCEEDS" as *u8) } if gr==2 { g_puts("PARITY" as *u8) } if gr==1 { g_puts("BEHIND" as *u8) } return 0 } |
| 33 | func main() -> i64 |