code wiki / _hdl_build / nx_frame_codec_adaptive.nx
nx_frame_codec_adaptive.nx
buildroot/runtime/_hdl_build/nx_frame_codec_adaptive.nx
about
nx_frame_codec_adaptive.nx -- TUTOR-AUTHORED SCAFFOLD (Claude), NOT team-emitter output.
ADAPTIVE 2-D lossless frame codec: the UNION of the field's best lossless predictors
(SUB/UP/AVG/PAETH/MED) with PER-FRAME best-pick by min Rice bits -- the S-class EXCEED
mechanism. A single codec commits to ONE predictor (FFV1=MED, PNG=per-row filter); this
carries ALL of them and picks the smallest, exact-integer, lossless. FOUNDED on nx_nv1_lpc
(Rice bit I/O + best-k) and the proven nx_frame_codec MED bootstrap (X-CDC-FRAME-001).
Bit-exact (lossless); tamper-evident (-7). main() = self-test: round-trip on diverse frames
+ the selector PICKS THE RIGHT PREDICTOR (h-ramp->SUB, v-ramp->UP) + adaptive <= MED ratio.
NOT FLOATING (founded on GREEN nv1_lpc). BACK-FILL: the team RE-AUTHORS this from a DATA spec
via the emitter-of-emitters (X-AUT-006c/e/f, spec 2026-06-13-codec-dual-spec-and-kat.md sec 1-6);
NOT credited as team self-authoring (meter-integrity). Header: u32 w|u32 h|u8 pid|u8 k|Rice.
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_nv1_lpc.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
| 16 | const K_MAGIC_2463534242: i64 = 2463534242 |
| 17 | const K_MAGIC_1103515245: i64 = 1103515245 |
| 18 | const K_MAGIC_12345: i64 = 12345 |
| 19 | const K_MAGIC_2147483647: i64 = 2147483647 |
| 20 | const K_MAGIC_65536: i64 = 65536 |
functions
| 22 | func fa_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 23 | func fa_putn(v: i64) -> i64 |
| 29 | func fa_predname(pid: i64) -> *u8 called by 1: fa_roundtrip |
| 37 | func fa_med(a: i64, b: i64, c: i64) -> i64 called by 1: fa_pred |
| 44 | func fa_paeth(a: i64, b: i64, c: i64) -> i64 called by 1: fa_pred |
| 55 | func fa_pred(buf: *u8, w: i64, x: i64, y: i64, pid: i64) -> i64 |
| 72 | func fa_residuals(buf: *u8, w: i64, h: i64, pid: i64, u: *i64) -> i64 |
| 94 | func fa_encode(buf: *u8, w: i64, h: i64, out: *u8, outcap: i64, pidout: *i64) -> i64 |
| 128 | func fa_decode(pl: *u8, plen: i64, out: *u8, outcap: i64) -> i64 |
| 163 | func fa_med_size(buf: *u8, w: i64, h: i64) -> i64 |
| 173 | func fa_gen_hgrad(buf: *u8, w: i64, h: i64) -> i64 called by 1: main |
| 178 | func fa_gen_vgrad(buf: *u8, w: i64, h: i64) -> i64 called by 1: main |
| 183 | func fa_gen_checker(buf: *u8, w: i64, h: i64) -> i64 called by 1: main |
| 188 | func fa_gen_noise(buf: *u8, w: i64, h: i64) -> i64 called by 1: main |
| 194 | func fa_roundtrip(name: *u8, buf: *u8, w: i64, h: i64) -> i64 |
| 214 | func main() -> i64 |