swscale: support gray to 9bit and 10bit formats
[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 */
6d5600e8
LB
530 { 2, 0, 1, 0, 7 }, /* V */
531 { 3, 0, 1, 0, 7 }, /* A */
532 },
533 .flags = PIX_FMT_PLANAR,
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 },
546 .flags = PIX_FMT_PLANAR,
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 },
6b0768e2 559 .flags = PIX_FMT_PLANAR,
10151b13 560 },
716d413c 561 [AV_PIX_FMT_VDPAU_H264] = {
3fa70a3b
SS
562 .name = "vdpau_h264",
563 .log2_chroma_w = 1,
564 .log2_chroma_h = 1,
565 .flags = PIX_FMT_HWACCEL,
566 },
716d413c 567 [AV_PIX_FMT_VDPAU_MPEG1] = {
3fa70a3b
SS
568 .name = "vdpau_mpeg1",
569 .log2_chroma_w = 1,
570 .log2_chroma_h = 1,
571 .flags = PIX_FMT_HWACCEL,
572 },
716d413c 573 [AV_PIX_FMT_VDPAU_MPEG2] = {
3fa70a3b
SS
574 .name = "vdpau_mpeg2",
575 .log2_chroma_w = 1,
576 .log2_chroma_h = 1,
577 .flags = PIX_FMT_HWACCEL,
578 },
716d413c 579 [AV_PIX_FMT_VDPAU_WMV3] = {
3fa70a3b
SS
580 .name = "vdpau_wmv3",
581 .log2_chroma_w = 1,
582 .log2_chroma_h = 1,
583 .flags = PIX_FMT_HWACCEL,
584 },
716d413c 585 [AV_PIX_FMT_VDPAU_VC1] = {
3fa70a3b
SS
586 .name = "vdpau_vc1",
587 .log2_chroma_w = 1,
588 .log2_chroma_h = 1,
589 .flags = PIX_FMT_HWACCEL,
590 },
716d413c 591 [AV_PIX_FMT_VDPAU_MPEG4] = {
dd6308ad
CEH
592 .name = "vdpau_mpeg4",
593 .log2_chroma_w = 1,
594 .log2_chroma_h = 1,
595 .flags = PIX_FMT_HWACCEL,
596 },
716d413c 597 [AV_PIX_FMT_RGB48BE] = {
1e896640 598 .name = "rgb48be",
4a59eca9
TB
599 .nb_components = 3,
600 .log2_chroma_w = 0,
601 .log2_chroma_h = 0,
9b61d838 602 .comp = {
4a59eca9
TB
603 { 0, 5, 1, 0, 15 }, /* R */
604 { 0, 5, 3, 0, 15 }, /* G */
605 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 606 },
f7f18352 607 .flags = PIX_FMT_RGB | PIX_FMT_BE,
9b61d838 608 },
716d413c 609 [AV_PIX_FMT_RGB48LE] = {
bcbd9a14 610 .name = "rgb48le",
4a59eca9
TB
611 .nb_components = 3,
612 .log2_chroma_w = 0,
613 .log2_chroma_h = 0,
9b61d838 614 .comp = {
4a59eca9
TB
615 { 0, 5, 1, 0, 15 }, /* R */
616 { 0, 5, 3, 0, 15 }, /* G */
617 { 0, 5, 5, 0, 15 }, /* B */
9b61d838 618 },
6b0768e2 619 .flags = PIX_FMT_RGB,
9b61d838 620 },
716d413c 621 [AV_PIX_FMT_RGB565BE] = {
1e896640 622 .name = "rgb565be",
4a59eca9
TB
623 .nb_components = 3,
624 .log2_chroma_w = 0,
625 .log2_chroma_h = 0,
9b61d838 626 .comp = {
4a59eca9
TB
627 { 0, 1, 0, 3, 4 }, /* R */
628 { 0, 1, 1, 5, 5 }, /* G */
629 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 630 },
6b0768e2 631 .flags = PIX_FMT_BE | PIX_FMT_RGB,
9b61d838 632 },
716d413c 633 [AV_PIX_FMT_RGB565LE] = {
bcbd9a14 634 .name = "rgb565le",
4a59eca9
TB
635 .nb_components = 3,
636 .log2_chroma_w = 0,
637 .log2_chroma_h = 0,
9b61d838 638 .comp = {
4a59eca9
TB
639 { 0, 1, 2, 3, 4 }, /* R */
640 { 0, 1, 1, 5, 5 }, /* G */
641 { 0, 1, 1, 0, 4 }, /* B */
9b61d838 642 },
6b0768e2 643 .flags = PIX_FMT_RGB,
9b61d838 644 },
716d413c 645 [AV_PIX_FMT_RGB555BE] = {
10151b13 646 .name = "rgb555be",
4a59eca9
TB
647 .nb_components = 3,
648 .log2_chroma_w = 0,
649 .log2_chroma_h = 0,
10151b13 650 .comp = {
4a59eca9
TB
651 { 0, 1, 0, 2, 4 }, /* R */
652 { 0, 1, 1, 5, 4 }, /* G */
653 { 0, 1, 1, 0, 4 }, /* B */
10151b13 654 },
6b0768e2 655 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 656 },
716d413c 657 [AV_PIX_FMT_RGB555LE] = {
10151b13 658 .name = "rgb555le",
4a59eca9
TB
659 .nb_components = 3,
660 .log2_chroma_w = 0,
661 .log2_chroma_h = 0,
10151b13 662 .comp = {
4a59eca9
TB
663 { 0, 1, 2, 2, 4 }, /* R */
664 { 0, 1, 1, 5, 4 }, /* G */
665 { 0, 1, 1, 0, 4 }, /* B */
10151b13 666 },
6b0768e2 667 .flags = PIX_FMT_RGB,
10151b13 668 },
716d413c 669 [AV_PIX_FMT_RGB444BE] = {
2b7cf167 670 .name = "rgb444be",
4a59eca9
TB
671 .nb_components = 3,
672 .log2_chroma_w = 0,
673 .log2_chroma_h = 0,
2b7cf167 674 .comp = {
4a59eca9
TB
675 { 0, 1, 0, 0, 3 }, /* R */
676 { 0, 1, 1, 4, 3 }, /* G */
677 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 678 },
6b0768e2 679 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167 680 },
716d413c 681 [AV_PIX_FMT_RGB444LE] = {
2b7cf167 682 .name = "rgb444le",
4a59eca9
TB
683 .nb_components = 3,
684 .log2_chroma_w = 0,
685 .log2_chroma_h = 0,
2b7cf167 686 .comp = {
4a59eca9
TB
687 { 0, 1, 2, 0, 3 }, /* R */
688 { 0, 1, 1, 4, 3 }, /* G */
689 { 0, 1, 1, 0, 3 }, /* B */
2b7cf167 690 },
6b0768e2 691 .flags = PIX_FMT_RGB,
2b7cf167 692 },
716d413c 693 [AV_PIX_FMT_BGR48BE] = {
73389754 694 .name = "bgr48be",
4a59eca9
TB
695 .nb_components = 3,
696 .log2_chroma_w = 0,
697 .log2_chroma_h = 0,
73389754 698 .comp = {
4a59eca9
TB
699 { 0, 5, 1, 0, 15 }, /* B */
700 { 0, 5, 3, 0, 15 }, /* G */
701 { 0, 5, 5, 0, 15 }, /* R */
73389754 702 },
6b0768e2 703 .flags = PIX_FMT_BE | PIX_FMT_RGB,
73389754 704 },
716d413c 705 [AV_PIX_FMT_BGR48LE] = {
73389754 706 .name = "bgr48le",
4a59eca9
TB
707 .nb_components = 3,
708 .log2_chroma_w = 0,
709 .log2_chroma_h = 0,
73389754 710 .comp = {
4a59eca9
TB
711 { 0, 5, 1, 0, 15 }, /* B */
712 { 0, 5, 3, 0, 15 }, /* G */
713 { 0, 5, 5, 0, 15 }, /* R */
73389754 714 },
6b0768e2 715 .flags = PIX_FMT_RGB,
73389754 716 },
716d413c 717 [AV_PIX_FMT_BGR565BE] = {
10151b13 718 .name = "bgr565be",
4a59eca9
TB
719 .nb_components = 3,
720 .log2_chroma_w = 0,
721 .log2_chroma_h = 0,
10151b13 722 .comp = {
4a59eca9
TB
723 { 0, 1, 0, 3, 4 }, /* B */
724 { 0, 1, 1, 5, 5 }, /* G */
725 { 0, 1, 1, 0, 4 }, /* R */
10151b13 726 },
6b0768e2 727 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 728 },
716d413c 729 [AV_PIX_FMT_BGR565LE] = {
10151b13 730 .name = "bgr565le",
4a59eca9
TB
731 .nb_components = 3,
732 .log2_chroma_w = 0,
733 .log2_chroma_h = 0,
10151b13 734 .comp = {
4a59eca9
TB
735 { 0, 1, 2, 3, 4 }, /* B */
736 { 0, 1, 1, 5, 5 }, /* G */
737 { 0, 1, 1, 0, 4 }, /* R */
10151b13 738 },
6b0768e2 739 .flags = PIX_FMT_RGB,
10151b13 740 },
716d413c 741 [AV_PIX_FMT_BGR555BE] = {
10151b13 742 .name = "bgr555be",
4a59eca9
TB
743 .nb_components = 3,
744 .log2_chroma_w = 0,
745 .log2_chroma_h = 0,
10151b13 746 .comp = {
4a59eca9
TB
747 { 0, 1, 0, 2, 4 }, /* B */
748 { 0, 1, 1, 5, 4 }, /* G */
749 { 0, 1, 1, 0, 4 }, /* R */
10151b13 750 },
6b0768e2 751 .flags = PIX_FMT_BE | PIX_FMT_RGB,
10151b13 752 },
716d413c 753 [AV_PIX_FMT_BGR555LE] = {
10151b13 754 .name = "bgr555le",
4a59eca9
TB
755 .nb_components = 3,
756 .log2_chroma_w = 0,
757 .log2_chroma_h = 0,
10151b13 758 .comp = {
4a59eca9
TB
759 { 0, 1, 2, 2, 4 }, /* B */
760 { 0, 1, 1, 5, 4 }, /* G */
761 { 0, 1, 1, 0, 4 }, /* R */
10151b13 762 },
6b0768e2 763 .flags = PIX_FMT_RGB,
10151b13 764 },
716d413c 765 [AV_PIX_FMT_BGR444BE] = {
2b7cf167 766 .name = "bgr444be",
4a59eca9
TB
767 .nb_components = 3,
768 .log2_chroma_w = 0,
769 .log2_chroma_h = 0,
2b7cf167 770 .comp = {
4a59eca9
TB
771 { 0, 1, 0, 0, 3 }, /* B */
772 { 0, 1, 1, 4, 3 }, /* G */
773 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 774 },
6b0768e2 775 .flags = PIX_FMT_BE | PIX_FMT_RGB,
2b7cf167 776 },
716d413c 777 [AV_PIX_FMT_BGR444LE] = {
2b7cf167 778 .name = "bgr444le",
4a59eca9
TB
779 .nb_components = 3,
780 .log2_chroma_w = 0,
781 .log2_chroma_h = 0,
2b7cf167 782 .comp = {
4a59eca9
TB
783 { 0, 1, 2, 0, 3 }, /* B */
784 { 0, 1, 1, 4, 3 }, /* G */
785 { 0, 1, 1, 0, 3 }, /* R */
2b7cf167 786 },
6b0768e2 787 .flags = PIX_FMT_RGB,
2b7cf167 788 },
716d413c 789 [AV_PIX_FMT_VAAPI_MOCO] = {
3fa70a3b
SS
790 .name = "vaapi_moco",
791 .log2_chroma_w = 1,
792 .log2_chroma_h = 1,
793 .flags = PIX_FMT_HWACCEL,
794 },
716d413c 795 [AV_PIX_FMT_VAAPI_IDCT] = {
3fa70a3b
SS
796 .name = "vaapi_idct",
797 .log2_chroma_w = 1,
798 .log2_chroma_h = 1,
799 .flags = PIX_FMT_HWACCEL,
800 },
716d413c 801 [AV_PIX_FMT_VAAPI_VLD] = {
3fa70a3b
SS
802 .name = "vaapi_vld",
803 .log2_chroma_w = 1,
804 .log2_chroma_h = 1,
805 .flags = PIX_FMT_HWACCEL,
806 },
716d413c 807 [AV_PIX_FMT_VDA_VLD] = {
ac3dbb4d
SZ
808 .name = "vda_vld",
809 .log2_chroma_w = 1,
810 .log2_chroma_h = 1,
811 .flags = PIX_FMT_HWACCEL,
812 },
716d413c 813 [AV_PIX_FMT_YUV420P9LE] = {
42239ced 814 .name = "yuv420p9le",
4a59eca9
TB
815 .nb_components = 3,
816 .log2_chroma_w = 1,
817 .log2_chroma_h = 1,
42239ced 818 .comp = {
4a59eca9
TB
819 { 0, 1, 1, 0, 8 }, /* Y */
820 { 1, 1, 1, 0, 8 }, /* U */
821 { 2, 1, 1, 0, 8 }, /* V */
42239ced 822 },
6b0768e2 823 .flags = PIX_FMT_PLANAR,
42239ced 824 },
716d413c 825 [AV_PIX_FMT_YUV420P9BE] = {
42239ced 826 .name = "yuv420p9be",
4a59eca9
TB
827 .nb_components = 3,
828 .log2_chroma_w = 1,
829 .log2_chroma_h = 1,
42239ced 830 .comp = {
4a59eca9
TB
831 { 0, 1, 1, 0, 8 }, /* Y */
832 { 1, 1, 1, 0, 8 }, /* U */
833 { 2, 1, 1, 0, 8 }, /* V */
42239ced 834 },
6b0768e2 835 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced 836 },
716d413c 837 [AV_PIX_FMT_YUV420P10LE] = {
42239ced 838 .name = "yuv420p10le",
4a59eca9
TB
839 .nb_components = 3,
840 .log2_chroma_w = 1,
841 .log2_chroma_h = 1,
42239ced 842 .comp = {
4a59eca9
TB
843 { 0, 1, 1, 0, 9 }, /* Y */
844 { 1, 1, 1, 0, 9 }, /* U */
845 { 2, 1, 1, 0, 9 }, /* V */
42239ced 846 },
6b0768e2 847 .flags = PIX_FMT_PLANAR,
42239ced 848 },
716d413c 849 [AV_PIX_FMT_YUV420P10BE] = {
42239ced 850 .name = "yuv420p10be",
4a59eca9
TB
851 .nb_components = 3,
852 .log2_chroma_w = 1,
853 .log2_chroma_h = 1,
42239ced 854 .comp = {
4a59eca9
TB
855 { 0, 1, 1, 0, 9 }, /* Y */
856 { 1, 1, 1, 0, 9 }, /* U */
857 { 2, 1, 1, 0, 9 }, /* V */
42239ced 858 },
6b0768e2 859 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
42239ced 860 },
716d413c 861 [AV_PIX_FMT_YUV420P16LE] = {
35f6c154 862 .name = "yuv420p16le",
4a59eca9
TB
863 .nb_components = 3,
864 .log2_chroma_w = 1,
865 .log2_chroma_h = 1,
75801da5 866 .comp = {
4a59eca9
TB
867 { 0, 1, 1, 0, 15 }, /* Y */
868 { 1, 1, 1, 0, 15 }, /* U */
869 { 2, 1, 1, 0, 15 }, /* V */
75801da5 870 },
6b0768e2 871 .flags = PIX_FMT_PLANAR,
75801da5 872 },
716d413c 873 [AV_PIX_FMT_YUV420P16BE] = {
35f6c154 874 .name = "yuv420p16be",
4a59eca9
TB
875 .nb_components = 3,
876 .log2_chroma_w = 1,
877 .log2_chroma_h = 1,
75801da5 878 .comp = {
4a59eca9
TB
879 { 0, 1, 1, 0, 15 }, /* Y */
880 { 1, 1, 1, 0, 15 }, /* U */
881 { 2, 1, 1, 0, 15 }, /* V */
75801da5 882 },
6b0768e2 883 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 884 },
716d413c 885 [AV_PIX_FMT_YUV422P9LE] = {
dc49bf12 886 .name = "yuv422p9le",
4a59eca9
TB
887 .nb_components = 3,
888 .log2_chroma_w = 1,
889 .log2_chroma_h = 0,
dc49bf12 890 .comp = {
4a59eca9
TB
891 { 0, 1, 1, 0, 8 }, /* Y */
892 { 1, 1, 1, 0, 8 }, /* U */
893 { 2, 1, 1, 0, 8 }, /* V */
dc49bf12 894 },
6b0768e2 895 .flags = PIX_FMT_PLANAR,
dc49bf12 896 },
716d413c 897 [AV_PIX_FMT_YUV422P9BE] = {
dc49bf12 898 .name = "yuv422p9be",
4a59eca9
TB
899 .nb_components = 3,
900 .log2_chroma_w = 1,
901 .log2_chroma_h = 0,
dc49bf12 902 .comp = {
a6842670
LB
903 { 0, 1, 1, 0, 8 }, /* Y */
904 { 1, 1, 1, 0, 8 }, /* U */
905 { 2, 1, 1, 0, 8 }, /* V */
dc49bf12 906 },
6b0768e2 907 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
dc49bf12 908 },
716d413c 909 [AV_PIX_FMT_YUV422P10LE] = {
5c511ad4 910 .name = "yuv422p10le",
4a59eca9
TB
911 .nb_components = 3,
912 .log2_chroma_w = 1,
913 .log2_chroma_h = 0,
5c511ad4 914 .comp = {
4a59eca9
TB
915 { 0, 1, 1, 0, 9 }, /* Y */
916 { 1, 1, 1, 0, 9 }, /* U */
917 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 918 },
6b0768e2 919 .flags = PIX_FMT_PLANAR,
5c511ad4 920 },
716d413c 921 [AV_PIX_FMT_YUV422P10BE] = {
5c511ad4 922 .name = "yuv422p10be",
4a59eca9
TB
923 .nb_components = 3,
924 .log2_chroma_w = 1,
925 .log2_chroma_h = 0,
5c511ad4 926 .comp = {
4a59eca9
TB
927 { 0, 1, 1, 0, 9 }, /* Y */
928 { 1, 1, 1, 0, 9 }, /* U */
929 { 2, 1, 1, 0, 9 }, /* V */
5c511ad4 930 },
6b0768e2 931 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
5c511ad4 932 },
716d413c 933 [AV_PIX_FMT_YUV422P16LE] = {
35f6c154 934 .name = "yuv422p16le",
4a59eca9
TB
935 .nb_components = 3,
936 .log2_chroma_w = 1,
937 .log2_chroma_h = 0,
75801da5 938 .comp = {
4a59eca9
TB
939 { 0, 1, 1, 0, 15 }, /* Y */
940 { 1, 1, 1, 0, 15 }, /* U */
941 { 2, 1, 1, 0, 15 }, /* V */
75801da5 942 },
6b0768e2 943 .flags = PIX_FMT_PLANAR,
75801da5 944 },
716d413c 945 [AV_PIX_FMT_YUV422P16BE] = {
35f6c154 946 .name = "yuv422p16be",
4a59eca9
TB
947 .nb_components = 3,
948 .log2_chroma_w = 1,
949 .log2_chroma_h = 0,
75801da5 950 .comp = {
4a59eca9
TB
951 { 0, 1, 1, 0, 15 }, /* Y */
952 { 1, 1, 1, 0, 15 }, /* U */
953 { 2, 1, 1, 0, 15 }, /* V */
75801da5 954 },
6b0768e2 955 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 956 },
716d413c 957 [AV_PIX_FMT_YUV444P16LE] = {
35f6c154 958 .name = "yuv444p16le",
4a59eca9
TB
959 .nb_components = 3,
960 .log2_chroma_w = 0,
961 .log2_chroma_h = 0,
75801da5 962 .comp = {
4a59eca9
TB
963 { 0, 1, 1, 0, 15 }, /* Y */
964 { 1, 1, 1, 0, 15 }, /* U */
965 { 2, 1, 1, 0, 15 }, /* V */
75801da5 966 },
6b0768e2 967 .flags = PIX_FMT_PLANAR,
75801da5 968 },
716d413c 969 [AV_PIX_FMT_YUV444P16BE] = {
35f6c154 970 .name = "yuv444p16be",
4a59eca9
TB
971 .nb_components = 3,
972 .log2_chroma_w = 0,
973 .log2_chroma_h = 0,
75801da5 974 .comp = {
4a59eca9
TB
975 { 0, 1, 1, 0, 15 }, /* Y */
976 { 1, 1, 1, 0, 15 }, /* U */
977 { 2, 1, 1, 0, 15 }, /* V */
75801da5 978 },
6b0768e2 979 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
75801da5 980 },
716d413c 981 [AV_PIX_FMT_YUV444P10LE] = {
103278f7 982 .name = "yuv444p10le",
4a59eca9
TB
983 .nb_components = 3,
984 .log2_chroma_w = 0,
985 .log2_chroma_h = 0,
103278f7 986 .comp = {
4a59eca9
TB
987 { 0, 1, 1, 0, 9 }, /* Y */
988 { 1, 1, 1, 0, 9 }, /* U */
989 { 2, 1, 1, 0, 9 }, /* V */
103278f7 990 },
6b0768e2 991 .flags = PIX_FMT_PLANAR,
103278f7 992 },
716d413c 993 [AV_PIX_FMT_YUV444P10BE] = {
103278f7 994 .name = "yuv444p10be",
4a59eca9
TB
995 .nb_components = 3,
996 .log2_chroma_w = 0,
997 .log2_chroma_h = 0,
103278f7 998 .comp = {
4a59eca9
TB
999 { 0, 1, 1, 0, 9 }, /* Y */
1000 { 1, 1, 1, 0, 9 }, /* U */
1001 { 2, 1, 1, 0, 9 }, /* V */
103278f7 1002 },
6b0768e2 1003 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7 1004 },
716d413c 1005 [AV_PIX_FMT_YUV444P9LE] = {
103278f7 1006 .name = "yuv444p9le",
4a59eca9
TB
1007 .nb_components = 3,
1008 .log2_chroma_w = 0,
1009 .log2_chroma_h = 0,
103278f7 1010 .comp = {
4a59eca9
TB
1011 { 0, 1, 1, 0, 8 }, /* Y */
1012 { 1, 1, 1, 0, 8 }, /* U */
1013 { 2, 1, 1, 0, 8 }, /* V */
103278f7 1014 },
6b0768e2 1015 .flags = PIX_FMT_PLANAR,
103278f7 1016 },
716d413c 1017 [AV_PIX_FMT_YUV444P9BE] = {
103278f7 1018 .name = "yuv444p9be",
4a59eca9
TB
1019 .nb_components = 3,
1020 .log2_chroma_w = 0,
1021 .log2_chroma_h = 0,
103278f7 1022 .comp = {
4a59eca9
TB
1023 { 0, 1, 1, 0, 8 }, /* Y */
1024 { 1, 1, 1, 0, 8 }, /* U */
1025 { 2, 1, 1, 0, 8 }, /* V */
103278f7 1026 },
6b0768e2 1027 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
103278f7 1028 },
716d413c 1029 [AV_PIX_FMT_DXVA2_VLD] = {
92c6a099
LA
1030 .name = "dxva2_vld",
1031 .log2_chroma_w = 1,
1032 .log2_chroma_h = 1,
1033 .flags = PIX_FMT_HWACCEL,
1034 },
716d413c 1035 [AV_PIX_FMT_Y400A] = {
4744f896 1036 .name = "y400a",
4a59eca9 1037 .nb_components = 2,
4744f896 1038 .comp = {
4a59eca9
TB
1039 { 0, 1, 1, 0, 7 }, /* Y */
1040 { 0, 1, 2, 0, 7 }, /* A */
4744f896
1041 },
1042 },
716d413c 1043 [AV_PIX_FMT_GBRP] = {
bd97b2e1 1044 .name = "gbrp",
4a59eca9
TB
1045 .nb_components = 3,
1046 .log2_chroma_w = 0,
1047 .log2_chroma_h = 0,
bd97b2e1 1048 .comp = {
4a59eca9
TB
1049 { 0, 0, 1, 0, 7 }, /* G */
1050 { 1, 0, 1, 0, 7 }, /* B */
1051 { 2, 0, 1, 0, 7 }, /* R */
bd97b2e1 1052 },
6b0768e2 1053 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1054 },
716d413c 1055 [AV_PIX_FMT_GBRP9LE] = {
bd97b2e1 1056 .name = "gbrp9le",
4a59eca9
TB
1057 .nb_components = 3,
1058 .log2_chroma_w = 0,
1059 .log2_chroma_h = 0,
bd97b2e1 1060 .comp = {
4a59eca9
TB
1061 { 0, 1, 1, 0, 8 }, /* G */
1062 { 1, 1, 1, 0, 8 }, /* B */
1063 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1064 },
6b0768e2 1065 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1066 },
716d413c 1067 [AV_PIX_FMT_GBRP9BE] = {
bd97b2e1 1068 .name = "gbrp9be",
4a59eca9
TB
1069 .nb_components = 3,
1070 .log2_chroma_w = 0,
1071 .log2_chroma_h = 0,
bd97b2e1 1072 .comp = {
4a59eca9
TB
1073 { 0, 1, 1, 0, 8 }, /* G */
1074 { 1, 1, 1, 0, 8 }, /* B */
1075 { 2, 1, 1, 0, 8 }, /* R */
bd97b2e1 1076 },
6b0768e2 1077 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1078 },
716d413c 1079 [AV_PIX_FMT_GBRP10LE] = {
bd97b2e1 1080 .name = "gbrp10le",
4a59eca9
TB
1081 .nb_components = 3,
1082 .log2_chroma_w = 0,
1083 .log2_chroma_h = 0,
bd97b2e1 1084 .comp = {
4a59eca9
TB
1085 { 0, 1, 1, 0, 9 }, /* G */
1086 { 1, 1, 1, 0, 9 }, /* B */
1087 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1088 },
6b0768e2 1089 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1090 },
716d413c 1091 [AV_PIX_FMT_GBRP10BE] = {
bd97b2e1 1092 .name = "gbrp10be",
4a59eca9
TB
1093 .nb_components = 3,
1094 .log2_chroma_w = 0,
1095 .log2_chroma_h = 0,
bd97b2e1 1096 .comp = {
4a59eca9
TB
1097 { 0, 1, 1, 0, 9 }, /* G */
1098 { 1, 1, 1, 0, 9 }, /* B */
1099 { 2, 1, 1, 0, 9 }, /* R */
bd97b2e1 1100 },
6b0768e2 1101 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1102 },
716d413c 1103 [AV_PIX_FMT_GBRP16LE] = {
bd97b2e1 1104 .name = "gbrp16le",
4a59eca9
TB
1105 .nb_components = 3,
1106 .log2_chroma_w = 0,
1107 .log2_chroma_h = 0,
bd97b2e1 1108 .comp = {
4a59eca9
TB
1109 { 0, 1, 1, 0, 15 }, /* G */
1110 { 1, 1, 1, 0, 15 }, /* B */
1111 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1112 },
6b0768e2 1113 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1114 },
716d413c 1115 [AV_PIX_FMT_GBRP16BE] = {
bd97b2e1 1116 .name = "gbrp16be",
4a59eca9
TB
1117 .nb_components = 3,
1118 .log2_chroma_w = 0,
1119 .log2_chroma_h = 0,
bd97b2e1 1120 .comp = {
4a59eca9
TB
1121 { 0, 1, 1, 0, 15 }, /* G */
1122 { 1, 1, 1, 0, 15 }, /* B */
1123 { 2, 1, 1, 0, 15 }, /* R */
bd97b2e1 1124 },
6b0768e2 1125 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
bd97b2e1 1126 },
9b61d838 1127};
5efccce2 1128
716d413c 1129static enum AVPixelFormat get_pix_fmt_internal(const char *name)
80a07f6e 1130{
716d413c 1131 enum AVPixelFormat pix_fmt;
80a07f6e 1132
716d413c 1133 for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
80a07f6e
SS
1134 if (av_pix_fmt_descriptors[pix_fmt].name &&
1135 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1136 return pix_fmt;
1137
716d413c 1138 return AV_PIX_FMT_NONE;
80a07f6e
SS
1139}
1140
716d413c 1141const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
8f653e28 1142{
716d413c 1143 return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
8f653e28
SS
1144 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1145}
1146
80a07f6e
SS
1147#if HAVE_BIGENDIAN
1148# define X_NE(be, le) be
1149#else
1150# define X_NE(be, le) le
1151#endif
1152
716d413c 1153enum AVPixelFormat av_get_pix_fmt(const char *name)
80a07f6e 1154{
716d413c 1155 enum AVPixelFormat pix_fmt;
80a07f6e
SS
1156
1157 if (!strcmp(name, "rgb32"))
1158 name = X_NE("argb", "bgra");
1159 else if (!strcmp(name, "bgr32"))
1160 name = X_NE("abgr", "rgba");
1161
1162 pix_fmt = get_pix_fmt_internal(name);
716d413c 1163 if (pix_fmt == AV_PIX_FMT_NONE) {
80a07f6e
SS
1164 char name2[32];
1165
1166 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1167 pix_fmt = get_pix_fmt_internal(name2);
1168 }
1169 return pix_fmt;
1170}
1171
5efccce2
SS
1172int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1173{
1174 int c, bits = 0;
1175 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1176
b8873c2a 1177 for (c = 0; c < pixdesc->nb_components; c++) {
4a59eca9
TB
1178 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1179 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
5efccce2
SS
1180 }
1181
1182 return bits >> log2_pixels;
1183}
bb4afa13 1184
716d413c 1185char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt)
bb4afa13
SS
1186{
1187 /* print header */
1188 if (pix_fmt < 0) {
4a59eca9 1189 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
bb4afa13
SS
1190 } else {
1191 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
4a59eca9
TB
1192 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1193 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
bb4afa13
SS
1194 }
1195
1196 return buf;
1197}
d2fcb356
AK
1198
1199const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
1200{
1201 if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
1202 return NULL;
1203 return &av_pix_fmt_descriptors[pix_fmt];
1204}
1205
1206const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
1207{
1208 if (!prev)
1209 return &av_pix_fmt_descriptors[0];
1210 if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
1211 return prev + 1;
1212 return NULL;
1213}
1214
1215enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
1216{
1217 if (desc < av_pix_fmt_descriptors ||
1218 desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
1219 return AV_PIX_FMT_NONE;
1220
1221 return desc - av_pix_fmt_descriptors;
1222}