code wiki / _hdl_build / nx_reader_tile.nx

nx_reader_tile.nx

buildroot/runtime/_hdl_build/nx_reader_tile.nx

8890 B158 linesdepth 10pulls 55 transitivereach 2 importersview sourcekind librarytopic reader
docsdependenciesstructsconstsfunctions

about

nx_reader_tile.nx -- SOVEREIGN tiled-pyramid emitter (reader census gap: DZI/IIIF-class smooth mobile zoom of huge manga/document scans). Given one page image (JPEG or PNG), emits a Deep-Zoom-style pyramid: for each level 0..maxlevel (level maxlevel = full res, each lower level halves) it box-downscales the page and cuts it into fixed T x T JPEG tiles. A mobile viewer then fetches ONLY the tiles visible at the current zoom = smooth zoom without downloading the whole 8000px scan. Composes PROVEN sovereign organs (DRY, zero 3rd-party): universal decode nx_img_bytes_to_rgb (JPEG+PNG) -> nx_img_scale_bilinear -> jcw_write_color. KEY: each level's dims are rounded to a multiple of 8 and T is a multiple of 8, so EVERY tile (incl right/bottom edges) is a multiple of 8 -> the baseline JPEG encoder handles all tiles. This is a LIB (no main) so nx_reader_tile_gate exercises rt_emit directly (nx_mgmt_upload lib+gate split). Fork-per-page in the daemon -> the per-tile mmaps die with the child. license_tier: ORIGINAL

dependencies 9 imports · 2 importers

nx_syscalls.nx nx_img_bytes_to_rgb.nx nx_img_dims.nx nx_img_scale.nx nx_jpeg_color_write.nx nx_quant_table.nx nx_jpeg_huff_enc.nx nx_zigzag.nx nx_dct8.nx nx_reader_tile.nx nx_reader_page_prep.nx nx_reader_tile_gate.nx

imports: nx_syscalls.nxnx_img_bytes_to_rgb.nxnx_img_dims.nxnx_img_scale.nxnx_jpeg_color_write.nxnx_quant_table.nxnx_jpeg_huff_enc.nxnx_zigzag.nxnx_dct8.nx

imported by: nx_reader_page_prep.nxnx_reader_tile_gate.nx

structs

none

consts

20const K_MAGIC_1200: i64 = 1200
21const K_MAGIC_1600: i64 = 1600
22const K_MAGIC_1024: i64 = 1024
23const K_MAGIC_8192: i64 = 8192

functions

25func rt_ap_str(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[o + i] = s[i]; i = i + 1 } return o + i }
26func rt_ap_num(dst: *u8, o: i64, v: i64) -> i64
called by 2: rt_raw_manifestrt_emit calls 1: sys_mmap
34func rt_mkdir(path: *u8) -> i64 { __syscall(258, 0 - 100, path as i64, 0x1ed, 0, 0, 0); return 0 }
35func rt_writefile(path: *u8, buf: *u8, n: i64) -> i64
45func rt_raw_manifest(data: *u8, n: i64, outdir: *u8) -> i64
61func rt_emit(src: *u8, outdir: *u8, tilesize: i64) -> i64