code wiki / _hdl_build / nx_codec_rd_gate.nx
nx_codec_rd_gate.nx
buildroot/runtime/_hdl_build/nx_codec_rd_gate.nx
about
nx_codec_rd_gate.nx -- SOVEREIGN measured RATE-DISTORTION head-to-head: our patent-free rANS entropy
coder vs JPEG's Huffman, on the IDENTICAL DCT-quantized coefficients at IDENTICAL quality. Both losslessly
encode the same per-block zigzag quantized coefficients (same image, same nx_dct8 + same Annex-K quant @
Q50) -> reconstruction is provably identical, so this is a pure rate-at-equal-distortion comparison that
isolates the ONE thing that differs: the entropy coder. No python, no 3rd party. This is the measurement
that flips nx_codec_exceed's compression axis from MEASURED-PENDING to an EARNED grade -- and it is
reported HONESTLY whichever way it lands (the gate verifies the grade matches the measured sizes, and a
liar-kill proves a loss can't be graded a win).
T1 JPEG entropy lossless (decode recovers the coeffs) T2 rANS entropy lossless (decode recovers bytes)
T3 both coders fed identical coefficients (equal quality by construction)
T4 measurement valid (both sizes computed > 0) T5 grade matches the measured sizes (honest)
T6 liar-kill: more-bytes can NOT be graded a win
GREEN iff 6/6. knowledge/status/codec_rd_gate.log. license_tier: ORIGINAL
dependencies 9 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_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
| 24 | const GRADE_BEHIND: i64 = 1 |
| 25 | const GRADE_PARITY: i64 = 2 |
| 26 | const GRADE_EXCEEDS: i64 = 4 |
functions
| 28 | 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 } |
| 29 | 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 } |
| 30 | 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 } |
| 31 | 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 |
| 33 | func rd_grade(our_bytes: i64, ref_bytes: i64) -> i64 { if our_bytes < ref_bytes { return GRADE_EXCEEDS } if our_bytes > ref_bytes { return GRADE_BEHIND } return GRADE_PARITY } called by 1: main |
| 34 | 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 } |
| 36 | func main() -> i64 |