nx_vp8.nx
buildroot/runtime/nx_vp8.nx
about
nx_vp8.nx -- VP8 lossy: the boolean entropy decoder and keyframe header.
The last missing piece of WebP. VP8's entropy coder is a BINARY arithmetic
coder -- one bit per call against an 8-bit probability -- which is a
different animal from VP8L's canonical Huffman and from AV1's multi-symbol
CDF coder. All three now exist in this tree and none substitutes for
another.
PROBABILITY 128 IS A RAW BIT. With prob 128 the split lands exactly at the
midpoint, so the coder degenerates to reading the bitstream MSB-first. That
is not a curiosity -- it is the property that makes the renormalisation
loop testable without an encoder: decode a run of prob-128 literals and
they must reproduce the raw bits exactly. Any error in the shift, the carry
or the byte refill breaks it immediately.
THE RANGE INVARIANT. After every decode the range must satisfy
128 <= range <= 255. A renormalisation loop that under- or over-shifts
still returns plausible bits for a while and then diverges; asserting the
invariant after every call catches it at the first bit rather than the
thousandth.
THE START CODE IS NOT OPTIONAL. A keyframe carries 9d 01 2a after the
3-byte tag. Skipping the check means a corrupt or non-VP8 payload is
decoded as if it were a frame, with dimensions read out of arbitrary bytes.
genealogy_id: vp8_rfc6386
lineage_id: nx_vp8_v1
license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: nx_vp8_gate.nxnx_vp8_kf.nxnx_vp8_kf_gate.nxnx_vp8probe.nx
structs
| 45 | struct NxVp8Bool |
consts
| 31 | const NX_MAGIC_16383: i64 = 16383 |
| 33 | const NX_VP8_BD_BYTES: i64 = 48 |
| 35 | const NX_VP8_FLD_KEYFRAME: i64 = 0 |
| 36 | const NX_VP8_FLD_VERSION: i64 = 1 |
| 37 | const NX_VP8_FLD_SHOW: i64 = 2 |
| 38 | const NX_VP8_FLD_PART1LEN: i64 = 3 |
| 39 | const NX_VP8_FLD_WIDTH: i64 = 4 |
| 40 | const NX_VP8_FLD_HEIGHT: i64 = 5 |
| 41 | const NX_VP8_FLD_HSCALE: i64 = 6 |
| 42 | const NX_VP8_FLD_VSCALE: i64 = 7 |
| 43 | const NX_VP8_FLD_HDRLEN: i64 = 8 |
functions
| 55 | func nx_vp8_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 } |
| 59 | func nx_vp8_bool_init(d: *u8, n: i64, off: i64) -> *NxVp8Bool |
| 72 | func nx_vp8_bool_get(b: *NxVp8Bool, prob: i64) -> i64 called by 8: nx_vp8_bool_bitmainvp8kf_tree_readvp8kf_read_ymodevp8kf_read_uvmodevp8kf_read_segid+2 calls 1: nx_vp8_at |
| 111 | func nx_vp8_bool_bit(b: *NxVp8Bool) -> i64 |
| 116 | func nx_vp8_bool_literal(b: *NxVp8Bool, n: i64) -> i64 |
| 129 | func nx_vp8_bool_signed(b: *NxVp8Bool, n: i64) -> i64 |
| 136 | func nx_vp8_bool_maybe_signed(b: *NxVp8Bool, n: i64) -> i64 |
| 146 | func nx_vp8_frame_parse(d: *u8, n: i64, fld: *i64) -> i64 |
| 189 | func nx_vp8_frame_write(o: *u8, cap: i64, width: i64, height: i64, called by 1: main |