code wiki / _hdl_build / nx_codec_real_rd3.nx

nx_codec_real_rd3.nx

buildroot/runtime/_hdl_build/nx_codec_real_rd3.nx

11900 B204 linesdepth 5pulls 10 transitivereach 0 importersview sourcekind tooltopic codec
docsdependenciesstructsconstsfunctions

about

nx_codec_real_rd3.nx -- the INTRA-PREDICTED patent-free intra codec on a REAL frame (576x1024 luma). The efficiency rung above nx_codec_real_rd2 (modeled entropy): adds sovereign 8x8 directional INTRA PREDICTION (DC/V/H/DDR, generalizing nx_intra_pred's 4x4 modes), so each block is predicted from its already-RECONSTRUCTED neighbors and only the small residual is transform-coded. Pipeline per 8x8 block: pick mode by SAD vs reconstructed-neighbor prediction -> residual = orig - pred -> 2D DCT (nx_dct8, EXPIRED) -> perceptual quant (nx_qt_luma) -> zigzag -> [recon: dequant -> IDCT -> +pred -> clamp -> feed forward]. Entropy: per-block mode byte + DC-diff/run-size symbols (nx_jsym) -> rANS (nx_rans, PD); magnitude bits raw. HONEST total = 512B table + 64B quant + 8B hdr + rANS(symbols incl modes) + magbits. The decoder REPLAYS prediction from its own reconstructed neighbors; rec(enc)==rec(dec) pixel-exact is the liar-kill. Bordered recon buffer (1px 128 border) makes all 4 modes always available with no edge special-casing. Every tool EXPIRED/PD; no CABAC; integer-only; 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_rd3.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_qt_luma sys_mmap ↻ _qt_luma_base _qt_quality_to_scale _qt_scale pred8 sad8 iabs nx_dct8_forward_2d nx_dct8_forward_1d qrnd nx_zigzag_scan nx_dct8_inverse_2d nx_dct8_inverse_1d bw_init jsym_encode_block jhe_mag_cat bw_write_bits bw_write_bit

structs

none

consts

21const K_MAGIC_1024: i64 = 1024
22const K_MAGIC_4096: i64 = 4096

functions

24func 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
29func g_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
30func 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
35func g_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
36func iabs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 2: sad8main
37func 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
41func pred8(rec: *u8, RW: i64, px: i64, py: i64, mode: i64, pred: *i64) -> i64
called by 1: main
72func sad8(fb: *u8, W: i64, px: i64, py: i64, pred: *i64) -> i64
called by 1: main calls 1: iabs
78func main() -> i64