# Rust wrapper for AOMedia AV1 decoder
It's a minimal safe wrapper that allows decoding individual AV1 frames. It's meant for decoding AVIF images.
## Usage
See [`examples/to_png.rs`](examples/to_png.rs) for the full code.
You'll need the [avif-parse](https://lib.rs/avif-parse) crate to get AV1 data out of an AVIF file, and the [yuv](https://lib.rs/yuv) crate to convert YUV pixels into RGB.
The easiest way is to let the [`Avif`] wrapper do the conversion for you:
```rust
use aom_decode::avif::Avif;
let avif = Avif::decode(&std::fs::read(path)?, &Config { threads: 4 })?;
let rgb = avif.convert()?; // `Image::RGB8`, `RGBA8`, `Gray8`, or 16-bit variants
```
For decoding without conversion, use [`Decoder`]. It gives you [`FrameTempRef`]
with raw Y/U/V planes of the decoded frame:
```rust
let avif = avif_parse::read_avif(file)?;
let mut d = Decoder::new(&Config {
threads: std::thread::available_parallelism().map(|v| v.get()).unwrap_or(4),
})?;
let img = d.decode_frame(&avif.primary_item)?;
match img.planes()? {
Planes::YuvPlanes8 { y, u, v, chroma_sampling } => {
// Y, U, V row iterators, with `y.width()`/`y.height()` dimensions,
// and the `yuv` crate's `YuvPlanarImage` for conversion to RGB
},
Planes::Mono8(y) => {},
Planes::Mono16(y, depth) => {},
Planes::YuvPlanes16 { y, u, v, chroma_sampling, depth } => {},
}
```