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
unsafecode 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§
- Color
Info - Color information
- Content
Light Level - 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
- Inloop
Filters - Inloop filter flags
- Mastering
Display - HDR mastering display color volume (SMPTE 2086)
- Plane
View8 - Zero-copy view of an 8-bit plane
- Plane
View16 - 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
enoughcrate so callers can pass a&dyn Stop/Arc<dyn Stop>toDecoder::set_stopwithout depending onenoughdirectly. AStopimplementation that never stops (no cooperative cancellation).
Enums§
- Color
Primaries - Color primaries (CIE 1931 xy chromaticity coordinates)
- Color
Range - Color range
- CpuLevel
- CPU feature level for SIMD dispatch control.
- Decode
Frame Type - Which frame types to decode
- Error
- Decoder errors
- Matrix
Coefficients - Matrix coefficients (YUV to RGB conversion)
- Pixel
Layout - Pixel layout (chroma subsampling)
- Planes
- Zero-copy access to pixel planes
- Stop
Reason - Cooperative cancellation token support (issue #412). Re-exported from the
enoughcrate so callers can pass a&dyn Stop/Arc<dyn Stop>toDecoder::set_stopwithout depending onenoughdirectly. Why an operation was stopped. - Strictness
- How much the decoder tolerates from a stream that violates the AV1 specification.
- Transfer
Characteristics - Transfer characteristics (EOTF / gamma curve)
Traits§
- Stop
- Cooperative cancellation token support (issue #412). Re-exported from the
enoughcrate so callers can pass a&dyn Stop/Arc<dyn Stop>toDecoder::set_stopwithout depending onenoughdirectly. Cooperative cancellation check.
Functions§
- enabled_
features - Returns a comma-delimited string of enabled compile-time feature flags.
- is_
unchecked - Returns
trueif theuncheckedfeature 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 bareRav1dError/Rav1dResulttypes, so this wrapper never enters an inner loop — it only applies at the per-frame managed-API boundary. Match the inner error witherr.error()(borrow) orerr.decompose().0(owned).