code wiki / _hdl_build / nx_codec_rd2_gate.nx

nx_codec_rd2_gate.nx

buildroot/runtime/_hdl_build/nx_codec_rd2_gate.nx

9142 B125 linesdepth 5pulls 11 transitivereach 0 importersview sourcekind gate/prooftopic codec
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_emit_lib.nx nx_h264_bitwriter.nx nx_dct8.nx nx_quant_table.nx nx_zigzag.nx nx_jpeg_huff_enc.nx nx_jpeg_block_enc.nx nx_jpeg_sym.nx nx_rans.nx nx_codec_rd2_gate.nx

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

main g_puts sys_write sys_mmap jhe_dc_bits jhe_dc_val jhe_ac_bits jhe_ac_val jhe_gen sys_mmap ↻ nx_qt_luma sys_mmap ↻ _qt_luma_base _qt_quality_to_scale _qt_scale nx_zigzag_init nx_dct8_init nx_dct8_forward_2d nx_dct8_forward_1d qrnd nx_zigzag_scan bw_init jbe_encode_block jhe_emit_dc jhe_mag_cat bw_write_bits bw_write_bit jhe_mag_bits jhe_emit_ac jhe_mag_cat ↻ bw_write_bits ↻ jhe_mag_bits ↻ bw_write_bit ↻ jbe_decode_block jhe_decode_sym jhe_read_bit jhe_decode_mag jhe_read_bit ↻ jsym_encode_block jhe_mag_cat ↻

structs

none

consts

22const GRADE_BEHIND: i64 = 1
23const GRADE_PARITY: i64 = 2
24const GRADE_EXCEEDS: i64 = 4

functions

26func 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 }
called by 1: main calls 2: sys_mmapsys_write
27func 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 }
called by 1: main calls 1: sys_write
28func 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 }
called by 1: main calls 2: sys_mmapsys_write
29func 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
30func 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
31func 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 }
called by 1: main calls 1: g_puts
33func main() -> i64