Expand description
§zenavif
Pure Rust AVIF image codec powered by rav1d-safe and zenravif.
Decodes and encodes AVIF images using the pure Rust rav1d AV1 decoder and zenavif-parse container parser.
§Quick Start
use zenavif::decode;
let avif_data = std::fs::read("image.avif").unwrap();
let image = decode(&avif_data).unwrap();
println!("{}x{}", image.width(), image.height());§Features
unsafe-asm: Hand-written assembly decoder via C FFI (fastest) — overrides the default safe decoderencode: AVIF encoding via zenravifzencodec: Integration withzencodectraits
The default decoder uses rav1d-safe’s managed API — completely safe Rust with zero unsafe code in the entire decode path.
§Configuration
For more control over decoding, use decode_with with a DecoderConfig:
use zenavif::{decode_with, DecoderConfig};
use enough::Unstoppable;
let config = DecoderConfig::new()
.threads(4)
.apply_grain(true)
.frame_size_limit(8192 * 8192);
let avif_data = std::fs::read("image.avif").unwrap();
let image = decode_with(&avif_data, &config, &Unstoppable).unwrap();Modules§
- detect
- AVIF quality estimation and re-encoding recommendations. AVIF source analysis and quality estimation.
Structs§
- Animation
Decoder - Frame-by-frame animation decoder.
- Avif
Depth Map - Depth auxiliary image extracted from an AVIF container.
- Avif
Gain Map - Gain map for SDR/HDR tone mapping (ISO 21496-1), bundled from AVIF container.
- Clean
Aperture - Clean aperture from the
clapproperty box. - Color
Primaries - Color primaries
- Content
Light Level - Content light level info from the
clliproperty box. - Decoded
Animation - A fully decoded animation: frames + metadata.
- Decoded
Animation Info - Metadata about a decoded animation.
- Decoded
Frame - A single decoded frame from an animated AVIF sequence.
- Decoder
Config - Configuration for AVIF decoding
- Gain
MapChannel - Per-channel gain map parameters from ISO 21496-1.
- Gain
MapMetadata - Gain map metadata from a ToneMapImage (
tmap) derived image item. - Image
Info - Metadata about the decoded image
- Image
Mirror - Image mirror from the
imirproperty box. - Image
Rotation - Image rotation from the
irotproperty box. - Managed
Avif Decoder - Managed decoder wrapper - 100% safe!
- Mastering
Display Colour Volume - Mastering display colour volume from the
mdcvproperty box. - Matrix
Coefficients - Matrix coefficients for YUV to RGB conversion
- Pixel
Aspect Ratio - Pixel aspect ratio from the
paspproperty box. - Pixel
Buffer - Owned pixel buffer with format metadata.
- Transfer
Characteristics - Transfer characteristics (gamma curve)
- Unstoppable
- A
Stopimplementation that never stops (no cooperative cancellation).
Enums§
- Chroma
Sampling - Chroma subsampling format
- Color
Range - Color range
- Error
- Error type for zenavif decoding operations
- Stop
Reason - Why an operation was stopped.
Traits§
- Stop
- Cooperative cancellation check.
Functions§
- decode
- Decode an AVIF image with default settings
- decode_
animation - Decode an animated AVIF with default settings
- decode_
animation_ with - Decode an animated AVIF with custom settings and cancellation support
- decode_
av1_ obu - Decode a raw AV1 OBU bitstream to pixels.
- decode_
with - Decode an AVIF image with custom settings and cancellation support
Type Aliases§
- Result
- Result type for zenavif operations with location tracking