oxideav-vp8
Pure-Rust VP8 video codec (RFC 6386). Decoder and encoder both at production status as of 2026-05-27.
- RFC 6386 key + inter decode, bit-exact against the reference output on 10+ multi-frame fixtures (mid-GOP golden refresh, 10-frame auto-alt-ref, ARNR).
- Phase-2 encoder with SPLITMV, GOLDEN / ALTREF, multi-partition, RefreshControls, LoopFilterDeltas, §11 intra picker, §13.4 token-probability fitter, and a complexity-aware two-pass rate-control family.
- The full crates.io
0.1.13public surface is reachable, both with the defaultregistrybuild and under--no-default-features. Compile-only assertion suite: per-symbol contract andtests/api_compat_0_1_13.rsfor the compile-only assertion suite.
Install
# With oxideav-core for use under the OxideAV runtime:
[]
= "0.2"
# Or standalone, without any framework dependency:
[]
= { = "0.2", = false }
| Feature | Default | What it does |
|---|---|---|
registry |
✅ on | Pulls oxideav-core and the framework-trait factories (make_encoder / make_decoder returning Box<dyn Encoder> / Box<dyn Decoder>) plus Vp8Decoder (the oxideav_core::Decoder impl) and the register* entry points. |
simd |
— | Nightly-only. Switches the §14.3 inverse 4×4 WHT (inverse_wht_4x4) over to a core::simd::Simd<i32, 4> rewrite; byte-exact against the scalar path on every test fixture, ≈ −20 % on the inverse_transform_4x4/inverse_wht_4x4 criterion micro-bench (9.4 ns → 7.5 ns on aarch64-apple-darwin). Requires a nightly toolchain because core::simd is itself nightly. Default (stable) builds use the scalar §14.3 path unchanged. See BENCHMARKS.md for the A/B numbers + the round-170 profile that motivated this primitive's vectorisation. |
Standalone use (no oxideav-core)
Decode one VP8 frame
decode_vp8 is the keyframe entry point. For inter-frame sequences
the caller drives the stateful Vp8DecoderState that keeps the LAST
/ GOLDEN / ALTREF reference slots:
use ;
// One-shot single-frame decode of a VP8 keyframe.
let frame = decode_vp8?;
let = ;
assert_eq!;
assert_eq!;
assert_eq!;
// Multi-frame inter decode — one Vp8DecoderState per stream.
let mut state = new;
for packet in vp8_frame_packets
Vp8DecodedFrame (also re-exported as Vp8Frame) carries the visible
width / height plus three tightly-packed Vec<u8> planes.
Encode one VP8 keyframe
use ;
let frame = packed;
let params = new;
let vp8_bytes: = encode_keyframe?;
// The output is a raw VP8 keyframe bitstream (3-byte tag + 7-byte
// start code + partitions). Wrap it in an IVF / RIFF-WEBP / Matroska
// container as needed for your downstream consumer.
For a multi-frame inter encoder use Vp8Encoder + Vp8EncoderConfig
(both reachable standalone) and feed successive I420Frames; see
tests/encoder_inter_stream.rs for a worked example.
Two-pass rate-control encode
use ;
// First pass: cheap per-frame complexity stats (no encode).
let stats = first_pass_analyze;
// Second pass: per-frame qindex distribution + actual encode.
let config = default; // wraps a base Vp8EncoderConfig
let qindices = two_pass_qindices?;
let encoder = new;
let packets = encoder.encode?;
The algorithm distributes per-frame qindex around config.base.qindex
so heavier-than-mean frames get lower qindex (better quality) and
lighter frames get higher qindex (smaller bytes), with scene-cut
detection forcing extra-quality keyframes.
Container helpers
The ivf module gives you a standalone IVF reader / writer for the
common case of *.ivf test fixtures:
use ;
let mut out = Vecnew;
let hdr = vp8;
out.extend_from_slice;
for in &timed_packets
Quality knob
If you have a 0.0..=100.0 quality scalar (the WebP-canonical
convention) and want the matching VP8 qindex:
use quality_to_qindex;
let qindex = quality_to_qindex; // → 32
let qindex = quality_to_qindex; // → 0 (best)
let qindex = quality_to_qindex; // → 127 (worst, safe)
With the OxideAV runtime (registry feature on, the default)
use RuntimeContext;
use CODEC_ID_STR; // = "vp8"
let mut ctx = new;
register;
// ctx.codecs now has a "vp8" Decoder + Encoder factory.
// Or directly call the factories:
use ;
let enc = make_encoder_with_quality?; // Box<dyn Encoder>
let enc = make_encoder_with_qindex?;
Both factories return Box<dyn oxideav_core::Encoder> and integrate
with the OxideAV pipeline through send_frame / receive_packet.
Clean-room sources
Implementation is derived entirely from the public format spec:
- RFC 6386 — VP8 Data Format and Decoding Guide
(
docs/video/vp8/rfc6386-vp8-bitstream.txt).
The two-pass rate-control algorithm is intentionally outside RFC scope (the spec is silent on rate control by design) — the design is clean-room, sourced from the in-tree per-MB activity primitives plus log-MAD + log-variance first-pass statistics.
Fixture expected.yuv reference pictures are produced by black-box
invocations of the reference decoder binary; no third-party codec
library source is consulted.
Interop test coverage
The crate ships two interop suites layered on top of the per-stage unit tests:
tests/standalone_e2e.rs— keyframe, multi-frame inter, two-pass, IVF container, andquality_to_qindexend-to-end checks against thedefault-features = falsestandalone surface. Every imported symbol must resolve without theregistryfeature; passes under both feature configurations.tests/ffmpeg_oracle.rs— bidirectional cross-validation againstffmpegas a black-box oracle. Direction A is our encode → ffmpeg decode (PSNR-Y ≥ 30 dB on the recovered picture); direction B is ffmpeg encode → our decode via the crate's ownivf::parse_headerwalker (PSNR-Y ≥ 25 dB). Skips cleanly viaeprintln! + returnwhenffmpegisn't on$PATH— never#[ignore].
License
MIT. See LICENSE.