• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include <cstdint>
4 
5 namespace kms
6 {
7 struct YUV;
8 
9 enum class YUVType {
10 	BT601_Lim = 0,
11 	BT601_Full,
12 	BT709_Lim,
13 	BT709_Full,
14 	MAX,
15 };
16 
17 struct RGB {
18 	RGB();
19 	RGB(uint8_t r, uint8_t g, uint8_t b);
20 	RGB(uint8_t a, uint8_t r, uint8_t g, uint8_t b);
21 	RGB(uint32_t argb);
22 
23 	uint32_t rgb888() const;
24 	uint32_t bgr888() const;
25 	uint32_t argb8888() const;
26 	uint32_t abgr8888() const;
27 	uint32_t rgba8888() const;
28 	uint32_t bgra8888() const;
29 
30 	// XXX these functions leave the lowest 2 bits zero
31 	uint32_t argb2101010() const;
32 	uint32_t abgr2101010() const;
33 	uint32_t rgba1010102() const;
34 	uint32_t bgra1010102() const;
35 
36 	uint8_t rgb332() const;
37 	uint16_t rgb565() const;
38 	uint16_t bgr565() const;
39 	uint16_t argb4444() const;
40 	uint16_t argb1555() const;
41 	YUV yuv(YUVType type = YUVType::BT601_Lim) const;
42 
43 	uint8_t b;
44 	uint8_t g;
45 	uint8_t r;
46 	uint8_t a;
47 };
48 
49 struct YUV {
50 	YUV();
51 	YUV(uint8_t y, uint8_t u, uint8_t v);
52 	YUV(const RGB& rgb, YUVType type = YUVType::BT601_Lim);
53 
54 	uint8_t v;
55 	uint8_t u;
56 	uint8_t y;
57 	uint8_t a;
58 };
59 } // namespace kms
60