lavu,lavd: do not use av_pix_fmt_descriptors directly.
[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>
d2fcb356
AK
24
25#include "common.h"
51135d1d 26#include "pixfmt.h"
9b61d838
MN
27#include "pixdesc.h"
28
f47a7cb7
SS
29#include "intreadwrite.h"
30
a6842670
LB
31void av_read_image_line(uint16_t *dst,
32 const uint8_t *data[4], const int linesize[4],
33 const AVPixFmtDescriptor *desc,
34 int x, int y, int c, int w,
4a59eca9 35 int read_pal_component)
f47a7cb7 36{
4a59eca9
TB
37 AVComponentDescriptor comp = desc->comp[c];
38 int plane = comp.plane;
39 int depth = comp.depth_minus1 + 1;
40 int mask = (1 << depth) - 1;
41 int shift = comp.shift;
42 int step = comp.step_minus1 + 1;
43 int flags = desc->flags;
f47a7cb7 44
4a59eca9
TB
45 if (flags & PIX_FMT_BITSTREAM) {
46 int skip = x * step + comp.offset_plus1 - 1;
47 const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
48 int shift = 8 - depth - (skip & 7);
f47a7cb7 49
4a59eca9 50 while (w--) {
f47a7cb7 51 int val = (*p >> shift) & mask;
4a59eca9
TB
52 if (read_pal_component)
53 val = data[1][4*val + c];
f47a7cb7 54 shift -= step;
4a59eca9 55 p -= shift >> 3;
f47a7cb7 56 shift &= 7;
4a59eca9 57 *dst++ = val;
f47a7cb7
SS
58 }
59 } else {
a6842670
LB
60 const uint8_t *p = data[plane] + y * linesize[plane] +
61 x * step + comp.offset_plus1 - 1;
4660143a 62 int is_8bit = shift + depth <= 8;
f47a7cb7 63
4660143a 64 if (is_8bit)
9525243f 65 p += !!(flags & PIX_FMT_BE);
4660143a 66
4a59eca9 67 while (w--) {
9525243f
MR
68 int val = is_8bit ? *p :
69 flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
4a59eca9
TB
70 val = (val >> shift) & mask;
71 if (read_pal_component)
72 val = data[1][4 * val + c];
73 p += step;
74 *dst++ = val;
f47a7cb7
SS
75 }
76 }
77}
78
a6842670
LB
79void av_write_image_line(const uint16_t *src,
80 uint8_t *data[4], const int linesize[4],
81 const AVPixFmtDescriptor *desc,
82 int x, int y, int c, int w)
f47a7cb7
SS
83{
84 AVComponentDescriptor comp = desc->comp[c];
85 int plane = comp.plane;
4a59eca9
TB
86 int depth = comp.depth_minus1 + 1;
87 int step = comp.step_minus1 + 1;
f47a7cb7
SS
88 int flags = desc->flags;
89
90 if (flags & PIX_FMT_BITSTREAM) {
4a59eca9
TB
91 int skip = x * step + comp.offset_plus1 - 1;
92 uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
93 int shift = 8 - depth - (skip & 7);
f47a7cb7
SS
94
95 while (w--) {
96 *p |= *src++ << shift;
97 shift -= step;
4a59eca9 98 p -= shift >> 3;
f47a7cb7
SS
99 shift &= 7;
100 }
101 } else {
102 int shift = comp.shift;
a6842670
LB
103 uint8_t *p = data[plane] + y * linesize[plane] +
104 x * step + comp.offset_plus1 - 1;
f47a7cb7 105
9525243f
MR
106 if (shift + depth <= 8) {
107 p += !!(flags & PIX_FMT_BE);
108 while (w--) {
4a59eca9 109 *p |= (*src++ << shift);
9525243f
MR
110 p += step;
111 }
112 } else {
78b19cf0
MR
113 while (w--) {
114 if (flags & PIX_FMT_BE) {
4a59eca9 115 uint16_t val = AV_RB16(p) | (*src++ << shift);
78b19cf0
MR
116 AV_WB16(p, val);
117 } else {
4a59eca9 118 uint16_t val = AV_RL16(p) | (*src++ << shift);
78b19cf0
MR
119 AV_WL16(p, val);
120 }
4a59eca9 121 p += step;
f47a7cb7 122 }
9525243f 123 }
f47a7cb7
SS
124 }
125}
126
d2fcb356
AK
127#if !FF_API_PIX_FMT_DESC
128static
129#endif
716d413c
AK
130const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
131 [AV_PIX_FMT_YUV420P] = {
bcbd9a14 132 .name = "yuv420p",
4a59eca9
TB
133 .nb_components = 3,
134 .log2_chroma_w = 1,
135 .log2_chroma_h = 1,
9b61d838 136 .comp = {
4a59eca9
TB
137 { 0, 0, 1, 0, 7 }, /* Y */
138 { 1, 0, 1, 0, 7 }, /* U */
139 { 2, 0, 1, 0, 7 }, /* V */
9b61d838 140 },
6b0768e2 141 .flags = PIX_FMT_PLANAR,
9b61d838 142 },
716d413c 143 [AV_PIX_FMT_YUYV422] = {
bcbd9a14 144 .name = "yuyv422",
4a59eca9
TB
145 .nb_components = 3,
146 .log2_chroma_w = 1,
147 .log2_chroma_h = 0,
bcbd9a14 148 .comp = {
4a59eca9
TB
149 { 0, 1, 1, 0, 7 }, /* Y */
150 { 0, 3, 2, 0, 7 }, /* U */
151 { 0, 3, 4, 0, 7 }, /* V */
bcbd9a14
SS
152 },
153 },
716d413c 154 [AV_PIX_FMT_RGB24] = {
bcbd9a14 155 .name = "rgb24",
4a59eca9
TB
156 .nb_components = 3,
157 .log2_chroma_w = 0,
158 .log2_chroma_h = 0,
bcbd9a14 159 .comp = {
4a59eca9
TB
160 { 0, 2, 1, 0, 7 }, /* R */
161 { 0, 2, 2, 0, 7 }, /* G */
162 { 0, 2, 3, 0, 7 }, /* B */
bcbd9a14 163 },
6b0768e2 164 .flags = PIX_FMT_RGB,
bcbd9a14 165 },
716d413c 166 [AV_PIX_FMT_BGR24] = {
10151b13 167 .name = "bgr24",
4a59eca9
TB
168 .nb_components = 3,
169 .log2_chroma_w = 0,
170 .log2_chroma_h = 0,
10151b13 171 .comp = {
4a59eca9
TB
172 { 0, 2, 1, 0, 7 }, /* B */
173 { 0, 2, 2, 0, 7 }, /* G */
174 { 0, 2, 3, 0, 7 }, /* R */
10151b13 175 },
6b0768e2 176 .flags = PIX_FMT_RGB,
10151b13 177 },
716d413c 178 [AV_PIX_FMT_YUV422P] = {
bcbd9a14 179 .name = "yuv422p",
4a59eca9
TB
180 .nb_components = 3,
181 .log2_chroma_w = 1,
182 .log2_chroma_h = 0,
9b61d838 183 .comp = {
4a59eca9
TB
184 { 0, 0, 1, 0, 7 }, /* Y */
185 { 1, 0, 1, 0, 7 }, /* U */
186 { 2, 0, 1, 0, 7 }, /* V */
9b61d838 187 },
6b0768e2 188 .flags = PIX_FMT_PLANAR,
9b61d838 189 },
716d413c 190 [AV_PIX_FMT_YUV444P] = {
10151b13 191 .name = "yuv444p",
4a59eca9
TB
192 .nb_components = 3,
193 .log2_chroma_w = 0,
194 .log2_chroma_h = 0,
10151b13 195 .comp = {
4a59eca9
TB
196 { 0, 0, 1, 0, 7 }, /* Y */
197 { 1, 0, 1, 0, 7 }, /* U */
198 { 2, 0, 1, 0, 7 }, /* V */
10151b13 199 },
6b0768e2 200 .flags = PIX_FMT_PLANAR,
10151b13 201 },
716d413c 202 [AV_PIX_FMT_YUV410P] = {
1e896640 203 .name = "yuv410p",
4a59eca9
TB
204 .nb_components = 3,
205 .log2_chroma_w = 2,
206 .log2_chroma_h = 2,
9b61d838 207 .comp = {
4a59eca9
TB
208 { 0, 0, 1, 0, 7 }, /* Y */
209 { 1, 0, 1, 0, 7 }, /* U */
210 { 2, 0, 1, 0, 7 }, /* V */
9b61d838 211 },
6b0768e2 212 .flags = PIX_FMT_PLANAR,
9b61d838 213 },
716d413c 214 [AV_PIX_FMT_YUV411P] = {
10151b13 215 .name = "yuv411p",
4a59eca9
TB
216 .nb_components = 3,
217 .log2_chroma_w = 2,
218 .log2_chroma_h = 0,
10151b13 219 .comp = {
4a59eca9
TB
220 { 0, 0, 1, 0, 7 }, /* Y */
221 { 1, 0, 1, 0, 7 }, /* U */
222 { 2, 0, 1, 0, 7 }, /* V */
10151b13 223 },
6b0768e2 224 .flags = PIX_FMT_PLANAR,
10151b13 225 },
716d413c 226 [AV_PIX_FMT_GRAY8] = {
382cb115 227 .name = "gray",
4a59eca9
TB
228 .nb_components = 1,
229 .log2_chroma_w = 0,
230 .log2_chroma_h = 0,
10151b13 231 .comp = {
4a59eca9 232 { 0, 0, 1, 0, 7 }, /* Y */
10151b13
SS
233 },
234 },
716d413c 235 [AV_PIX_FMT_MONOWHITE] = {
382cb115 236 .name = "monow",
4a59eca9
TB
237 .nb_components = 1,
238 .log2_chroma_w = 0,
239 .log2_chroma_h = 0,
10151b13 240 .comp = {
4a59eca9 241 { 0, 0, 1, 0, 0 }, /* Y */
10151b13
SS
242 },
243 .flags = PIX_FMT_BITSTREAM,
244 },
716d413c 245 [AV_PIX_FMT_MONOBLACK] = {
382cb115 246 .name = "monob",
4a59eca9
TB
247 .nb_components = 1,
248 .log2_chroma_w = 0,
249 .log2_chroma_h = 0,
9b61d838 250 .comp = {
4a59eca9 251 { 0, 0, 1, 7, 0 }, /* Y */
9b61d838 252 },
bcbd9a14 253 .flags = PIX_FMT_BITSTREAM,
9b61d838 254 },
716d413c 255 [AV_PIX_FMT_PAL8] = {
bcbd9a14 256 .name = "pal8",
4a59eca9
TB
257 .nb_components = 1,
258 .log2_chroma_w = 0,
259 .log2_chroma_h = 0,
9b61d838 260 .comp = {
4a59eca9 261 { 0, 0, 1, 0, 7 },
9b61d838 262 },
bcbd9a14 263 .flags = PIX_FMT_PAL,
9b61d838 264 },
716d413c 265 [AV_PIX_FMT_YUVJ420P] = {
10151b13 266 .name = "yuvj420p",
4a59eca9
TB
267 .nb_components = 3,
268 .log2_chroma_w = 1,
269 .log2_chroma_h = 1,
10151b13 270 .comp = {
4a59eca9
TB
271 { 0, 0, 1, 0, 7 }, /* Y */
272 { 1, 0, 1, 0, 7 }, /* U */
273 { 2, 0, 1, 0, 7 }, /* V */
10151b13 274 },
6b0768e2 275 .flags = PIX_FMT_PLANAR,
10151b13 276 },
716d413c 277 [AV_PIX_FMT_YUVJ422P] = {
10151b13 278 .name = "yuvj422p",
4a59eca9
TB
279 .nb_components = 3,
280 .log2_chroma_w = 1,
281 .log2_chroma_h = 0,
10151b13 282 .comp = {
4a59eca9
TB
283 { 0, 0, 1, 0, 7 }, /* Y */
284 { 1, 0, 1, 0, 7 }, /* U */
285 { 2, 0, 1, 0, 7 }, /* V */
10151b13 286 },
6b0768e2 287 .flags = PIX_FMT_PLANAR,
10151b13 288 },
716d413c 289 [AV_PIX_FMT_YUVJ444P] = {
10151b13 290 .name = "yuvj444p",
4a59eca9
TB
291 .nb_components = 3,
292 .log2_chroma_w = 0,
293 .log2_chroma_h = 0,
10151b13 294 .comp = {
4a59eca9
TB
295 {0, 0, 1, 0, 7}, /* Y */
296 {1, 0, 1, 0, 7}, /* U */
297 {2, 0, 1, 0, 7}, /* V */
10151b13 298 },
6b0768e2 299 .flags = PIX_FMT_PLANAR,
10151b13 300 },
716d413c 301 [AV_PIX_FMT_XVMC_MPEG2_MC] = {
382cb115 302 .name = "xvmcmc",
3fa70a3b
SS
303 .flags = PIX_FMT_HWACCEL,
304 },
716d413c 305 [AV_PIX_FMT_XVMC_MPEG2_IDCT] = {
382cb115 306 .name = "xvmcidct",
3fa70a3b
SS
307 .flags = PIX_FMT_HWACCEL,
308 },
716d413c 309 [AV_PIX_FMT_UYVY422] = {
1e896640 310 .name = "uyvy422",
4a59eca9
TB
311 .nb_components = 3,
312 .log2_chroma_w = 1,
313 .log2_chroma_h = 0,
9b61d838 314 .comp = {
4a59eca9
TB
315 { 0, 1, 2, 0, 7 }, /* Y */
316 { 0, 3, 1, 0, 7 }, /* U */
317 { 0, 3, 3, 0, 7 }, /* V */
9b61d838
MN
318 },
319 },
716d413c 320 [AV_PIX_FMT_UYYVYY411] = {
10151b13 321 .name = "uyyvyy411",
4a59eca9
TB
322 .nb_components = 3,
323 .log2_chroma_w = 2,
324 .log2_chroma_h = 0,
10151b13 325 .comp = {
4a59eca9
TB
326 { 0, 3, 2, 0, 7 }, /* Y */
327 { 0, 5, 1, 0, 7 }, /* U */
328 { 0, 5, 4, 0, 7 }, /* V */
10151b13
SS
329 },
330 },
716d413c 331 [AV_PIX_FMT_BGR8] = {
10151b13 332 .name = "bgr8",
4a59eca9
TB
333 .nb_components = 3,
334 .log2_chroma_w = 0,
335 .log2_chroma_h = 0,
10151b13 336 .comp = {
4a59eca9
TB
337 { 0, 0, 1, 6, 1 }, /* B */
338 { 0, 0, 1, 3, 2 }, /* G */
339 { 0, 0, 1, 0, 2 }, /* R */
10151b13 340 },
38d55332 341 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13 342 },
716d413c 343 [AV_PIX_FMT_BGR4] = {
10151b13 344 .name = "bgr4",
4a59eca9
TB
345 .nb_components = 3,
346 .log2_chroma_w = 0,
347 .log2_chroma_h = 0,
10151b13 348 .comp = {
4a59eca9
TB
349 { 0, 3, 1, 0, 0 }, /* B */
350 { 0, 3, 2, 0, 1 }, /* G */
351 { 0, 3, 4, 0, 0 }, /* R */
10151b13 352 },
6b0768e2 353 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
10151b13 354 },
716d413c 355 [AV_PIX_FMT_BGR4_BYTE] = {
10151b13 356 .name = "bgr4_byte",
4a59eca9
TB
357 .nb_components = 3,
358 .log2_chroma_w = 0,
359 .log2_chroma_h = 0,
10151b13 360 .comp = {
4a59eca9
TB
361 { 0, 0, 1, 3, 0 }, /* B */
362 { 0, 0, 1, 1, 1 }, /* G */
363 { 0, 0, 1, 0, 0 }, /* R */
10151b13 364 },
38d55332 365 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13 366 },
716d413c 367 [AV_PIX_FMT_RGB8] = {
10151b13 368 .name = "rgb8",
4a59eca9
TB
369 .nb_components = 3,
370 .log2_chroma_w = 0,
371 .log2_chroma_h = 0,
10151b13 372 .comp = {
4a59eca9
TB
373 { 0, 0, 1, 6, 1 }, /* R */
374 { 0, 0, 1, 3, 2 }, /* G */
375 { 0, 0, 1, 0, 2 }, /* B */
10151b13 376 },
38d55332 377 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13 378 },
716d413c 379 [AV_PIX_FMT_RGB4] = {
10151b13 380 .name = "rgb4",
4a59eca9
TB
381 .nb_components = 3,
382 .log2_chroma_w = 0,
383 .log2_chroma_h = 0,
10151b13 384 .comp = {
4a59eca9
TB
385 { 0, 3, 1, 0, 0 }, /* R */
386 { 0, 3, 2, 0, 1 }, /* G */
387 { 0, 3, 4, 0, 0 }, /* B */
10151b13 388 },
6b0768e2 389 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
10151b13 390 },
716d413c 391 [AV_PIX_FMT_RGB4_BYTE] = {
10151b13 392 .name = "rgb4_byte",
4a59eca9
TB
393 .nb_components = 3,
394 .log2_chroma_w = 0,
395 .log2_chroma_h = 0,
10151b13 396 .comp = {
4a59eca9
TB
397 { 0, 0, 1, 3, 0 }, /* R */
398 { 0, 0, 1, 1, 1 }, /* G */
399 { 0, 0, 1, 0, 0 }, /* B */
10151b13 400 },
38d55332 401 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
10151b13 402 },
716d413c 403 [AV_PIX_FMT_NV12] = {
bcbd9a14 404 .name = "nv12",
4a59eca9
TB
405 .nb_components = 3,
406 .log2_chroma_w = 1,
407 .log2_chroma_h = 1,
9b61d838 408 .comp = {
a6842670
LB
409 { 0, 0, 1, 0, 7 }, /* Y */
410 { 1, 1, 1, 0, 7 }, /* U */
411 { 1, 1, 2, 0, 7 }, /* V */
9b61d838 412 },
6b0768e2 413 .flags = PIX_FMT_PLANAR,
9b61d838 414 },
716d413c 415 [AV_PIX_FMT_NV21] = {
10151b13 416 .name = "nv21",
4a59eca9
TB
417 .nb_components = 3,
418 .log2_chroma_w = 1,
419 .log2_chroma_h = 1,
10151b13 420 .comp = {
4a59eca9
TB
421 { 0, 0, 1, 0, 7 }, /* Y */
422 { 1, 1, 1, 0, 7 }, /* V */
423 { 1, 1, 2, 0, 7 }, /* U */
10151b13 424 },
6b0768e2 425 .flags = PIX_FMT_PLANAR,
10151b13 426 },
716d413c 427 [AV_PIX_FMT_ARGB] = {
10151b13 428 .name = "argb",
4a59eca9
TB
429 .nb_components = 4,
430 .log2_chroma_w = 0,
431 .log2_chroma_h = 0,
10151b13 432 .comp = {
4a59eca9
TB
433 { 0, 3, 1, 0, 7 }, /* A */
434 { 0, 3, 2, 0, 7 }, /* R */
435 { 0, 3, 3, 0, 7 }, /* G */
436 { 0, 3, 4, 0, 7 }, /* B */
10151b13 437 },
6b0768e2 438 .flags = PIX_FMT_RGB,
10151b13 439 },
716d413c 440 [AV_PIX_FMT_RGBA] = {
1e896640 441 .name = "rgba",
4a59eca9
TB
442 .nb_components = 4,
443 .log2_chroma_w = 0,
444 .log2_chroma_h = 0,
9b61d838 445 .comp = {
4a59eca9
TB
446 { 0, 3, 1, 0, 7 }, /* R */
447 { 0, 3, 2, 0, 7 }, /* G */
448 { 0, 3, 3, 0, 7 }, /* B */
449 { 0, 3, 4, 0, 7 }, /* A */
9b61d838 450 },
6b0768e2 451 .flags = PIX_FMT_RGB,
9b61d838 452 },
716d413c 453 [AV_PIX_FMT_ABGR] = {
10151b13 454 .name = "abgr",
4a59eca9
TB
455 .nb_components = 4,
456 .log2_chroma_w = 0,
457 .log2_chroma_h = 0,
10151b13 458 .comp = {
4a59eca9
TB
459 { 0, 3, 1, 0, 7 }, /* A */
460 { 0, 3, 2, 0, 7 }, /* B */
461 { 0, 3, 3, 0, 7 }, /* G */
462 { 0, 3, 4, 0, 7 }, /* R */
10151b13 463 },
6b0768e2 464 .flags = PIX_FMT_RGB,
10151b13 465 },
716d413c 466 [AV_PIX_FMT_BGRA] = {
10151b13 467 .name = "bgra",
4a59eca9
TB
468 .nb_components = 4,
469 .log2_chroma_w = 0,
470 .log2_chroma_h = 0,
10151b13 471 .comp = {
4a59eca9
TB
472 { 0, 3, 1, 0, 7 }, /* B */
473 { 0, 3, 2, 0, 7 }, /* G */
474 { 0, 3, 3, 0, 7 }, /* R */
475 { 0, 3, 4, 0, 7 }, /* A */
10151b13 476 },
6b0768e2 477 .flags = PIX_FMT_RGB,
10151b13 478 },
716d413c 479 [AV_PIX_FMT_GRAY16BE] = {
bcbd9a14 480 .name = "gray16be",
4a59eca9
TB
481 .nb_components = 1,
482 .log2_chroma_w = 0,
483 .log2_chroma_h = 0,
9b61d838 484 .comp = {
4a59eca9 485 { 0, 1, 1, 0, 15 }, /* Y */
bcbd9a14
SS
486 },
487 .flags = PIX_FMT_BE,
488 },
716d413c 489 [AV_PIX_FMT_GRAY16LE] = {
bcbd9a14 490 .name = "gray16le",
4a59eca9
TB
491 .nb_components = 1,
492 .log2_chroma_w = 0,
493 .log2_chroma_h = 0,
bcbd9a14 494 .comp = {
4a59eca9 495 { 0, 1, 1, 0, 15 }, /* Y */
9b61d838
MN
496 },
497 },
716d413c 498 [AV_PIX_FMT_YUV440P] = {
10151b13 499 .name = "yuv440p",
4a59eca9
TB
500 .nb_components = 3,
501 .log2_chroma_w = 0,
502 .log2_chroma_h = 1,
10151b13 503 .comp = {
4a59eca9
TB
504 { 0, 0, 1, 0, 7 }, /* Y */
505 { 1, 0, 1, 0, 7 }, /* U */
506 { 2, 0, 1, 0, 7 }, /* V */
10151b13 507 },
6b0768e2 508 .flags = PIX_FMT_PLANAR,
10151b13 509 },
716d413c 510 [AV_PIX_FMT_YUVJ440P] = {
10151b13 511 .name = "yuvj440p",
4a59eca9
TB
512 .nb_components = 3,
513 .log2_chroma_w = 0,
514 .log2_chroma_h = 1,
10151b13 515 .comp = {
4a59eca9
TB
516 { 0, 0, 1, 0, 7 }, /* Y */
517 { 1, 0, 1, 0, 7 }, /* U */
518 { 2, 0, 1, 0, 7 }, /* V */
10151b13 519 },
6b0768e2 520 .flags = PIX_FMT_PLANAR,
10151b13 521 },
716d413c 522 [AV_PIX_FMT_YUVA420P] = {
10151b13 523 .name = "yuva420p",
4a59eca9
TB
524 .nb_components = 4,
525 .log2_chroma_w = 1,
526 .log2_chroma_h = 1,
10151b13 527 .comp = {
4a59eca9
TB
528 { 0, 0, 1, 0, 7 }, /* Y */
529 { 1, 0, 1, 0, 7 }, /* U */
530 { 2, 0, 1, 0, 7 }, /* V */
531 { 3, 0, 1, 0, 7 }, /* A */
10151b13 532 },
6b0768e2 533 .flags = PIX_FMT_PLANAR,
10151b13 534 },
716d413c 535 [AV_PIX_FMT_VDPAU_H264] = {
3fa70a3b
SS
536 .name = "vdpau_h264",
537 .log2_chroma_w = 1,
538 .log2_chroma_h = 1,
539 .flags = PIX_FMT_HWACCEL,
540 },
716d413c 541 [AV_PIX_FMT_VDPAU_MPEG1] = {
3fa70a3b
SS
542 .name = "vdpau_mpeg1",
543 .log2_chroma_w = 1,
544 .log2_chroma_h = 1,
545 .flags = PIX_FMT_HWACCEL,
546 },
716d413c 547 [AV_PIX_FMT_VDPAU_MPEG2] = {
3fa70a3b
SS
548 .name = "vdpau_mpeg2",
549 .log2_chroma_w = 1,
550 .log2_chroma_h = 1,
551 .flags = PIX_FMT_HWACCEL,
552 },
716d413c 553 [AV_PIX_FMT_VDPAU_WMV3] = {
3fa70a3b
SS
554 .name = "vdpau_wmv3",
555 .log2_chroma_w = 1,
556 .log2_chroma_h = 1,
557 .flags = PIX_FMT_HWACCEL,
558 },
716d413c 559 [AV_PIX_FMT_VDPAU_VC1] = {
3fa70a3b
SS
560 .name = "vdpau_vc1",
561 .log2_chroma_w = 1,
562 .log2_chroma_h = 1,
563 .flags = PIX_FMT_HWACCEL,
564 },
716d413c 565 [AV_PIX_FMT_VDPAU_MPEG4] = {
dd6308ad
CEH
566 .name = "vdpau_mpeg4",
567 .log2_chroma_w = 1,
568 .log2_chroma_h = 1,
569 .flags = PIX_FMT_HWACCEL,
570 },
716d413c 571 [AV_PIX_FMT_RGB48BE] = {
1e896640 572 .name = "rgb48be",
4a59eca9
TB
573 .nb_components = 3,
574 .log2_chroma_w = 0,
575 .log2_chroma_h = 0,
9b61d838 576 .comp = {
4a59eca9
TB
577 { 0, 5, 1, 0, 15 }, /* R */
578 { 0, 5, 3, 0, 15 }, /* G */
579 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 580 },
f7f18352 581 .flags = PIX_FMT_RGB | PIX_FMT_BE,
9b61d838 582 },
716d413c 583 [AV_PIX_FMT_RGB48LE] = {
bcbd9a14 584 .name = "rgb48le",
4a59eca9
TB
585 .nb_components = 3,
586 .log2_chroma_w = 0,
587 .log2_chroma_h = 0,
9b61d838 588 .comp = {
4a59eca9
TB
589 { 0, 5, 1, 0, 15 }, /* R */
590 { 0, 5, 3, 0, 15 }, /* G */
591 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 592 },
6b0768e2 593 .flags = PIX_FMT_RGB,
9b61d838 594 },
716d413c 595 [AV_PIX_FMT_RGB565BE] = {
1e896640 596 .name = "rgb565be",
4a59eca9
TB
597 .nb_components = 3,
598 .log2_chroma_w = 0,
599 .log2_chroma_h = 0,
9b61d838 600 .comp = {
4a59eca9
TB
601 { 0, 1, 0, 3, 4 }, /* R */
602 { 0, 1, 1, 5, 5 }, /* G */
603 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 604 },
6b0768e2 605 .flags = PIX_FMT_BE | PIX_FMT_RGB,
9b61d838 606 },
716d413c 607 [AV_PIX_FMT_RGB565LE] = {
bcbd9a14 608 .name = "rgb565le",
4a59eca9
TB
609 .nb_components = 3,
610 .log2_chroma_w = 0,
611 .log2_chroma_h = 0,
9b61d838 612 .comp = {
4a59eca9
TB
613 { 0, 1, 2, 3, 4 }, /* R */
614 { 0, 1, 1, 5, 5 }, /* G */
615 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 616 },
6b0768e2 617 .flags = PIX_FMT_RGB,
9b61d838 618 },
716d413c 619 [AV_PIX_FMT_RGB555BE] = {
10151b13 620 .name = "rgb555be",
4a59eca9
TB
621 .nb_components = 3,
622 .log2_chroma_w = 0,
623 .log2_chroma_h = 0,
10151b13 624 .comp = {
4a59eca9
TB
625 { 0, 1, 0, 2, 4 }, /* R */
626 { 0, 1, 1, 5, 4 }, /* G */
627 { 0, 1, 1, 0, 4 }, /* B */
10151b13 628 },
6b0768e2 629 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 630 },
716d413c 631 [AV_PIX_FMT_RGB555LE] = {
10151b13 632 .name = "rgb555le",
4a59eca9
TB
633 .nb_components = 3,
634 .log2_chroma_w = 0,
635 .log2_chroma_h = 0,
10151b13 636 .comp = {
4a59eca9
TB
637 { 0, 1, 2, 2, 4 }, /* R */
638 { 0, 1, 1, 5, 4 }, /* G */
639 { 0, 1, 1, 0, 4 }, /* B */
10151b13 640 },
6b0768e2 641 .flags = PIX_FMT_RGB,
10151b13 642 },
716d413c 643 [AV_PIX_FMT_RGB444BE] = {
2b7cf167 644 .name = "rgb444be",
4a59eca9
TB
645 .nb_components = 3,
646 .log2_chroma_w = 0,
647 .log2_chroma_h = 0,
2b7cf167 648 .comp = {
4a59eca9
TB
649 { 0, 1, 0, 0, 3 }, /* R */
650 { 0, 1, 1, 4, 3 }, /* G */
651 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 652 },
6b0768e2 653 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167 654 },
716d413c 655 [AV_PIX_FMT_RGB444LE] = {
2b7cf167 656 .name = "rgb444le",
4a59eca9
TB
657 .nb_components = 3,
658 .log2_chroma_w = 0,
659 .log2_chroma_h = 0,
2b7cf167 660 .comp = {
4a59eca9
TB
661 { 0, 1, 2, 0, 3 }, /* R */
662 { 0, 1, 1, 4, 3 }, /* G */
663 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 664 },
6b0768e2 665 .flags = PIX_FMT_RGB,
2b7cf167 666 },
716d413c 667 [AV_PIX_FMT_BGR48BE] = {
73389754 668 .name = "bgr48be",
4a59eca9
TB
669 .nb_components = 3,
670 .log2_chroma_w = 0,
671 .log2_chroma_h = 0,
73389754 672 .comp = {
4a59eca9
TB
673 { 0, 5, 1, 0, 15 }, /* B */
674 { 0, 5, 3, 0, 15 }, /* G */
675 { 0, 5, 5, 0, 15 }, /* R */
73389754 676 },
6b0768e2 677 .flags = PIX_FMT_BE | PIX_FMT_RGB,
73389754 678 },
716d413c 679 [AV_PIX_FMT_BGR48LE] = {
73389754 680 .name = "bgr48le",
4a59eca9
TB
681 .nb_components = 3,
682 .log2_chroma_w = 0,
683 .log2_chroma_h = 0,
73389754 684 .comp = {
4a59eca9
TB
685 { 0, 5, 1, 0, 15 }, /* B */
686 { 0, 5, 3, 0, 15 }, /* G */
687 { 0, 5, 5, 0, 15 }, /* R */
73389754 688 },
6b0768e2 689 .flags = PIX_FMT_RGB,
73389754 690 },
716d413c 691 [AV_PIX_FMT_BGR565BE] = {
10151b13 692 .name = "bgr565be",
4a59eca9
TB
693 .nb_components = 3,
694 .log2_chroma_w = 0,
695 .log2_chroma_h = 0,
10151b13 696 .comp = {
4a59eca9
TB
697 { 0, 1, 0, 3, 4 }, /* B */
698 { 0, 1, 1, 5, 5 }, /* G */
699 { 0, 1, 1, 0, 4 }, /* R */
10151b13 700 },
6b0768e2 701 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 702 },
716d413c 703 [AV_PIX_FMT_BGR565LE] = {
10151b13 704 .name = "bgr565le",
4a59eca9
TB
705 .nb_components = 3,
706 .log2_chroma_w = 0,
707 .log2_chroma_h = 0,
10151b13 708 .comp = {
4a59eca9
TB
709 { 0, 1, 2, 3, 4 }, /* B */
710 { 0, 1, 1, 5, 5 }, /* G */
711 { 0, 1, 1, 0, 4 }, /* R */
10151b13 712 },
6b0768e2 713 .flags = PIX_FMT_RGB,
10151b13 714 },
716d413c 715 [AV_PIX_FMT_BGR555BE] = {
10151b13 716 .name = "bgr555be",
4a59eca9
TB
717 .nb_components = 3,
718 .log2_chroma_w = 0,
719 .log2_chroma_h = 0,
10151b13 720 .comp = {
4a59eca9
TB
721 { 0, 1, 0, 2, 4 }, /* B */
722 { 0, 1, 1, 5, 4 }, /* G */
723 { 0, 1, 1, 0, 4 }, /* R */
10151b13 724 },
6b0768e2 725 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 726 },
716d413c 727 [AV_PIX_FMT_BGR555LE] = {
10151b13 728 .name = "bgr555le",
4a59eca9
TB
729 .nb_components = 3,
730 .log2_chroma_w = 0,
731 .log2_chroma_h = 0,
10151b13 732 .comp = {
4a59eca9
TB
733 { 0, 1, 2, 2, 4 }, /* B */
734 { 0, 1, 1, 5, 4 }, /* G */
735 { 0, 1, 1, 0, 4 }, /* R */
10151b13 736 },
6b0768e2 737 .flags = PIX_FMT_RGB,
10151b13 738 },
716d413c 739 [AV_PIX_FMT_BGR444BE] = {
2b7cf167 740 .name = "bgr444be",
4a59eca9
TB
741 .nb_components = 3,
742 .log2_chroma_w = 0,
743 .log2_chroma_h = 0,
2b7cf167 744 .comp = {
4a59eca9
TB
745 { 0, 1, 0, 0, 3 }, /* B */
746 { 0, 1, 1, 4, 3 }, /* G */
747 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 748 },
6b0768e2 749 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167 750 },
716d413c 751 [AV_PIX_FMT_BGR444LE] = {
2b7cf167 752 .name = "bgr444le",
4a59eca9
TB
753 .nb_components = 3,
754 .log2_chroma_w = 0,
755 .log2_chroma_h = 0,
2b7cf167 756 .comp = {
4a59eca9
TB
757 { 0, 1, 2, 0, 3 }, /* B */
758 { 0, 1, 1, 4, 3 }, /* G */
759 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 760 },
6b0768e2 761 .flags = PIX_FMT_RGB,
2b7cf167 762 },
716d413c 763 [AV_PIX_FMT_VAAPI_MOCO] = {
3fa70a3b
SS
764 .name = "vaapi_moco",
765 .log2_chroma_w = 1,
766 .log2_chroma_h = 1,
767 .flags = PIX_FMT_HWACCEL,
768 },
716d413c 769 [AV_PIX_FMT_VAAPI_IDCT] = {
3fa70a3b
SS
770 .name = "vaapi_idct",
771 .log2_chroma_w = 1,
772 .log2_chroma_h = 1,
773 .flags = PIX_FMT_HWACCEL,
774 },
716d413c 775 [AV_PIX_FMT_VAAPI_VLD] = {
3fa70a3b
SS
776 .name = "vaapi_vld",
777 .log2_chroma_w = 1,
778 .log2_chroma_h = 1,
779 .flags = PIX_FMT_HWACCEL,
780 },
716d413c 781 [AV_PIX_FMT_VDA_VLD] = {
ac3dbb4d
SZ
782 .name = "vda_vld",
783 .log2_chroma_w = 1,
784 .log2_chroma_h = 1,
785 .flags = PIX_FMT_HWACCEL,
786 },
716d413c 787 [AV_PIX_FMT_YUV420P9LE] = {
42239ced 788 .name = "yuv420p9le",
4a59eca9
TB
789 .nb_components = 3,
790 .log2_chroma_w = 1,
791 .log2_chroma_h = 1,
42239ced 792 .comp = {
4a59eca9
TB
793 { 0, 1, 1, 0, 8 }, /* Y */
794 { 1, 1, 1, 0, 8 }, /* U */
795 { 2, 1, 1, 0, 8 }, /* V */
42239ced 796 },
6b0768e2 797 .flags = PIX_FMT_PLANAR,
42239ced 798 },
716d413c 799 [AV_PIX_FMT_YUV420P9BE] = {
42239ced 800 .name = "yuv420p9be",
4a59eca9
TB
801 .nb_components = 3,
802 .log2_chroma_w = 1,
803 .log2_chroma_h = 1,
42239ced 804 .comp = {
4a59eca9
TB
805 { 0, 1, 1, 0, 8 }, /* Y */
806 { 1, 1, 1, 0, 8 }, /* U */
807 { 2, 1, 1, 0, 8 }, /* V */
42239ced 808 },
6b0768e2 809 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced 810 },
716d413c 811 [AV_PIX_FMT_YUV420P10LE] = {
42239ced 812 .name = "yuv420p10le",
4a59eca9
TB
813 .nb_components = 3,
814 .log2_chroma_w = 1,
815 .log2_chroma_h = 1,
42239ced 816 .comp = {
4a59eca9
TB
817 { 0, 1, 1, 0, 9 }, /* Y */
818 { 1, 1, 1, 0, 9 }, /* U */
819 { 2, 1, 1, 0, 9 }, /* V */
42239ced 820 },
6b0768e2 821 .flags = PIX_FMT_PLANAR,
42239ced 822 },
716d413c 823 [AV_PIX_FMT_YUV420P10BE] = {
42239ced 824 .name = "yuv420p10be",
4a59eca9
TB
825 .nb_components = 3,
826 .log2_chroma_w = 1,
827 .log2_chroma_h = 1,
42239ced 828 .comp = {
4a59eca9
TB
829 { 0, 1, 1, 0, 9 }, /* Y */
830 { 1, 1, 1, 0, 9 }, /* U */
831 { 2, 1, 1, 0, 9 }, /* V */
42239ced 832 },
6b0768e2 833 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced 834 },
716d413c 835 [AV_PIX_FMT_YUV420P16LE] = {
35f6c154 836 .name = "yuv420p16le",
4a59eca9
TB
837 .nb_components = 3,
838 .log2_chroma_w = 1,
839 .log2_chroma_h = 1,
75801da5 840 .comp = {
4a59eca9
TB
841 { 0, 1, 1, 0, 15 }, /* Y */
842 { 1, 1, 1, 0, 15 }, /* U */
843 { 2, 1, 1, 0, 15 }, /* V */
75801da5 844 },
6b0768e2 845 .flags = PIX_FMT_PLANAR,
75801da5 846 },
716d413c 847 [AV_PIX_FMT_YUV420P16BE] = {
35f6c154 848 .name = "yuv420p16be",
4a59eca9
TB
849 .nb_components = 3,
850 .log2_chroma_w = 1,
851 .log2_chroma_h = 1,
75801da5 852 .comp = {
4a59eca9
TB
853 { 0, 1, 1, 0, 15 }, /* Y */
854 { 1, 1, 1, 0, 15 }, /* U */
855 { 2, 1, 1, 0, 15 }, /* V */
75801da5 856 },
6b0768e2 857 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 858 },
716d413c 859 [AV_PIX_FMT_YUV422P9LE] = {
dc49bf12 860 .name = "yuv422p9le",
4a59eca9
TB
861 .nb_components = 3,
862 .log2_chroma_w = 1,
863 .log2_chroma_h = 0,
dc49bf12 864 .comp = {
4a59eca9
TB
865 { 0, 1, 1, 0, 8 }, /* Y */
866 { 1, 1, 1, 0, 8 }, /* U */
867 { 2, 1, 1, 0, 8 }, /* V */
dc49bf12 868 },
6b0768e2 869 .flags = PIX_FMT_PLANAR,
dc49bf12 870 },
716d413c 871 [AV_PIX_FMT_YUV422P9BE] = {
dc49bf12 872 .name = "yuv422p9be",
4a59eca9
TB
873 .nb_components = 3,
874 .log2_chroma_w = 1,
875 .log2_chroma_h = 0,
dc49bf12 876 .comp = {
a6842670
LB
877 { 0, 1, 1, 0, 8 }, /* Y */
878 { 1, 1, 1, 0, 8 }, /* U */
879 { 2, 1, 1, 0, 8 }, /* V */
dc49bf12 880 },
6b0768e2 881 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
dc49bf12 882 },
716d413c 883 [AV_PIX_FMT_YUV422P10LE] = {
5c511ad4 884 .name = "yuv422p10le",
4a59eca9
TB
885 .nb_components = 3,
886 .log2_chroma_w = 1,
887 .log2_chroma_h = 0,
5c511ad4 888 .comp = {
4a59eca9
TB
889 { 0, 1, 1, 0, 9 }, /* Y */
890 { 1, 1, 1, 0, 9 }, /* U */
891 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 892 },
6b0768e2 893 .flags = PIX_FMT_PLANAR,
5c511ad4 894 },
716d413c 895 [AV_PIX_FMT_YUV422P10BE] = {
5c511ad4 896 .name = "yuv422p10be",
4a59eca9
TB
897 .nb_components = 3,
898 .log2_chroma_w = 1,
899 .log2_chroma_h = 0,
5c511ad4 900 .comp = {
4a59eca9
TB
901 { 0, 1, 1, 0, 9 }, /* Y */
902 { 1, 1, 1, 0, 9 }, /* U */
903 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 904 },
6b0768e2 905 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
5c511ad4 906 },
716d413c 907 [AV_PIX_FMT_YUV422P16LE] = {
35f6c154 908 .name = "yuv422p16le",
4a59eca9
TB
909 .nb_components = 3,
910 .log2_chroma_w = 1,
911 .log2_chroma_h = 0,
75801da5 912 .comp = {
4a59eca9
TB
913 { 0, 1, 1, 0, 15 }, /* Y */
914 { 1, 1, 1, 0, 15 }, /* U */
915 { 2, 1, 1, 0, 15 }, /* V */
75801da5 916 },
6b0768e2 917 .flags = PIX_FMT_PLANAR,
75801da5 918 },
716d413c 919 [AV_PIX_FMT_YUV422P16BE] = {
35f6c154 920 .name = "yuv422p16be",
4a59eca9
TB
921 .nb_components = 3,
922 .log2_chroma_w = 1,
923 .log2_chroma_h = 0,
75801da5 924 .comp = {
4a59eca9
TB
925 { 0, 1, 1, 0, 15 }, /* Y */
926 { 1, 1, 1, 0, 15 }, /* U */
927 { 2, 1, 1, 0, 15 }, /* V */
75801da5 928 },
6b0768e2 929 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 930 },
716d413c 931 [AV_PIX_FMT_YUV444P16LE] = {
35f6c154 932 .name = "yuv444p16le",
4a59eca9
TB
933 .nb_components = 3,
934 .log2_chroma_w = 0,
935 .log2_chroma_h = 0,
75801da5 936 .comp = {
4a59eca9
TB
937 { 0, 1, 1, 0, 15 }, /* Y */
938 { 1, 1, 1, 0, 15 }, /* U */
939 { 2, 1, 1, 0, 15 }, /* V */
75801da5 940 },
6b0768e2 941 .flags = PIX_FMT_PLANAR,
75801da5 942 },
716d413c 943 [AV_PIX_FMT_YUV444P16BE] = {
35f6c154 944 .name = "yuv444p16be",
4a59eca9
TB
945 .nb_components = 3,
946 .log2_chroma_w = 0,
947 .log2_chroma_h = 0,
75801da5 948 .comp = {
4a59eca9
TB
949 { 0, 1, 1, 0, 15 }, /* Y */
950 { 1, 1, 1, 0, 15 }, /* U */
951 { 2, 1, 1, 0, 15 }, /* V */
75801da5 952 },
6b0768e2 953 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 954 },
716d413c 955 [AV_PIX_FMT_YUV444P10LE] = {
103278f7 956 .name = "yuv444p10le",
4a59eca9
TB
957 .nb_components = 3,
958 .log2_chroma_w = 0,
959 .log2_chroma_h = 0,
103278f7 960 .comp = {
4a59eca9
TB
961 { 0, 1, 1, 0, 9 }, /* Y */
962 { 1, 1, 1, 0, 9 }, /* U */
963 { 2, 1, 1, 0, 9 }, /* V */
103278f7 964 },
6b0768e2 965 .flags = PIX_FMT_PLANAR,
103278f7 966 },
716d413c 967 [AV_PIX_FMT_YUV444P10BE] = {
103278f7 968 .name = "yuv444p10be",
4a59eca9
TB
969 .nb_components = 3,
970 .log2_chroma_w = 0,
971 .log2_chroma_h = 0,
103278f7 972 .comp = {
4a59eca9
TB
973 { 0, 1, 1, 0, 9 }, /* Y */
974 { 1, 1, 1, 0, 9 }, /* U */
975 { 2, 1, 1, 0, 9 }, /* V */
103278f7 976 },
6b0768e2 977 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7 978 },
716d413c 979 [AV_PIX_FMT_YUV444P9LE] = {
103278f7 980 .name = "yuv444p9le",
4a59eca9
TB
981 .nb_components = 3,
982 .log2_chroma_w = 0,
983 .log2_chroma_h = 0,
103278f7 984 .comp = {
4a59eca9
TB
985 { 0, 1, 1, 0, 8 }, /* Y */
986 { 1, 1, 1, 0, 8 }, /* U */
987 { 2, 1, 1, 0, 8 }, /* V */
103278f7 988 },
6b0768e2 989 .flags = PIX_FMT_PLANAR,
103278f7 990 },
716d413c 991 [AV_PIX_FMT_YUV444P9BE] = {
103278f7 992 .name = "yuv444p9be",
4a59eca9
TB
993 .nb_components = 3,
994 .log2_chroma_w = 0,
995 .log2_chroma_h = 0,
103278f7 996 .comp = {
4a59eca9
TB
997 { 0, 1, 1, 0, 8 }, /* Y */
998 { 1, 1, 1, 0, 8 }, /* U */
999 { 2, 1, 1, 0, 8 }, /* V */
103278f7 1000 },
6b0768e2 1001 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7 1002 },
716d413c 1003 [AV_PIX_FMT_DXVA2_VLD] = {
92c6a099
LA
1004 .name = "dxva2_vld",
1005 .log2_chroma_w = 1,
1006 .log2_chroma_h = 1,
1007 .flags = PIX_FMT_HWACCEL,
1008 },
716d413c 1009 [AV_PIX_FMT_Y400A] = {
4744f896 1010 .name = "y400a",
4a59eca9 1011 .nb_components = 2,
4744f896 1012 .comp = {
4a59eca9
TB
1013 { 0, 1, 1, 0, 7 }, /* Y */
1014 { 0, 1, 2, 0, 7 }, /* A */
4744f896
1015 },
1016 },
716d413c 1017 [AV_PIX_FMT_GBRP] = {
bd97b2e1 1018 .name = "gbrp",
4a59eca9
TB
1019 .nb_components = 3,
1020 .log2_chroma_w = 0,
1021 .log2_chroma_h = 0,
bd97b2e1 1022 .comp = {
4a59eca9
TB
1023 { 0, 0, 1, 0, 7 }, /* G */
1024 { 1, 0, 1, 0, 7 }, /* B */
1025 { 2, 0, 1, 0, 7 }, /* R */
bd97b2e1 1026 },
6b0768e2 1027 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1028 },
716d413c 1029 [AV_PIX_FMT_GBRP9LE] = {
bd97b2e1 1030 .name = "gbrp9le",
4a59eca9
TB
1031 .nb_components = 3,
1032 .log2_chroma_w = 0,
1033 .log2_chroma_h = 0,
bd97b2e1 1034 .comp = {
4a59eca9
TB
1035 { 0, 1, 1, 0, 8 }, /* G */
1036 { 1, 1, 1, 0, 8 }, /* B */
1037 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1038 },
6b0768e2 1039 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1040 },
716d413c 1041 [AV_PIX_FMT_GBRP9BE] = {
bd97b2e1 1042 .name = "gbrp9be",
4a59eca9
TB
1043 .nb_components = 3,
1044 .log2_chroma_w = 0,
1045 .log2_chroma_h = 0,
bd97b2e1 1046 .comp = {
4a59eca9
TB
1047 { 0, 1, 1, 0, 8 }, /* G */
1048 { 1, 1, 1, 0, 8 }, /* B */
1049 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1050 },
6b0768e2 1051 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1052 },
716d413c 1053 [AV_PIX_FMT_GBRP10LE] = {
bd97b2e1 1054 .name = "gbrp10le",
4a59eca9
TB
1055 .nb_components = 3,
1056 .log2_chroma_w = 0,
1057 .log2_chroma_h = 0,
bd97b2e1 1058 .comp = {
4a59eca9
TB
1059 { 0, 1, 1, 0, 9 }, /* G */
1060 { 1, 1, 1, 0, 9 }, /* B */
1061 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1062 },
6b0768e2 1063 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1064 },
716d413c 1065 [AV_PIX_FMT_GBRP10BE] = {
bd97b2e1 1066 .name = "gbrp10be",
4a59eca9
TB
1067 .nb_components = 3,
1068 .log2_chroma_w = 0,
1069 .log2_chroma_h = 0,
bd97b2e1 1070 .comp = {
4a59eca9
TB
1071 { 0, 1, 1, 0, 9 }, /* G */
1072 { 1, 1, 1, 0, 9 }, /* B */
1073 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1074 },
6b0768e2 1075 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1076 },
716d413c 1077 [AV_PIX_FMT_GBRP16LE] = {
bd97b2e1 1078 .name = "gbrp16le",
4a59eca9
TB
1079 .nb_components = 3,
1080 .log2_chroma_w = 0,
1081 .log2_chroma_h = 0,
bd97b2e1 1082 .comp = {
4a59eca9
TB
1083 { 0, 1, 1, 0, 15 }, /* G */
1084 { 1, 1, 1, 0, 15 }, /* B */
1085 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1086 },
6b0768e2 1087 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1088 },
716d413c 1089 [AV_PIX_FMT_GBRP16BE] = {
bd97b2e1 1090 .name = "gbrp16be",
4a59eca9
TB
1091 .nb_components = 3,
1092 .log2_chroma_w = 0,
1093 .log2_chroma_h = 0,
bd97b2e1 1094 .comp = {
4a59eca9
TB
1095 { 0, 1, 1, 0, 15 }, /* G */
1096 { 1, 1, 1, 0, 15 }, /* B */
1097 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1098 },
6b0768e2 1099 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1100 },
9b61d838 1101};
5efccce2 1102
716d413c 1103static enum AVPixelFormat get_pix_fmt_internal(const char *name)
80a07f6e 1104{
716d413c 1105 enum AVPixelFormat pix_fmt;
80a07f6e 1106
716d413c 1107 for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
80a07f6e
SS
1108 if (av_pix_fmt_descriptors[pix_fmt].name &&
1109 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1110 return pix_fmt;
1111
716d413c 1112 return AV_PIX_FMT_NONE;
80a07f6e
SS
1113}
1114
716d413c 1115const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
8f653e28 1116{
716d413c 1117 return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
8f653e28
SS
1118 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1119}
1120
80a07f6e
SS
1121#if HAVE_BIGENDIAN
1122# define X_NE(be, le) be
1123#else
1124# define X_NE(be, le) le
1125#endif
1126
716d413c 1127enum AVPixelFormat av_get_pix_fmt(const char *name)
80a07f6e 1128{
716d413c 1129 enum AVPixelFormat pix_fmt;
80a07f6e
SS
1130
1131 if (!strcmp(name, "rgb32"))
1132 name = X_NE("argb", "bgra");
1133 else if (!strcmp(name, "bgr32"))
1134 name = X_NE("abgr", "rgba");
1135
1136 pix_fmt = get_pix_fmt_internal(name);
716d413c 1137 if (pix_fmt == AV_PIX_FMT_NONE) {
80a07f6e
SS
1138 char name2[32];
1139
1140 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1141 pix_fmt = get_pix_fmt_internal(name2);
1142 }
1143 return pix_fmt;
1144}
1145
5efccce2
SS
1146int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1147{
1148 int c, bits = 0;
1149 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1150
b8873c2a 1151 for (c = 0; c < pixdesc->nb_components; c++) {
4a59eca9
TB
1152 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1153 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
5efccce2
SS
1154 }
1155
1156 return bits >> log2_pixels;
1157}
bb4afa13 1158
716d413c 1159char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt)
bb4afa13
SS
1160{
1161 /* print header */
1162 if (pix_fmt < 0) {
4a59eca9 1163 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
bb4afa13
SS
1164 } else {
1165 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
4a59eca9
TB
1166 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1167 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
bb4afa13
SS
1168 }
1169
1170 return buf;
1171}
d2fcb356
AK
1172
1173const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
1174{
1175 if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
1176 return NULL;
1177 return &av_pix_fmt_descriptors[pix_fmt];
1178}
1179
1180const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
1181{
1182 if (!prev)
1183 return &av_pix_fmt_descriptors[0];
1184 if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
1185 return prev + 1;
1186 return NULL;
1187}
1188
1189enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
1190{
1191 if (desc < av_pix_fmt_descriptors ||
1192 desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
1193 return AV_PIX_FMT_NONE;
1194
1195 return desc - av_pix_fmt_descriptors;
1196}