code wiki / (root) / nx_jpeg_ascii.nx

nx_jpeg_ascii.nx

buildroot/runtime/nx_jpeg_ascii.nx

14934 B357 linesdepth 8pulls 20 transitivereach 71 importersview sourcekind librarytopic jpeg
docsdependenciesstructsconstsfunctions

about

nx_jpeg_ascii.nx -- bridge: baseline-JPEG bytes -> luminance ASCII. Decodes a baseline JPEG, takes the Y (luma) plane, box-downscales it to (target_w x target_h), and writes it into a caller Framebuffer as grayscale RGBA so nx_paint_fb_ascii_dump / _write can render the image in a terminal. This is the last brick of the image pipeline: real bytes off the wire -> visible pixels, every layer NishiLang. Why luma-only: ASCII art needs luminance, and the JPEG Y component IS luminance at full resolution. We deliberately skip chroma upsample + YCbCr->RGB -- fewer bytes between the silicon and the pixel, exactly the bits-up discipline. A future colour path (ANSI true-colour cells) composes the existing nx_jpeg_upsample + nx_jpeg_ycbcr bricks on top of this same decode. hardens: CVE-2014-9707 (libjpeg-turbo MCU overflow on malformed DCT) -> dimensions bounded by NX_JPEG_ASCII_MAX_DIM with a sealed OVERSIZE verdict BEFORE any plane allocation. CVE-2018-13785 (libpng length-add integer overflow) -> i64 dims + explicit bound check before alloc; never trust attacker-supplied dimensions to fit a budget. NISHI_BROWSER_KNOWN_LESSONS.md §4 (image decoders) + §12 (bounded loops): every loop below is bounded by image or target dimensions; no open-ended scan. genealogy_id: nishi_browser_image_pipeline_phase_5 lineage_id: nishi_jpeg_ascii_v1 license_tier: ORIGINAL

dependencies 9 imports · 29 importers

nx_syscalls.nx nx_jpeg_marker.nx nx_jpeg_sof.nx nx_jpeg_decode.nx nx_jpeg_progressive.nx nx_jpeg_upsample.nx nx_jpeg_ycbcr.nx nx_paint_solid_rect.nx nx_paint_fb_ascii_dump.nx nx_jpeg_ascii.nx nx_browser_image_demo_test.nx nx_face_probe.nx nx_face_project_gate.nx nx_face_vs_target.nx nx_faceanat_gate.nx nx_faceanat_stereo_gate.nx nx_faceanat_texbake_gate.nx nx_faceprofile_gate.nx nx_grade.nx nx_gsplat_elara_gate.nx

diagram shows first 10 each side; +0 more imports, +19 more importers in the complete lists below.

imports: nx_syscalls.nxnx_jpeg_marker.nxnx_jpeg_sof.nxnx_jpeg_decode.nxnx_jpeg_progressive.nxnx_jpeg_upsample.nxnx_jpeg_ycbcr.nxnx_paint_solid_rect.nxnx_paint_fb_ascii_dump.nx

imported by: nx_browser_image_demo_test.nxnx_face_probe.nxnx_face_project_gate.nxnx_face_vs_target.nxnx_faceanat_gate.nxnx_faceanat_stereo_gate.nxnx_faceanat_texbake_gate.nxnx_faceprofile_gate.nxnx_grade.nxnx_gsplat_elara_gate.nxnx_gsplat_face_gate.nxnx_gsplat_photofit_gate.nxnx_gsplat_showcase.nxnx_image_gray.nxnx_img_bytes_to_rgb.nxnx_jpeg_ascii_test.nxnx_jpeg_pgm_dump_test.nxnx_jpeg_ppm_dump_test.nxnx_jpeg_probe.nxnx_jpeg_rst_gate.nxnx_jpegprobe.nxnx_media_convert.nxnx_media_index.nxnx_natstat_corpus.nxnx_pose_preprocess.nxnx_skinfam_train_gate.nxnx_skintex_train_gate.nxnx_swgpu_showcase.nxnx_vitpose_prep.nx

structs

none

consts

43const NX_JPEG_ASCII_OK: i64 = 0
44const NX_JPEG_ASCII_OVERSIZE: i64 = 100
45const NX_JPEG_ASCII_NO_SOF: i64 = 101
46const NX_JPEG_ASCII_DECODE_FAIL: i64 = 102
47const NX_JPEG_ASCII_BAD_TARGET: i64 = 103
51const NX_JPEG_ASCII_MAX_DIM: i64 = 8192

functions

57func _jpeg_ascii_probe_sof(jpeg: *u8, jpeg_len: i64, ctx: *NxJpegDecCtx) -> i64
91func nx_jpeg_decode_luma(jpeg: *u8, jpeg_len: i64,
155func nx_jpeg_to_ascii_fb(jpeg: *u8, jpeg_len: i64,
217func nx_jpeg_render_ascii(jpeg: *u8, jpeg_len: i64,
231func nx_jpeg_render_ascii_fit(jpeg: *u8, jpeg_len: i64, max_cols: i64) -> i64
255func nx_jpeg_decode_rgb(jpeg: *u8, jpeg_len: i64,