code wiki / (root) / nx_codec_caps.nx

nx_codec_caps.nx

buildroot/runtime/nx_codec_caps.nx

10356 B279 linesdepth 2pulls 2 transitivereach 548 importersview sourcekind librarytopic codec
docsdependenciesstructsconstsfunctions

about

nx_codec_caps.nx -- the SINGLE source of truth for what we may advertise. THE DEFECT THIS EXISTS TO KILL. Thirteen call sites across the fetchers and the browser each hand-wrote their own negotiation headers. Two of them lie: nx_http_client sends `Accept: ...,image/avif,image/webp,...` and nx_polite_browser sends `Accept-Encoding: gzip, deflate, br`. We have no AVIF pixel codec and no Brotli decoder. A server that believes either one answers with bytes we cannot read -- and the failure is not an error, it is a blank image or a body of binary noise handed to an HTML parser. The other nine sites have the opposite defect: they send `Accept-Encoding: identity` while nx_gzip_inflate and nx_zlib_inflate are both in-tree and complete. That is a real capability left on the floor on every fetch. A FIX THAT NEEDS MEMORY AT THIRTEEN SITES IS NOT A FIX. So the header is not written anywhere -- it is DERIVED, here, from a registry of what actually decodes. Adding a decoder means flipping one flag in one table and every call site that composes this becomes honest in the same act. Drift is not discouraged, it is unrepresentable. WHAT IS DECLARED HAVE, AND WHY (verified 2026-07-31 by reading the tree, not by recalling it): image/gif -- nx_gif_decode.nx (gif_decode -> w*h grayscale, LZW, + gate) WIRED into nx_img_bytes_to_rgb 2026-08-04; before that the decoder existed but no image path called it. WITHDRAWN 2026-08-04 -- image/webp, and WHY (measured, not recalled): The row above claimed "VP8L lossless + VP8 keyframe". VP8L is real. VP8 KEYFRAME IS NOT: nx_vp8.nx is the boolean entropy decoder + frame-header parser ONLY -- no macroblock modes, no coefficient decode, no dequant/IDCT, no intra prediction, no reconstruction. And webp_decode() walks chunks to the VP8L fourcc and returns 0 for anything else. MEASURED (nx_webpprobe over a 101-file real-web corpus): 25 of 25 WebP were VP8 LOSSY, and webp_decode returned 0 on every one. Zero VP8L in the wild. CONSEQUENCE OF THE LIE: because we advertised image/webp, content-negotiating origins served WebP for URLs ending .jpg (proven: a Wikimedia 250px-*.jpg came back RIFF/WEBP), so the advertisement CREATED the undecodable corpus it claimed to be able to read. Restore have=1 only when a VP8 keyframe decoder reconstructs real pixels.

dependencies 1 imports · 4 importers

nx_syscalls.nx nx_codec_caps.nx nx_codec_caps_gate.nx nx_http_client.nx nx_https_get_spoof.nx nx_polite_browser.nx

imports: nx_syscalls.nx

imported by: nx_codec_caps_gate.nxnx_http_client.nxnx_https_get_spoof.nxnx_polite_browser.nx

structs

none

consts

58const NX_MAGIC_1024: i64 = 1024
62const NX_CC_N_IMAGE: i64 = 8
94const NX_CC_N_ENCODING: i64 = 4

functions

64func cc_image_name(i: i64) -> *u8
76func cc_image_have(i: i64) -> i64
96func cc_encoding_name(i: i64) -> *u8
104func cc_encoding_have(i: i64) -> i64
114func nx_cc_len(s: *u8) -> i64
121func nx_cc_eq(a: *u8, b: *u8) -> i64
135func nx_cc_put(out: *u8, off: i64, s: *u8) -> i64
150func nx_cc_find(hay: *u8, needle: *u8) -> i64
called by 1: main calls 1: nx_cc_len
174func nx_cc_count_tokens(s: *u8) -> i64
called by 1: main calls 1: nx_cc_len
191func nx_codec_caps_have_image(name: *u8) -> i64
200func nx_codec_caps_have_encoding(name: *u8) -> i64
215func nx_codec_caps_accept_image(out: *u8) -> i64
233func nx_codec_caps_accept_encoding(out: *u8) -> i64
253func nx_codec_caps_accept_document(out: *u8) -> i64
266func nx_codec_caps_headers(out: *u8) -> i64