proresenc: Don't free a buffer not owned by the codec
[libav.git] / libavutil / pixdesc.c
CommitLineData
9b61d838 1/*
e0cffbe7 2 * pixel format descriptor
9b61d838
MN
3 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
4 *
2912e87a 5 * This file is part of Libav.
9b61d838 6 *
2912e87a 7 * Libav is free software; you can redistribute it and/or
9b61d838
MN
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
2912e87a 12 * Libav is distributed in the hope that it will be useful,
9b61d838
MN
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
2912e87a 18 * License along with Libav; if not, write to the Free Software
9b61d838
MN
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
47bfd50a
MR
22#include <stdio.h>
23#include <string.h>
51135d1d 24#include "pixfmt.h"
9b61d838
MN
25#include "pixdesc.h"
26
f47a7cb7
SS
27#include "intreadwrite.h"
28
ce1cd1cb 29void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
4a59eca9
TB
30 const AVPixFmtDescriptor *desc, int x, int y, int c, int w,
31 int read_pal_component)
f47a7cb7 32{
4a59eca9
TB
33 AVComponentDescriptor comp = desc->comp[c];
34 int plane = comp.plane;
35 int depth = comp.depth_minus1 + 1;
36 int mask = (1 << depth) - 1;
37 int shift = comp.shift;
38 int step = comp.step_minus1 + 1;
39 int flags = desc->flags;
f47a7cb7 40
4a59eca9
TB
41 if (flags & PIX_FMT_BITSTREAM) {
42 int skip = x * step + comp.offset_plus1 - 1;
43 const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
44 int shift = 8 - depth - (skip & 7);
f47a7cb7 45
4a59eca9 46 while (w--) {
f47a7cb7 47 int val = (*p >> shift) & mask;
4a59eca9
TB
48 if (read_pal_component)
49 val = data[1][4*val + c];
f47a7cb7 50 shift -= step;
4a59eca9 51 p -= shift >> 3;
f47a7cb7 52 shift &= 7;
4a59eca9 53 *dst++ = val;
f47a7cb7
SS
54 }
55 } else {
4a59eca9 56 const uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
4660143a 57 int is_8bit = shift + depth <= 8;
f47a7cb7 58
4660143a 59 if (is_8bit)
9525243f 60 p += !!(flags & PIX_FMT_BE);
4660143a 61
4a59eca9 62 while (w--) {
9525243f
MR
63 int val = is_8bit ? *p :
64 flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
4a59eca9
TB
65 val = (val >> shift) & mask;
66 if (read_pal_component)
67 val = data[1][4 * val + c];
68 p += step;
69 *dst++ = val;
f47a7cb7
SS
70 }
71 }
72}
73
ce1cd1cb 74void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
ee435580 75 const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
f47a7cb7
SS
76{
77 AVComponentDescriptor comp = desc->comp[c];
78 int plane = comp.plane;
4a59eca9
TB
79 int depth = comp.depth_minus1 + 1;
80 int step = comp.step_minus1 + 1;
f47a7cb7
SS
81 int flags = desc->flags;
82
83 if (flags & PIX_FMT_BITSTREAM) {
4a59eca9
TB
84 int skip = x * step + comp.offset_plus1 - 1;
85 uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
86 int shift = 8 - depth - (skip & 7);
f47a7cb7
SS
87
88 while (w--) {
89 *p |= *src++ << shift;
90 shift -= step;
4a59eca9 91 p -= shift >> 3;
f47a7cb7
SS
92 shift &= 7;
93 }
94 } else {
95 int shift = comp.shift;
4a59eca9 96 uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
f47a7cb7 97
9525243f
MR
98 if (shift + depth <= 8) {
99 p += !!(flags & PIX_FMT_BE);
100 while (w--) {
4a59eca9 101 *p |= (*src++ << shift);
9525243f
MR
102 p += step;
103 }
104 } else {
78b19cf0
MR
105 while (w--) {
106 if (flags & PIX_FMT_BE) {
4a59eca9 107 uint16_t val = AV_RB16(p) | (*src++ << shift);
78b19cf0
MR
108 AV_WB16(p, val);
109 } else {
4a59eca9 110 uint16_t val = AV_RL16(p) | (*src++ << shift);
78b19cf0
MR
111 AV_WL16(p, val);
112 }
4a59eca9 113 p += step;
f47a7cb7 114 }
9525243f 115 }
f47a7cb7
SS
116 }
117}
118
d2863e72 119const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
bcbd9a14
SS
120 [PIX_FMT_YUV420P] = {
121 .name = "yuv420p",
4a59eca9
TB
122 .nb_components = 3,
123 .log2_chroma_w = 1,
124 .log2_chroma_h = 1,
9b61d838 125 .comp = {
4a59eca9
TB
126 { 0, 0, 1, 0, 7 }, /* Y */
127 { 1, 0, 1, 0, 7 }, /* U */
128 { 2, 0, 1, 0, 7 }, /* V */
9b61d838 129 },
6b0768e2 130 .flags = PIX_FMT_PLANAR,
9b61d838 131 },
bcbd9a14
SS
132 [PIX_FMT_YUYV422] = {
133 .name = "yuyv422",
4a59eca9
TB
134 .nb_components = 3,
135 .log2_chroma_w = 1,
136 .log2_chroma_h = 0,
bcbd9a14 137 .comp = {
4a59eca9
TB
138 { 0, 1, 1, 0, 7 }, /* Y */
139 { 0, 3, 2, 0, 7 }, /* U */
140 { 0, 3, 4, 0, 7 }, /* V */
bcbd9a14
SS
141 },
142 },
143 [PIX_FMT_RGB24] = {
144 .name = "rgb24",
4a59eca9
TB
145 .nb_components = 3,
146 .log2_chroma_w = 0,
147 .log2_chroma_h = 0,
bcbd9a14 148 .comp = {
4a59eca9
TB
149 { 0, 2, 1, 0, 7 }, /* R */
150 { 0, 2, 2, 0, 7 }, /* G */
151 { 0, 2, 3, 0, 7 }, /* B */
bcbd9a14 152 },
6b0768e2 153 .flags = PIX_FMT_RGB,
bcbd9a14 154 },
10151b13
SS
155 [PIX_FMT_BGR24] = {
156 .name = "bgr24",
4a59eca9
TB
157 .nb_components = 3,
158 .log2_chroma_w = 0,
159 .log2_chroma_h = 0,
10151b13 160 .comp = {
4a59eca9
TB
161 { 0, 2, 1, 0, 7 }, /* B */
162 { 0, 2, 2, 0, 7 }, /* G */
163 { 0, 2, 3, 0, 7 }, /* R */
10151b13 164 },
6b0768e2 165 .flags = PIX_FMT_RGB,
10151b13 166 },
bcbd9a14
SS
167 [PIX_FMT_YUV422P] = {
168 .name = "yuv422p",
4a59eca9
TB
169 .nb_components = 3,
170 .log2_chroma_w = 1,
171 .log2_chroma_h = 0,
9b61d838 172 .comp = {
4a59eca9
TB
173 { 0, 0, 1, 0, 7 }, /* Y */
174 { 1, 0, 1, 0, 7 }, /* U */
175 { 2, 0, 1, 0, 7 }, /* V */
9b61d838 176 },
6b0768e2 177 .flags = PIX_FMT_PLANAR,
9b61d838 178 },
10151b13
SS
179 [PIX_FMT_YUV444P] = {
180 .name = "yuv444p",
4a59eca9
TB
181 .nb_components = 3,
182 .log2_chroma_w = 0,
183 .log2_chroma_h = 0,
10151b13 184 .comp = {
4a59eca9
TB
185 { 0, 0, 1, 0, 7 }, /* Y */
186 { 1, 0, 1, 0, 7 }, /* U */
187 { 2, 0, 1, 0, 7 }, /* V */
10151b13 188 },
6b0768e2 189 .flags = PIX_FMT_PLANAR,
10151b13 190 },
9b61d838 191 [PIX_FMT_YUV410P] = {
1e896640 192 .name = "yuv410p",
4a59eca9
TB
193 .nb_components = 3,
194 .log2_chroma_w = 2,
195 .log2_chroma_h = 2,
9b61d838 196 .comp = {
4a59eca9
TB
197 { 0, 0, 1, 0, 7 }, /* Y */
198 { 1, 0, 1, 0, 7 }, /* U */
199 { 2, 0, 1, 0, 7 }, /* V */
9b61d838 200 },
6b0768e2 201 .flags = PIX_FMT_PLANAR,
9b61d838 202 },
10151b13
SS
203 [PIX_FMT_YUV411P] = {
204 .name = "yuv411p",
4a59eca9
TB
205 .nb_components = 3,
206 .log2_chroma_w = 2,
207 .log2_chroma_h = 0,
10151b13 208 .comp = {
4a59eca9
TB
209 { 0, 0, 1, 0, 7 }, /* Y */
210 { 1, 0, 1, 0, 7 }, /* U */
211 { 2, 0, 1, 0, 7 }, /* V */
10151b13 212 },
6b0768e2 213 .flags = PIX_FMT_PLANAR,
10151b13
SS
214 },
215 [PIX_FMT_GRAY8] = {
382cb115 216 .name = "gray",
4a59eca9
TB
217 .nb_components = 1,
218 .log2_chroma_w = 0,
219 .log2_chroma_h = 0,
10151b13 220 .comp = {
4a59eca9 221 { 0, 0, 1, 0, 7 }, /* Y */
10151b13
SS
222 },
223 },
224 [PIX_FMT_MONOWHITE] = {
382cb115 225 .name = "monow",
4a59eca9
TB
226 .nb_components = 1,
227 .log2_chroma_w = 0,
228 .log2_chroma_h = 0,
10151b13 229 .comp = {
4a59eca9 230 { 0, 0, 1, 0, 0 }, /* Y */
10151b13
SS
231 },
232 .flags = PIX_FMT_BITSTREAM,
233 },
bcbd9a14 234 [PIX_FMT_MONOBLACK] = {
382cb115 235 .name = "monob",
4a59eca9
TB
236 .nb_components = 1,
237 .log2_chroma_w = 0,
238 .log2_chroma_h = 0,
9b61d838 239 .comp = {
4a59eca9 240 { 0, 0, 1, 7, 0 }, /* Y */
9b61d838 241 },
bcbd9a14 242 .flags = PIX_FMT_BITSTREAM,
9b61d838 243 },
bcbd9a14
SS
244 [PIX_FMT_PAL8] = {
245 .name = "pal8",
4a59eca9
TB
246 .nb_components = 1,
247 .log2_chroma_w = 0,
248 .log2_chroma_h = 0,
9b61d838 249 .comp = {
4a59eca9 250 { 0, 0, 1, 0, 7 },
9b61d838 251 },
bcbd9a14 252 .flags = PIX_FMT_PAL,
9b61d838 253 },
10151b13
SS
254 [PIX_FMT_YUVJ420P] = {
255 .name = "yuvj420p",
4a59eca9
TB
256 .nb_components = 3,
257 .log2_chroma_w = 1,
258 .log2_chroma_h = 1,
10151b13 259 .comp = {
4a59eca9
TB
260 { 0, 0, 1, 0, 7 }, /* Y */
261 { 1, 0, 1, 0, 7 }, /* U */
262 { 2, 0, 1, 0, 7 }, /* V */
10151b13 263 },
6b0768e2 264 .flags = PIX_FMT_PLANAR,
10151b13
SS
265 },
266 [PIX_FMT_YUVJ422P] = {
267 .name = "yuvj422p",
4a59eca9
TB
268 .nb_components = 3,
269 .log2_chroma_w = 1,
270 .log2_chroma_h = 0,
10151b13 271 .comp = {
4a59eca9
TB
272 { 0, 0, 1, 0, 7 }, /* Y */
273 { 1, 0, 1, 0, 7 }, /* U */
274 { 2, 0, 1, 0, 7 }, /* V */
10151b13 275 },
6b0768e2 276 .flags = PIX_FMT_PLANAR,
10151b13
SS
277 },
278 [PIX_FMT_YUVJ444P] = {
279 .name = "yuvj444p",
4a59eca9
TB
280 .nb_components = 3,
281 .log2_chroma_w = 0,
282 .log2_chroma_h = 0,
10151b13 283 .comp = {
4a59eca9
TB
284 {0, 0, 1, 0, 7}, /* Y */
285 {1, 0, 1, 0, 7}, /* U */
286 {2, 0, 1, 0, 7}, /* V */
10151b13 287 },
6b0768e2 288 .flags = PIX_FMT_PLANAR,
10151b13 289 },
3fa70a3b 290 [PIX_FMT_XVMC_MPEG2_MC] = {
382cb115 291 .name = "xvmcmc",
3fa70a3b
SS
292 .flags = PIX_FMT_HWACCEL,
293 },
294 [PIX_FMT_XVMC_MPEG2_IDCT] = {
382cb115 295 .name = "xvmcidct",
3fa70a3b
SS
296 .flags = PIX_FMT_HWACCEL,
297 },
9b61d838 298 [PIX_FMT_UYVY422] = {
1e896640 299 .name = "uyvy422",
4a59eca9
TB
300 .nb_components = 3,
301 .log2_chroma_w = 1,
302 .log2_chroma_h = 0,
9b61d838 303 .comp = {
4a59eca9
TB
304 { 0, 1, 2, 0, 7 }, /* Y */
305 { 0, 3, 1, 0, 7 }, /* U */
306 { 0, 3, 3, 0, 7 }, /* V */
9b61d838
MN
307 },
308 },
10151b13
SS
309 [PIX_FMT_UYYVYY411] = {
310 .name = "uyyvyy411",
4a59eca9
TB
311 .nb_components = 3,
312 .log2_chroma_w = 2,
313 .log2_chroma_h = 0,
10151b13 314 .comp = {
4a59eca9
TB
315 { 0, 3, 2, 0, 7 }, /* Y */
316 { 0, 5, 1, 0, 7 }, /* U */
317 { 0, 5, 4, 0, 7 }, /* V */
10151b13
SS
318 },
319 },
320 [PIX_FMT_BGR8] = {
321 .name = "bgr8",
4a59eca9
TB
322 .nb_components = 3,
323 .log2_chroma_w = 0,
324 .log2_chroma_h = 0,
10151b13 325 .comp = {
4a59eca9
TB
326 { 0, 0, 1, 6, 1 }, /* B */
327 { 0, 0, 1, 3, 2 }, /* G */
328 { 0, 0, 1, 0, 2 }, /* R */
10151b13 329 },
38d55332 330 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13
SS
331 },
332 [PIX_FMT_BGR4] = {
333 .name = "bgr4",
4a59eca9
TB
334 .nb_components = 3,
335 .log2_chroma_w = 0,
336 .log2_chroma_h = 0,
10151b13 337 .comp = {
4a59eca9
TB
338 { 0, 3, 1, 0, 0 }, /* B */
339 { 0, 3, 2, 0, 1 }, /* G */
340 { 0, 3, 4, 0, 0 }, /* R */
10151b13 341 },
6b0768e2 342 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
10151b13
SS
343 },
344 [PIX_FMT_BGR4_BYTE] = {
345 .name = "bgr4_byte",
4a59eca9
TB
346 .nb_components = 3,
347 .log2_chroma_w = 0,
348 .log2_chroma_h = 0,
10151b13 349 .comp = {
4a59eca9
TB
350 { 0, 0, 1, 3, 0 }, /* B */
351 { 0, 0, 1, 1, 1 }, /* G */
352 { 0, 0, 1, 0, 0 }, /* R */
10151b13 353 },
38d55332 354 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13
SS
355 },
356 [PIX_FMT_RGB8] = {
357 .name = "rgb8",
4a59eca9
TB
358 .nb_components = 3,
359 .log2_chroma_w = 0,
360 .log2_chroma_h = 0,
10151b13 361 .comp = {
4a59eca9
TB
362 { 0, 0, 1, 6, 1 }, /* R */
363 { 0, 0, 1, 3, 2 }, /* G */
364 { 0, 0, 1, 0, 2 }, /* B */
10151b13 365 },
38d55332 366 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13
SS
367 },
368 [PIX_FMT_RGB4] = {
369 .name = "rgb4",
4a59eca9
TB
370 .nb_components = 3,
371 .log2_chroma_w = 0,
372 .log2_chroma_h = 0,
10151b13 373 .comp = {
4a59eca9
TB
374 { 0, 3, 1, 0, 0 }, /* R */
375 { 0, 3, 2, 0, 1 }, /* G */
376 { 0, 3, 4, 0, 0 }, /* B */
10151b13 377 },
6b0768e2 378 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
10151b13
SS
379 },
380 [PIX_FMT_RGB4_BYTE] = {
381 .name = "rgb4_byte",
4a59eca9
TB
382 .nb_components = 3,
383 .log2_chroma_w = 0,
384 .log2_chroma_h = 0,
10151b13 385 .comp = {
4a59eca9
TB
386 { 0, 0, 1, 3, 0 }, /* R */
387 { 0, 0, 1, 1, 1 }, /* G */
388 { 0, 0, 1, 0, 0 }, /* B */
10151b13 389 },
38d55332 390 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13 391 },
bcbd9a14
SS
392 [PIX_FMT_NV12] = {
393 .name = "nv12",
4a59eca9
TB
394 .nb_components = 3,
395 .log2_chroma_w = 1,
396 .log2_chroma_h = 1,
9b61d838 397 .comp = {
4a59eca9
TB
398 { 0,0,1,0,7 }, /* Y */
399 { 1,1,1,0,7 }, /* U */
400 { 1,1,2,0,7 }, /* V */
9b61d838 401 },
6b0768e2 402 .flags = PIX_FMT_PLANAR,
9b61d838 403 },
10151b13
SS
404 [PIX_FMT_NV21] = {
405 .name = "nv21",
4a59eca9
TB
406 .nb_components = 3,
407 .log2_chroma_w = 1,
408 .log2_chroma_h = 1,
10151b13 409 .comp = {
4a59eca9
TB
410 { 0, 0, 1, 0, 7 }, /* Y */
411 { 1, 1, 1, 0, 7 }, /* V */
412 { 1, 1, 2, 0, 7 }, /* U */
10151b13 413 },
6b0768e2 414 .flags = PIX_FMT_PLANAR,
10151b13
SS
415 },
416 [PIX_FMT_ARGB] = {
417 .name = "argb",
4a59eca9
TB
418 .nb_components = 4,
419 .log2_chroma_w = 0,
420 .log2_chroma_h = 0,
10151b13 421 .comp = {
4a59eca9
TB
422 { 0, 3, 1, 0, 7 }, /* A */
423 { 0, 3, 2, 0, 7 }, /* R */
424 { 0, 3, 3, 0, 7 }, /* G */
425 { 0, 3, 4, 0, 7 }, /* B */
10151b13 426 },
6b0768e2 427 .flags = PIX_FMT_RGB,
10151b13 428 },
9b61d838 429 [PIX_FMT_RGBA] = {
1e896640 430 .name = "rgba",
4a59eca9
TB
431 .nb_components = 4,
432 .log2_chroma_w = 0,
433 .log2_chroma_h = 0,
9b61d838 434 .comp = {
4a59eca9
TB
435 { 0, 3, 1, 0, 7 }, /* R */
436 { 0, 3, 2, 0, 7 }, /* G */
437 { 0, 3, 3, 0, 7 }, /* B */
438 { 0, 3, 4, 0, 7 }, /* A */
9b61d838 439 },
6b0768e2 440 .flags = PIX_FMT_RGB,
9b61d838 441 },
10151b13
SS
442 [PIX_FMT_ABGR] = {
443 .name = "abgr",
4a59eca9
TB
444 .nb_components = 4,
445 .log2_chroma_w = 0,
446 .log2_chroma_h = 0,
10151b13 447 .comp = {
4a59eca9
TB
448 { 0, 3, 1, 0, 7 }, /* A */
449 { 0, 3, 2, 0, 7 }, /* B */
450 { 0, 3, 3, 0, 7 }, /* G */
451 { 0, 3, 4, 0, 7 }, /* R */
10151b13 452 },
6b0768e2 453 .flags = PIX_FMT_RGB,
10151b13
SS
454 },
455 [PIX_FMT_BGRA] = {
456 .name = "bgra",
4a59eca9
TB
457 .nb_components = 4,
458 .log2_chroma_w = 0,
459 .log2_chroma_h = 0,
10151b13 460 .comp = {
4a59eca9
TB
461 { 0, 3, 1, 0, 7 }, /* B */
462 { 0, 3, 2, 0, 7 }, /* G */
463 { 0, 3, 3, 0, 7 }, /* R */
464 { 0, 3, 4, 0, 7 }, /* A */
10151b13 465 },
6b0768e2 466 .flags = PIX_FMT_RGB,
10151b13 467 },
bcbd9a14
SS
468 [PIX_FMT_GRAY16BE] = {
469 .name = "gray16be",
4a59eca9
TB
470 .nb_components = 1,
471 .log2_chroma_w = 0,
472 .log2_chroma_h = 0,
9b61d838 473 .comp = {
4a59eca9 474 { 0, 1, 1, 0, 15 }, /* Y */
bcbd9a14
SS
475 },
476 .flags = PIX_FMT_BE,
477 },
478 [PIX_FMT_GRAY16LE] = {
479 .name = "gray16le",
4a59eca9
TB
480 .nb_components = 1,
481 .log2_chroma_w = 0,
482 .log2_chroma_h = 0,
bcbd9a14 483 .comp = {
4a59eca9 484 { 0, 1, 1, 0, 15 }, /* Y */
9b61d838
MN
485 },
486 },
10151b13
SS
487 [PIX_FMT_YUV440P] = {
488 .name = "yuv440p",
4a59eca9
TB
489 .nb_components = 3,
490 .log2_chroma_w = 0,
491 .log2_chroma_h = 1,
10151b13 492 .comp = {
4a59eca9
TB
493 { 0, 0, 1, 0, 7 }, /* Y */
494 { 1, 0, 1, 0, 7 }, /* U */
495 { 2, 0, 1, 0, 7 }, /* V */
10151b13 496 },
6b0768e2 497 .flags = PIX_FMT_PLANAR,
10151b13
SS
498 },
499 [PIX_FMT_YUVJ440P] = {
500 .name = "yuvj440p",
4a59eca9
TB
501 .nb_components = 3,
502 .log2_chroma_w = 0,
503 .log2_chroma_h = 1,
10151b13 504 .comp = {
4a59eca9
TB
505 { 0, 0, 1, 0, 7 }, /* Y */
506 { 1, 0, 1, 0, 7 }, /* U */
507 { 2, 0, 1, 0, 7 }, /* V */
10151b13 508 },
6b0768e2 509 .flags = PIX_FMT_PLANAR,
10151b13
SS
510 },
511 [PIX_FMT_YUVA420P] = {
512 .name = "yuva420p",
4a59eca9
TB
513 .nb_components = 4,
514 .log2_chroma_w = 1,
515 .log2_chroma_h = 1,
10151b13 516 .comp = {
4a59eca9
TB
517 { 0, 0, 1, 0, 7 }, /* Y */
518 { 1, 0, 1, 0, 7 }, /* U */
519 { 2, 0, 1, 0, 7 }, /* V */
520 { 3, 0, 1, 0, 7 }, /* A */
10151b13 521 },
6b0768e2 522 .flags = PIX_FMT_PLANAR,
10151b13 523 },
3fa70a3b
SS
524 [PIX_FMT_VDPAU_H264] = {
525 .name = "vdpau_h264",
526 .log2_chroma_w = 1,
527 .log2_chroma_h = 1,
528 .flags = PIX_FMT_HWACCEL,
529 },
530 [PIX_FMT_VDPAU_MPEG1] = {
531 .name = "vdpau_mpeg1",
532 .log2_chroma_w = 1,
533 .log2_chroma_h = 1,
534 .flags = PIX_FMT_HWACCEL,
535 },
536 [PIX_FMT_VDPAU_MPEG2] = {
537 .name = "vdpau_mpeg2",
538 .log2_chroma_w = 1,
539 .log2_chroma_h = 1,
540 .flags = PIX_FMT_HWACCEL,
541 },
542 [PIX_FMT_VDPAU_WMV3] = {
543 .name = "vdpau_wmv3",
544 .log2_chroma_w = 1,
545 .log2_chroma_h = 1,
546 .flags = PIX_FMT_HWACCEL,
547 },
548 [PIX_FMT_VDPAU_VC1] = {
549 .name = "vdpau_vc1",
550 .log2_chroma_w = 1,
551 .log2_chroma_h = 1,
552 .flags = PIX_FMT_HWACCEL,
553 },
dd6308ad
CEH
554 [PIX_FMT_VDPAU_MPEG4] = {
555 .name = "vdpau_mpeg4",
556 .log2_chroma_w = 1,
557 .log2_chroma_h = 1,
558 .flags = PIX_FMT_HWACCEL,
559 },
9b61d838 560 [PIX_FMT_RGB48BE] = {
1e896640 561 .name = "rgb48be",
4a59eca9
TB
562 .nb_components = 3,
563 .log2_chroma_w = 0,
564 .log2_chroma_h = 0,
9b61d838 565 .comp = {
4a59eca9
TB
566 { 0, 5, 1, 0, 15 }, /* R */
567 { 0, 5, 3, 0, 15 }, /* G */
568 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 569 },
f7f18352 570 .flags = PIX_FMT_RGB | PIX_FMT_BE,
9b61d838 571 },
bcbd9a14
SS
572 [PIX_FMT_RGB48LE] = {
573 .name = "rgb48le",
4a59eca9
TB
574 .nb_components = 3,
575 .log2_chroma_w = 0,
576 .log2_chroma_h = 0,
9b61d838 577 .comp = {
4a59eca9
TB
578 { 0, 5, 1, 0, 15 }, /* R */
579 { 0, 5, 3, 0, 15 }, /* G */
580 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 581 },
6b0768e2 582 .flags = PIX_FMT_RGB,
9b61d838 583 },
e5681ba0 584 [PIX_FMT_RGB565BE] = {
1e896640 585 .name = "rgb565be",
4a59eca9
TB
586 .nb_components = 3,
587 .log2_chroma_w = 0,
588 .log2_chroma_h = 0,
9b61d838 589 .comp = {
4a59eca9
TB
590 { 0, 1, 0, 3, 4 }, /* R */
591 { 0, 1, 1, 5, 5 }, /* G */
592 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 593 },
6b0768e2 594 .flags = PIX_FMT_BE | PIX_FMT_RGB,
9b61d838 595 },
bcbd9a14
SS
596 [PIX_FMT_RGB565LE] = {
597 .name = "rgb565le",
4a59eca9
TB
598 .nb_components = 3,
599 .log2_chroma_w = 0,
600 .log2_chroma_h = 0,
9b61d838 601 .comp = {
4a59eca9
TB
602 { 0, 1, 2, 3, 4 }, /* R */
603 { 0, 1, 1, 5, 5 }, /* G */
604 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 605 },
6b0768e2 606 .flags = PIX_FMT_RGB,
9b61d838 607 },
10151b13
SS
608 [PIX_FMT_RGB555BE] = {
609 .name = "rgb555be",
4a59eca9
TB
610 .nb_components = 3,
611 .log2_chroma_w = 0,
612 .log2_chroma_h = 0,
10151b13 613 .comp = {
4a59eca9
TB
614 { 0, 1, 0, 2, 4 }, /* R */
615 { 0, 1, 1, 5, 4 }, /* G */
616 { 0, 1, 1, 0, 4 }, /* B */
10151b13 617 },
6b0768e2 618 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13
SS
619 },
620 [PIX_FMT_RGB555LE] = {
621 .name = "rgb555le",
4a59eca9
TB
622 .nb_components = 3,
623 .log2_chroma_w = 0,
624 .log2_chroma_h = 0,
10151b13 625 .comp = {
4a59eca9
TB
626 { 0, 1, 2, 2, 4 }, /* R */
627 { 0, 1, 1, 5, 4 }, /* G */
628 { 0, 1, 1, 0, 4 }, /* B */
10151b13 629 },
6b0768e2 630 .flags = PIX_FMT_RGB,
10151b13 631 },
2b7cf167
JK
632 [PIX_FMT_RGB444BE] = {
633 .name = "rgb444be",
4a59eca9
TB
634 .nb_components = 3,
635 .log2_chroma_w = 0,
636 .log2_chroma_h = 0,
2b7cf167 637 .comp = {
4a59eca9
TB
638 { 0, 1, 0, 0, 3 }, /* R */
639 { 0, 1, 1, 4, 3 }, /* G */
640 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 641 },
6b0768e2 642 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167
JK
643 },
644 [PIX_FMT_RGB444LE] = {
645 .name = "rgb444le",
4a59eca9
TB
646 .nb_components = 3,
647 .log2_chroma_w = 0,
648 .log2_chroma_h = 0,
2b7cf167 649 .comp = {
4a59eca9
TB
650 { 0, 1, 2, 0, 3 }, /* R */
651 { 0, 1, 1, 4, 3 }, /* G */
652 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 653 },
6b0768e2 654 .flags = PIX_FMT_RGB,
2b7cf167 655 },
73389754
PR
656 [PIX_FMT_BGR48BE] = {
657 .name = "bgr48be",
4a59eca9
TB
658 .nb_components = 3,
659 .log2_chroma_w = 0,
660 .log2_chroma_h = 0,
73389754 661 .comp = {
4a59eca9
TB
662 { 0, 5, 1, 0, 15 }, /* B */
663 { 0, 5, 3, 0, 15 }, /* G */
664 { 0, 5, 5, 0, 15 }, /* R */
73389754 665 },
6b0768e2 666 .flags = PIX_FMT_BE | PIX_FMT_RGB,
73389754
PR
667 },
668 [PIX_FMT_BGR48LE] = {
669 .name = "bgr48le",
4a59eca9
TB
670 .nb_components = 3,
671 .log2_chroma_w = 0,
672 .log2_chroma_h = 0,
73389754 673 .comp = {
4a59eca9
TB
674 { 0, 5, 1, 0, 15 }, /* B */
675 { 0, 5, 3, 0, 15 }, /* G */
676 { 0, 5, 5, 0, 15 }, /* R */
73389754 677 },
6b0768e2 678 .flags = PIX_FMT_RGB,
73389754 679 },
10151b13
SS
680 [PIX_FMT_BGR565BE] = {
681 .name = "bgr565be",
4a59eca9
TB
682 .nb_components = 3,
683 .log2_chroma_w = 0,
684 .log2_chroma_h = 0,
10151b13 685 .comp = {
4a59eca9
TB
686 { 0, 1, 0, 3, 4 }, /* B */
687 { 0, 1, 1, 5, 5 }, /* G */
688 { 0, 1, 1, 0, 4 }, /* R */
10151b13 689 },
6b0768e2 690 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13
SS
691 },
692 [PIX_FMT_BGR565LE] = {
693 .name = "bgr565le",
4a59eca9
TB
694 .nb_components = 3,
695 .log2_chroma_w = 0,
696 .log2_chroma_h = 0,
10151b13 697 .comp = {
4a59eca9
TB
698 { 0, 1, 2, 3, 4 }, /* B */
699 { 0, 1, 1, 5, 5 }, /* G */
700 { 0, 1, 1, 0, 4 }, /* R */
10151b13 701 },
6b0768e2 702 .flags = PIX_FMT_RGB,
10151b13
SS
703 },
704 [PIX_FMT_BGR555BE] = {
705 .name = "bgr555be",
4a59eca9
TB
706 .nb_components = 3,
707 .log2_chroma_w = 0,
708 .log2_chroma_h = 0,
10151b13 709 .comp = {
4a59eca9
TB
710 { 0, 1, 0, 2, 4 }, /* B */
711 { 0, 1, 1, 5, 4 }, /* G */
712 { 0, 1, 1, 0, 4 }, /* R */
10151b13 713 },
6b0768e2 714 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13
SS
715 },
716 [PIX_FMT_BGR555LE] = {
717 .name = "bgr555le",
4a59eca9
TB
718 .nb_components = 3,
719 .log2_chroma_w = 0,
720 .log2_chroma_h = 0,
10151b13 721 .comp = {
4a59eca9
TB
722 { 0, 1, 2, 2, 4 }, /* B */
723 { 0, 1, 1, 5, 4 }, /* G */
724 { 0, 1, 1, 0, 4 }, /* R */
10151b13 725 },
6b0768e2 726 .flags = PIX_FMT_RGB,
10151b13 727 },
2b7cf167
JK
728 [PIX_FMT_BGR444BE] = {
729 .name = "bgr444be",
4a59eca9
TB
730 .nb_components = 3,
731 .log2_chroma_w = 0,
732 .log2_chroma_h = 0,
2b7cf167 733 .comp = {
4a59eca9
TB
734 { 0, 1, 0, 0, 3 }, /* B */
735 { 0, 1, 1, 4, 3 }, /* G */
736 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 737 },
6b0768e2 738 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167
JK
739 },
740 [PIX_FMT_BGR444LE] = {
741 .name = "bgr444le",
4a59eca9
TB
742 .nb_components = 3,
743 .log2_chroma_w = 0,
744 .log2_chroma_h = 0,
2b7cf167 745 .comp = {
4a59eca9
TB
746 { 0, 1, 2, 0, 3 }, /* B */
747 { 0, 1, 1, 4, 3 }, /* G */
748 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 749 },
6b0768e2 750 .flags = PIX_FMT_RGB,
2b7cf167 751 },
3fa70a3b
SS
752 [PIX_FMT_VAAPI_MOCO] = {
753 .name = "vaapi_moco",
754 .log2_chroma_w = 1,
755 .log2_chroma_h = 1,
756 .flags = PIX_FMT_HWACCEL,
757 },
758 [PIX_FMT_VAAPI_IDCT] = {
759 .name = "vaapi_idct",
760 .log2_chroma_w = 1,
761 .log2_chroma_h = 1,
762 .flags = PIX_FMT_HWACCEL,
763 },
764 [PIX_FMT_VAAPI_VLD] = {
765 .name = "vaapi_vld",
766 .log2_chroma_w = 1,
767 .log2_chroma_h = 1,
768 .flags = PIX_FMT_HWACCEL,
769 },
ac3dbb4d
SZ
770 [PIX_FMT_VDA_VLD] = {
771 .name = "vda_vld",
772 .log2_chroma_w = 1,
773 .log2_chroma_h = 1,
774 .flags = PIX_FMT_HWACCEL,
775 },
42239ced
OA
776 [PIX_FMT_YUV420P9LE] = {
777 .name = "yuv420p9le",
4a59eca9
TB
778 .nb_components = 3,
779 .log2_chroma_w = 1,
780 .log2_chroma_h = 1,
42239ced 781 .comp = {
4a59eca9
TB
782 { 0, 1, 1, 0, 8 }, /* Y */
783 { 1, 1, 1, 0, 8 }, /* U */
784 { 2, 1, 1, 0, 8 }, /* V */
42239ced 785 },
6b0768e2 786 .flags = PIX_FMT_PLANAR,
42239ced
OA
787 },
788 [PIX_FMT_YUV420P9BE] = {
789 .name = "yuv420p9be",
4a59eca9
TB
790 .nb_components = 3,
791 .log2_chroma_w = 1,
792 .log2_chroma_h = 1,
42239ced 793 .comp = {
4a59eca9
TB
794 { 0, 1, 1, 0, 8 }, /* Y */
795 { 1, 1, 1, 0, 8 }, /* U */
796 { 2, 1, 1, 0, 8 }, /* V */
42239ced 797 },
6b0768e2 798 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced
OA
799 },
800 [PIX_FMT_YUV420P10LE] = {
801 .name = "yuv420p10le",
4a59eca9
TB
802 .nb_components = 3,
803 .log2_chroma_w = 1,
804 .log2_chroma_h = 1,
42239ced 805 .comp = {
4a59eca9
TB
806 { 0, 1, 1, 0, 9 }, /* Y */
807 { 1, 1, 1, 0, 9 }, /* U */
808 { 2, 1, 1, 0, 9 }, /* V */
42239ced 809 },
6b0768e2 810 .flags = PIX_FMT_PLANAR,
42239ced
OA
811 },
812 [PIX_FMT_YUV420P10BE] = {
813 .name = "yuv420p10be",
4a59eca9
TB
814 .nb_components = 3,
815 .log2_chroma_w = 1,
816 .log2_chroma_h = 1,
42239ced 817 .comp = {
4a59eca9
TB
818 { 0, 1, 1, 0, 9 }, /* Y */
819 { 1, 1, 1, 0, 9 }, /* U */
820 { 2, 1, 1, 0, 9 }, /* V */
42239ced 821 },
6b0768e2 822 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced 823 },
35f6c154
LT
824 [PIX_FMT_YUV420P16LE] = {
825 .name = "yuv420p16le",
4a59eca9
TB
826 .nb_components = 3,
827 .log2_chroma_w = 1,
828 .log2_chroma_h = 1,
75801da5 829 .comp = {
4a59eca9
TB
830 { 0, 1, 1, 0, 15 }, /* Y */
831 { 1, 1, 1, 0, 15 }, /* U */
832 { 2, 1, 1, 0, 15 }, /* V */
75801da5 833 },
6b0768e2 834 .flags = PIX_FMT_PLANAR,
75801da5 835 },
35f6c154
LT
836 [PIX_FMT_YUV420P16BE] = {
837 .name = "yuv420p16be",
4a59eca9
TB
838 .nb_components = 3,
839 .log2_chroma_w = 1,
840 .log2_chroma_h = 1,
75801da5 841 .comp = {
4a59eca9
TB
842 { 0, 1, 1, 0, 15 }, /* Y */
843 { 1, 1, 1, 0, 15 }, /* U */
844 { 2, 1, 1, 0, 15 }, /* V */
75801da5 845 },
6b0768e2 846 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 847 },
dc49bf12
RB
848 [PIX_FMT_YUV422P9LE] = {
849 .name = "yuv422p9le",
4a59eca9
TB
850 .nb_components = 3,
851 .log2_chroma_w = 1,
852 .log2_chroma_h = 0,
dc49bf12 853 .comp = {
4a59eca9
TB
854 { 0, 1, 1, 0, 8 }, /* Y */
855 { 1, 1, 1, 0, 8 }, /* U */
856 { 2, 1, 1, 0, 8 }, /* V */
dc49bf12 857 },
6b0768e2 858 .flags = PIX_FMT_PLANAR,
dc49bf12
RB
859 },
860 [PIX_FMT_YUV422P9BE] = {
861 .name = "yuv422p9be",
4a59eca9
TB
862 .nb_components = 3,
863 .log2_chroma_w = 1,
864 .log2_chroma_h = 0,
dc49bf12
RB
865 .comp = {
866 {0,1,1,0,8}, /* Y */
867 {1,1,1,0,8}, /* U */
868 {2,1,1,0,8}, /* V */
869 },
6b0768e2 870 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
dc49bf12 871 },
5c511ad4
BC
872 [PIX_FMT_YUV422P10LE] = {
873 .name = "yuv422p10le",
4a59eca9
TB
874 .nb_components = 3,
875 .log2_chroma_w = 1,
876 .log2_chroma_h = 0,
5c511ad4 877 .comp = {
4a59eca9
TB
878 { 0, 1, 1, 0, 9 }, /* Y */
879 { 1, 1, 1, 0, 9 }, /* U */
880 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 881 },
6b0768e2 882 .flags = PIX_FMT_PLANAR,
5c511ad4
BC
883 },
884 [PIX_FMT_YUV422P10BE] = {
885 .name = "yuv422p10be",
4a59eca9
TB
886 .nb_components = 3,
887 .log2_chroma_w = 1,
888 .log2_chroma_h = 0,
5c511ad4 889 .comp = {
4a59eca9
TB
890 { 0, 1, 1, 0, 9 }, /* Y */
891 { 1, 1, 1, 0, 9 }, /* U */
892 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 893 },
6b0768e2 894 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
5c511ad4 895 },
35f6c154
LT
896 [PIX_FMT_YUV422P16LE] = {
897 .name = "yuv422p16le",
4a59eca9
TB
898 .nb_components = 3,
899 .log2_chroma_w = 1,
900 .log2_chroma_h = 0,
75801da5 901 .comp = {
4a59eca9
TB
902 { 0, 1, 1, 0, 15 }, /* Y */
903 { 1, 1, 1, 0, 15 }, /* U */
904 { 2, 1, 1, 0, 15 }, /* V */
75801da5 905 },
6b0768e2 906 .flags = PIX_FMT_PLANAR,
75801da5 907 },
35f6c154
LT
908 [PIX_FMT_YUV422P16BE] = {
909 .name = "yuv422p16be",
4a59eca9
TB
910 .nb_components = 3,
911 .log2_chroma_w = 1,
912 .log2_chroma_h = 0,
75801da5 913 .comp = {
4a59eca9
TB
914 { 0, 1, 1, 0, 15 }, /* Y */
915 { 1, 1, 1, 0, 15 }, /* U */
916 { 2, 1, 1, 0, 15 }, /* V */
75801da5 917 },
6b0768e2 918 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 919 },
35f6c154
LT
920 [PIX_FMT_YUV444P16LE] = {
921 .name = "yuv444p16le",
4a59eca9
TB
922 .nb_components = 3,
923 .log2_chroma_w = 0,
924 .log2_chroma_h = 0,
75801da5 925 .comp = {
4a59eca9
TB
926 { 0, 1, 1, 0, 15 }, /* Y */
927 { 1, 1, 1, 0, 15 }, /* U */
928 { 2, 1, 1, 0, 15 }, /* V */
75801da5 929 },
6b0768e2 930 .flags = PIX_FMT_PLANAR,
75801da5 931 },
35f6c154
LT
932 [PIX_FMT_YUV444P16BE] = {
933 .name = "yuv444p16be",
4a59eca9
TB
934 .nb_components = 3,
935 .log2_chroma_w = 0,
936 .log2_chroma_h = 0,
75801da5 937 .comp = {
4a59eca9
TB
938 { 0, 1, 1, 0, 15 }, /* Y */
939 { 1, 1, 1, 0, 15 }, /* U */
940 { 2, 1, 1, 0, 15 }, /* V */
75801da5 941 },
6b0768e2 942 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 943 },
103278f7
RB
944 [PIX_FMT_YUV444P10LE] = {
945 .name = "yuv444p10le",
4a59eca9
TB
946 .nb_components = 3,
947 .log2_chroma_w = 0,
948 .log2_chroma_h = 0,
103278f7 949 .comp = {
4a59eca9
TB
950 { 0, 1, 1, 0, 9 }, /* Y */
951 { 1, 1, 1, 0, 9 }, /* U */
952 { 2, 1, 1, 0, 9 }, /* V */
103278f7 953 },
6b0768e2 954 .flags = PIX_FMT_PLANAR,
103278f7
RB
955 },
956 [PIX_FMT_YUV444P10BE] = {
957 .name = "yuv444p10be",
4a59eca9
TB
958 .nb_components = 3,
959 .log2_chroma_w = 0,
960 .log2_chroma_h = 0,
103278f7 961 .comp = {
4a59eca9
TB
962 { 0, 1, 1, 0, 9 }, /* Y */
963 { 1, 1, 1, 0, 9 }, /* U */
964 { 2, 1, 1, 0, 9 }, /* V */
103278f7 965 },
6b0768e2 966 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7
RB
967 },
968 [PIX_FMT_YUV444P9LE] = {
969 .name = "yuv444p9le",
4a59eca9
TB
970 .nb_components = 3,
971 .log2_chroma_w = 0,
972 .log2_chroma_h = 0,
103278f7 973 .comp = {
4a59eca9
TB
974 { 0, 1, 1, 0, 8 }, /* Y */
975 { 1, 1, 1, 0, 8 }, /* U */
976 { 2, 1, 1, 0, 8 }, /* V */
103278f7 977 },
6b0768e2 978 .flags = PIX_FMT_PLANAR,
103278f7
RB
979 },
980 [PIX_FMT_YUV444P9BE] = {
981 .name = "yuv444p9be",
4a59eca9
TB
982 .nb_components = 3,
983 .log2_chroma_w = 0,
984 .log2_chroma_h = 0,
103278f7 985 .comp = {
4a59eca9
TB
986 { 0, 1, 1, 0, 8 }, /* Y */
987 { 1, 1, 1, 0, 8 }, /* U */
988 { 2, 1, 1, 0, 8 }, /* V */
103278f7 989 },
6b0768e2 990 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7 991 },
92c6a099
LA
992 [PIX_FMT_DXVA2_VLD] = {
993 .name = "dxva2_vld",
994 .log2_chroma_w = 1,
995 .log2_chroma_h = 1,
996 .flags = PIX_FMT_HWACCEL,
997 },
4744f896
998 [PIX_FMT_Y400A] = {
999 .name = "y400a",
4a59eca9 1000 .nb_components = 2,
4744f896 1001 .comp = {
4a59eca9
TB
1002 { 0, 1, 1, 0, 7 }, /* Y */
1003 { 0, 1, 2, 0, 7 }, /* A */
4744f896
1004 },
1005 },
bd97b2e1
RB
1006 [PIX_FMT_GBRP] = {
1007 .name = "gbrp",
4a59eca9
TB
1008 .nb_components = 3,
1009 .log2_chroma_w = 0,
1010 .log2_chroma_h = 0,
bd97b2e1 1011 .comp = {
4a59eca9
TB
1012 { 0, 0, 1, 0, 7 }, /* G */
1013 { 1, 0, 1, 0, 7 }, /* B */
1014 { 2, 0, 1, 0, 7 }, /* R */
bd97b2e1 1015 },
6b0768e2 1016 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1
RB
1017 },
1018 [PIX_FMT_GBRP9LE] = {
1019 .name = "gbrp9le",
4a59eca9
TB
1020 .nb_components = 3,
1021 .log2_chroma_w = 0,
1022 .log2_chroma_h = 0,
bd97b2e1 1023 .comp = {
4a59eca9
TB
1024 { 0, 1, 1, 0, 8 }, /* G */
1025 { 1, 1, 1, 0, 8 }, /* B */
1026 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1027 },
6b0768e2 1028 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1
RB
1029 },
1030 [PIX_FMT_GBRP9BE] = {
1031 .name = "gbrp9be",
4a59eca9
TB
1032 .nb_components = 3,
1033 .log2_chroma_w = 0,
1034 .log2_chroma_h = 0,
bd97b2e1 1035 .comp = {
4a59eca9
TB
1036 { 0, 1, 1, 0, 8 }, /* G */
1037 { 1, 1, 1, 0, 8 }, /* B */
1038 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1039 },
6b0768e2 1040 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1
RB
1041 },
1042 [PIX_FMT_GBRP10LE] = {
1043 .name = "gbrp10le",
4a59eca9
TB
1044 .nb_components = 3,
1045 .log2_chroma_w = 0,
1046 .log2_chroma_h = 0,
bd97b2e1 1047 .comp = {
4a59eca9
TB
1048 { 0, 1, 1, 0, 9 }, /* G */
1049 { 1, 1, 1, 0, 9 }, /* B */
1050 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1051 },
6b0768e2 1052 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1
RB
1053 },
1054 [PIX_FMT_GBRP10BE] = {
1055 .name = "gbrp10be",
4a59eca9
TB
1056 .nb_components = 3,
1057 .log2_chroma_w = 0,
1058 .log2_chroma_h = 0,
bd97b2e1 1059 .comp = {
4a59eca9
TB
1060 { 0, 1, 1, 0, 9 }, /* G */
1061 { 1, 1, 1, 0, 9 }, /* B */
1062 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1063 },
6b0768e2 1064 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1
RB
1065 },
1066 [PIX_FMT_GBRP16LE] = {
1067 .name = "gbrp16le",
4a59eca9
TB
1068 .nb_components = 3,
1069 .log2_chroma_w = 0,
1070 .log2_chroma_h = 0,
bd97b2e1 1071 .comp = {
4a59eca9
TB
1072 { 0, 1, 1, 0, 15 }, /* G */
1073 { 1, 1, 1, 0, 15 }, /* B */
1074 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1075 },
6b0768e2 1076 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1
RB
1077 },
1078 [PIX_FMT_GBRP16BE] = {
1079 .name = "gbrp16be",
4a59eca9
TB
1080 .nb_components = 3,
1081 .log2_chroma_w = 0,
1082 .log2_chroma_h = 0,
bd97b2e1 1083 .comp = {
4a59eca9
TB
1084 { 0, 1, 1, 0, 15 }, /* G */
1085 { 1, 1, 1, 0, 15 }, /* B */
1086 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1087 },
6b0768e2 1088 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1089 },
9b61d838 1090};
5efccce2 1091
80a07f6e
SS
1092static enum PixelFormat get_pix_fmt_internal(const char *name)
1093{
1094 enum PixelFormat pix_fmt;
1095
1096 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
1097 if (av_pix_fmt_descriptors[pix_fmt].name &&
1098 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1099 return pix_fmt;
1100
1101 return PIX_FMT_NONE;
1102}
1103
8f653e28
SS
1104const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
1105{
1106 return (unsigned)pix_fmt < PIX_FMT_NB ?
1107 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1108}
1109
80a07f6e
SS
1110#if HAVE_BIGENDIAN
1111# define X_NE(be, le) be
1112#else
1113# define X_NE(be, le) le
1114#endif
1115
1116enum PixelFormat av_get_pix_fmt(const char *name)
1117{
1118 enum PixelFormat pix_fmt;
1119
1120 if (!strcmp(name, "rgb32"))
1121 name = X_NE("argb", "bgra");
1122 else if (!strcmp(name, "bgr32"))
1123 name = X_NE("abgr", "rgba");
1124
1125 pix_fmt = get_pix_fmt_internal(name);
1126 if (pix_fmt == PIX_FMT_NONE) {
1127 char name2[32];
1128
1129 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1130 pix_fmt = get_pix_fmt_internal(name2);
1131 }
1132 return pix_fmt;
1133}
1134
5efccce2
SS
1135int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1136{
1137 int c, bits = 0;
1138 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1139
b8873c2a 1140 for (c = 0; c < pixdesc->nb_components; c++) {
4a59eca9
TB
1141 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1142 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
5efccce2
SS
1143 }
1144
1145 return bits >> log2_pixels;
1146}
bb4afa13
SS
1147
1148char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
1149{
1150 /* print header */
1151 if (pix_fmt < 0) {
4a59eca9 1152 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
bb4afa13
SS
1153 } else {
1154 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
4a59eca9
TB
1155 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1156 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
bb4afa13
SS
1157 }
1158
1159 return buf;
1160}