rav2d 0.3.0

AV2 video decoder in Rust
Documentation
  • Coverage
  • 8.62%
    20 out of 232 items documented1 out of 1 items with examples
  • Size
  • Source code size: 3.68 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 15.47 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • stukenov/rav2d
    19 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • stukenov

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 rav2d::{Decoder, Settings, Data, Rav2dError};

let mut decoder = Decoder::open(&Settings::default())?;

// Feed OBU data
decoder.send_data(Some(Data::wrap(obu_bytes)))?;

// Get decoded frames
loop {
    match decoder.get_picture() {
        Ok(pic) => {
            println!("{}x{} bpc={}", pic.p.w, pic.p.h, pic.p.bpc);
            // Access pixel data via pic.data[0..3] (Y, U, V planes)
        }
        Err(Rav2dError::Again) => break,
        Err(e) => return Err(e.into()),
    }
}

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 cargo test -p rav2d

# Linux
LD_LIBRARY_PATH=../../dav2d/build/src cargo test -p rav2d

License

BSD-2-Clause