Skip to main content

Module managed

Module managed 

Source
Expand description

100% safe Rust API for AV1 decoding

This module provides a fully safe, zero-copy API wrapping rav1d’s internal decoder. 100% Safe Rust API for rav1d-safe decoder

This module provides a fully safe, zero-copy API for decoding AV1 video. It wraps the internal rav1d decoder with type-safe, lifetime-safe abstractions.

§Features

  • 100% Safe Rust - No unsafe code in this module
  • Zero-Copy - Direct access to decoded pixel data without copying
  • Type Safety - Enums and strong types instead of raw integers
  • HDR Support - Full access to HDR10, HLG metadata
  • Multi-threaded - Configurable thread pool for parallel decoding

§Example

use rav1d_safe::src::managed::{Decoder, Settings, Planes};

let mut decoder = Decoder::new()?;
let obu_data = b"..."; // AV1 OBU bitstream data

if let Some(frame) = decoder.decode(obu_data)? {
    println!("Decoded {}x{} frame at {}-bit",
             frame.width(), frame.height(), frame.bit_depth());

    // Zero-copy access to pixel data
    match frame.planes() {
        Planes::Depth8(planes) => {
            let y_plane = planes.y();
            for row in y_plane.rows() {
                // Process 8-bit row data
            }
        }
        Planes::Depth16(planes) => {
            let y_plane = planes.y();
            let pixel = y_plane.pixel(0, 0);
            println!("Top-left pixel: {}", pixel);
        }
    }
}

Structs§

ColorInfo
Color information
ContentLightLevel
HDR content light level (SMPTE 2086 / CTA-861.3)
Decoder
Safe AV1 decoder instance
Frame
A decoded AV1 frame with zero-copy access to pixel data
InloopFilters
Inloop filter flags
MasteringDisplay
HDR mastering display color volume (SMPTE 2086)
PlaneView8
Zero-copy view of an 8-bit plane
PlaneView16
Zero-copy view of a 10/12-bit plane
Planes8
8-bit pixel plane accessor
Planes16
10/12-bit pixel plane accessor
Settings
Decoder configuration settings
Unstoppable
Cooperative cancellation token support (issue #412). Re-exported from the enough crate so callers can pass a &dyn Stop / Arc<dyn Stop> to Decoder::set_stop without depending on enough directly. A Stop implementation that never stops (no cooperative cancellation).

Enums§

ColorPrimaries
Color primaries (CIE 1931 xy chromaticity coordinates)
ColorRange
Color range
CpuLevel
CPU feature level for SIMD dispatch control.
DecodeFrameType
Which frame types to decode
Error
Decoder errors
MatrixCoefficients
Matrix coefficients (YUV to RGB conversion)
PixelLayout
Pixel layout (chroma subsampling)
Planes
Zero-copy access to pixel planes
StopReason
Cooperative cancellation token support (issue #412). Re-exported from the enough crate so callers can pass a &dyn Stop / Arc<dyn Stop> to Decoder::set_stop without depending on enough directly. Why an operation was stopped.
Strictness
How much the decoder tolerates from a stream that violates the AV1 specification.
TransferCharacteristics
Transfer characteristics (EOTF / gamma curve)

Traits§

Stop
Cooperative cancellation token support (issue #412). Re-exported from the enough crate so callers can pass a &dyn Stop / Arc<dyn Stop> to Decoder::set_stop without depending on enough directly. Cooperative cancellation check.

Functions§

enabled_features
Returns a comma-delimited string of enabled compile-time feature flags.
is_unchecked
Returns true if the unchecked feature is enabled.

Type Aliases§

Result
Result type for the managed API. The error is wrapped in whereat::At, which records the source location where the failure surfaced (for server-side logs). The internal decoder hot path uses the separate bare Rav1dError/Rav1dResult types, so this wrapper never enters an inner loop — it only applies at the per-frame managed-API boundary. Match the inner error with err.error() (borrow) or err.decompose().0 (owned).