code wiki / (root) / nx_galx_upscale.nx

nx_galx_upscale.nx

buildroot/runtime/nx_galx_upscale.nx

5680 B117 linesdepth 8pulls 15 transitivereach 0 importersview sourcekind tooltopic galx
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itoa_lib.nx nx_png_decoder.nx nx_png.nx nx_img_scale.nx nx_galx_upscale.nx

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

main up_p sys_write sys_exit up_mkdir up_atoi up_one sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_png_decode sys_mmap ↻ _png_check_signature _png_read_u32_be nx_crc32 nx_crc32_update nx_crc32_init nx_crc32_table_at _png_n_channels _png_bytes_per_pixel _png_n_channels ↻ _png_a7_expected _png_a7_col0 _png_a7_coli _png_a7_row0 _png_a7_rowi nx_zlib_inflate sys_mmap ↻ nx_deflate_inflate sys_mmap ↻ nx_bitstream_alloc sys_mmap ↻ _deflate_inflate_block nx_bitstream_read_lsb nx_bitstream_byte_align nx_bitstream_read_byte_ali

structs

none

consts

21const UP_MAGIC_65536: i64 = 65536
23const UP_DIR: *u8 = "knowledge/store/galx-upscale" as *u8
24const UP_MAXDIM: i64 = 4096 // hard cap on each output dimension (memory bound, rule 11/21)

functions

26func 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 }
called by 1: main calls 1: sys_write
31func up_n(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
32func 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
33func up_mkdir(path: *u8) -> i64 { return __syscall(258, 0-100, path as i64, 0x1ed, 0, 0, 0) }
called by 1: main
37func up_one(src: *u8, out: *u8, scale: i64) -> i64
99func main(argc: i64, argv: *i64) -> i64