code wiki / _hdl_build / _codec_real_med.nx

_codec_real_med.nx

buildroot/runtime/_hdl_build/_codec_real_med.nx

12376 B279 linesdepth 8pulls 17 transitivereach 0 importersview sourcekind tooltopic codec
docsdependenciesstructsconstsfunctions

about

_codec_real_med.nx -- X-CDC-FRAME-LZ-001 representative-corpus rung: the SAME predictor-isolation head-to-head as _codec_bench_med, but on REAL PHOTO pixels (a decoded gallery PNG) instead of synthetic frames -- closing the "synthetic is unrepresentative" caveat with a no-wave verdict. Pipeline: read a real 1024x768 8-bit RGB PNG -> nx_png_decode -> raw pixels -> sample 3 deterministic 64x64 patches (1/4, center, 3/4 positions; no cherry-pick) per RGB channel -> for each plane compare MED(JPEG-LS)-prefilter+deflate vs PNG-Sub-prefilter+deflate (SAME sovereign deflate, SAME pixels). No-false-green: MED+deflate round-trips end-to-end on each plane + a tamper check that MUST fail. GREEN iff round-trip exact on all planes AND tamper detected; the win COUNT is reported, never forced. Dimensions/color are read from raw IHDR bytes (avoids the nx_int struct-field-alias hazard); only res.pixels (a pointer field at offset 8, before any nx_int field) is read from the result struct.

dependencies 4 imports · 0 importers

nx_frame_codec.nx nx_deflate_fixed.nx nx_png_decoder.nx nx_syscalls.nx _codec_real_med.nx

imports: nx_frame_codec.nxnx_deflate_fixed.nxnx_png_decoder.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close bp sys_write sys_exit be32 bn sys_mmap ↻ sys_write ↻ nx_png_decode sys_mmap ↻ _png_check_signature _png_read_u32_be nx_crc32 nx_crc32_update nx_crc32_init nx_crc32_table_at _png_n_channels _png_bytes_per_pixel _png_n_channels ↻ _png_a7_expected _png_a7_col0 _png_a7_coli _png_a7_row0 _png_a7_rowi nx_zlib_inflate sys_mmap ↻ nx_deflate_inflate sys_mmap ↻ nx_bitstream_alloc sys_mmap ↻ _deflate_inflate_block nx_bitstream_read_lsb nx_bitstream_bits_remainin

structs

none

consts

none

functions

16func bp(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 2: bench_planemain calls 1: sys_write
17func bn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; let t: *u8=sys_mmap(28); if m==0{t[0]=48;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{b[i]=t[k-1-i];i=i+1}; sys_write(1,b,k); return 0 }
called by 2: bench_planemain calls 2: sys_mmapsys_write
18func lw(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
19func ln(fd: i64, v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; let t: *u8=sys_mmap(28); if m==0{t[0]=48;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{b[i]=t[k-1-i];i=i+1}; sys_write(fd,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
21func be32(b: *u8, o: i64) -> i64 { return ((b[o] as i64 & 255)<<24)|((b[o+1] as i64 & 255)<<16)|((b[o+2] as i64 & 255)<<8)|(b[o+3] as i64 & 255) }
called by 1: main
24func sub_filter(buf: *u8, w: i64, h: i64, res: *u8) -> i64
called by 1: bench_plane
37func med_filter(buf: *u8, w: i64, h: i64, res: *u8) -> i64
called by 2: bench_planemain calls 1: fc_pred
50func med_unfilter(res: *u8, w: i64, h: i64, out: *u8) -> i64
called by 2: bench_planemain calls 1: fc_pred
64func paeth_filter(buf: *u8, w: i64, h: i64, res: *u8) -> i64
called by 1: bench_plane calls 1: _png_paeth
86func absb(r: i64) -> i64 { if r < 128 { return r } return 256 - r }
called by 1: adaptive_filter
87func apred(f: i64, left: i64, above: i64, ul: i64) -> i64
called by 1: adaptive_filter calls 2: _png_paethfc_med
96func adaptive_filter(buf: *u8, w: i64, h: i64, res: *u8, nf: i64) -> i64
called by 1: bench_plane calls 2: apredabsb
138func extract(px: *u8, w: i64, nch: i64, c: i64, x0: i64, y0: i64, pw: i64, ph: i64, plane: *u8) -> i64
called by 1: main
151func bench_plane(label: *u8, plane: *u8, pw: i64, ph: i64, scratch: *u8, cap: i64, acc: *i64) -> i64
192func main() -> i64