nx_galx_upscale.nx
buildroot/runtime/nx_galx_upscale.nx
about
nx_galx_upscale.nx -- SOVEREIGN gallery image UPSCALER. Composes the existing sovereign codecs
(nx_png_decoder = RFC2083 decode, nx_png = RGB8 encode) with the existing sovereign resampler
(nx_img_scale.nx = bilinear Q16.16, OpenCV INTER_LINEAR convention) -- NO ffmpeg / PIL / libpng,
NO re-inlined resize math (reuses nx_img_scale_bilinear per the consolidation discipline).
Enlarges a stored gen/image by an integer factor (2x..4x), capped to UP_MAXDIM, and re-encodes a
larger PNG. Output is CID-addressed under knowledge/store/galx-upscale/<CID>_<n>x.png so the daemon
serves it at GET /upscale/<CID>?s=<n>. (True AI super-resolution is the GPU/diffusion path -- the
sd-server migration; this is the sovereign no-GPU 2x/4x stopgap that needs no GPU worker.)
MEMORY DISCIPLINE (same as nx_galx_thumb): nx_png_decode mmaps a 64MiB IDAT buffer per call and the
toolchain has no sys_munmap, so the gallery FORKS one child per /upscale request -- the kernel reclaims
every mmap on child exit, bounding RSS regardless of how many upscales are requested.
mode: nx_galx_upscale one <src.png> <out.png> [scale] -- upscale a single image (the gate path)
license_tier: ORIGINAL
dependencies 5 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_png_decoder.nxnx_png.nxnx_img_scale.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
| 21 | const UP_MAGIC_65536: i64 = 65536 |
| 23 | const UP_DIR: *u8 = "knowledge/store/galx-upscale" as *u8 |
| 24 | const UP_MAXDIM: i64 = 4096 // hard cap on each output dimension (memory bound, rule 11/21) |
functions
| 26 | func up_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 31 | func up_n(v: i64) -> i64 { nxi_out(v); return 0 } |
| 32 | func up_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ if s[i]>=(48 as u8){ if s[i]<=(57 as u8){ v=v*10+((s[i]-(48 as u8)) as i64) } } i=i+1 } return v } called by 1: main |
| 33 | func up_mkdir(path: *u8) -> i64 { return __syscall(258, 0-100, path as i64, 0x1ed, 0, 0, 0) } called by 1: main |
| 37 | func up_one(src: *u8, out: *u8, scale: i64) -> i64 |
| 99 | func main(argc: i64, argv: *i64) -> i64 |