swscale: Use alpha from the right row in yuva2rgba_c
[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 },
cbe5a60c 438 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
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 },
cbe5a60c 451 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
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 },
cbe5a60c 464 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
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 },
cbe5a60c 477 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
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 */
6d5600e8
LB
530 { 2, 0, 1, 0, 7 }, /* V */
531 { 3, 0, 1, 0, 7 }, /* A */
532 },
cbe5a60c 533 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
6d5600e8
LB
534 },
535 [AV_PIX_FMT_YUVA422P] = {
536 .name = "yuva422p",
537 .nb_components = 4,
538 .log2_chroma_w = 1,
539 .log2_chroma_h = 0,
540 .comp = {
541 { 0, 0, 1, 0, 7 }, /* Y */
542 { 1, 0, 1, 0, 7 }, /* U */
543 { 2, 0, 1, 0, 7 }, /* V */
544 { 3, 0, 1, 0, 7 }, /* A */
545 },
cbe5a60c 546 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
6d5600e8
LB
547 },
548 [AV_PIX_FMT_YUVA444P] = {
549 .name = "yuva444p",
550 .nb_components = 4,
551 .log2_chroma_w = 0,
552 .log2_chroma_h = 0,
553 .comp = {
554 { 0, 0, 1, 0, 7 }, /* Y */
555 { 1, 0, 1, 0, 7 }, /* U */
4a59eca9
TB
556 { 2, 0, 1, 0, 7 }, /* V */
557 { 3, 0, 1, 0, 7 }, /* A */
10151b13 558 },
cbe5a60c 559 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
10151b13 560 },
7658295b
LB
561 [AV_PIX_FMT_YUVA420P9BE] = {
562 .name = "yuva420p9be",
563 .nb_components = 4,
564 .log2_chroma_w = 1,
565 .log2_chroma_h = 1,
566 .comp = {
567 { 0, 1, 1, 0, 8 }, /* Y */
568 { 1, 1, 1, 0, 8 }, /* U */
569 { 2, 1, 1, 0, 8 }, /* V */
570 { 3, 1, 1, 0, 8 }, /* A */
571 },
572 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
573 },
574 [AV_PIX_FMT_YUVA420P9LE] = {
575 .name = "yuva420p9le",
576 .nb_components = 4,
577 .log2_chroma_w = 1,
578 .log2_chroma_h = 1,
579 .comp = {
580 { 0, 1, 1, 0, 8 }, /* Y */
581 { 1, 1, 1, 0, 8 }, /* U */
582 { 2, 1, 1, 0, 8 }, /* V */
583 { 3, 1, 1, 0, 8 }, /* A */
584 },
cbe5a60c 585 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
586 },
587 [AV_PIX_FMT_YUVA422P9BE] = {
588 .name = "yuva422p9be",
589 .nb_components = 4,
590 .log2_chroma_w = 1,
591 .log2_chroma_h = 0,
592 .comp = {
593 { 0, 1, 1, 0, 8 }, /* Y */
594 { 1, 1, 1, 0, 8 }, /* U */
595 { 2, 1, 1, 0, 8 }, /* V */
596 { 3, 1, 1, 0, 8 }, /* A */
597 },
cbe5a60c 598 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
599 },
600 [AV_PIX_FMT_YUVA422P9LE] = {
601 .name = "yuva422p9le",
602 .nb_components = 4,
603 .log2_chroma_w = 1,
604 .log2_chroma_h = 0,
605 .comp = {
606 { 0, 1, 1, 0, 8 }, /* Y */
607 { 1, 1, 1, 0, 8 }, /* U */
608 { 2, 1, 1, 0, 8 }, /* V */
609 { 3, 1, 1, 0, 8 }, /* A */
610 },
cbe5a60c 611 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
612 },
613 [AV_PIX_FMT_YUVA444P9BE] = {
614 .name = "yuva444p9be",
615 .nb_components = 4,
616 .log2_chroma_w = 0,
617 .log2_chroma_h = 0,
618 .comp = {
619 { 0, 1, 1, 0, 8 }, /* Y */
620 { 1, 1, 1, 0, 8 }, /* U */
621 { 2, 1, 1, 0, 8 }, /* V */
622 { 3, 1, 1, 0, 8 }, /* A */
623 },
cbe5a60c 624 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
625 },
626 [AV_PIX_FMT_YUVA444P9LE] = {
627 .name = "yuva444p9le",
628 .nb_components = 4,
629 .log2_chroma_w = 0,
630 .log2_chroma_h = 0,
631 .comp = {
632 { 0, 1, 1, 0, 8 }, /* Y */
633 { 1, 1, 1, 0, 8 }, /* U */
634 { 2, 1, 1, 0, 8 }, /* V */
635 { 3, 1, 1, 0, 8 }, /* A */
636 },
cbe5a60c 637 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
638 },
639 [AV_PIX_FMT_YUVA420P10BE] = {
640 .name = "yuva420p10be",
641 .nb_components = 4,
642 .log2_chroma_w = 1,
643 .log2_chroma_h = 1,
644 .comp = {
645 { 0, 1, 1, 0, 9 }, /* Y */
646 { 1, 1, 1, 0, 9 }, /* U */
647 { 2, 1, 1, 0, 9 }, /* V */
648 { 3, 1, 1, 0, 9 }, /* A */
649 },
cbe5a60c 650 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
651 },
652 [AV_PIX_FMT_YUVA420P10LE] = {
653 .name = "yuva420p10le",
654 .nb_components = 4,
655 .log2_chroma_w = 1,
656 .log2_chroma_h = 1,
657 .comp = {
b519298a
PM
658 { 0, 1, 1, 0, 9 }, /* Y */
659 { 1, 1, 1, 0, 9 }, /* U */
660 { 2, 1, 1, 0, 9 }, /* V */
661 { 3, 1, 1, 0, 9 }, /* A */
7658295b 662 },
cbe5a60c 663 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
664 },
665 [AV_PIX_FMT_YUVA422P10BE] = {
666 .name = "yuva422p10be",
667 .nb_components = 4,
668 .log2_chroma_w = 1,
669 .log2_chroma_h = 0,
670 .comp = {
b519298a
PM
671 { 0, 1, 1, 0, 9 }, /* Y */
672 { 1, 1, 1, 0, 9 }, /* U */
673 { 2, 1, 1, 0, 9 }, /* V */
674 { 3, 1, 1, 0, 9 }, /* A */
7658295b 675 },
cbe5a60c 676 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
677 },
678 [AV_PIX_FMT_YUVA422P10LE] = {
679 .name = "yuva422p10le",
680 .nb_components = 4,
681 .log2_chroma_w = 1,
682 .log2_chroma_h = 0,
683 .comp = {
b519298a
PM
684 { 0, 1, 1, 0, 9 }, /* Y */
685 { 1, 1, 1, 0, 9 }, /* U */
686 { 2, 1, 1, 0, 9 }, /* V */
687 { 3, 1, 1, 0, 9 }, /* A */
7658295b 688 },
cbe5a60c 689 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
690 },
691 [AV_PIX_FMT_YUVA444P10BE] = {
692 .name = "yuva444p10be",
693 .nb_components = 4,
694 .log2_chroma_w = 0,
695 .log2_chroma_h = 0,
696 .comp = {
b519298a
PM
697 { 0, 1, 1, 0, 9 }, /* Y */
698 { 1, 1, 1, 0, 9 }, /* U */
699 { 2, 1, 1, 0, 9 }, /* V */
700 { 3, 1, 1, 0, 9 }, /* A */
7658295b 701 },
cbe5a60c 702 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
703 },
704 [AV_PIX_FMT_YUVA444P10LE] = {
705 .name = "yuva444p10le",
706 .nb_components = 4,
707 .log2_chroma_w = 0,
708 .log2_chroma_h = 0,
709 .comp = {
b519298a
PM
710 { 0, 1, 1, 0, 9 }, /* Y */
711 { 1, 1, 1, 0, 9 }, /* U */
712 { 2, 1, 1, 0, 9 }, /* V */
713 { 3, 1, 1, 0, 9 }, /* A */
7658295b 714 },
cbe5a60c 715 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
716 },
717 [AV_PIX_FMT_YUVA420P16BE] = {
718 .name = "yuva420p16be",
719 .nb_components = 4,
720 .log2_chroma_w = 1,
721 .log2_chroma_h = 1,
722 .comp = {
723 { 0, 1, 1, 0, 15 }, /* Y */
724 { 1, 1, 1, 0, 15 }, /* U */
725 { 2, 1, 1, 0, 15 }, /* V */
726 { 3, 1, 1, 0, 15 }, /* A */
727 },
cbe5a60c 728 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
729 },
730 [AV_PIX_FMT_YUVA420P16LE] = {
731 .name = "yuva420p16le",
732 .nb_components = 4,
733 .log2_chroma_w = 1,
734 .log2_chroma_h = 1,
735 .comp = {
736 { 0, 1, 1, 0, 15 }, /* Y */
737 { 1, 1, 1, 0, 15 }, /* U */
738 { 2, 1, 1, 0, 15 }, /* V */
739 { 3, 1, 1, 0, 15 }, /* A */
740 },
cbe5a60c 741 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
742 },
743 [AV_PIX_FMT_YUVA422P16BE] = {
744 .name = "yuva422p16be",
745 .nb_components = 4,
746 .log2_chroma_w = 1,
747 .log2_chroma_h = 0,
748 .comp = {
749 { 0, 1, 1, 0, 15 }, /* Y */
750 { 1, 1, 1, 0, 15 }, /* U */
751 { 2, 1, 1, 0, 15 }, /* V */
752 { 3, 1, 1, 0, 15 }, /* A */
753 },
cbe5a60c 754 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
755 },
756 [AV_PIX_FMT_YUVA422P16LE] = {
757 .name = "yuva422p16le",
758 .nb_components = 4,
759 .log2_chroma_w = 1,
760 .log2_chroma_h = 0,
761 .comp = {
762 { 0, 1, 1, 0, 15 }, /* Y */
763 { 1, 1, 1, 0, 15 }, /* U */
764 { 2, 1, 1, 0, 15 }, /* V */
765 { 3, 1, 1, 0, 15 }, /* A */
766 },
cbe5a60c 767 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
768 },
769 [AV_PIX_FMT_YUVA444P16BE] = {
770 .name = "yuva444p16be",
771 .nb_components = 4,
772 .log2_chroma_w = 0,
773 .log2_chroma_h = 0,
774 .comp = {
775 { 0, 1, 1, 0, 15 }, /* Y */
776 { 1, 1, 1, 0, 15 }, /* U */
777 { 2, 1, 1, 0, 15 }, /* V */
778 { 3, 1, 1, 0, 15 }, /* A */
779 },
cbe5a60c 780 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b
LB
781 },
782 [AV_PIX_FMT_YUVA444P16LE] = {
783 .name = "yuva444p16le",
784 .nb_components = 4,
785 .log2_chroma_w = 0,
786 .log2_chroma_h = 0,
787 .comp = {
788 { 0, 1, 1, 0, 15 }, /* Y */
789 { 1, 1, 1, 0, 15 }, /* U */
790 { 2, 1, 1, 0, 15 }, /* V */
791 { 3, 1, 1, 0, 15 }, /* A */
792 },
cbe5a60c 793 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
7658295b 794 },
716d413c 795 [AV_PIX_FMT_VDPAU_H264] = {
3fa70a3b
SS
796 .name = "vdpau_h264",
797 .log2_chroma_w = 1,
798 .log2_chroma_h = 1,
799 .flags = PIX_FMT_HWACCEL,
800 },
716d413c 801 [AV_PIX_FMT_VDPAU_MPEG1] = {
3fa70a3b
SS
802 .name = "vdpau_mpeg1",
803 .log2_chroma_w = 1,
804 .log2_chroma_h = 1,
805 .flags = PIX_FMT_HWACCEL,
806 },
716d413c 807 [AV_PIX_FMT_VDPAU_MPEG2] = {
3fa70a3b
SS
808 .name = "vdpau_mpeg2",
809 .log2_chroma_w = 1,
810 .log2_chroma_h = 1,
811 .flags = PIX_FMT_HWACCEL,
812 },
716d413c 813 [AV_PIX_FMT_VDPAU_WMV3] = {
3fa70a3b
SS
814 .name = "vdpau_wmv3",
815 .log2_chroma_w = 1,
816 .log2_chroma_h = 1,
817 .flags = PIX_FMT_HWACCEL,
818 },
716d413c 819 [AV_PIX_FMT_VDPAU_VC1] = {
3fa70a3b
SS
820 .name = "vdpau_vc1",
821 .log2_chroma_w = 1,
822 .log2_chroma_h = 1,
823 .flags = PIX_FMT_HWACCEL,
824 },
716d413c 825 [AV_PIX_FMT_VDPAU_MPEG4] = {
dd6308ad
CEH
826 .name = "vdpau_mpeg4",
827 .log2_chroma_w = 1,
828 .log2_chroma_h = 1,
829 .flags = PIX_FMT_HWACCEL,
830 },
716d413c 831 [AV_PIX_FMT_RGB48BE] = {
1e896640 832 .name = "rgb48be",
4a59eca9
TB
833 .nb_components = 3,
834 .log2_chroma_w = 0,
835 .log2_chroma_h = 0,
9b61d838 836 .comp = {
4a59eca9
TB
837 { 0, 5, 1, 0, 15 }, /* R */
838 { 0, 5, 3, 0, 15 }, /* G */
839 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 840 },
f7f18352 841 .flags = PIX_FMT_RGB | PIX_FMT_BE,
9b61d838 842 },
716d413c 843 [AV_PIX_FMT_RGB48LE] = {
bcbd9a14 844 .name = "rgb48le",
4a59eca9
TB
845 .nb_components = 3,
846 .log2_chroma_w = 0,
847 .log2_chroma_h = 0,
9b61d838 848 .comp = {
4a59eca9
TB
849 { 0, 5, 1, 0, 15 }, /* R */
850 { 0, 5, 3, 0, 15 }, /* G */
851 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 852 },
6b0768e2 853 .flags = PIX_FMT_RGB,
9b61d838 854 },
716d413c 855 [AV_PIX_FMT_RGB565BE] = {
1e896640 856 .name = "rgb565be",
4a59eca9
TB
857 .nb_components = 3,
858 .log2_chroma_w = 0,
859 .log2_chroma_h = 0,
9b61d838 860 .comp = {
4a59eca9
TB
861 { 0, 1, 0, 3, 4 }, /* R */
862 { 0, 1, 1, 5, 5 }, /* G */
863 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 864 },
6b0768e2 865 .flags = PIX_FMT_BE | PIX_FMT_RGB,
9b61d838 866 },
716d413c 867 [AV_PIX_FMT_RGB565LE] = {
bcbd9a14 868 .name = "rgb565le",
4a59eca9
TB
869 .nb_components = 3,
870 .log2_chroma_w = 0,
871 .log2_chroma_h = 0,
9b61d838 872 .comp = {
4a59eca9
TB
873 { 0, 1, 2, 3, 4 }, /* R */
874 { 0, 1, 1, 5, 5 }, /* G */
875 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 876 },
6b0768e2 877 .flags = PIX_FMT_RGB,
9b61d838 878 },
716d413c 879 [AV_PIX_FMT_RGB555BE] = {
10151b13 880 .name = "rgb555be",
4a59eca9
TB
881 .nb_components = 3,
882 .log2_chroma_w = 0,
883 .log2_chroma_h = 0,
10151b13 884 .comp = {
4a59eca9
TB
885 { 0, 1, 0, 2, 4 }, /* R */
886 { 0, 1, 1, 5, 4 }, /* G */
887 { 0, 1, 1, 0, 4 }, /* B */
10151b13 888 },
6b0768e2 889 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 890 },
716d413c 891 [AV_PIX_FMT_RGB555LE] = {
10151b13 892 .name = "rgb555le",
4a59eca9
TB
893 .nb_components = 3,
894 .log2_chroma_w = 0,
895 .log2_chroma_h = 0,
10151b13 896 .comp = {
4a59eca9
TB
897 { 0, 1, 2, 2, 4 }, /* R */
898 { 0, 1, 1, 5, 4 }, /* G */
899 { 0, 1, 1, 0, 4 }, /* B */
10151b13 900 },
6b0768e2 901 .flags = PIX_FMT_RGB,
10151b13 902 },
716d413c 903 [AV_PIX_FMT_RGB444BE] = {
2b7cf167 904 .name = "rgb444be",
4a59eca9
TB
905 .nb_components = 3,
906 .log2_chroma_w = 0,
907 .log2_chroma_h = 0,
2b7cf167 908 .comp = {
4a59eca9
TB
909 { 0, 1, 0, 0, 3 }, /* R */
910 { 0, 1, 1, 4, 3 }, /* G */
911 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 912 },
6b0768e2 913 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167 914 },
716d413c 915 [AV_PIX_FMT_RGB444LE] = {
2b7cf167 916 .name = "rgb444le",
4a59eca9
TB
917 .nb_components = 3,
918 .log2_chroma_w = 0,
919 .log2_chroma_h = 0,
2b7cf167 920 .comp = {
4a59eca9
TB
921 { 0, 1, 2, 0, 3 }, /* R */
922 { 0, 1, 1, 4, 3 }, /* G */
923 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 924 },
6b0768e2 925 .flags = PIX_FMT_RGB,
2b7cf167 926 },
716d413c 927 [AV_PIX_FMT_BGR48BE] = {
73389754 928 .name = "bgr48be",
4a59eca9
TB
929 .nb_components = 3,
930 .log2_chroma_w = 0,
931 .log2_chroma_h = 0,
73389754 932 .comp = {
4a59eca9
TB
933 { 0, 5, 1, 0, 15 }, /* B */
934 { 0, 5, 3, 0, 15 }, /* G */
935 { 0, 5, 5, 0, 15 }, /* R */
73389754 936 },
6b0768e2 937 .flags = PIX_FMT_BE | PIX_FMT_RGB,
73389754 938 },
716d413c 939 [AV_PIX_FMT_BGR48LE] = {
73389754 940 .name = "bgr48le",
4a59eca9
TB
941 .nb_components = 3,
942 .log2_chroma_w = 0,
943 .log2_chroma_h = 0,
73389754 944 .comp = {
4a59eca9
TB
945 { 0, 5, 1, 0, 15 }, /* B */
946 { 0, 5, 3, 0, 15 }, /* G */
947 { 0, 5, 5, 0, 15 }, /* R */
73389754 948 },
6b0768e2 949 .flags = PIX_FMT_RGB,
73389754 950 },
716d413c 951 [AV_PIX_FMT_BGR565BE] = {
10151b13 952 .name = "bgr565be",
4a59eca9
TB
953 .nb_components = 3,
954 .log2_chroma_w = 0,
955 .log2_chroma_h = 0,
10151b13 956 .comp = {
4a59eca9
TB
957 { 0, 1, 0, 3, 4 }, /* B */
958 { 0, 1, 1, 5, 5 }, /* G */
959 { 0, 1, 1, 0, 4 }, /* R */
10151b13 960 },
6b0768e2 961 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 962 },
716d413c 963 [AV_PIX_FMT_BGR565LE] = {
10151b13 964 .name = "bgr565le",
4a59eca9
TB
965 .nb_components = 3,
966 .log2_chroma_w = 0,
967 .log2_chroma_h = 0,
10151b13 968 .comp = {
4a59eca9
TB
969 { 0, 1, 2, 3, 4 }, /* B */
970 { 0, 1, 1, 5, 5 }, /* G */
971 { 0, 1, 1, 0, 4 }, /* R */
10151b13 972 },
6b0768e2 973 .flags = PIX_FMT_RGB,
10151b13 974 },
716d413c 975 [AV_PIX_FMT_BGR555BE] = {
10151b13 976 .name = "bgr555be",
4a59eca9
TB
977 .nb_components = 3,
978 .log2_chroma_w = 0,
979 .log2_chroma_h = 0,
10151b13 980 .comp = {
4a59eca9
TB
981 { 0, 1, 0, 2, 4 }, /* B */
982 { 0, 1, 1, 5, 4 }, /* G */
983 { 0, 1, 1, 0, 4 }, /* R */
10151b13 984 },
6b0768e2 985 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 986 },
716d413c 987 [AV_PIX_FMT_BGR555LE] = {
10151b13 988 .name = "bgr555le",
4a59eca9
TB
989 .nb_components = 3,
990 .log2_chroma_w = 0,
991 .log2_chroma_h = 0,
10151b13 992 .comp = {
4a59eca9
TB
993 { 0, 1, 2, 2, 4 }, /* B */
994 { 0, 1, 1, 5, 4 }, /* G */
995 { 0, 1, 1, 0, 4 }, /* R */
10151b13 996 },
6b0768e2 997 .flags = PIX_FMT_RGB,
10151b13 998 },
716d413c 999 [AV_PIX_FMT_BGR444BE] = {
2b7cf167 1000 .name = "bgr444be",
4a59eca9
TB
1001 .nb_components = 3,
1002 .log2_chroma_w = 0,
1003 .log2_chroma_h = 0,
2b7cf167 1004 .comp = {
4a59eca9
TB
1005 { 0, 1, 0, 0, 3 }, /* B */
1006 { 0, 1, 1, 4, 3 }, /* G */
1007 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 1008 },
6b0768e2 1009 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167 1010 },
716d413c 1011 [AV_PIX_FMT_BGR444LE] = {
2b7cf167 1012 .name = "bgr444le",
4a59eca9
TB
1013 .nb_components = 3,
1014 .log2_chroma_w = 0,
1015 .log2_chroma_h = 0,
2b7cf167 1016 .comp = {
4a59eca9
TB
1017 { 0, 1, 2, 0, 3 }, /* B */
1018 { 0, 1, 1, 4, 3 }, /* G */
1019 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 1020 },
6b0768e2 1021 .flags = PIX_FMT_RGB,
2b7cf167 1022 },
716d413c 1023 [AV_PIX_FMT_VAAPI_MOCO] = {
3fa70a3b
SS
1024 .name = "vaapi_moco",
1025 .log2_chroma_w = 1,
1026 .log2_chroma_h = 1,
1027 .flags = PIX_FMT_HWACCEL,
1028 },
716d413c 1029 [AV_PIX_FMT_VAAPI_IDCT] = {
3fa70a3b
SS
1030 .name = "vaapi_idct",
1031 .log2_chroma_w = 1,
1032 .log2_chroma_h = 1,
1033 .flags = PIX_FMT_HWACCEL,
1034 },
716d413c 1035 [AV_PIX_FMT_VAAPI_VLD] = {
3fa70a3b
SS
1036 .name = "vaapi_vld",
1037 .log2_chroma_w = 1,
1038 .log2_chroma_h = 1,
1039 .flags = PIX_FMT_HWACCEL,
1040 },
716d413c 1041 [AV_PIX_FMT_VDA_VLD] = {
ac3dbb4d
SZ
1042 .name = "vda_vld",
1043 .log2_chroma_w = 1,
1044 .log2_chroma_h = 1,
1045 .flags = PIX_FMT_HWACCEL,
1046 },
716d413c 1047 [AV_PIX_FMT_YUV420P9LE] = {
42239ced 1048 .name = "yuv420p9le",
4a59eca9
TB
1049 .nb_components = 3,
1050 .log2_chroma_w = 1,
1051 .log2_chroma_h = 1,
42239ced 1052 .comp = {
4a59eca9
TB
1053 { 0, 1, 1, 0, 8 }, /* Y */
1054 { 1, 1, 1, 0, 8 }, /* U */
1055 { 2, 1, 1, 0, 8 }, /* V */
42239ced 1056 },
6b0768e2 1057 .flags = PIX_FMT_PLANAR,
42239ced 1058 },
716d413c 1059 [AV_PIX_FMT_YUV420P9BE] = {
42239ced 1060 .name = "yuv420p9be",
4a59eca9
TB
1061 .nb_components = 3,
1062 .log2_chroma_w = 1,
1063 .log2_chroma_h = 1,
42239ced 1064 .comp = {
4a59eca9
TB
1065 { 0, 1, 1, 0, 8 }, /* Y */
1066 { 1, 1, 1, 0, 8 }, /* U */
1067 { 2, 1, 1, 0, 8 }, /* V */
42239ced 1068 },
6b0768e2 1069 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced 1070 },
716d413c 1071 [AV_PIX_FMT_YUV420P10LE] = {
42239ced 1072 .name = "yuv420p10le",
4a59eca9
TB
1073 .nb_components = 3,
1074 .log2_chroma_w = 1,
1075 .log2_chroma_h = 1,
42239ced 1076 .comp = {
4a59eca9
TB
1077 { 0, 1, 1, 0, 9 }, /* Y */
1078 { 1, 1, 1, 0, 9 }, /* U */
1079 { 2, 1, 1, 0, 9 }, /* V */
42239ced 1080 },
6b0768e2 1081 .flags = PIX_FMT_PLANAR,
42239ced 1082 },
716d413c 1083 [AV_PIX_FMT_YUV420P10BE] = {
42239ced 1084 .name = "yuv420p10be",
4a59eca9
TB
1085 .nb_components = 3,
1086 .log2_chroma_w = 1,
1087 .log2_chroma_h = 1,
42239ced 1088 .comp = {
4a59eca9
TB
1089 { 0, 1, 1, 0, 9 }, /* Y */
1090 { 1, 1, 1, 0, 9 }, /* U */
1091 { 2, 1, 1, 0, 9 }, /* V */
42239ced 1092 },
6b0768e2 1093 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced 1094 },
716d413c 1095 [AV_PIX_FMT_YUV420P16LE] = {
35f6c154 1096 .name = "yuv420p16le",
4a59eca9
TB
1097 .nb_components = 3,
1098 .log2_chroma_w = 1,
1099 .log2_chroma_h = 1,
75801da5 1100 .comp = {
4a59eca9
TB
1101 { 0, 1, 1, 0, 15 }, /* Y */
1102 { 1, 1, 1, 0, 15 }, /* U */
1103 { 2, 1, 1, 0, 15 }, /* V */
75801da5 1104 },
6b0768e2 1105 .flags = PIX_FMT_PLANAR,
75801da5 1106 },
716d413c 1107 [AV_PIX_FMT_YUV420P16BE] = {
35f6c154 1108 .name = "yuv420p16be",
4a59eca9
TB
1109 .nb_components = 3,
1110 .log2_chroma_w = 1,
1111 .log2_chroma_h = 1,
75801da5 1112 .comp = {
4a59eca9
TB
1113 { 0, 1, 1, 0, 15 }, /* Y */
1114 { 1, 1, 1, 0, 15 }, /* U */
1115 { 2, 1, 1, 0, 15 }, /* V */
75801da5 1116 },
6b0768e2 1117 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 1118 },
716d413c 1119 [AV_PIX_FMT_YUV422P9LE] = {
dc49bf12 1120 .name = "yuv422p9le",
4a59eca9
TB
1121 .nb_components = 3,
1122 .log2_chroma_w = 1,
1123 .log2_chroma_h = 0,
dc49bf12 1124 .comp = {
4a59eca9
TB
1125 { 0, 1, 1, 0, 8 }, /* Y */
1126 { 1, 1, 1, 0, 8 }, /* U */
1127 { 2, 1, 1, 0, 8 }, /* V */
dc49bf12 1128 },
6b0768e2 1129 .flags = PIX_FMT_PLANAR,
dc49bf12 1130 },
716d413c 1131 [AV_PIX_FMT_YUV422P9BE] = {
dc49bf12 1132 .name = "yuv422p9be",
4a59eca9
TB
1133 .nb_components = 3,
1134 .log2_chroma_w = 1,
1135 .log2_chroma_h = 0,
dc49bf12 1136 .comp = {
a6842670
LB
1137 { 0, 1, 1, 0, 8 }, /* Y */
1138 { 1, 1, 1, 0, 8 }, /* U */
1139 { 2, 1, 1, 0, 8 }, /* V */
dc49bf12 1140 },
6b0768e2 1141 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
dc49bf12 1142 },
716d413c 1143 [AV_PIX_FMT_YUV422P10LE] = {
5c511ad4 1144 .name = "yuv422p10le",
4a59eca9
TB
1145 .nb_components = 3,
1146 .log2_chroma_w = 1,
1147 .log2_chroma_h = 0,
5c511ad4 1148 .comp = {
4a59eca9
TB
1149 { 0, 1, 1, 0, 9 }, /* Y */
1150 { 1, 1, 1, 0, 9 }, /* U */
1151 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 1152 },
6b0768e2 1153 .flags = PIX_FMT_PLANAR,
5c511ad4 1154 },
716d413c 1155 [AV_PIX_FMT_YUV422P10BE] = {
5c511ad4 1156 .name = "yuv422p10be",
4a59eca9
TB
1157 .nb_components = 3,
1158 .log2_chroma_w = 1,
1159 .log2_chroma_h = 0,
5c511ad4 1160 .comp = {
4a59eca9
TB
1161 { 0, 1, 1, 0, 9 }, /* Y */
1162 { 1, 1, 1, 0, 9 }, /* U */
1163 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 1164 },
6b0768e2 1165 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
5c511ad4 1166 },
716d413c 1167 [AV_PIX_FMT_YUV422P16LE] = {
35f6c154 1168 .name = "yuv422p16le",
4a59eca9
TB
1169 .nb_components = 3,
1170 .log2_chroma_w = 1,
1171 .log2_chroma_h = 0,
75801da5 1172 .comp = {
4a59eca9
TB
1173 { 0, 1, 1, 0, 15 }, /* Y */
1174 { 1, 1, 1, 0, 15 }, /* U */
1175 { 2, 1, 1, 0, 15 }, /* V */
75801da5 1176 },
6b0768e2 1177 .flags = PIX_FMT_PLANAR,
75801da5 1178 },
716d413c 1179 [AV_PIX_FMT_YUV422P16BE] = {
35f6c154 1180 .name = "yuv422p16be",
4a59eca9
TB
1181 .nb_components = 3,
1182 .log2_chroma_w = 1,
1183 .log2_chroma_h = 0,
75801da5 1184 .comp = {
4a59eca9
TB
1185 { 0, 1, 1, 0, 15 }, /* Y */
1186 { 1, 1, 1, 0, 15 }, /* U */
1187 { 2, 1, 1, 0, 15 }, /* V */
75801da5 1188 },
6b0768e2 1189 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 1190 },
716d413c 1191 [AV_PIX_FMT_YUV444P16LE] = {
35f6c154 1192 .name = "yuv444p16le",
4a59eca9
TB
1193 .nb_components = 3,
1194 .log2_chroma_w = 0,
1195 .log2_chroma_h = 0,
75801da5 1196 .comp = {
4a59eca9
TB
1197 { 0, 1, 1, 0, 15 }, /* Y */
1198 { 1, 1, 1, 0, 15 }, /* U */
1199 { 2, 1, 1, 0, 15 }, /* V */
75801da5 1200 },
6b0768e2 1201 .flags = PIX_FMT_PLANAR,
75801da5 1202 },
716d413c 1203 [AV_PIX_FMT_YUV444P16BE] = {
35f6c154 1204 .name = "yuv444p16be",
4a59eca9
TB
1205 .nb_components = 3,
1206 .log2_chroma_w = 0,
1207 .log2_chroma_h = 0,
75801da5 1208 .comp = {
4a59eca9
TB
1209 { 0, 1, 1, 0, 15 }, /* Y */
1210 { 1, 1, 1, 0, 15 }, /* U */
1211 { 2, 1, 1, 0, 15 }, /* V */
75801da5 1212 },
6b0768e2 1213 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 1214 },
716d413c 1215 [AV_PIX_FMT_YUV444P10LE] = {
103278f7 1216 .name = "yuv444p10le",
4a59eca9
TB
1217 .nb_components = 3,
1218 .log2_chroma_w = 0,
1219 .log2_chroma_h = 0,
103278f7 1220 .comp = {
4a59eca9
TB
1221 { 0, 1, 1, 0, 9 }, /* Y */
1222 { 1, 1, 1, 0, 9 }, /* U */
1223 { 2, 1, 1, 0, 9 }, /* V */
103278f7 1224 },
6b0768e2 1225 .flags = PIX_FMT_PLANAR,
103278f7 1226 },
716d413c 1227 [AV_PIX_FMT_YUV444P10BE] = {
103278f7 1228 .name = "yuv444p10be",
4a59eca9
TB
1229 .nb_components = 3,
1230 .log2_chroma_w = 0,
1231 .log2_chroma_h = 0,
103278f7 1232 .comp = {
4a59eca9
TB
1233 { 0, 1, 1, 0, 9 }, /* Y */
1234 { 1, 1, 1, 0, 9 }, /* U */
1235 { 2, 1, 1, 0, 9 }, /* V */
103278f7 1236 },
6b0768e2 1237 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7 1238 },
716d413c 1239 [AV_PIX_FMT_YUV444P9LE] = {
103278f7 1240 .name = "yuv444p9le",
4a59eca9
TB
1241 .nb_components = 3,
1242 .log2_chroma_w = 0,
1243 .log2_chroma_h = 0,
103278f7 1244 .comp = {
4a59eca9
TB
1245 { 0, 1, 1, 0, 8 }, /* Y */
1246 { 1, 1, 1, 0, 8 }, /* U */
1247 { 2, 1, 1, 0, 8 }, /* V */
103278f7 1248 },
6b0768e2 1249 .flags = PIX_FMT_PLANAR,
103278f7 1250 },
716d413c 1251 [AV_PIX_FMT_YUV444P9BE] = {
103278f7 1252 .name = "yuv444p9be",
4a59eca9
TB
1253 .nb_components = 3,
1254 .log2_chroma_w = 0,
1255 .log2_chroma_h = 0,
103278f7 1256 .comp = {
4a59eca9
TB
1257 { 0, 1, 1, 0, 8 }, /* Y */
1258 { 1, 1, 1, 0, 8 }, /* U */
1259 { 2, 1, 1, 0, 8 }, /* V */
103278f7 1260 },
6b0768e2 1261 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7 1262 },
716d413c 1263 [AV_PIX_FMT_DXVA2_VLD] = {
92c6a099
LA
1264 .name = "dxva2_vld",
1265 .log2_chroma_w = 1,
1266 .log2_chroma_h = 1,
1267 .flags = PIX_FMT_HWACCEL,
1268 },
716d413c 1269 [AV_PIX_FMT_Y400A] = {
4744f896 1270 .name = "y400a",
4a59eca9 1271 .nb_components = 2,
4744f896 1272 .comp = {
4a59eca9
TB
1273 { 0, 1, 1, 0, 7 }, /* Y */
1274 { 0, 1, 2, 0, 7 }, /* A */
4744f896 1275 },
cbe5a60c 1276 .flags = PIX_FMT_ALPHA,
4744f896 1277 },
716d413c 1278 [AV_PIX_FMT_GBRP] = {
bd97b2e1 1279 .name = "gbrp",
4a59eca9
TB
1280 .nb_components = 3,
1281 .log2_chroma_w = 0,
1282 .log2_chroma_h = 0,
bd97b2e1 1283 .comp = {
4a59eca9
TB
1284 { 0, 0, 1, 0, 7 }, /* G */
1285 { 1, 0, 1, 0, 7 }, /* B */
1286 { 2, 0, 1, 0, 7 }, /* R */
bd97b2e1 1287 },
6b0768e2 1288 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1289 },
716d413c 1290 [AV_PIX_FMT_GBRP9LE] = {
bd97b2e1 1291 .name = "gbrp9le",
4a59eca9
TB
1292 .nb_components = 3,
1293 .log2_chroma_w = 0,
1294 .log2_chroma_h = 0,
bd97b2e1 1295 .comp = {
4a59eca9
TB
1296 { 0, 1, 1, 0, 8 }, /* G */
1297 { 1, 1, 1, 0, 8 }, /* B */
1298 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1299 },
6b0768e2 1300 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1301 },
716d413c 1302 [AV_PIX_FMT_GBRP9BE] = {
bd97b2e1 1303 .name = "gbrp9be",
4a59eca9
TB
1304 .nb_components = 3,
1305 .log2_chroma_w = 0,
1306 .log2_chroma_h = 0,
bd97b2e1 1307 .comp = {
4a59eca9
TB
1308 { 0, 1, 1, 0, 8 }, /* G */
1309 { 1, 1, 1, 0, 8 }, /* B */
1310 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1311 },
6b0768e2 1312 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1313 },
716d413c 1314 [AV_PIX_FMT_GBRP10LE] = {
bd97b2e1 1315 .name = "gbrp10le",
4a59eca9
TB
1316 .nb_components = 3,
1317 .log2_chroma_w = 0,
1318 .log2_chroma_h = 0,
bd97b2e1 1319 .comp = {
4a59eca9
TB
1320 { 0, 1, 1, 0, 9 }, /* G */
1321 { 1, 1, 1, 0, 9 }, /* B */
1322 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1323 },
6b0768e2 1324 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1325 },
716d413c 1326 [AV_PIX_FMT_GBRP10BE] = {
bd97b2e1 1327 .name = "gbrp10be",
4a59eca9
TB
1328 .nb_components = 3,
1329 .log2_chroma_w = 0,
1330 .log2_chroma_h = 0,
bd97b2e1 1331 .comp = {
4a59eca9
TB
1332 { 0, 1, 1, 0, 9 }, /* G */
1333 { 1, 1, 1, 0, 9 }, /* B */
1334 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1335 },
6b0768e2 1336 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1337 },
716d413c 1338 [AV_PIX_FMT_GBRP16LE] = {
bd97b2e1 1339 .name = "gbrp16le",
4a59eca9
TB
1340 .nb_components = 3,
1341 .log2_chroma_w = 0,
1342 .log2_chroma_h = 0,
bd97b2e1 1343 .comp = {
4a59eca9
TB
1344 { 0, 1, 1, 0, 15 }, /* G */
1345 { 1, 1, 1, 0, 15 }, /* B */
1346 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1347 },
6b0768e2 1348 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1349 },
716d413c 1350 [AV_PIX_FMT_GBRP16BE] = {
bd97b2e1 1351 .name = "gbrp16be",
4a59eca9
TB
1352 .nb_components = 3,
1353 .log2_chroma_w = 0,
1354 .log2_chroma_h = 0,
bd97b2e1 1355 .comp = {
4a59eca9
TB
1356 { 0, 1, 1, 0, 15 }, /* G */
1357 { 1, 1, 1, 0, 15 }, /* B */
1358 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1359 },
6b0768e2 1360 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1361 },
169fb94f
RDC
1362 [AV_PIX_FMT_VDPAU] = {
1363 .name = "vdpau",
1364 .log2_chroma_w = 1,
1365 .log2_chroma_h = 1,
1366 .flags = PIX_FMT_HWACCEL,
1367 },
8c652645
NB
1368 [AV_PIX_FMT_XYZ12LE] = {
1369 .name = "xyz12le",
1370 .nb_components = 3,
1371 .log2_chroma_w = 0,
1372 .log2_chroma_h = 0,
1373 .comp = {
1374 { 0, 5, 1, 4, 11 }, /* X */
1375 { 0, 5, 3, 4, 11 }, /* Y */
1376 { 0, 5, 5, 4, 11 }, /* Z */
1377 },
1378 /*.flags = -- not used*/
1379 },
1380 [AV_PIX_FMT_XYZ12BE] = {
1381 .name = "xyz12be",
1382 .nb_components = 3,
1383 .log2_chroma_w = 0,
1384 .log2_chroma_h = 0,
1385 .comp = {
1386 { 0, 5, 1, 4, 11 }, /* X */
1387 { 0, 5, 3, 4, 11 }, /* Y */
1388 { 0, 5, 5, 4, 11 }, /* Z */
1389 },
1390 .flags = PIX_FMT_BE,
1391 },
9b61d838 1392};
5efccce2 1393
716d413c 1394static enum AVPixelFormat get_pix_fmt_internal(const char *name)
80a07f6e 1395{
716d413c 1396 enum AVPixelFormat pix_fmt;
80a07f6e 1397
716d413c 1398 for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
80a07f6e
SS
1399 if (av_pix_fmt_descriptors[pix_fmt].name &&
1400 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1401 return pix_fmt;
1402
716d413c 1403 return AV_PIX_FMT_NONE;
80a07f6e
SS
1404}
1405
716d413c 1406const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
8f653e28 1407{
716d413c 1408 return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
8f653e28
SS
1409 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1410}
1411
80a07f6e
SS
1412#if HAVE_BIGENDIAN
1413# define X_NE(be, le) be
1414#else
1415# define X_NE(be, le) le
1416#endif
1417
716d413c 1418enum AVPixelFormat av_get_pix_fmt(const char *name)
80a07f6e 1419{
716d413c 1420 enum AVPixelFormat pix_fmt;
80a07f6e
SS
1421
1422 if (!strcmp(name, "rgb32"))
1423 name = X_NE("argb", "bgra");
1424 else if (!strcmp(name, "bgr32"))
1425 name = X_NE("abgr", "rgba");
1426
1427 pix_fmt = get_pix_fmt_internal(name);
716d413c 1428 if (pix_fmt == AV_PIX_FMT_NONE) {
80a07f6e
SS
1429 char name2[32];
1430
1431 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1432 pix_fmt = get_pix_fmt_internal(name2);
1433 }
1434 return pix_fmt;
1435}
1436
5efccce2
SS
1437int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1438{
1439 int c, bits = 0;
1440 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1441
b8873c2a 1442 for (c = 0; c < pixdesc->nb_components; c++) {
4a59eca9
TB
1443 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1444 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
5efccce2
SS
1445 }
1446
1447 return bits >> log2_pixels;
1448}
bb4afa13 1449
716d413c 1450char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt)
bb4afa13
SS
1451{
1452 /* print header */
1453 if (pix_fmt < 0) {
4a59eca9 1454 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
bb4afa13
SS
1455 } else {
1456 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
4a59eca9
TB
1457 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1458 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
bb4afa13
SS
1459 }
1460
1461 return buf;
1462}
d2fcb356
AK
1463
1464const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
1465{
1466 if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
1467 return NULL;
1468 return &av_pix_fmt_descriptors[pix_fmt];
1469}
1470
1471const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
1472{
1473 if (!prev)
1474 return &av_pix_fmt_descriptors[0];
1475 if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
1476 return prev + 1;
1477 return NULL;
1478}
1479
1480enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
1481{
1482 if (desc < av_pix_fmt_descriptors ||
1483 desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
1484 return AV_PIX_FMT_NONE;
1485
1486 return desc - av_pix_fmt_descriptors;
1487}
c1a02e88
LB
1488
1489int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
1490 int *h_shift, int *v_shift)
1491{
1492 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
1493 if (!desc)
1494 return AVERROR(ENOSYS);
1495 *h_shift = desc->log2_chroma_w;
1496 *v_shift = desc->log2_chroma_h;
1497
1498 return 0;
1499}
2c328a90
AK
1500
1501int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
1502{
1503 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
1504 int i, planes[4] = { 0 }, ret = 0;
1505
1506 if (!desc)
1507 return AVERROR(EINVAL);
1508
1509 for (i = 0; i < desc->nb_components; i++)
1510 planes[desc->comp[i].plane] = 1;
1511 for (i = 0; i < FF_ARRAY_ELEMS(planes); i++)
1512 ret += planes[i];
1513 return ret;
1514}