nx_webp_alpha.nx
buildroot/runtime/nx_webp_alpha.nx
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
imports: nx_syscalls.nx
imported by: nx_webp_alpha_gate.nx
structs
| none |
consts
| 28 | const NX_MAGIC_16777216: i64 = 16777216 |
| 30 | const NX_VP8X_FLAG_ICC: i64 = 0x20 |
| 31 | const NX_VP8X_FLAG_ALPHA: i64 = 0x10 |
| 32 | const NX_VP8X_FLAG_EXIF: i64 = 0x08 |
| 33 | const NX_VP8X_FLAG_XMP: i64 = 0x04 |
| 34 | const NX_VP8X_FLAG_ANIM: i64 = 0x02 |
| 36 | const NX_ALPH_FILTER_NONE: i64 = 0 |
| 37 | const NX_ALPH_FILTER_HORIZ: i64 = 1 |
| 38 | const NX_ALPH_FILTER_VERT: i64 = 2 |
| 39 | const NX_ALPH_FILTER_GRAD: i64 = 3 |
| 41 | const NX_VP8X_FLD_FLAGS: i64 = 0 |
| 42 | const NX_VP8X_FLD_WIDTH: i64 = 1 |
| 43 | const NX_VP8X_FLD_HEIGHT: i64 = 2 |
| 45 | const NX_ALPH_FLD_PREPROC: i64 = 0 |
| 46 | const NX_ALPH_FLD_FILTER: i64 = 1 |
| 47 | const NX_ALPH_FLD_COMPRESS: i64 = 2 |
functions
| 49 | func nx_wa_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 } |
| 51 | func nx_wa_le24(d: *u8, off: i64) -> i64 |
| 55 | func nx_wa_le24_w(o: *u8, off: i64, v: i64) -> i64 called by 1: nx_vp8x_write |
| 62 | func nx_wa_clamp255(v: i64) -> i64 |
| 73 | func nx_vp8x_write(o: *u8, cap: i64, flags: i64, width: i64, height: i64) -> i64 |
| 88 | func nx_vp8x_parse(d: *u8, n: i64, off: i64, fld: *i64) -> i64 |
| 101 | func nx_vp8x_has_alpha(flags: i64) -> i64 called by 1: main |
| 111 | func nx_alph_parse_header(b: i64, fld: *i64) -> i64 called by 1: main |
| 119 | func nx_alph_build_header(preproc: i64, filter: i64, compress: i64) -> i64 called by 1: main |
| 131 | func nx_alph_unfilter(data: *u8, out: *u8, w: i64, h: i64, filter: i64) -> i64 |
| 185 | func nx_alph_filter(src: *u8, out: *u8, w: i64, h: i64, filter: i64) -> i64 |