Skip to main content

vp8_decoder/
lib.rs

1//! A VP8 video decoder in pure, safe Rust (RFC 6386).
2//!
3//! It decodes every VP8 bitstream version (0 to 3): keyframes and
4//! interframes, all intra and inter prediction modes including split motion
5//! vectors, segmentation, the normal and simple loop filters, token
6//! partitions, probability updates and persistence, and the last, golden and
7//! alt-ref reference frames with their sign bias and buffer copies. Its
8//! output matches the WebM project's VP8 test vectors bit for bit.
9//!
10//! Input is one raw VP8 frame at a time, starting at the frame tag (no IVF,
11//! WebM or RTP framing). Output is a borrowed I420 [`Picture`].
12//!
13//! ```no_run
14//! let frames: Vec<Vec<u8>> = Vec::new(); // raw VP8 frames, in order
15//! let mut decoder = vp8_decoder::Decoder::new();
16//! for frame in &frames {
17//!     match decoder.decode(frame) {
18//!         Ok(Some(picture)) => { let _i420 = picture.to_i420(); }
19//!         Ok(None) => {} // a frame that only updates references
20//!         Err(vp8_decoder::DecodeError::NeedKeyframe) => {} // wait for a keyframe
21//!         Err(_) => {} // corrupt: ask the sender for a keyframe
22//!     }
23//! }
24//! ```
25//!
26//! See PROVENANCE.md for how this crate was written.
27
28#![forbid(unsafe_code)]
29
30mod bool_decoder;
31mod decoder;
32mod frame;
33pub mod ivf;
34
35// Shared with the vp8-encoder crate. Not a stable API: it may change in any
36// release, and vp8-encoder pins this crate's exact version. Lockstep rule:
37// any vp8-decoder release that touches these modules ships with a matching
38// vp8-encoder release that bumps its `=` pin.
39#[doc(hidden)]
40pub mod bool_encoder;
41#[doc(hidden)]
42pub mod idct;
43#[doc(hidden)]
44pub mod loop_filter;
45#[doc(hidden)]
46pub mod modes;
47#[doc(hidden)]
48pub mod predict;
49#[doc(hidden)]
50pub mod tables;
51
52pub use decoder::{frame_info, DecodeError, Decoder, Dimensions, FrameInfo, DEFAULT_MAX_PIXELS};
53pub use frame::Picture;
54
55// The README's examples are compiled as doc tests.
56#[cfg(doctest)]
57#[doc = include_str!("../README.md")]
58struct ReadmeDoctests;