wedeo_core/
pixel_format.rs1use bitflags::bitflags;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6#[repr(i32)]
7pub enum PixelFormat {
8 None = -1,
9 Yuv420p = 0,
10 Yuyv422 = 1,
11 Rgb24 = 2,
12 Bgr24 = 3,
13 Yuv422p = 4,
14 Yuv444p = 5,
15 Yuv410p = 6,
16 Yuv411p = 7,
17 Gray8 = 8,
18 MonoWhite = 9,
19 MonoBlack = 10,
20 Pal8 = 11,
21 Yuvj420p = 12,
22 Yuvj422p = 13,
23 Yuvj444p = 14,
24 Uyvy422 = 15,
25 Nv12 = 25,
26 Nv21 = 26,
27 Argb = 27,
28 Rgba = 28,
29 Abgr = 29,
30 Bgra = 30,
31 Gray16be = 31,
32 Gray16le = 32,
33 Yuv420p16le = 55,
34 Yuv420p16be = 56,
35 Rgb48be = 41,
36 Rgb48le = 42,
37 Yuv420p10le = 90,
38 Yuv420p10be = 91,
39}
40
41impl PixelFormat {
42 pub fn name(self) -> &'static str {
43 match self {
44 PixelFormat::None => "none",
45 PixelFormat::Yuv420p => "yuv420p",
46 PixelFormat::Yuyv422 => "yuyv422",
47 PixelFormat::Rgb24 => "rgb24",
48 PixelFormat::Bgr24 => "bgr24",
49 PixelFormat::Yuv422p => "yuv422p",
50 PixelFormat::Yuv444p => "yuv444p",
51 PixelFormat::Yuv410p => "yuv410p",
52 PixelFormat::Yuv411p => "yuv411p",
53 PixelFormat::Gray8 => "gray8",
54 PixelFormat::MonoWhite => "monowhite",
55 PixelFormat::MonoBlack => "monoblack",
56 PixelFormat::Pal8 => "pal8",
57 PixelFormat::Yuvj420p => "yuvj420p",
58 PixelFormat::Yuvj422p => "yuvj422p",
59 PixelFormat::Yuvj444p => "yuvj444p",
60 PixelFormat::Uyvy422 => "uyvy422",
61 PixelFormat::Nv12 => "nv12",
62 PixelFormat::Nv21 => "nv21",
63 PixelFormat::Argb => "argb",
64 PixelFormat::Rgba => "rgba",
65 PixelFormat::Abgr => "abgr",
66 PixelFormat::Bgra => "bgra",
67 PixelFormat::Gray16be => "gray16be",
68 PixelFormat::Gray16le => "gray16le",
69 PixelFormat::Yuv420p16le => "yuv420p16le",
70 PixelFormat::Yuv420p16be => "yuv420p16be",
71 PixelFormat::Rgb48be => "rgb48be",
72 PixelFormat::Rgb48le => "rgb48le",
73 PixelFormat::Yuv420p10le => "yuv420p10le",
74 PixelFormat::Yuv420p10be => "yuv420p10be",
75 }
76 }
77}
78
79bitflags! {
80 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
82 pub struct PixelFormatFlags: u64 {
83 const BIG_ENDIAN = 1 << 0;
84 const PAL = 1 << 1;
85 const BITSTREAM = 1 << 2;
86 const HWACCEL = 1 << 3;
87 const PLANAR = 1 << 4;
88 const RGB = 1 << 5;
89 const ALPHA = 1 << 7;
90 const BAYER = 1 << 8;
91 const FLOAT = 1 << 9;
92 }
93}
94
95#[derive(Debug, Clone, Copy)]
97pub struct PixelFormatComponentDescriptor {
98 pub plane: u16,
100 pub step: u16,
102 pub offset: u16,
104 pub shift: u16,
106 pub depth: u16,
108}
109
110#[derive(Debug, Clone)]
112pub struct PixelFormatDescriptor {
113 pub name: &'static str,
114 pub nb_components: u8,
115 pub log2_chroma_w: u8,
117 pub log2_chroma_h: u8,
119 pub flags: PixelFormatFlags,
120 pub components: [PixelFormatComponentDescriptor; 4],
121}