code wiki / (root) / nx_webp_alpha.nx

nx_webp_alpha.nx

buildroot/runtime/nx_webp_alpha.nx

7671 B229 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic webp
docsdependenciesstructsconstsfunctions

about

nx_webp_alpha.nx -- WebP VP8X extended container + ALPH alpha channel. Completes the extended half of WebP. Transparent WebP is everywhere on the real web, and it does NOT live in the VP8/VP8L bitstream: a VP8X file carries the colour planes in one chunk and an entirely separate ALPH chunk holding the alpha plane, filtered independently. Filters are implemented in BOTH directions so the pair proves by exact round-trip rather than against reference images. THE FIRST ROW AND COLUMN PREDICT DIFFERENTLY PER FILTER. Horizontal predicts the first column from ABOVE; vertical predicts the first row from the LEFT. Using the nominal direction at the edges reads outside the plane, and clamping that to zero instead produces an alpha channel that is correct in the interior and wrong along two edges -- which looks like a subtle halo rather than a decode failure. THE GRADIENT PREDICTOR CLAMPS BEFORE ADDING. clamp(left + top - topleft) is clamped to 0..255 and THEN the residual is added modulo 256. Clamping after the addition, or not clamping at all, diverges only where the gradient overshoots -- i.e. at sharp alpha edges, exactly where it is visible. genealogy_id: webp_container_spec_vp8x_alph lineage_id: nx_webp_alpha_v1 license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_webp_alpha.nx nx_webp_alpha_gate.nx

imports: nx_syscalls.nx

imported by: nx_webp_alpha_gate.nx

structs

none

consts

28const NX_MAGIC_16777216: i64 = 16777216
30const NX_VP8X_FLAG_ICC: i64 = 0x20
31const NX_VP8X_FLAG_ALPHA: i64 = 0x10
32const NX_VP8X_FLAG_EXIF: i64 = 0x08
33const NX_VP8X_FLAG_XMP: i64 = 0x04
34const NX_VP8X_FLAG_ANIM: i64 = 0x02
36const NX_ALPH_FILTER_NONE: i64 = 0
37const NX_ALPH_FILTER_HORIZ: i64 = 1
38const NX_ALPH_FILTER_VERT: i64 = 2
39const NX_ALPH_FILTER_GRAD: i64 = 3
41const NX_VP8X_FLD_FLAGS: i64 = 0
42const NX_VP8X_FLD_WIDTH: i64 = 1
43const NX_VP8X_FLD_HEIGHT: i64 = 2
45const NX_ALPH_FLD_PREPROC: i64 = 0
46const NX_ALPH_FLD_FILTER: i64 = 1
47const NX_ALPH_FLD_COMPRESS: i64 = 2

functions

49func nx_wa_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 }
51func nx_wa_le24(d: *u8, off: i64) -> i64
called by 1: nx_vp8x_parse calls 1: nx_wa_at
55func nx_wa_le24_w(o: *u8, off: i64, v: i64) -> i64
called by 1: nx_vp8x_write
62func nx_wa_clamp255(v: i64) -> i64
73func nx_vp8x_write(o: *u8, cap: i64, flags: i64, width: i64, height: i64) -> i64
called by 1: main calls 1: nx_wa_le24_w
88func nx_vp8x_parse(d: *u8, n: i64, off: i64, fld: *i64) -> i64
called by 1: main calls 2: nx_wa_atnx_wa_le24
101func nx_vp8x_has_alpha(flags: i64) -> i64
called by 1: main
111func nx_alph_parse_header(b: i64, fld: *i64) -> i64
called by 1: main
119func nx_alph_build_header(preproc: i64, filter: i64, compress: i64) -> i64
called by 1: main
131func nx_alph_unfilter(data: *u8, out: *u8, w: i64, h: i64, filter: i64) -> i64
called by 1: main calls 2: nx_wa_atnx_wa_clamp255
185func nx_alph_filter(src: *u8, out: *u8, w: i64, h: i64, filter: i64) -> i64
called by 1: main calls 2: nx_wa_atnx_wa_clamp255