code wiki / _hdl_build / _codec_real_med.nx
_codec_real_med.nx
buildroot/runtime/_hdl_build/_codec_real_med.nx
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
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
structs
| none |
consts
| none |
functions
| 16 | func bp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 17 | func 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 } |
| 18 | func 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 } |
| 19 | func 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 } |
| 21 | func 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 |
| 24 | func sub_filter(buf: *u8, w: i64, h: i64, res: *u8) -> i64 called by 1: bench_plane |
| 37 | func med_filter(buf: *u8, w: i64, h: i64, res: *u8) -> i64 |
| 50 | func med_unfilter(res: *u8, w: i64, h: i64, out: *u8) -> i64 |
| 64 | func paeth_filter(buf: *u8, w: i64, h: i64, res: *u8) -> i64 |
| 86 | func absb(r: i64) -> i64 { if r < 128 { return r } return 256 - r } called by 1: adaptive_filter |
| 87 | func apred(f: i64, left: i64, above: i64, ul: i64) -> i64 |
| 96 | func adaptive_filter(buf: *u8, w: i64, h: i64, res: *u8, nf: i64) -> i64 |
| 138 | func extract(px: *u8, w: i64, nch: i64, c: i64, x0: i64, y0: i64, pw: i64, ph: i64, plane: *u8) -> i64 called by 1: main |
| 151 | func bench_plane(label: *u8, plane: *u8, pw: i64, ph: i64, scratch: *u8, cap: i64, acc: *i64) -> i64 |
| 192 | func main() -> i64 |