openh264/formats/mod.rs
1//! Handles conversions, e.g., between RGB and YUV.
2//!
3//! In particular when encoding frames your source data might be a YUV buffer, or one of multiple RGB formats. The structs and
4//! traits in here can help you with that format conversion.
5//!
6//! # Examples
7//!
8//! Load a _vanilla_ 3x8 bit-per-pixel RGB slice into a [YUVBuffer]:
9//!
10//! ```rust
11//! use openh264::formats::{RgbSliceU8, YUVBuffer};
12//!
13//! // Assume this is a 2x2 pixel RGB buffer you got from somewhere.
14//! let raw_rgb = &[ 10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40 ];
15//! let rgb_source = RgbSliceU8::new(raw_rgb, (2, 2));
16//!
17//! // Now you have a YUV which you can feed into the encoder.
18//! let yuv = YUVBuffer::from_rgb_source(rgb_source);
19//! ```
20//!
21
22mod rgb;
23pub(crate) mod rgb2yuv;
24mod yuv;
25pub(crate) mod yuv2rgb;
26
27pub use rgb::{
28 AbgrSliceU8, AbgrSliceU32, ArgbSliceU8, ArgbSliceU32, BgrSliceU8, BgraSliceU8, BgraSliceU32, RGB8Source, RGBSource,
29 RgbSliceU8, RgbaSliceU8, RgbaSliceU32,
30};
31pub use yuv::{YUVBuffer, YUVSlices, YUVSource};