rav2d
Memory-safe AV2 video decoder library in Rust, ported from dav2d. Bit-exact with the dav2d C reference across the full conformance corpus (8-bit, filters off and on) and 10-bit streams.
Features
- Full OBU bitstream parsing (sequence, frame, tile group headers)
- Entropy decoding (MSAC) with CDF adaptation
- Intra (CfL, MHCCP, MRL, DIP, palette, IntraBC) and inter (compound, warp-affine, OBMC, interintra, BAWP, TIP, OPFL) block decoding
- Complete filter pipeline: deblock, CDEF, CCSO, loop restoration (Wiener / PC-Wiener / GDF), film grain
- Motion compensation with optical-flow refinement
- Inverse transforms (all sizes/types), segmentation, delta-Q, lossless
- High bit depth (10-bit) decode, bit-exact
- Reference frame management and motion vector prediction
- aarch64 NEON dispatch (motion compensation + intra H/V/smooth) via FFI to dav2d, scalar Rust fallback (
RAV2D_NEON_OFF=all)
Usage
use ;
let mut decoder = open?;
// Feed OBU data
decoder.send_data?;
// Get decoded frames
loop
Public API
| Type | Description |
|---|---|
Decoder |
Main decoder handle — open, send_data, get_picture, flush |
Settings |
Configuration: threads, film grain, operating point |
Data |
Reference-counted byte buffer for compressed input |
Picture |
Decoded frame with pixel planes, headers, and metadata |
Rav2dError |
Error enum: Eof, Again, InvalidData, FrameTooLarge, InvalidParam, OutOfMemory |
SequenceHeader |
Parsed sequence-level parameters |
FrameHeader |
Parsed frame-level parameters |
Logger |
Configurable logging callback |
PicAllocator |
Custom picture memory allocator trait |
Building
Requires dav2d built locally (for FFI assembly kernels):
# macOS
DYLD_LIBRARY_PATH=../../dav2d/build/src
# Linux
LD_LIBRARY_PATH=../../dav2d/build/src
License
BSD-2-Clause