nx_pwg_rle.nx
buildroot/runtime/nx_pwg_rle.nx
about
nx_pwg_rle.nx -- the PackBits-like run-length codec shared by PWG-Raster AND URF (Apple Raster).
This is the pixel-data encoding of "driverless" printing -- the bytes a real IPP printer rasterizes.
Verified against the AUTHORITATIVE CUPS/PWG raster spec (sovereign-fetched, cited:
knowledge/fetched/cups_raster_spec.raw, lines 483-501):
- Each LINE begins with a 1-byte line-repeat count = (repeats - 1): 0x00 = appears once, 0xFF = 256x.
- Within a line, whole pixels ("colors") are PackBits-encoded:
control 0x00..0x7F -> REPEATED run: (ctrl+1) copies of the ONE following pixel (count 1..128)
control 0x80..0xFF -> LITERAL run: (257-ctrl) following pixels verbatim (count 2..128)
- one pixel = bpp bytes (sgray_8 -> 1 byte; sRGB -> 3 bytes).
Cross-checked on the spec's worked example line
00 FE FFFF00 0000FF FFFF00 02 FFFFFF 00 00FF00 00 FFFFFF
= yellow,blue,yellow, white,white,white, green, white (proves the decoder matches the spec).
NEVER-BRICK (#26): pure byte arithmetic; NO syscalls, no hardware access. Sovereign (no imports).
no_silent_failure: the decoder bounds-checks every read/write and returns -1 on truncation/overrun.
genealogy_id: project-printer-management-ipp-sclass-2026-06-20 ; license_tier: ORIGINAL
dependencies 0 imports · 9 importers
imports: none
imported by: nx_doc_print.nxnx_doc_to_urf.nxnx_doc_to_urf_test.nxnx_img_print.nxnx_ipp_submit_test.nxnx_toner_track.nxnx_urf.nxnx_urf_make.nxnx_urf_test.nx
structs
| none |
consts
| none |
functions
| 20 | func nx_rle_px_eq(line: *u8, i: i64, j: i64, bpp: i64) -> i64 called by 1: nx_rle_encode_line |
| 31 | func nx_rle_line_eq(bitmap: *u8, width: i64, bpp: i64, ya: i64, yb: i64) -> i64 called by 1: nx_rle_encode_page |
| 45 | func nx_rle_encode_line(line: *u8, width: i64, bpp: i64, out: *u8, off0: i64) -> i64 |
| 107 | func nx_rle_encode_page(bitmap: *u8, width: i64, height: i64, bpp: i64, out: *u8) -> i64 |
| 134 | func nx_rle_decode(src: *u8, n: i64, width: i64, height: i64, bpp: i64, out: *u8, out_cap: i64) -> i64 |