code wiki / (root) / nx_vp8.nx

nx_vp8.nx

buildroot/runtime/nx_vp8.nx

7084 B218 linesdepth 2pulls 2 transitivereach 43 importersview sourcekind librarytopic vp8
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_vp8.nx nx_vp8_gate.nx nx_vp8_kf.nx nx_vp8_kf_gate.nx nx_vp8probe.nx

imports: nx_syscalls.nx

imported by: nx_vp8_gate.nxnx_vp8_kf.nxnx_vp8_kf_gate.nxnx_vp8probe.nx

structs

45struct NxVp8Bool

consts

31const NX_MAGIC_16383: i64 = 16383
33const NX_VP8_BD_BYTES: i64 = 48
35const NX_VP8_FLD_KEYFRAME: i64 = 0
36const NX_VP8_FLD_VERSION: i64 = 1
37const NX_VP8_FLD_SHOW: i64 = 2
38const NX_VP8_FLD_PART1LEN: i64 = 3
39const NX_VP8_FLD_WIDTH: i64 = 4
40const NX_VP8_FLD_HEIGHT: i64 = 5
41const NX_VP8_FLD_HSCALE: i64 = 6
42const NX_VP8_FLD_VSCALE: i64 = 7
43const NX_VP8_FLD_HDRLEN: i64 = 8

functions

55func nx_vp8_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 }
59func nx_vp8_bool_init(d: *u8, n: i64, off: i64) -> *NxVp8Bool
72func nx_vp8_bool_get(b: *NxVp8Bool, prob: i64) -> i64
111func nx_vp8_bool_bit(b: *NxVp8Bool) -> i64
116func nx_vp8_bool_literal(b: *NxVp8Bool, n: i64) -> i64
129func nx_vp8_bool_signed(b: *NxVp8Bool, n: i64) -> i64
136func nx_vp8_bool_maybe_signed(b: *NxVp8Bool, n: i64) -> i64
146func nx_vp8_frame_parse(d: *u8, n: i64, fld: *i64) -> i64
called by 2: mainnx_vp8_kf_decode calls 1: nx_vp8_at
189func nx_vp8_frame_write(o: *u8, cap: i64, width: i64, height: i64,
called by 1: main