Expand description
rusty_vp9 — an in-house VP9 decoder + encoder, pure Rust with no C/FFI.
VP9 is a large block-based video codec. This crate carries the whole engine:
the MSB bit reader and the boolean arithmetic decoder (BitReader /
BoolDecoder), the uncompressed frame header parser (frame type,
profile, colour config, frame size), the full reconstruction pipeline
(compressed header, intra/inter prediction, transforms, loop filter) behind
the stateful Vp9Decoder, and the encoder behind Vp9Encoder.
The decoder is bit-exact against all 315 official libvpx conformance
vectors; the encoder’s output is validated pixel-exact against libvpx and
ffmpeg. The push/pull API mirrors FFmpeg’s send/receive convention:
Error::Again means “feed more input”, Error::Eof means “drained”.
Modules§
- encode_
prof - The ENCODER’s stage profiler (
VP9_PROF2), re-exported for thevideo-testsanalyzer. The encoder itself stays private; only the read side of the instrument is public. Seeproffor the decoder’s. Primitive profiler for the VP9 encoder hot path (VP9_PROF2=1, orset_enabledfrom an in-process harness). - prof
- Function-level decode profiler (
VP9_DPROF). Public so thevideo-testsanalyzer can drive it in-process; a normal decode never touches it. Function-level stage profiler for the VP9 decoder hot path.
Macros§
- prof2
- Time an expression under
stage(no-op unlessVP9_PROF2).
Structs§
- BitReader
- MSB-first bit reader for the uncompressed header.
- Bool
Decoder - VP9 boolean arithmetic decoder (ISO/VP9 spec §9.2), structured as libvpx
vpx_reader: a 64-bit left-justifiedvaluewindow with a bulk byte refill, so renormalization is a single shift + acountdecrement instead of a per-bit loop. Bit-identical output to the spec; just much faster bookkeeping. - Decoded
Frame - One decoded picture, cropped to its visible size.
- Encoded
Packet - One coded VP9 packet out of the encoder.
datais a raw coded frame (or a superframe when a hidden ALT-REF rides with the next shown frame) — exactly the payload an IVF/WebM muxer stores per packet. Packets are emitted in coded order;ptsis currently alwaysNone(callers timestamp packets by order).keyframeis derived from the leading frame-type bits. - Frame
Header - The parsed VP9 uncompressed frame header (the fields decoded so far).
- Vp9Decoder
- The stateful VP9 decoder: superframe splitting, the eight reference-frame
slots, frame-context management and the plane pool. Drive it FFmpeg-style:
pushcoded packets in,next_framedecoded pictures out (Error::Again= feed more,Error::Eof= drained afterflush). - Vp9Encoder
- In-house VP9 encoder: the first frame is a key frame, subsequent frames are P frames (ZEROMV, single-reference LAST) against the previous reconstruction.
- Vp9Encoder
Config - Configuration for
Vp9Encoder::configure— the native mirror of the ffmpeg-style options the rff adapter parses (-qp/-crf/-q,-b:v+-r,-lag,arnr-strength,dispatch-budget,-pass 2/twopass=1,-cpu-used/-speed).Noneleaves the encoder’s default untouched.
Enums§
- Error
- Errors (and control-flow signals) produced by the VP9 decoder and encoder.
Functions§
- consume_
compressed_ header - Structurally decode the compressed header for a key/intra frame over
data(which must be exactlyheader_sizebytes), returning the bits the boolean decoder consumed. A correct structure consumes ~all ofdata. - parse_
uncompressed_ header - Parse the VP9 uncompressed header (ISO/VP9 spec §6.2).
ref_dimsgives the (width, height) of each of the 8 reference slots, used to resolve an inter frame’sframe_size_with_refs; pass zeros when only key/intra frames are expected (the size then comes from the explicit fields). - ref_
hist_ take - Runtime A/B switch for the snapshot buffer pool (see
frameenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (seeframeenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (seeframeenc::set_snap_pool). Read and clear the reference histogram. - set_
modemap_ std - Runtime A/B switch for the snapshot buffer pool (see
frameenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (seeframeenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (seeframeenc::set_snap_pool). Select the old tuple/SipHash backend at runtime, so a bench can ALTERNATE the arms inside one process (same reasoning asset_snap_pool). - set_
snap_ pool - Runtime A/B switch for the snapshot buffer pool (see
frameenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (seeframeenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (seeframeenc::set_snap_pool). Flip the pool at runtime so a bench can ALTERNATE the two arms inside one process. Comparing two separate runs cannot separate the change from machine state: the first attempt here read -10.6% and the second +16.9%, with stages the pool never touches moving just as much. Interleaving is the only honest A/B.
Type Aliases§
- Result
- Crate-wide result alias.