code wiki / (root) / nx_galx_thumb.nx

nx_galx_thumb.nx

buildroot/runtime/nx_galx_thumb.nx

10794 B212 linesdepth 10pulls 47 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 4 imports · 0 importers

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

imports: nx_syscalls.nxnx_png_decoder.nxnx_png.nxnx_img_bytes_to_rgb.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 nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close th_decode_any nx_img_bytes_to_rgb sys_mmap ↻ nx_jpeg_decode_rgb sys_mmap ↻ nx_jpeg_dec_ctx_init sys_mmap ↻ nx_jpeg_ctx_tables_reset _jpeg_ascii_probe_sof sys_mmap ↻ nx_jpeg_seg_init nx_jpeg_seg_next

structs

none

consts

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

functions

28func 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
29func th_n(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" 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{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
30func 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
31func 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
33func th_mkdir(path: *u8) -> i64 { return __syscall(258, 0-100, path as i64, 0x1ed, 0, 0, 0) }
called by 1: main
42func th_decode_any(raw: *u8, rawlen: i64, out_wh: *i64) -> *u8
called by 1: th_one calls 1: nx_img_bytes_to_rgb
48func th_one(src: *u8, out: *u8) -> i64
122func th_exists(path: *u8) -> i64
called by 1: main calls 2: sys_openat_rdsys_close
129func main(argc: i64, argv: *i64) -> i64