1pub trait Format: Copy + Clone + PartialEq + Eq {
2 const ID: &'static str;
3 const NUM_CHANNELS: usize;
4
5 type T;
6 type Data;
7}
8
9pub struct Plane<T> {
10 pub data: Vec<T>,
11 pub stride: usize,
12}
13
14pub struct Planar<T, const NUM_CHANNELS: usize> {
15 pub planes: [Plane<T>; NUM_CHANNELS],
16}
17
18#[derive(Copy, Clone, PartialEq, Eq)]
19pub struct Rgb24;
20
21impl Format for Rgb24 {
22 const ID: &'static str = "rgb24";
23 const NUM_CHANNELS: usize = 3;
24
25 type T = u8;
26 type Data = Plane<Self::T>;
27}
28
29#[derive(Copy, Clone, PartialEq, Eq)]
30pub struct Yuv420p;
31
32impl Format for Yuv420p {
33 const ID: &'static str = "yuv420";
34 const NUM_CHANNELS: usize = 3;
35
36 type T = u8;
37 type Data = Planar<Self::T, { Self::NUM_CHANNELS }>;
38}
39
40macro_rules! impl_display_for {
41 ($f:ty) => {
42 impl std::fmt::Display for $f {
43 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
44 write!(f, "{}", Self::ID)
45 }
46 }
47 };
48}
49
50impl_display_for!(Yuv420p);