1 #include <map>
2
3 #include <kms++/pixelformats.h>
4
5 using namespace std;
6
7 namespace kms
8 {
9 static const map<PixelFormat, PixelFormatInfo> format_info_array = {
10 /* YUV packed */
11 { PixelFormat::UYVY, {
12 PixelColorType::YUV,
13 1,
14 { { 16, 2, 1 } },
15 } },
16 { PixelFormat::YUYV, {
17 PixelColorType::YUV,
18 1,
19 { { 16, 2, 1 } },
20 } },
21 { PixelFormat::YVYU, {
22 PixelColorType::YUV,
23 1,
24 { { 16, 2, 1 } },
25 } },
26 { PixelFormat::VYUY, {
27 PixelColorType::YUV,
28 1,
29 { { 16, 2, 1 } },
30 } },
31 /* YUV semi-planar */
32 { PixelFormat::NV12, {
33 PixelColorType::YUV,
34 2,
35 { {
36 8,
37 1,
38 1,
39 },
40 { 8, 2, 2 } },
41 } },
42 { PixelFormat::NV21, {
43 PixelColorType::YUV,
44 2,
45 { {
46 8,
47 1,
48 1,
49 },
50 { 8, 2, 2 } },
51 } },
52 { PixelFormat::NV16, {
53 PixelColorType::YUV,
54 2,
55 { {
56 8,
57 1,
58 1,
59 },
60 { 8, 2, 1 } },
61 } },
62 { PixelFormat::NV61, {
63 PixelColorType::YUV,
64 2,
65 { {
66 8,
67 1,
68 1,
69 },
70 { 8, 2, 1 } },
71 } },
72 /* YUV planar */
73 { PixelFormat::YUV420, {
74 PixelColorType::YUV,
75 3,
76 { {
77 8,
78 1,
79 1,
80 },
81 { 8, 2, 2 },
82 { 8, 2, 2 } },
83 } },
84 { PixelFormat::YVU420, {
85 PixelColorType::YUV,
86 3,
87 { {
88 8,
89 1,
90 1,
91 },
92 { 8, 2, 2 },
93 { 8, 2, 2 } },
94 } },
95 { PixelFormat::YUV422, {
96 PixelColorType::YUV,
97 3,
98 { {
99 8,
100 1,
101 1,
102 },
103 { 8, 2, 1 },
104 { 8, 2, 1 } },
105 } },
106 { PixelFormat::YVU422, {
107 PixelColorType::YUV,
108 3,
109 { {
110 8,
111 1,
112 1,
113 },
114 { 8, 2, 1 },
115 { 8, 2, 1 } },
116 } },
117 { PixelFormat::YUV444, {
118 PixelColorType::YUV,
119 3,
120 { {
121 8,
122 1,
123 1,
124 },
125 { 8, 1, 1 },
126 { 8, 1, 1 } },
127 } },
128 { PixelFormat::YVU444, {
129 PixelColorType::YUV,
130 3,
131 { {
132 8,
133 1,
134 1,
135 },
136 { 8, 1, 1 },
137 { 8, 1, 1 } },
138 } },
139 /* RGB8 */
140 { PixelFormat::RGB332, {
141 PixelColorType::RGB,
142 1,
143 { { 8, 1, 1 } },
144 } },
145 /* RGB16 */
146 { PixelFormat::RGB565, {
147 PixelColorType::RGB,
148 1,
149 { { 16, 1, 1 } },
150 } },
151 { PixelFormat::BGR565, {
152 PixelColorType::RGB,
153 1,
154 { { 16, 1, 1 } },
155 } },
156 { PixelFormat::XRGB4444, {
157 PixelColorType::RGB,
158 1,
159 { { 16, 1, 1 } },
160 } },
161 { PixelFormat::XRGB1555, {
162 PixelColorType::RGB,
163 1,
164 { { 16, 1, 1 } },
165 } },
166 { PixelFormat::ARGB4444, {
167 PixelColorType::RGB,
168 1,
169 { { 16, 1, 1 } },
170 } },
171 { PixelFormat::ARGB1555, {
172 PixelColorType::RGB,
173 1,
174 { { 16, 1, 1 } },
175 } },
176 /* RGB24 */
177 { PixelFormat::RGB888, {
178 PixelColorType::RGB,
179 1,
180 { { 24, 1, 1 } },
181 } },
182 { PixelFormat::BGR888, {
183 PixelColorType::RGB,
184 1,
185 { { 24, 1, 1 } },
186 } },
187 /* RGB32 */
188 { PixelFormat::XRGB8888, {
189 PixelColorType::RGB,
190 1,
191 { { 32, 1, 1 } },
192 } },
193 { PixelFormat::XBGR8888, {
194 PixelColorType::RGB,
195 1,
196 { { 32, 1, 1 } },
197 } },
198 { PixelFormat::RGBX8888, {
199 PixelColorType::RGB,
200 1,
201 { { 32, 1, 1 } },
202 } },
203 { PixelFormat::BGRX8888, {
204 PixelColorType::RGB,
205 1,
206 { { 32, 1, 1 } },
207 } },
208
209 { PixelFormat::ARGB8888, {
210 PixelColorType::RGB,
211 1,
212 { { 32, 1, 1 } },
213 } },
214 { PixelFormat::ABGR8888, {
215 PixelColorType::RGB,
216 1,
217 { { 32, 1, 1 } },
218 } },
219 { PixelFormat::RGBA8888, {
220 PixelColorType::RGB,
221 1,
222 { { 32, 1, 1 } },
223 } },
224 { PixelFormat::BGRA8888, {
225 PixelColorType::RGB,
226 1,
227 { { 32, 1, 1 } },
228 } },
229
230 { PixelFormat::XRGB2101010, {
231 PixelColorType::RGB,
232 1,
233 { { 32, 1, 1 } },
234 } },
235 { PixelFormat::XBGR2101010, {
236 PixelColorType::RGB,
237 1,
238 { { 32, 1, 1 } },
239 } },
240 { PixelFormat::RGBX1010102, {
241 PixelColorType::RGB,
242 1,
243 { { 32, 1, 1 } },
244 } },
245 { PixelFormat::BGRX1010102, {
246 PixelColorType::RGB,
247 1,
248 { { 32, 1, 1 } },
249 } },
250
251 { PixelFormat::ARGB2101010, {
252 PixelColorType::RGB,
253 1,
254 { { 32, 1, 1 } },
255 } },
256 { PixelFormat::ABGR2101010, {
257 PixelColorType::RGB,
258 1,
259 { { 32, 1, 1 } },
260 } },
261 { PixelFormat::RGBA1010102, {
262 PixelColorType::RGB,
263 1,
264 { { 32, 1, 1 } },
265 } },
266 { PixelFormat::BGRA1010102, {
267 PixelColorType::RGB,
268 1,
269 { { 32, 1, 1 } },
270 } },
271 };
272
get_pixel_format_info(PixelFormat format)273 const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format)
274 {
275 if (!format_info_array.count(format))
276 throw invalid_argument("get_pixel_format_info: Unsupported pixelformat");
277
278 return format_info_array.at(format);
279 }
280
281 } // namespace kms
282