code wiki / _hdl_build / nx_codec_real_rd2g.nx

nx_codec_real_rd2g.nx

buildroot/runtime/_hdl_build/nx_codec_real_rd2g.nx

8850 B145 linesdepth 5pulls 10 transitivereach 0 importersview sourcekind tooltopic codec
docsdependenciesstructsconstsfunctions

about

nx_codec_real_rd2.nx -- the MODELED patent-free intra codec on a REAL frame's luma (576x1024), the efficiency upgrade over nx_codec_real_rd (naive raw-coeff rANS). Per 8x8 block: level-shift -> 2D DCT (nx_dct8, EXPIRED) -> PERCEPTUAL quant matrix (nx_qt_luma, JPEG Annex-K, EXPIRED) -> zigzag (nx_zigzag) -> DC-differential + AC run/size SYMBOL stream (nx_jsym) separated from raw magnitude bits -> rANS the symbols (nx_rans, PUBLIC DOMAIN); magnitude bits stored raw (near-incompressible). HONEST total = 512B rANS table + 64B quant table + 8B header + rANS(symbols) + magbits. This is exactly the modeling nx_codec_rd2_gate MEASURED at 3.5x over naive (at block level) -- now on the real frame, swept over JPEG quality, to RE-MEASURE vs x264. Round-trip (rANS + jsym) asserted bit-exact each quality = liar-kill. Every tool EXPIRED/PD; no CABAC; integer-only; nx_cc->nxasm, no gcc. license_tier: ORIGINAL

dependencies 9 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_h264_bitwriter.nx nx_dct8.nx nx_quant_table.nx nx_zigzag.nx nx_jpeg_huff_enc.nx nx_jpeg_sym.nx nx_rans.nx nx_codec_real_rd2g.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_h264_bitwriter.nxnx_dct8.nxnx_quant_table.nxnx_zigzag.nxnx_jpeg_huff_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 sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close sys_exit g_num nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap nx_dct8_init nx_zigzag_init sys_openat_append nx_dct8_forward_2d nx_dct8_forward_1d qrnd nx_zigzag_scan bw_init jsym_encode_block jhe_mag_cat bw_write_bits bw_write_bit jhe_mag_bits bw_write_bit ↻ bw_total_bits rans_count rans_normalize rans_cum rans_build_slot2sym rans_encode sys_mmap ↻ rans_decode

structs

none

consts

19const K_MAGIC_1024: i64 = 1024
20const K_MAGIC_9216: i64 = 9216
21const K_MAGIC_4096: i64 = 4096

functions

23func g_puts(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 1: main calls 1: sys_write
28func g_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
29func 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
34func g_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
35func iabs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 1: main
36func qrnd(v: i64, q: i64) -> i64 { let o: i64=q/3; if v>=0 { return (v + o)/q } return 0 - (((0-v) + o)/q) } // DEADZONE f=1/3 (offset q/3 < q/2): wider zero-bin -> more zeros, RD-favorable for Laplacian DCT coeffs
called by 1: main
38func main() -> i64