Skip to main content

Crate zenavif

Crate zenavif 

Source
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 decoder
  • encode: AVIF encoding via zenravif
  • zencodec: Integration with zencodec traits

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§

AnimationDecoder
Frame-by-frame animation decoder.
AvifDepthMap
Depth auxiliary image extracted from an AVIF container.
AvifGainMap
Gain map for SDR/HDR tone mapping (ISO 21496-1), bundled from AVIF container.
CleanAperture
Clean aperture from the clap property box.
ColorPrimaries
Color primaries
ContentLightLevel
Content light level info from the clli property box.
DecodedAnimation
A fully decoded animation: frames + metadata.
DecodedAnimationInfo
Metadata about a decoded animation.
DecodedFrame
A single decoded frame from an animated AVIF sequence.
DecoderConfig
Configuration for AVIF decoding
GainMapChannel
Per-channel gain map parameters from ISO 21496-1.
GainMapMetadata
Gain map metadata from a ToneMapImage (tmap) derived image item.
ImageInfo
Metadata about the decoded image
ImageMirror
Image mirror from the imir property box.
ImageRotation
Image rotation from the irot property box.
ManagedAvifDecoder
Managed decoder wrapper - 100% safe!
MasteringDisplayColourVolume
Mastering display colour volume from the mdcv property box.
MatrixCoefficients
Matrix coefficients for YUV to RGB conversion
PixelAspectRatio
Pixel aspect ratio from the pasp property box.
PixelBuffer
Owned pixel buffer with format metadata.
TransferCharacteristics
Transfer characteristics (gamma curve)
Unstoppable
A Stop implementation that never stops (no cooperative cancellation).

Enums§

ChromaSampling
Chroma subsampling format
ColorRange
Color range
Error
Error type for zenavif decoding operations
StopReason
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