ravif/
lib.rs

1//! ```rust
2//! use ravif::*;
3//! # fn doit(pixels: &[RGBA8], width: usize, height: usize) -> Result<(), Error> {
4//! let res = Encoder::new()
5//!     .with_quality(70.)
6//!     .with_speed(4)
7//!     .encode_rgba(Img::new(pixels, width, height))?;
8//! std::fs::write("hello.avif", res.avif_file);
9//! # Ok(()) }
10
11mod av1encoder;
12
13mod error;
14pub use error::Error;
15pub use av1encoder::ColorSpace;
16pub use av1encoder::AlphaColorMode;
17pub use av1encoder::Encoder;
18pub use av1encoder::EncodedImage;
19#[doc(inline)]
20pub use rav1e::prelude::MatrixCoefficients;
21
22mod dirtyalpha;
23
24#[doc(no_inline)]
25pub use imgref::Img;
26#[doc(no_inline)]
27pub use rgb::{RGB8, RGBA8};
28
29#[cfg(not(feature = "threading"))]
30mod rayoff {
31    pub fn current_num_threads() -> usize {
32        std::thread::available_parallelism().map(|v| v.get()).unwrap_or(1)
33    }
34
35    pub fn join<A, B>(a: impl FnOnce() -> A, b: impl FnOnce() -> B) -> (A, B) {
36        (a(), b())
37    }
38}