nx_img_scale_emit.nx source
↩ module page · 36 lines · 1256 B
1// nx_img_scale_emit.nx -- measured-exceed harness, step 1 (emit).
2//
3// Writes a deterministic 64x64 gray gradient to /tmp/sv_in.raw, then my
4// sovereign bilinear 64x64 -> 100x100 upscale to /tmp/sv_mine.raw. The shell
5// then runs ffmpeg swscale bilinear on /tmp/sv_in.raw to produce the reference
6// /tmp/sv_ref.raw, and nx_img_scale_diff measures the deviation. ffmpeg is a
7// MEASURING STICK in the harness only -- never in the product.
8// license_tier: ORIGINAL
9
10import "nx_syscalls.nx"
11import "nx_img_scale.nx"
12import "nx_seg_store.nx"
13
14func main() -> i64 {
15 let sw: i64 = 64
16 let sh: i64 = 64
17 let src: *u8 = sys_mmap(sw * sh + 16)
18 var y: i64 = 0
19 while y < sh {
20 var x: i64 = 0
21 while x < sw {
22 let v: i64 = (x * 255 / 63 + y * 255 / 63) / 2 // smooth diagonal ramp 0..255
23 src[y * sw + x] = v as u8
24 x = x + 1
25 }
26 y = y + 1
27 }
28 if ss_writefile("/tmp/sv_in.raw" as *u8, src, sw * sh) != 0 { return 1 }
29
30 let dw: i64 = 100
31 let dh: i64 = 100
32 let dst: *u8 = sys_mmap(dw * dh + 16)
33 if nx_img_scale_bilinear(src, sw, sh, 1, dst, dw, dh) != 0 { return 2 }
34 if ss_writefile("/tmp/sv_mine.raw" as *u8, dst, dw * dh) != 0 { return 3 }
35 return 0
36}