code wiki / (root) / nx_galx_thumb.nx

nx_galx_thumb.nx

buildroot/runtime/nx_galx_thumb.nx

9745 B202 linesdepth 8pulls 13 transitivereach 0 importersview sourcekind tooltopic galx
docsdependenciesstructsconstsfunctions

about

nx_galx_thumb.nx -- SOVEREIGN gallery THUMBNAIL generator. Composes the existing sovereign codecs (nx_png_decoder = RFC2083 decode, nx_png = RGB8 encode) with an integer box-average downscale -- NO ffmpeg / PIL / libpng. Produces a small thumbnail PNG (max dimension TH_MAX px) so the gallery grid loads ~KB thumbs instead of ~MB full-res images. Output is CID-addressed under knowledge/store/galx-thumb/ so the daemon serves it at GET /thumb/<CID>. MEMORY DISCIPLINE: nx_png_decode mmaps a 64MiB IDAT buffer per call and the toolchain has no sys_munmap, so a single process MUST NOT decode many images. The batch mode therefore FORKS one child per image -- the kernel reclaims every mmap on child exit, bounding RSS regardless of corpus size (same sovereign pattern as nx_galx_fill / nx_torrent_get). modes: nx_galx_thumb one <src.png> <out.png> -- thumbnail a single image (the gate path) nx_galx_thumb batch <start> <count> -- walk knowledge/status/galx_cid_paths.tsv [start,start+count), thumbnail each to galx-thumb/<CID>.png, idempotent (skip if present) license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_png_decoder.nx nx_png.nx nx_galx_thumb.nx

imports: nx_syscalls.nxnx_png_decoder.nxnx_png.nx

imported by: nobody (leaf or entry point)

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

main th_p sys_write sys_exit th_mkdir th_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 _deflate_build_static_litl

structs

none

consts

20const TH_MAGIC_65536: i64 = 65536
21const TH_MAGIC_1000000000: i64 = 1000000000
22const TH_MAGIC_1024: i64 = 1024
24const TH_MAX: i64 = 256 // max thumbnail dimension in px (data-driven cap, rule 11)
25const TH_DIR: *u8 = "knowledge/store/galx-thumb" as *u8

functions

27func th_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
28func th_n(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; 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{b[i]=t[k-1-i];i=i+1}; sys_write(1,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
29func th_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
30func th_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+i }
called by 1: main
32func th_mkdir(path: *u8) -> i64 { return __syscall(258, 0-100, path as i64, 0x1ed, 0, 0, 0) }
called by 1: main
36func th_one(src: *u8, out: *u8) -> i64
112func th_exists(path: *u8) -> i64
called by 1: main calls 2: sys_openat_rdsys_close
119func main(argc: i64, argv: *i64) -> i64