code wiki / _hdl_build / nx_frame_codec.nx

nx_frame_codec.nx

buildroot/runtime/_hdl_build/nx_frame_codec.nx

9715 B215 linesdepth 4pulls 5 transitivereach 8 importersview sourcekind tooltopic frame
docsdependenciesstructsconstsfunctions

about

nx_frame_codec.nx -- TUTOR-AUTHORED SCAFFOLD (Claude), NOT team-emitter output. 2-D LOSSLESS image/video-FRAME codec: JPEG-LS/FFV1-class MED (median) predictor over causal neighbors + zigzag + Rice residuals. FOUNDED ON nx_nv1_lpc: it REUSES that organ's proven Rice bit I/O (nv1l_rice_put/get), best-k (nv1l_best_k) and the predict->zigzag->Rice machinery, lifted from 1-D audio samples to 2-D pixels. Bit-exact (lossless): decode(encode(f)) == f. Tamper-evident: an out-of-range reconstruction returns -7 (the nv1_lpc doctrine). This is the lossless-VIDEO fidelity anchor (the bird's video pixel-exact); JPEG/lossy demotes to a measured fallback tier. main() is the unforgeable self-test: round-trip bit-exact on gradient/checker/edge/extremes/noise + compression-actual (gradient must shrink) + tamper. NOT FLOATING (operator law 2026-06-13 "don't build things that hang in the air"): it sits on nx_nv1_lpc (a GREEN organ). 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) -- this scaffold is the sanctioned one-time bootstrap, NOT credited as team self-authoring (meter-integrity). v1 = single 8-bit plane, single MED predictor; the adaptive predictor library + NFC1 container are the named follow-ons. No verbatim escape yet (buffers sized 2n so noise cannot overrun). license_tier: ORIGINAL

dependencies 2 imports · 6 importers

nx_nv1_lpc.nx nx_itoa_lib.nx nx_frame_codec.nx _codec_bench.nx _codec_bench2.nx _codec_bench_med.nx _codec_real_med.nx _fc_rtgate.nx _fc_rtgate_sa.nx

imports: nx_nv1_lpc.nxnx_itoa_lib.nx

imported by: _codec_bench.nx_codec_bench2.nx_codec_bench_med.nx_codec_real_med.nx_fc_rtgate.nx_fc_rtgate_sa.nx

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

main fc_puts fc_gen_gradient fc_roundtrip fc_encode fc_pred fc_med nv1l_best_k nv1l_cost_bits nv1_wr_u32 nv1l_rice_put nv1l_bit_put fc_puts ↻ fc_putn nxi_out nxi_fd sys_mmap ccz_cat_num sys_write sys_munmap fc_decode nv1_rd_u32 nv1l_rice_get nv1l_bit_get fc_pred ↻ fc_gen_checker fc_gen_edge fc_gen_extremes fc_gen_noise fc_encode ↻ fc_putn ↻ fc_decode ↻

structs

none

consts

22const K_MAGIC_2463534242: i64 = 2463534242
23const K_MAGIC_1103515245: i64 = 1103515245
24const K_MAGIC_12345: i64 = 12345
25const K_MAGIC_2147483647: i64 = 2147483647
26const K_MAGIC_65536: i64 = 65536

functions

28func fc_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 2: fc_roundtripmain
33func fc_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 2: fc_roundtripmain calls 1: nxi_out
36func fc_med(a: i64, b: i64, c: i64) -> i64
called by 2: apredfc_pred
45func fc_pred(buf: *u8, w: i64, x: i64, y: i64) -> i64
58func fc_encode(buf: *u8, w: i64, h: i64, out: *u8, outcap: i64) -> i64
96func fc_decode(pl: *u8, plen: i64, out: *u8, outcap: i64) -> i64
129func fc_gen_gradient(buf: *u8, w: i64, h: i64) -> i64
called by 4: mainmainmainmain
133func fc_gen_checker(buf: *u8, w: i64, h: i64) -> i64
called by 4: mainmainmainmain
138func fc_gen_edge(buf: *u8, w: i64, h: i64) -> i64
called by 4: mainmainmainmain
143func fc_gen_extremes(buf: *u8, w: i64, h: i64) -> i64
called by 4: mainmainmainmain
147func fc_gen_noise(buf: *u8, w: i64, h: i64) -> i64
called by 4: mainmainmainmain
153func fc_roundtrip(name: *u8, buf: *u8, w: i64, h: i64) -> i64
169func main() -> i64