Skip to main content

Crate rusty_vp9

Crate rusty_vp9 

Source
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 the video-tests analyzer. The encoder itself stays private; only the read side of the instrument is public. See prof for the decoder’s. Primitive profiler for the VP9 encoder hot path (VP9_PROF2=1, or set_enabled from an in-process harness).
prof
Function-level decode profiler (VP9_DPROF). Public so the video-tests analyzer 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 unless VP9_PROF2).

Structs§

BitReader
MSB-first bit reader for the uncompressed header.
BoolDecoder
VP9 boolean arithmetic decoder (ISO/VP9 spec §9.2), structured as libvpx vpx_reader: a 64-bit left-justified value window with a bulk byte refill, so renormalization is a single shift + a count decrement instead of a per-bit loop. Bit-identical output to the spec; just much faster bookkeeping.
DecodedFrame
One decoded picture, cropped to its visible size.
EncodedPacket
One coded VP9 packet out of the encoder. data is 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; pts is currently always None (callers timestamp packets by order). keyframe is derived from the leading frame-type bits.
FrameHeader
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: push coded packets in, next_frame decoded pictures out (Error::Again = feed more, Error::Eof = drained after flush).
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.
Vp9EncoderConfig
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). None leaves 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 exactly header_size bytes), returning the bits the boolean decoder consumed. A correct structure consumes ~all of data.
parse_uncompressed_header
Parse the VP9 uncompressed header (ISO/VP9 spec §6.2). ref_dims gives the (width, height) of each of the 8 reference slots, used to resolve an inter frame’s frame_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 (see frameenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (see frameenc::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 (see frameenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (see frameenc::set_snap_pool). Select the old tuple/SipHash backend at runtime, so a bench can ALTERNATE the arms inside one process (same reasoning as set_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 (see frameenc::set_snap_pool). Runtime A/B switch for the snapshot buffer pool (see frameenc::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.