code wiki / _hdl_build / nx_pattern_emit11.nx
nx_pattern_emit11.nx
buildroot/runtime/_hdl_build/nx_pattern_emit11.nx
about
nx_pattern_emit11.nx -- PATTERN EMITTER: PREDICTOR_CODER (shape 16 -- grown from the NV1
FLAC-class LPC rung, the media-codec core NO covered pattern could author; that build named
exactly the three concepts this emitter closes):
predict next sample = FIXED linear comb of the last o samples (binomial coeffs, o = 0..3:
0 | p1 | 2p1-p2 | 3p1-3p2+p3), exact integer math
zigzag signed residual -> unsigned (r>=0 -> 2r, r<0 -> -2r-1), exactly invertible
invert restore(residuals(x)) == x BIT-EXACT (the lossless law) and an out-of-range
reconstruction is REFUSED at decode (-2) -- the NV1 tamper-evidence doctrine
Authored fns: <name>_pred(p1,p2,p3); <name>_residuals(x,n,u) -> n-o residuals (-1 if n<=o);
<name>_restore(u,m,w,x) -> sample count or -2 out-of-range (bound vmax BAKED, rule 11).
EMIT-TIME RAIL (the PID-emitter discipline): the emitter RUNS the full round-trip on a
synthetic vector with its own math BEFORE writing any file -- a spec whose round-trip is not
bit-exact is REFUSED. Param rails: order outside 0..3 or vmax outside 16..65535 -> REFUSED.
Test KATs (residual values, tamper push, n<=o refusal) computed BY the emitter at emit time.
LAWS: struct-free, integer-only, flat ifs, no &&/||, <=6 args per func. license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_pattern_emit11_demo.nxnx_warden_build.nx
structs
| none |
consts
| 17 | const K_MAGIC_65535: i64 = 65535 |
functions
| 19 | func p11_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 6: p11_litp11_emit_pred_bodyp11_emit_pred_argsp11_emit_modulep11_emit_testmain calls 1: sys_write |
| 20 | func p11_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; 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{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 22 | func p11_lit(fd: i64, v: i64) -> i64 |
| 29 | func p11_pred(o: i64, p1: i64, p2: i64, p3: i64) -> i64 |
| 36 | func p11_residuals(o: i64, x: *i64, n: i64, u: *i64) -> i64 |
| 55 | func p11_restore(o: i64, vmax: i64, u: *i64, m: i64, w: *i64, x: *i64) -> i64 |
| 85 | func p11_vec(vmax: i64, x: *i64) -> i64 |
| 95 | func p11_emit_pred_body(fd: i64, o: i64) -> i64 |
| 104 | func p11_emit_pred_args(fd: i64, o: i64) -> i64 |
| 112 | func p11_emit_module(fd: i64, name: *u8, o: i64, vmax: i64) -> i64 |
| 144 | func p11_emit_test(fd: i64, name: *u8, o: i64, vmax: i64, u: *i64) -> i64 |
| 178 | func pe11_author_predictor_coder(name: *u8, modpath: *u8, testpath: *u8, o: i64, vmax: i64) -> i64 |