Coverage Report

Created: 2024-09-06 07:53

/src/ffmpeg/libavutil/pixdesc.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * pixel format descriptor
3
 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
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
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
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
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21
22
#include <stdio.h>
23
#include <string.h>
24
25
#include "avstring.h"
26
#include "common.h"
27
#include "pixfmt.h"
28
#include "pixdesc.h"
29
#include "intreadwrite.h"
30
31
void av_read_image_line2(void *dst,
32
                        const uint8_t *data[4], const int linesize[4],
33
                        const AVPixFmtDescriptor *desc,
34
                        int x, int y, int c, int w,
35
                        int read_pal_component,
36
                        int dst_element_size)
37
0
{
38
0
    AVComponentDescriptor comp = desc->comp[c];
39
0
    int plane = comp.plane;
40
0
    int depth = comp.depth;
41
0
    unsigned mask  = (1ULL << depth) - 1;
42
0
    int shift = comp.shift;
43
0
    int step  = comp.step;
44
0
    int flags = desc->flags;
45
0
    uint16_t *dst16 = dst;
46
0
    uint32_t *dst32 = dst;
47
48
0
    if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
49
0
        if (depth == 10) {
50
            // Assume all channels are packed into a 32bit value
51
0
            const uint8_t *byte_p = data[plane] + y * linesize[plane];
52
0
            const uint32_t *p = (uint32_t *)byte_p;
53
54
0
            while (w--) {
55
0
                int val = AV_RB32(p);
56
0
                val = (val >> comp.offset) & mask;
57
0
                if (read_pal_component)
58
0
                    val = data[1][4*val + c];
59
0
                if (dst_element_size == 4) *dst32++ = val;
60
0
                else                       *dst16++ = val;
61
0
                p++;
62
0
            }
63
0
        } else {
64
0
            int skip = x * step + comp.offset;
65
0
            const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
66
0
            int shift = 8 - depth - (skip & 7);
67
68
0
            while (w--) {
69
0
                int val = (*p >> shift) & mask;
70
0
                if (read_pal_component)
71
0
                    val = data[1][4*val + c];
72
0
                shift -= step;
73
0
                p -= shift >> 3;
74
0
                shift &= 7;
75
0
                if (dst_element_size == 4) *dst32++ = val;
76
0
                else                       *dst16++ = val;
77
0
            }
78
0
        }
79
0
    } else {
80
0
        const uint8_t *p = data[plane] + y * linesize[plane] +
81
0
                           x * step + comp.offset;
82
0
        int is_8bit = shift + depth <= 8;
83
0
        int is_16bit= shift + depth <=16;
84
85
0
        if (is_8bit)
86
0
            p += !!(flags & AV_PIX_FMT_FLAG_BE);
87
88
0
        while (w--) {
89
0
            unsigned val;
90
0
            if     (is_8bit)  val = *p;
91
0
            else if(is_16bit) val = flags & AV_PIX_FMT_FLAG_BE ? AV_RB16(p) : AV_RL16(p);
92
0
            else              val = flags & AV_PIX_FMT_FLAG_BE ? AV_RB32(p) : AV_RL32(p);
93
0
            val = (val >> shift) & mask;
94
0
            if (read_pal_component)
95
0
                val = data[1][4 * val + c];
96
0
            p += step;
97
0
            if (dst_element_size == 4) *dst32++ = val;
98
0
            else                       *dst16++ = val;
99
0
        }
100
0
    }
101
0
}
102
103
void av_read_image_line(uint16_t *dst,
104
                        const uint8_t *data[4], const int linesize[4],
105
                        const AVPixFmtDescriptor *desc,
106
                        int x, int y, int c, int w,
107
                        int read_pal_component)
108
0
{
109
0
    av_read_image_line2(dst, data, linesize, desc,x, y, c, w,
110
0
                        read_pal_component,
111
0
                        2);
112
0
}
113
114
void av_write_image_line2(const void *src,
115
                         uint8_t *data[4], const int linesize[4],
116
                         const AVPixFmtDescriptor *desc,
117
                         int x, int y, int c, int w, int src_element_size)
118
39.3k
{
119
39.3k
    AVComponentDescriptor comp = desc->comp[c];
120
39.3k
    int plane = comp.plane;
121
39.3k
    int depth = comp.depth;
122
39.3k
    int step  = comp.step;
123
39.3k
    int flags = desc->flags;
124
39.3k
    const uint32_t *src32 = src;
125
39.3k
    const uint16_t *src16 = src;
126
127
39.3k
    if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
128
0
        if (depth == 10) {
129
            // Assume all channels are packed into a 32bit value
130
0
            const uint8_t *byte_p = data[plane] + y * linesize[plane];
131
0
            uint32_t *p = (uint32_t *)byte_p;
132
0
            int offset = comp.offset;
133
0
            uint32_t mask  = ((1ULL << depth) - 1) << offset;
134
135
0
            while (w--) {
136
0
                uint16_t val = src_element_size == 4 ? *src32++ : *src16++;
137
0
                AV_WB32(p, (AV_RB32(p) & ~mask) | (val << offset));
138
0
                p++;
139
0
            }
140
0
        } else {
141
0
            int skip = x * step + comp.offset;
142
0
            uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
143
0
            int shift = 8 - depth - (skip & 7);
144
145
0
            while (w--) {
146
0
                *p |= (src_element_size == 4 ? *src32++ : *src16++) << shift;
147
0
                shift -= step;
148
0
                p -= shift >> 3;
149
0
                shift &= 7;
150
0
            }
151
0
        }
152
39.3k
    } else {
153
39.3k
        int shift = comp.shift;
154
39.3k
        uint8_t *p = data[plane] + y * linesize[plane] +
155
39.3k
                     x * step + comp.offset;
156
157
39.3k
        if (shift + depth <= 8) {
158
29.1k
            p += !!(flags & AV_PIX_FMT_FLAG_BE);
159
58.2k
            while (w--) {
160
29.1k
                *p |= ((src_element_size == 4 ? *src32++ : *src16++) << shift);
161
29.1k
                p += step;
162
29.1k
            }
163
29.1k
        } else {
164
20.3k
            while (w--) {
165
10.1k
                unsigned s = (src_element_size == 4 ? *src32++ : *src16++);
166
10.1k
                if (shift + depth <= 16) {
167
10.1k
                    if (flags & AV_PIX_FMT_FLAG_BE) {
168
0
                        uint16_t val = AV_RB16(p) | (s << shift);
169
0
                        AV_WB16(p, val);
170
10.1k
                    } else {
171
10.1k
                        uint16_t val = AV_RL16(p) | (s << shift);
172
10.1k
                        AV_WL16(p, val);
173
10.1k
                    }
174
10.1k
                } else {
175
0
                    if (flags & AV_PIX_FMT_FLAG_BE) {
176
0
                        uint32_t val = AV_RB32(p) | (s << shift);
177
0
                        AV_WB32(p, val);
178
0
                    } else {
179
0
                        uint32_t val = AV_RL32(p) | (s << shift);
180
0
                        AV_WL32(p, val);
181
0
                    }
182
0
                }
183
10.1k
                p += step;
184
10.1k
            }
185
10.1k
        }
186
39.3k
    }
187
39.3k
}
188
189
void av_write_image_line(const uint16_t *src,
190
                         uint8_t *data[4], const int linesize[4],
191
                         const AVPixFmtDescriptor *desc,
192
                         int x, int y, int c, int w)
193
0
{
194
0
    av_write_image_line2(src, data, linesize, desc, x, y, c, w, 2);
195
0
}
196
197
static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
198
    [AV_PIX_FMT_YUV420P] = {
199
        .name = "yuv420p",
200
        .nb_components = 3,
201
        .log2_chroma_w = 1,
202
        .log2_chroma_h = 1,
203
        .comp = {
204
            { 0, 1, 0, 0, 8 },        /* Y */
205
            { 1, 1, 0, 0, 8 },        /* U */
206
            { 2, 1, 0, 0, 8 },        /* V */
207
        },
208
        .flags = AV_PIX_FMT_FLAG_PLANAR,
209
    },
210
    [AV_PIX_FMT_YUYV422] = {
211
        .name = "yuyv422",
212
        .nb_components = 3,
213
        .log2_chroma_w = 1,
214
        .log2_chroma_h = 0,
215
        .comp = {
216
            { 0, 2, 0, 0, 8 },        /* Y */
217
            { 0, 4, 1, 0, 8 },        /* U */
218
            { 0, 4, 3, 0, 8 },        /* V */
219
        },
220
    },
221
    [AV_PIX_FMT_YVYU422] = {
222
        .name = "yvyu422",
223
        .nb_components = 3,
224
        .log2_chroma_w = 1,
225
        .log2_chroma_h = 0,
226
        .comp = {
227
            { 0, 2, 0, 0, 8 },        /* Y */
228
            { 0, 4, 3, 0, 8 },        /* U */
229
            { 0, 4, 1, 0, 8 },        /* V */
230
        },
231
    },
232
    [AV_PIX_FMT_Y210LE] = {
233
        .name = "y210le",
234
        .nb_components = 3,
235
        .log2_chroma_w = 1,
236
        .log2_chroma_h = 0,
237
        .comp = {
238
            { 0, 4, 0, 6, 10 },        /* Y */
239
            { 0, 8, 2, 6, 10 },        /* U */
240
            { 0, 8, 6, 6, 10 },        /* V */
241
        },
242
    },
243
    [AV_PIX_FMT_Y210BE] = {
244
        .name = "y210be",
245
        .nb_components = 3,
246
        .log2_chroma_w = 1,
247
        .log2_chroma_h = 0,
248
        .comp = {
249
            { 0, 4, 0, 6, 10 },        /* Y */
250
            { 0, 8, 2, 6, 10 },        /* U */
251
            { 0, 8, 6, 6, 10 },        /* V */
252
        },
253
        .flags = AV_PIX_FMT_FLAG_BE,
254
    },
255
    [AV_PIX_FMT_RGB24] = {
256
        .name = "rgb24",
257
        .nb_components = 3,
258
        .log2_chroma_w = 0,
259
        .log2_chroma_h = 0,
260
        .comp = {
261
            { 0, 3, 0, 0, 8 },        /* R */
262
            { 0, 3, 1, 0, 8 },        /* G */
263
            { 0, 3, 2, 0, 8 },        /* B */
264
        },
265
        .flags = AV_PIX_FMT_FLAG_RGB,
266
    },
267
    [AV_PIX_FMT_BGR24] = {
268
        .name = "bgr24",
269
        .nb_components = 3,
270
        .log2_chroma_w = 0,
271
        .log2_chroma_h = 0,
272
        .comp = {
273
            { 0, 3, 2, 0, 8 },        /* R */
274
            { 0, 3, 1, 0, 8 },        /* G */
275
            { 0, 3, 0, 0, 8 },        /* B */
276
        },
277
        .flags = AV_PIX_FMT_FLAG_RGB,
278
    },
279
    [AV_PIX_FMT_X2RGB10LE] = {
280
        .name = "x2rgb10le",
281
        .nb_components= 3,
282
        .log2_chroma_w= 0,
283
        .log2_chroma_h= 0,
284
        .comp = {
285
            { 0, 4, 2, 4, 10 },       /* R */
286
            { 0, 4, 1, 2, 10 },       /* G */
287
            { 0, 4, 0, 0, 10 },       /* B */
288
        },
289
        .flags = AV_PIX_FMT_FLAG_RGB,
290
    },
291
    [AV_PIX_FMT_X2RGB10BE] = {
292
        .name = "x2rgb10be",
293
        .nb_components= 3,
294
        .log2_chroma_w= 0,
295
        .log2_chroma_h= 0,
296
        .comp = {
297
            { 0, 4, 0, 4, 10 },       /* R */
298
            { 0, 4, 1, 2, 10 },       /* G */
299
            { 0, 4, 2, 0, 10 },       /* B */
300
        },
301
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
302
    },
303
    [AV_PIX_FMT_X2BGR10LE] = {
304
        .name = "x2bgr10le",
305
        .nb_components= 3,
306
        .log2_chroma_w= 0,
307
        .log2_chroma_h= 0,
308
        .comp = {
309
            { 0, 4, 0, 0, 10 },       /* R */
310
            { 0, 4, 1, 2, 10 },       /* G */
311
            { 0, 4, 2, 4, 10 },       /* B */
312
        },
313
        .flags = AV_PIX_FMT_FLAG_RGB,
314
    },
315
    [AV_PIX_FMT_X2BGR10BE] = {
316
        .name = "x2bgr10be",
317
        .nb_components= 3,
318
        .log2_chroma_w= 0,
319
        .log2_chroma_h= 0,
320
        .comp = {
321
            { 0, 4, 2, 0, 10 },       /* R */
322
            { 0, 4, 1, 2, 10 },       /* G */
323
            { 0, 4, 0, 4, 10 },       /* B */
324
        },
325
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
326
    },
327
    [AV_PIX_FMT_YUV422P] = {
328
        .name = "yuv422p",
329
        .nb_components = 3,
330
        .log2_chroma_w = 1,
331
        .log2_chroma_h = 0,
332
        .comp = {
333
            { 0, 1, 0, 0, 8 },        /* Y */
334
            { 1, 1, 0, 0, 8 },        /* U */
335
            { 2, 1, 0, 0, 8 },        /* V */
336
        },
337
        .flags = AV_PIX_FMT_FLAG_PLANAR,
338
    },
339
    [AV_PIX_FMT_YUV444P] = {
340
        .name = "yuv444p",
341
        .nb_components = 3,
342
        .log2_chroma_w = 0,
343
        .log2_chroma_h = 0,
344
        .comp = {
345
            { 0, 1, 0, 0, 8 },        /* Y */
346
            { 1, 1, 0, 0, 8 },        /* U */
347
            { 2, 1, 0, 0, 8 },        /* V */
348
        },
349
        .flags = AV_PIX_FMT_FLAG_PLANAR,
350
    },
351
    [AV_PIX_FMT_YUV410P] = {
352
        .name = "yuv410p",
353
        .nb_components = 3,
354
        .log2_chroma_w = 2,
355
        .log2_chroma_h = 2,
356
        .comp = {
357
            { 0, 1, 0, 0, 8 },        /* Y */
358
            { 1, 1, 0, 0, 8 },        /* U */
359
            { 2, 1, 0, 0, 8 },        /* V */
360
        },
361
        .flags = AV_PIX_FMT_FLAG_PLANAR,
362
    },
363
    [AV_PIX_FMT_YUV411P] = {
364
        .name = "yuv411p",
365
        .nb_components = 3,
366
        .log2_chroma_w = 2,
367
        .log2_chroma_h = 0,
368
        .comp = {
369
            { 0, 1, 0, 0, 8 },        /* Y */
370
            { 1, 1, 0, 0, 8 },        /* U */
371
            { 2, 1, 0, 0, 8 },        /* V */
372
        },
373
        .flags = AV_PIX_FMT_FLAG_PLANAR,
374
    },
375
    [AV_PIX_FMT_YUVJ411P] = {
376
        .name = "yuvj411p",
377
        .nb_components = 3,
378
        .log2_chroma_w = 2,
379
        .log2_chroma_h = 0,
380
        .comp = {
381
            { 0, 1, 0, 0, 8 },        /* Y */
382
            { 1, 1, 0, 0, 8 },        /* U */
383
            { 2, 1, 0, 0, 8 },        /* V */
384
        },
385
        .flags = AV_PIX_FMT_FLAG_PLANAR,
386
    },
387
    [AV_PIX_FMT_GRAY8] = {
388
        .name = "gray",
389
        .nb_components = 1,
390
        .log2_chroma_w = 0,
391
        .log2_chroma_h = 0,
392
        .comp = {
393
            { 0, 1, 0, 0, 8 },        /* Y */
394
        },
395
        .alias = "gray8,y8",
396
    },
397
    [AV_PIX_FMT_MONOWHITE] = {
398
        .name = "monow",
399
        .nb_components = 1,
400
        .log2_chroma_w = 0,
401
        .log2_chroma_h = 0,
402
        .comp = {
403
            { 0, 1, 0, 0, 1 },        /* Y */
404
        },
405
        .flags = AV_PIX_FMT_FLAG_BITSTREAM,
406
    },
407
    [AV_PIX_FMT_MONOBLACK] = {
408
        .name = "monob",
409
        .nb_components = 1,
410
        .log2_chroma_w = 0,
411
        .log2_chroma_h = 0,
412
        .comp = {
413
            { 0, 1, 0, 7, 1 },        /* Y */
414
        },
415
        .flags = AV_PIX_FMT_FLAG_BITSTREAM,
416
    },
417
    [AV_PIX_FMT_PAL8] = {
418
        .name = "pal8",
419
        .nb_components = 1,
420
        .log2_chroma_w = 0,
421
        .log2_chroma_h = 0,
422
        .comp = {
423
            { 0, 1, 0, 0, 8 },
424
        },
425
        .flags = AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_ALPHA,
426
    },
427
    [AV_PIX_FMT_YUVJ420P] = {
428
        .name = "yuvj420p",
429
        .nb_components = 3,
430
        .log2_chroma_w = 1,
431
        .log2_chroma_h = 1,
432
        .comp = {
433
            { 0, 1, 0, 0, 8 },        /* Y */
434
            { 1, 1, 0, 0, 8 },        /* U */
435
            { 2, 1, 0, 0, 8 },        /* V */
436
        },
437
        .flags = AV_PIX_FMT_FLAG_PLANAR,
438
    },
439
    [AV_PIX_FMT_YUVJ422P] = {
440
        .name = "yuvj422p",
441
        .nb_components = 3,
442
        .log2_chroma_w = 1,
443
        .log2_chroma_h = 0,
444
        .comp = {
445
            { 0, 1, 0, 0, 8 },        /* Y */
446
            { 1, 1, 0, 0, 8 },        /* U */
447
            { 2, 1, 0, 0, 8 },        /* V */
448
        },
449
        .flags = AV_PIX_FMT_FLAG_PLANAR,
450
    },
451
    [AV_PIX_FMT_YUVJ444P] = {
452
        .name = "yuvj444p",
453
        .nb_components = 3,
454
        .log2_chroma_w = 0,
455
        .log2_chroma_h = 0,
456
        .comp = {
457
            { 0, 1, 0, 0, 8 },        /* Y */
458
            { 1, 1, 0, 0, 8 },        /* U */
459
            { 2, 1, 0, 0, 8 },        /* V */
460
        },
461
        .flags = AV_PIX_FMT_FLAG_PLANAR,
462
    },
463
    [AV_PIX_FMT_UYVY422] = {
464
        .name = "uyvy422",
465
        .nb_components = 3,
466
        .log2_chroma_w = 1,
467
        .log2_chroma_h = 0,
468
        .comp = {
469
            { 0, 2, 1, 0, 8 },        /* Y */
470
            { 0, 4, 0, 0, 8 },        /* U */
471
            { 0, 4, 2, 0, 8 },        /* V */
472
        },
473
    },
474
    [AV_PIX_FMT_UYYVYY411] = {
475
        .name = "uyyvyy411",
476
        .nb_components = 3,
477
        .log2_chroma_w = 2,
478
        .log2_chroma_h = 0,
479
        .comp = {
480
            { 0, 4, 1, 0, 8 },        /* Y */
481
            { 0, 6, 0, 0, 8 },        /* U */
482
            { 0, 6, 3, 0, 8 },        /* V */
483
        },
484
    },
485
    [AV_PIX_FMT_BGR8] = {
486
        .name = "bgr8",
487
        .nb_components = 3,
488
        .log2_chroma_w = 0,
489
        .log2_chroma_h = 0,
490
        .comp = {
491
            { 0, 1, 0, 0, 3 },        /* R */
492
            { 0, 1, 0, 3, 3 },        /* G */
493
            { 0, 1, 0, 6, 2 },        /* B */
494
        },
495
        .flags = AV_PIX_FMT_FLAG_RGB,
496
    },
497
    [AV_PIX_FMT_BGR4] = {
498
        .name = "bgr4",
499
        .nb_components = 3,
500
        .log2_chroma_w = 0,
501
        .log2_chroma_h = 0,
502
        .comp = {
503
            { 0, 4, 3, 0, 1 },        /* R */
504
            { 0, 4, 1, 0, 2 },        /* G */
505
            { 0, 4, 0, 0, 1 },        /* B */
506
        },
507
        .flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB,
508
    },
509
    [AV_PIX_FMT_BGR4_BYTE] = {
510
        .name = "bgr4_byte",
511
        .nb_components = 3,
512
        .log2_chroma_w = 0,
513
        .log2_chroma_h = 0,
514
        .comp = {
515
            { 0, 1, 0, 0, 1 },        /* R */
516
            { 0, 1, 0, 1, 2 },        /* G */
517
            { 0, 1, 0, 3, 1 },        /* B */
518
        },
519
        .flags = AV_PIX_FMT_FLAG_RGB,
520
    },
521
    [AV_PIX_FMT_RGB8] = {
522
        .name = "rgb8",
523
        .nb_components = 3,
524
        .log2_chroma_w = 0,
525
        .log2_chroma_h = 0,
526
        .comp = {
527
            { 0, 1, 0, 5, 3 },        /* R */
528
            { 0, 1, 0, 2, 3 },        /* G */
529
            { 0, 1, 0, 0, 2 },        /* B */
530
        },
531
        .flags = AV_PIX_FMT_FLAG_RGB,
532
    },
533
    [AV_PIX_FMT_RGB4] = {
534
        .name = "rgb4",
535
        .nb_components = 3,
536
        .log2_chroma_w = 0,
537
        .log2_chroma_h = 0,
538
        .comp = {
539
            { 0, 4, 0, 0, 1 },        /* R */
540
            { 0, 4, 1, 0, 2 },        /* G */
541
            { 0, 4, 3, 0, 1 },        /* B */
542
        },
543
        .flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB,
544
    },
545
    [AV_PIX_FMT_RGB4_BYTE] = {
546
        .name = "rgb4_byte",
547
        .nb_components = 3,
548
        .log2_chroma_w = 0,
549
        .log2_chroma_h = 0,
550
        .comp = {
551
            { 0, 1, 0, 3, 1 },        /* R */
552
            { 0, 1, 0, 1, 2 },        /* G */
553
            { 0, 1, 0, 0, 1 },        /* B */
554
        },
555
        .flags = AV_PIX_FMT_FLAG_RGB,
556
    },
557
    [AV_PIX_FMT_NV12] = {
558
        .name = "nv12",
559
        .nb_components = 3,
560
        .log2_chroma_w = 1,
561
        .log2_chroma_h = 1,
562
        .comp = {
563
            { 0, 1, 0, 0, 8 },        /* Y */
564
            { 1, 2, 0, 0, 8 },        /* U */
565
            { 1, 2, 1, 0, 8 },        /* V */
566
        },
567
        .flags = AV_PIX_FMT_FLAG_PLANAR,
568
    },
569
    [AV_PIX_FMT_NV21] = {
570
        .name = "nv21",
571
        .nb_components = 3,
572
        .log2_chroma_w = 1,
573
        .log2_chroma_h = 1,
574
        .comp = {
575
            { 0, 1, 0, 0, 8 },        /* Y */
576
            { 1, 2, 1, 0, 8 },        /* U */
577
            { 1, 2, 0, 0, 8 },        /* V */
578
        },
579
        .flags = AV_PIX_FMT_FLAG_PLANAR,
580
    },
581
    [AV_PIX_FMT_ARGB] = {
582
        .name = "argb",
583
        .nb_components = 4,
584
        .log2_chroma_w = 0,
585
        .log2_chroma_h = 0,
586
        .comp = {
587
            { 0, 4, 1, 0, 8 },        /* R */
588
            { 0, 4, 2, 0, 8 },        /* G */
589
            { 0, 4, 3, 0, 8 },        /* B */
590
            { 0, 4, 0, 0, 8 },        /* A */
591
        },
592
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
593
    },
594
    [AV_PIX_FMT_RGBA] = {
595
        .name = "rgba",
596
        .nb_components = 4,
597
        .log2_chroma_w = 0,
598
        .log2_chroma_h = 0,
599
        .comp = {
600
            { 0, 4, 0, 0, 8 },        /* R */
601
            { 0, 4, 1, 0, 8 },        /* G */
602
            { 0, 4, 2, 0, 8 },        /* B */
603
            { 0, 4, 3, 0, 8 },        /* A */
604
        },
605
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
606
    },
607
    [AV_PIX_FMT_ABGR] = {
608
        .name = "abgr",
609
        .nb_components = 4,
610
        .log2_chroma_w = 0,
611
        .log2_chroma_h = 0,
612
        .comp = {
613
            { 0, 4, 3, 0, 8 },        /* R */
614
            { 0, 4, 2, 0, 8 },        /* G */
615
            { 0, 4, 1, 0, 8 },        /* B */
616
            { 0, 4, 0, 0, 8 },        /* A */
617
        },
618
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
619
    },
620
    [AV_PIX_FMT_BGRA] = {
621
        .name = "bgra",
622
        .nb_components = 4,
623
        .log2_chroma_w = 0,
624
        .log2_chroma_h = 0,
625
        .comp = {
626
            { 0, 4, 2, 0, 8 },        /* R */
627
            { 0, 4, 1, 0, 8 },        /* G */
628
            { 0, 4, 0, 0, 8 },        /* B */
629
            { 0, 4, 3, 0, 8 },        /* A */
630
        },
631
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
632
    },
633
    [AV_PIX_FMT_0RGB] = {
634
        .name = "0rgb",
635
        .nb_components= 3,
636
        .log2_chroma_w= 0,
637
        .log2_chroma_h= 0,
638
        .comp = {
639
            { 0, 4, 1, 0, 8 },        /* R */
640
            { 0, 4, 2, 0, 8 },        /* G */
641
            { 0, 4, 3, 0, 8 },        /* B */
642
        },
643
        .flags = AV_PIX_FMT_FLAG_RGB,
644
    },
645
    [AV_PIX_FMT_RGB0] = {
646
        .name = "rgb0",
647
        .nb_components= 3,
648
        .log2_chroma_w= 0,
649
        .log2_chroma_h= 0,
650
        .comp = {
651
            { 0, 4, 0, 0, 8 },        /* R */
652
            { 0, 4, 1, 0, 8 },        /* G */
653
            { 0, 4, 2, 0, 8 },        /* B */
654
        },
655
        .flags = AV_PIX_FMT_FLAG_RGB,
656
    },
657
    [AV_PIX_FMT_0BGR] = {
658
        .name = "0bgr",
659
        .nb_components= 3,
660
        .log2_chroma_w= 0,
661
        .log2_chroma_h= 0,
662
        .comp = {
663
            { 0, 4, 3, 0, 8 },        /* R */
664
            { 0, 4, 2, 0, 8 },        /* G */
665
            { 0, 4, 1, 0, 8 },        /* B */
666
        },
667
        .flags = AV_PIX_FMT_FLAG_RGB,
668
    },
669
    [AV_PIX_FMT_BGR0] = {
670
        .name = "bgr0",
671
        .nb_components= 3,
672
        .log2_chroma_w= 0,
673
        .log2_chroma_h= 0,
674
        .comp = {
675
            { 0, 4, 2, 0, 8 },        /* R */
676
            { 0, 4, 1, 0, 8 },        /* G */
677
            { 0, 4, 0, 0, 8 },        /* B */
678
        },
679
        .flags = AV_PIX_FMT_FLAG_RGB,
680
    },
681
    [AV_PIX_FMT_GRAY9BE] = {
682
        .name = "gray9be",
683
        .nb_components = 1,
684
        .log2_chroma_w = 0,
685
        .log2_chroma_h = 0,
686
        .comp = {
687
            { 0, 2, 0, 0, 9 },       /* Y */
688
        },
689
        .flags = AV_PIX_FMT_FLAG_BE,
690
        .alias = "y9be",
691
    },
692
    [AV_PIX_FMT_GRAY9LE] = {
693
        .name = "gray9le",
694
        .nb_components = 1,
695
        .log2_chroma_w = 0,
696
        .log2_chroma_h = 0,
697
        .comp = {
698
            { 0, 2, 0, 0, 9 },       /* Y */
699
        },
700
        .alias = "y9le",
701
    },
702
    [AV_PIX_FMT_GRAY10BE] = {
703
        .name = "gray10be",
704
        .nb_components = 1,
705
        .log2_chroma_w = 0,
706
        .log2_chroma_h = 0,
707
        .comp = {
708
            { 0, 2, 0, 0, 10 },       /* Y */
709
        },
710
        .flags = AV_PIX_FMT_FLAG_BE,
711
        .alias = "y10be",
712
    },
713
    [AV_PIX_FMT_GRAY10LE] = {
714
        .name = "gray10le",
715
        .nb_components = 1,
716
        .log2_chroma_w = 0,
717
        .log2_chroma_h = 0,
718
        .comp = {
719
            { 0, 2, 0, 0, 10 },       /* Y */
720
        },
721
        .alias = "y10le",
722
    },
723
    [AV_PIX_FMT_GRAY12BE] = {
724
        .name = "gray12be",
725
        .nb_components = 1,
726
        .log2_chroma_w = 0,
727
        .log2_chroma_h = 0,
728
        .comp = {
729
            { 0, 2, 0, 0, 12 },       /* Y */
730
        },
731
        .flags = AV_PIX_FMT_FLAG_BE,
732
        .alias = "y12be",
733
    },
734
    [AV_PIX_FMT_GRAY12LE] = {
735
        .name = "gray12le",
736
        .nb_components = 1,
737
        .log2_chroma_w = 0,
738
        .log2_chroma_h = 0,
739
        .comp = {
740
            { 0, 2, 0, 0, 12 },       /* Y */
741
        },
742
        .alias = "y12le",
743
    },
744
    [AV_PIX_FMT_GRAY14BE] = {
745
        .name = "gray14be",
746
        .nb_components = 1,
747
        .log2_chroma_w = 0,
748
        .log2_chroma_h = 0,
749
        .comp = {
750
            { 0, 2, 0, 0, 14 },       /* Y */
751
        },
752
        .flags = AV_PIX_FMT_FLAG_BE,
753
        .alias = "y14be",
754
    },
755
    [AV_PIX_FMT_GRAY14LE] = {
756
        .name = "gray14le",
757
        .nb_components = 1,
758
        .log2_chroma_w = 0,
759
        .log2_chroma_h = 0,
760
        .comp = {
761
            { 0, 2, 0, 0, 14 },       /* Y */
762
        },
763
        .alias = "y14le",
764
    },
765
    [AV_PIX_FMT_GRAY16BE] = {
766
        .name = "gray16be",
767
        .nb_components = 1,
768
        .log2_chroma_w = 0,
769
        .log2_chroma_h = 0,
770
        .comp = {
771
            { 0, 2, 0, 0, 16 },       /* Y */
772
        },
773
        .flags = AV_PIX_FMT_FLAG_BE,
774
        .alias = "y16be",
775
    },
776
    [AV_PIX_FMT_GRAY16LE] = {
777
        .name = "gray16le",
778
        .nb_components = 1,
779
        .log2_chroma_w = 0,
780
        .log2_chroma_h = 0,
781
        .comp = {
782
            { 0, 2, 0, 0, 16 },       /* Y */
783
        },
784
        .alias = "y16le",
785
    },
786
    [AV_PIX_FMT_YUV440P] = {
787
        .name = "yuv440p",
788
        .nb_components = 3,
789
        .log2_chroma_w = 0,
790
        .log2_chroma_h = 1,
791
        .comp = {
792
            { 0, 1, 0, 0, 8 },        /* Y */
793
            { 1, 1, 0, 0, 8 },        /* U */
794
            { 2, 1, 0, 0, 8 },        /* V */
795
        },
796
        .flags = AV_PIX_FMT_FLAG_PLANAR,
797
    },
798
    [AV_PIX_FMT_YUVJ440P] = {
799
        .name = "yuvj440p",
800
        .nb_components = 3,
801
        .log2_chroma_w = 0,
802
        .log2_chroma_h = 1,
803
        .comp = {
804
            { 0, 1, 0, 0, 8 },        /* Y */
805
            { 1, 1, 0, 0, 8 },        /* U */
806
            { 2, 1, 0, 0, 8 },        /* V */
807
        },
808
        .flags = AV_PIX_FMT_FLAG_PLANAR,
809
    },
810
    [AV_PIX_FMT_YUV440P10LE] = {
811
        .name = "yuv440p10le",
812
        .nb_components = 3,
813
        .log2_chroma_w = 0,
814
        .log2_chroma_h = 1,
815
        .comp = {
816
            { 0, 2, 0, 0, 10 },        /* Y */
817
            { 1, 2, 0, 0, 10 },        /* U */
818
            { 2, 2, 0, 0, 10 },        /* V */
819
        },
820
        .flags = AV_PIX_FMT_FLAG_PLANAR,
821
    },
822
    [AV_PIX_FMT_YUV440P10BE] = {
823
        .name = "yuv440p10be",
824
        .nb_components = 3,
825
        .log2_chroma_w = 0,
826
        .log2_chroma_h = 1,
827
        .comp = {
828
            { 0, 2, 0, 0, 10 },        /* Y */
829
            { 1, 2, 0, 0, 10 },        /* U */
830
            { 2, 2, 0, 0, 10 },        /* V */
831
        },
832
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
833
    },
834
    [AV_PIX_FMT_YUV440P12LE] = {
835
        .name = "yuv440p12le",
836
        .nb_components = 3,
837
        .log2_chroma_w = 0,
838
        .log2_chroma_h = 1,
839
        .comp = {
840
            { 0, 2, 0, 0, 12 },        /* Y */
841
            { 1, 2, 0, 0, 12 },        /* U */
842
            { 2, 2, 0, 0, 12 },        /* V */
843
        },
844
        .flags = AV_PIX_FMT_FLAG_PLANAR,
845
    },
846
    [AV_PIX_FMT_YUV440P12BE] = {
847
        .name = "yuv440p12be",
848
        .nb_components = 3,
849
        .log2_chroma_w = 0,
850
        .log2_chroma_h = 1,
851
        .comp = {
852
            { 0, 2, 0, 0, 12 },        /* Y */
853
            { 1, 2, 0, 0, 12 },        /* U */
854
            { 2, 2, 0, 0, 12 },        /* V */
855
        },
856
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
857
    },
858
    [AV_PIX_FMT_YUVA420P] = {
859
        .name = "yuva420p",
860
        .nb_components = 4,
861
        .log2_chroma_w = 1,
862
        .log2_chroma_h = 1,
863
        .comp = {
864
            { 0, 1, 0, 0, 8 },        /* Y */
865
            { 1, 1, 0, 0, 8 },        /* U */
866
            { 2, 1, 0, 0, 8 },        /* V */
867
            { 3, 1, 0, 0, 8 },        /* A */
868
        },
869
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
870
    },
871
    [AV_PIX_FMT_YUVA422P] = {
872
        .name = "yuva422p",
873
        .nb_components = 4,
874
        .log2_chroma_w = 1,
875
        .log2_chroma_h = 0,
876
        .comp = {
877
            { 0, 1, 0, 0, 8 },        /* Y */
878
            { 1, 1, 0, 0, 8 },        /* U */
879
            { 2, 1, 0, 0, 8 },        /* V */
880
            { 3, 1, 0, 0, 8 },        /* A */
881
        },
882
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
883
    },
884
    [AV_PIX_FMT_YUVA444P] = {
885
        .name = "yuva444p",
886
        .nb_components = 4,
887
        .log2_chroma_w = 0,
888
        .log2_chroma_h = 0,
889
        .comp = {
890
            { 0, 1, 0, 0, 8 },        /* Y */
891
            { 1, 1, 0, 0, 8 },        /* U */
892
            { 2, 1, 0, 0, 8 },        /* V */
893
            { 3, 1, 0, 0, 8 },        /* A */
894
        },
895
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
896
    },
897
    [AV_PIX_FMT_YUVA420P9BE] = {
898
        .name = "yuva420p9be",
899
        .nb_components = 4,
900
        .log2_chroma_w = 1,
901
        .log2_chroma_h = 1,
902
        .comp = {
903
            { 0, 2, 0, 0, 9 },        /* Y */
904
            { 1, 2, 0, 0, 9 },        /* U */
905
            { 2, 2, 0, 0, 9 },        /* V */
906
            { 3, 2, 0, 0, 9 },        /* A */
907
        },
908
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
909
    },
910
    [AV_PIX_FMT_YUVA420P9LE] = {
911
        .name = "yuva420p9le",
912
        .nb_components = 4,
913
        .log2_chroma_w = 1,
914
        .log2_chroma_h = 1,
915
        .comp = {
916
            { 0, 2, 0, 0, 9 },        /* Y */
917
            { 1, 2, 0, 0, 9 },        /* U */
918
            { 2, 2, 0, 0, 9 },        /* V */
919
            { 3, 2, 0, 0, 9 },        /* A */
920
        },
921
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
922
    },
923
    [AV_PIX_FMT_YUVA422P9BE] = {
924
        .name = "yuva422p9be",
925
        .nb_components = 4,
926
        .log2_chroma_w = 1,
927
        .log2_chroma_h = 0,
928
        .comp = {
929
            { 0, 2, 0, 0, 9 },        /* Y */
930
            { 1, 2, 0, 0, 9 },        /* U */
931
            { 2, 2, 0, 0, 9 },        /* V */
932
            { 3, 2, 0, 0, 9 },        /* A */
933
        },
934
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
935
    },
936
    [AV_PIX_FMT_YUVA422P9LE] = {
937
        .name = "yuva422p9le",
938
        .nb_components = 4,
939
        .log2_chroma_w = 1,
940
        .log2_chroma_h = 0,
941
        .comp = {
942
            { 0, 2, 0, 0, 9 },        /* Y */
943
            { 1, 2, 0, 0, 9 },        /* U */
944
            { 2, 2, 0, 0, 9 },        /* V */
945
            { 3, 2, 0, 0, 9 },        /* A */
946
        },
947
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
948
    },
949
    [AV_PIX_FMT_YUVA444P9BE] = {
950
        .name = "yuva444p9be",
951
        .nb_components = 4,
952
        .log2_chroma_w = 0,
953
        .log2_chroma_h = 0,
954
        .comp = {
955
            { 0, 2, 0, 0, 9 },        /* Y */
956
            { 1, 2, 0, 0, 9 },        /* U */
957
            { 2, 2, 0, 0, 9 },        /* V */
958
            { 3, 2, 0, 0, 9 },        /* A */
959
        },
960
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
961
    },
962
    [AV_PIX_FMT_YUVA444P9LE] = {
963
        .name = "yuva444p9le",
964
        .nb_components = 4,
965
        .log2_chroma_w = 0,
966
        .log2_chroma_h = 0,
967
        .comp = {
968
            { 0, 2, 0, 0, 9 },        /* Y */
969
            { 1, 2, 0, 0, 9 },        /* U */
970
            { 2, 2, 0, 0, 9 },        /* V */
971
            { 3, 2, 0, 0, 9 },        /* A */
972
        },
973
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
974
    },
975
    [AV_PIX_FMT_YUVA420P10BE] = {
976
        .name = "yuva420p10be",
977
        .nb_components = 4,
978
        .log2_chroma_w = 1,
979
        .log2_chroma_h = 1,
980
        .comp = {
981
            { 0, 2, 0, 0, 10 },        /* Y */
982
            { 1, 2, 0, 0, 10 },        /* U */
983
            { 2, 2, 0, 0, 10 },        /* V */
984
            { 3, 2, 0, 0, 10 },        /* A */
985
        },
986
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
987
    },
988
    [AV_PIX_FMT_YUVA420P10LE] = {
989
        .name = "yuva420p10le",
990
        .nb_components = 4,
991
        .log2_chroma_w = 1,
992
        .log2_chroma_h = 1,
993
        .comp = {
994
            { 0, 2, 0, 0, 10 },        /* Y */
995
            { 1, 2, 0, 0, 10 },        /* U */
996
            { 2, 2, 0, 0, 10 },        /* V */
997
            { 3, 2, 0, 0, 10 },        /* A */
998
        },
999
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1000
    },
1001
    [AV_PIX_FMT_YUVA422P10BE] = {
1002
        .name = "yuva422p10be",
1003
        .nb_components = 4,
1004
        .log2_chroma_w = 1,
1005
        .log2_chroma_h = 0,
1006
        .comp = {
1007
            { 0, 2, 0, 0, 10 },        /* Y */
1008
            { 1, 2, 0, 0, 10 },        /* U */
1009
            { 2, 2, 0, 0, 10 },        /* V */
1010
            { 3, 2, 0, 0, 10 },        /* A */
1011
        },
1012
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1013
    },
1014
    [AV_PIX_FMT_YUVA422P10LE] = {
1015
        .name = "yuva422p10le",
1016
        .nb_components = 4,
1017
        .log2_chroma_w = 1,
1018
        .log2_chroma_h = 0,
1019
        .comp = {
1020
            { 0, 2, 0, 0, 10 },        /* Y */
1021
            { 1, 2, 0, 0, 10 },        /* U */
1022
            { 2, 2, 0, 0, 10 },        /* V */
1023
            { 3, 2, 0, 0, 10 },        /* A */
1024
        },
1025
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1026
    },
1027
    [AV_PIX_FMT_YUVA444P10BE] = {
1028
        .name = "yuva444p10be",
1029
        .nb_components = 4,
1030
        .log2_chroma_w = 0,
1031
        .log2_chroma_h = 0,
1032
        .comp = {
1033
            { 0, 2, 0, 0, 10 },        /* Y */
1034
            { 1, 2, 0, 0, 10 },        /* U */
1035
            { 2, 2, 0, 0, 10 },        /* V */
1036
            { 3, 2, 0, 0, 10 },        /* A */
1037
        },
1038
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1039
    },
1040
    [AV_PIX_FMT_YUVA444P10LE] = {
1041
        .name = "yuva444p10le",
1042
        .nb_components = 4,
1043
        .log2_chroma_w = 0,
1044
        .log2_chroma_h = 0,
1045
        .comp = {
1046
            { 0, 2, 0, 0, 10 },        /* Y */
1047
            { 1, 2, 0, 0, 10 },        /* U */
1048
            { 2, 2, 0, 0, 10 },        /* V */
1049
            { 3, 2, 0, 0, 10 },        /* A */
1050
        },
1051
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1052
    },
1053
    [AV_PIX_FMT_YUVA420P16BE] = {
1054
        .name = "yuva420p16be",
1055
        .nb_components = 4,
1056
        .log2_chroma_w = 1,
1057
        .log2_chroma_h = 1,
1058
        .comp = {
1059
            { 0, 2, 0, 0, 16 },        /* Y */
1060
            { 1, 2, 0, 0, 16 },        /* U */
1061
            { 2, 2, 0, 0, 16 },        /* V */
1062
            { 3, 2, 0, 0, 16 },        /* A */
1063
        },
1064
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1065
    },
1066
    [AV_PIX_FMT_YUVA420P16LE] = {
1067
        .name = "yuva420p16le",
1068
        .nb_components = 4,
1069
        .log2_chroma_w = 1,
1070
        .log2_chroma_h = 1,
1071
        .comp = {
1072
            { 0, 2, 0, 0, 16 },        /* Y */
1073
            { 1, 2, 0, 0, 16 },        /* U */
1074
            { 2, 2, 0, 0, 16 },        /* V */
1075
            { 3, 2, 0, 0, 16 },        /* A */
1076
        },
1077
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1078
    },
1079
    [AV_PIX_FMT_YUVA422P16BE] = {
1080
        .name = "yuva422p16be",
1081
        .nb_components = 4,
1082
        .log2_chroma_w = 1,
1083
        .log2_chroma_h = 0,
1084
        .comp = {
1085
            { 0, 2, 0, 0, 16 },        /* Y */
1086
            { 1, 2, 0, 0, 16 },        /* U */
1087
            { 2, 2, 0, 0, 16 },        /* V */
1088
            { 3, 2, 0, 0, 16 },        /* A */
1089
        },
1090
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1091
    },
1092
    [AV_PIX_FMT_YUVA422P16LE] = {
1093
        .name = "yuva422p16le",
1094
        .nb_components = 4,
1095
        .log2_chroma_w = 1,
1096
        .log2_chroma_h = 0,
1097
        .comp = {
1098
            { 0, 2, 0, 0, 16 },        /* Y */
1099
            { 1, 2, 0, 0, 16 },        /* U */
1100
            { 2, 2, 0, 0, 16 },        /* V */
1101
            { 3, 2, 0, 0, 16 },        /* A */
1102
        },
1103
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1104
    },
1105
    [AV_PIX_FMT_YUVA444P16BE] = {
1106
        .name = "yuva444p16be",
1107
        .nb_components = 4,
1108
        .log2_chroma_w = 0,
1109
        .log2_chroma_h = 0,
1110
        .comp = {
1111
            { 0, 2, 0, 0, 16 },        /* Y */
1112
            { 1, 2, 0, 0, 16 },        /* U */
1113
            { 2, 2, 0, 0, 16 },        /* V */
1114
            { 3, 2, 0, 0, 16 },        /* A */
1115
        },
1116
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1117
    },
1118
    [AV_PIX_FMT_YUVA444P16LE] = {
1119
        .name = "yuva444p16le",
1120
        .nb_components = 4,
1121
        .log2_chroma_w = 0,
1122
        .log2_chroma_h = 0,
1123
        .comp = {
1124
            { 0, 2, 0, 0, 16 },        /* Y */
1125
            { 1, 2, 0, 0, 16 },        /* U */
1126
            { 2, 2, 0, 0, 16 },        /* V */
1127
            { 3, 2, 0, 0, 16 },        /* A */
1128
        },
1129
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
1130
    },
1131
    [AV_PIX_FMT_RGB48BE] = {
1132
        .name = "rgb48be",
1133
        .nb_components = 3,
1134
        .log2_chroma_w = 0,
1135
        .log2_chroma_h = 0,
1136
        .comp = {
1137
            { 0, 6, 0, 0, 16 },       /* R */
1138
            { 0, 6, 2, 0, 16 },       /* G */
1139
            { 0, 6, 4, 0, 16 },       /* B */
1140
        },
1141
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
1142
    },
1143
    [AV_PIX_FMT_RGB48LE] = {
1144
        .name = "rgb48le",
1145
        .nb_components = 3,
1146
        .log2_chroma_w = 0,
1147
        .log2_chroma_h = 0,
1148
        .comp = {
1149
            { 0, 6, 0, 0, 16 },       /* R */
1150
            { 0, 6, 2, 0, 16 },       /* G */
1151
            { 0, 6, 4, 0, 16 },       /* B */
1152
        },
1153
        .flags = AV_PIX_FMT_FLAG_RGB,
1154
    },
1155
    [AV_PIX_FMT_RGBA64BE] = {
1156
        .name = "rgba64be",
1157
        .nb_components = 4,
1158
        .log2_chroma_w = 0,
1159
        .log2_chroma_h = 0,
1160
        .comp = {
1161
            { 0, 8, 0, 0, 16 },       /* R */
1162
            { 0, 8, 2, 0, 16 },       /* G */
1163
            { 0, 8, 4, 0, 16 },       /* B */
1164
            { 0, 8, 6, 0, 16 },       /* A */
1165
        },
1166
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
1167
    },
1168
    [AV_PIX_FMT_RGBA64LE] = {
1169
        .name = "rgba64le",
1170
        .nb_components = 4,
1171
        .log2_chroma_w = 0,
1172
        .log2_chroma_h = 0,
1173
        .comp = {
1174
            { 0, 8, 0, 0, 16 },       /* R */
1175
            { 0, 8, 2, 0, 16 },       /* G */
1176
            { 0, 8, 4, 0, 16 },       /* B */
1177
            { 0, 8, 6, 0, 16 },       /* A */
1178
        },
1179
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
1180
    },
1181
    [AV_PIX_FMT_RGB565BE] = {
1182
        .name = "rgb565be",
1183
        .nb_components = 3,
1184
        .log2_chroma_w = 0,
1185
        .log2_chroma_h = 0,
1186
        .comp = {
1187
            { 0, 2, -1, 3, 5 },        /* R */
1188
            { 0, 2,  0, 5, 6 },        /* G */
1189
            { 0, 2,  0, 0, 5 },        /* B */
1190
        },
1191
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
1192
    },
1193
    [AV_PIX_FMT_RGB565LE] = {
1194
        .name = "rgb565le",
1195
        .nb_components = 3,
1196
        .log2_chroma_w = 0,
1197
        .log2_chroma_h = 0,
1198
        .comp = {
1199
            { 0, 2, 1, 3, 5 },        /* R */
1200
            { 0, 2, 0, 5, 6 },        /* G */
1201
            { 0, 2, 0, 0, 5 },        /* B */
1202
        },
1203
        .flags = AV_PIX_FMT_FLAG_RGB,
1204
    },
1205
    [AV_PIX_FMT_RGB555BE] = {
1206
        .name = "rgb555be",
1207
        .nb_components = 3,
1208
        .log2_chroma_w = 0,
1209
        .log2_chroma_h = 0,
1210
        .comp = {
1211
            { 0, 2, -1, 2, 5 },        /* R */
1212
            { 0, 2,  0, 5, 5 },        /* G */
1213
            { 0, 2,  0, 0, 5 },        /* B */
1214
        },
1215
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
1216
    },
1217
    [AV_PIX_FMT_RGB555LE] = {
1218
        .name = "rgb555le",
1219
        .nb_components = 3,
1220
        .log2_chroma_w = 0,
1221
        .log2_chroma_h = 0,
1222
        .comp = {
1223
            { 0, 2, 1, 2, 5 },        /* R */
1224
            { 0, 2, 0, 5, 5 },        /* G */
1225
            { 0, 2, 0, 0, 5 },        /* B */
1226
        },
1227
        .flags = AV_PIX_FMT_FLAG_RGB,
1228
    },
1229
    [AV_PIX_FMT_RGB444BE] = {
1230
        .name = "rgb444be",
1231
        .nb_components = 3,
1232
        .log2_chroma_w = 0,
1233
        .log2_chroma_h = 0,
1234
        .comp = {
1235
            { 0, 2, -1, 0, 4 },        /* R */
1236
            { 0, 2,  0, 4, 4 },        /* G */
1237
            { 0, 2,  0, 0, 4 },        /* B */
1238
        },
1239
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
1240
    },
1241
    [AV_PIX_FMT_RGB444LE] = {
1242
        .name = "rgb444le",
1243
        .nb_components = 3,
1244
        .log2_chroma_w = 0,
1245
        .log2_chroma_h = 0,
1246
        .comp = {
1247
            { 0, 2, 1, 0, 4 },        /* R */
1248
            { 0, 2, 0, 4, 4 },        /* G */
1249
            { 0, 2, 0, 0, 4 },        /* B */
1250
        },
1251
        .flags = AV_PIX_FMT_FLAG_RGB,
1252
    },
1253
    [AV_PIX_FMT_BGR48BE] = {
1254
        .name = "bgr48be",
1255
        .nb_components = 3,
1256
        .log2_chroma_w = 0,
1257
        .log2_chroma_h = 0,
1258
        .comp = {
1259
            { 0, 6, 4, 0, 16 },       /* R */
1260
            { 0, 6, 2, 0, 16 },       /* G */
1261
            { 0, 6, 0, 0, 16 },       /* B */
1262
        },
1263
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
1264
    },
1265
    [AV_PIX_FMT_BGR48LE] = {
1266
        .name = "bgr48le",
1267
        .nb_components = 3,
1268
        .log2_chroma_w = 0,
1269
        .log2_chroma_h = 0,
1270
        .comp = {
1271
            { 0, 6, 4, 0, 16 },       /* R */
1272
            { 0, 6, 2, 0, 16 },       /* G */
1273
            { 0, 6, 0, 0, 16 },       /* B */
1274
        },
1275
        .flags = AV_PIX_FMT_FLAG_RGB,
1276
    },
1277
    [AV_PIX_FMT_BGRA64BE] = {
1278
        .name = "bgra64be",
1279
        .nb_components = 4,
1280
        .log2_chroma_w = 0,
1281
        .log2_chroma_h = 0,
1282
        .comp = {
1283
            { 0, 8, 4, 0, 16 },       /* R */
1284
            { 0, 8, 2, 0, 16 },       /* G */
1285
            { 0, 8, 0, 0, 16 },       /* B */
1286
            { 0, 8, 6, 0, 16 },       /* A */
1287
        },
1288
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
1289
    },
1290
    [AV_PIX_FMT_BGRA64LE] = {
1291
        .name = "bgra64le",
1292
        .nb_components = 4,
1293
        .log2_chroma_w = 0,
1294
        .log2_chroma_h = 0,
1295
        .comp = {
1296
            { 0, 8, 4, 0, 16 },       /* R */
1297
            { 0, 8, 2, 0, 16 },       /* G */
1298
            { 0, 8, 0, 0, 16 },       /* B */
1299
            { 0, 8, 6, 0, 16 },       /* A */
1300
        },
1301
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
1302
    },
1303
    [AV_PIX_FMT_BGR565BE] = {
1304
        .name = "bgr565be",
1305
        .nb_components = 3,
1306
        .log2_chroma_w = 0,
1307
        .log2_chroma_h = 0,
1308
        .comp = {
1309
            { 0, 2,  0, 0, 5 },        /* R */
1310
            { 0, 2,  0, 5, 6 },        /* G */
1311
            { 0, 2, -1, 3, 5 },        /* B */
1312
        },
1313
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
1314
    },
1315
    [AV_PIX_FMT_BGR565LE] = {
1316
        .name = "bgr565le",
1317
        .nb_components = 3,
1318
        .log2_chroma_w = 0,
1319
        .log2_chroma_h = 0,
1320
        .comp = {
1321
            { 0, 2, 0, 0, 5 },        /* R */
1322
            { 0, 2, 0, 5, 6 },        /* G */
1323
            { 0, 2, 1, 3, 5 },        /* B */
1324
        },
1325
        .flags = AV_PIX_FMT_FLAG_RGB,
1326
    },
1327
    [AV_PIX_FMT_BGR555BE] = {
1328
        .name = "bgr555be",
1329
        .nb_components = 3,
1330
        .log2_chroma_w = 0,
1331
        .log2_chroma_h = 0,
1332
        .comp = {
1333
            { 0, 2,  0, 0, 5 },       /* R */
1334
            { 0, 2,  0, 5, 5 },       /* G */
1335
            { 0, 2, -1, 2, 5 },       /* B */
1336
        },
1337
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
1338
     },
1339
    [AV_PIX_FMT_BGR555LE] = {
1340
        .name = "bgr555le",
1341
        .nb_components = 3,
1342
        .log2_chroma_w = 0,
1343
        .log2_chroma_h = 0,
1344
        .comp = {
1345
            { 0, 2, 0, 0, 5 },        /* R */
1346
            { 0, 2, 0, 5, 5 },        /* G */
1347
            { 0, 2, 1, 2, 5 },        /* B */
1348
        },
1349
        .flags = AV_PIX_FMT_FLAG_RGB,
1350
    },
1351
    [AV_PIX_FMT_BGR444BE] = {
1352
        .name = "bgr444be",
1353
        .nb_components = 3,
1354
        .log2_chroma_w = 0,
1355
        .log2_chroma_h = 0,
1356
        .comp = {
1357
            { 0, 2,  0, 0, 4 },       /* R */
1358
            { 0, 2,  0, 4, 4 },       /* G */
1359
            { 0, 2, -1, 0, 4 },       /* B */
1360
        },
1361
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB,
1362
     },
1363
    [AV_PIX_FMT_BGR444LE] = {
1364
        .name = "bgr444le",
1365
        .nb_components = 3,
1366
        .log2_chroma_w = 0,
1367
        .log2_chroma_h = 0,
1368
        .comp = {
1369
            { 0, 2, 0, 0, 4 },        /* R */
1370
            { 0, 2, 0, 4, 4 },        /* G */
1371
            { 0, 2, 1, 0, 4 },        /* B */
1372
        },
1373
        .flags = AV_PIX_FMT_FLAG_RGB,
1374
    },
1375
    [AV_PIX_FMT_VAAPI] = {
1376
        .name = "vaapi",
1377
        .log2_chroma_w = 1,
1378
        .log2_chroma_h = 1,
1379
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
1380
    },
1381
    [AV_PIX_FMT_YUV420P9LE] = {
1382
        .name = "yuv420p9le",
1383
        .nb_components = 3,
1384
        .log2_chroma_w = 1,
1385
        .log2_chroma_h = 1,
1386
        .comp = {
1387
            { 0, 2, 0, 0, 9 },        /* Y */
1388
            { 1, 2, 0, 0, 9 },        /* U */
1389
            { 2, 2, 0, 0, 9 },        /* V */
1390
        },
1391
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1392
    },
1393
    [AV_PIX_FMT_YUV420P9BE] = {
1394
        .name = "yuv420p9be",
1395
        .nb_components = 3,
1396
        .log2_chroma_w = 1,
1397
        .log2_chroma_h = 1,
1398
        .comp = {
1399
            { 0, 2, 0, 0, 9 },        /* Y */
1400
            { 1, 2, 0, 0, 9 },        /* U */
1401
            { 2, 2, 0, 0, 9 },        /* V */
1402
        },
1403
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1404
    },
1405
    [AV_PIX_FMT_YUV420P10LE] = {
1406
        .name = "yuv420p10le",
1407
        .nb_components = 3,
1408
        .log2_chroma_w = 1,
1409
        .log2_chroma_h = 1,
1410
        .comp = {
1411
            { 0, 2, 0, 0, 10 },        /* Y */
1412
            { 1, 2, 0, 0, 10 },        /* U */
1413
            { 2, 2, 0, 0, 10 },        /* V */
1414
        },
1415
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1416
    },
1417
    [AV_PIX_FMT_YUV420P10BE] = {
1418
        .name = "yuv420p10be",
1419
        .nb_components = 3,
1420
        .log2_chroma_w = 1,
1421
        .log2_chroma_h = 1,
1422
        .comp = {
1423
            { 0, 2, 0, 0, 10 },        /* Y */
1424
            { 1, 2, 0, 0, 10 },        /* U */
1425
            { 2, 2, 0, 0, 10 },        /* V */
1426
        },
1427
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1428
    },
1429
    [AV_PIX_FMT_YUV420P12LE] = {
1430
        .name = "yuv420p12le",
1431
        .nb_components = 3,
1432
        .log2_chroma_w = 1,
1433
        .log2_chroma_h = 1,
1434
        .comp = {
1435
            { 0, 2, 0, 0, 12 },        /* Y */
1436
            { 1, 2, 0, 0, 12 },        /* U */
1437
            { 2, 2, 0, 0, 12 },        /* V */
1438
        },
1439
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1440
    },
1441
    [AV_PIX_FMT_YUV420P12BE] = {
1442
        .name = "yuv420p12be",
1443
        .nb_components = 3,
1444
        .log2_chroma_w = 1,
1445
        .log2_chroma_h = 1,
1446
        .comp = {
1447
            { 0, 2, 0, 0, 12 },        /* Y */
1448
            { 1, 2, 0, 0, 12 },        /* U */
1449
            { 2, 2, 0, 0, 12 },        /* V */
1450
        },
1451
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1452
    },
1453
    [AV_PIX_FMT_YUV420P14LE] = {
1454
        .name = "yuv420p14le",
1455
        .nb_components = 3,
1456
        .log2_chroma_w = 1,
1457
        .log2_chroma_h = 1,
1458
        .comp = {
1459
            { 0, 2, 0, 0, 14 },        /* Y */
1460
            { 1, 2, 0, 0, 14 },        /* U */
1461
            { 2, 2, 0, 0, 14 },        /* V */
1462
        },
1463
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1464
    },
1465
    [AV_PIX_FMT_YUV420P14BE] = {
1466
        .name = "yuv420p14be",
1467
        .nb_components = 3,
1468
        .log2_chroma_w = 1,
1469
        .log2_chroma_h = 1,
1470
        .comp = {
1471
            { 0, 2, 0, 0, 14 },        /* Y */
1472
            { 1, 2, 0, 0, 14 },        /* U */
1473
            { 2, 2, 0, 0, 14 },        /* V */
1474
        },
1475
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1476
    },
1477
    [AV_PIX_FMT_YUV420P16LE] = {
1478
        .name = "yuv420p16le",
1479
        .nb_components = 3,
1480
        .log2_chroma_w = 1,
1481
        .log2_chroma_h = 1,
1482
        .comp = {
1483
            { 0, 2, 0, 0, 16 },        /* Y */
1484
            { 1, 2, 0, 0, 16 },        /* U */
1485
            { 2, 2, 0, 0, 16 },        /* V */
1486
        },
1487
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1488
    },
1489
    [AV_PIX_FMT_YUV420P16BE] = {
1490
        .name = "yuv420p16be",
1491
        .nb_components = 3,
1492
        .log2_chroma_w = 1,
1493
        .log2_chroma_h = 1,
1494
        .comp = {
1495
            { 0, 2, 0, 0, 16 },        /* Y */
1496
            { 1, 2, 0, 0, 16 },        /* U */
1497
            { 2, 2, 0, 0, 16 },        /* V */
1498
        },
1499
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1500
    },
1501
    [AV_PIX_FMT_YUV422P9LE] = {
1502
        .name = "yuv422p9le",
1503
        .nb_components = 3,
1504
        .log2_chroma_w = 1,
1505
        .log2_chroma_h = 0,
1506
        .comp = {
1507
            { 0, 2, 0, 0, 9 },        /* Y */
1508
            { 1, 2, 0, 0, 9 },        /* U */
1509
            { 2, 2, 0, 0, 9 },        /* V */
1510
        },
1511
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1512
    },
1513
    [AV_PIX_FMT_YUV422P9BE] = {
1514
        .name = "yuv422p9be",
1515
        .nb_components = 3,
1516
        .log2_chroma_w = 1,
1517
        .log2_chroma_h = 0,
1518
        .comp = {
1519
            { 0, 2, 0, 0, 9 },        /* Y */
1520
            { 1, 2, 0, 0, 9 },        /* U */
1521
            { 2, 2, 0, 0, 9 },        /* V */
1522
        },
1523
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1524
    },
1525
    [AV_PIX_FMT_YUV422P10LE] = {
1526
        .name = "yuv422p10le",
1527
        .nb_components = 3,
1528
        .log2_chroma_w = 1,
1529
        .log2_chroma_h = 0,
1530
        .comp = {
1531
            { 0, 2, 0, 0, 10 },        /* Y */
1532
            { 1, 2, 0, 0, 10 },        /* U */
1533
            { 2, 2, 0, 0, 10 },        /* V */
1534
        },
1535
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1536
    },
1537
    [AV_PIX_FMT_YUV422P10BE] = {
1538
        .name = "yuv422p10be",
1539
        .nb_components = 3,
1540
        .log2_chroma_w = 1,
1541
        .log2_chroma_h = 0,
1542
        .comp = {
1543
            { 0, 2, 0, 0, 10 },        /* Y */
1544
            { 1, 2, 0, 0, 10 },        /* U */
1545
            { 2, 2, 0, 0, 10 },        /* V */
1546
        },
1547
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1548
    },
1549
    [AV_PIX_FMT_YUV422P12LE] = {
1550
        .name = "yuv422p12le",
1551
        .nb_components = 3,
1552
        .log2_chroma_w = 1,
1553
        .log2_chroma_h = 0,
1554
        .comp = {
1555
            { 0, 2, 0, 0, 12 },        /* Y */
1556
            { 1, 2, 0, 0, 12 },        /* U */
1557
            { 2, 2, 0, 0, 12 },        /* V */
1558
        },
1559
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1560
    },
1561
    [AV_PIX_FMT_YUV422P12BE] = {
1562
        .name = "yuv422p12be",
1563
        .nb_components = 3,
1564
        .log2_chroma_w = 1,
1565
        .log2_chroma_h = 0,
1566
        .comp = {
1567
            { 0, 2, 0, 0, 12 },        /* Y */
1568
            { 1, 2, 0, 0, 12 },        /* U */
1569
            { 2, 2, 0, 0, 12 },        /* V */
1570
        },
1571
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1572
    },
1573
    [AV_PIX_FMT_YUV422P14LE] = {
1574
        .name = "yuv422p14le",
1575
        .nb_components = 3,
1576
        .log2_chroma_w = 1,
1577
        .log2_chroma_h = 0,
1578
        .comp = {
1579
            { 0, 2, 0, 0, 14 },        /* Y */
1580
            { 1, 2, 0, 0, 14 },        /* U */
1581
            { 2, 2, 0, 0, 14 },        /* V */
1582
        },
1583
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1584
    },
1585
    [AV_PIX_FMT_YUV422P14BE] = {
1586
        .name = "yuv422p14be",
1587
        .nb_components = 3,
1588
        .log2_chroma_w = 1,
1589
        .log2_chroma_h = 0,
1590
        .comp = {
1591
            { 0, 2, 0, 0, 14 },        /* Y */
1592
            { 1, 2, 0, 0, 14 },        /* U */
1593
            { 2, 2, 0, 0, 14 },        /* V */
1594
        },
1595
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1596
    },
1597
    [AV_PIX_FMT_YUV422P16LE] = {
1598
        .name = "yuv422p16le",
1599
        .nb_components = 3,
1600
        .log2_chroma_w = 1,
1601
        .log2_chroma_h = 0,
1602
        .comp = {
1603
            { 0, 2, 0, 0, 16 },        /* Y */
1604
            { 1, 2, 0, 0, 16 },        /* U */
1605
            { 2, 2, 0, 0, 16 },        /* V */
1606
        },
1607
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1608
    },
1609
    [AV_PIX_FMT_YUV422P16BE] = {
1610
        .name = "yuv422p16be",
1611
        .nb_components = 3,
1612
        .log2_chroma_w = 1,
1613
        .log2_chroma_h = 0,
1614
        .comp = {
1615
            { 0, 2, 0, 0, 16 },        /* Y */
1616
            { 1, 2, 0, 0, 16 },        /* U */
1617
            { 2, 2, 0, 0, 16 },        /* V */
1618
        },
1619
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1620
    },
1621
    [AV_PIX_FMT_YUV444P16LE] = {
1622
        .name = "yuv444p16le",
1623
        .nb_components = 3,
1624
        .log2_chroma_w = 0,
1625
        .log2_chroma_h = 0,
1626
        .comp = {
1627
            { 0, 2, 0, 0, 16 },        /* Y */
1628
            { 1, 2, 0, 0, 16 },        /* U */
1629
            { 2, 2, 0, 0, 16 },        /* V */
1630
        },
1631
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1632
    },
1633
    [AV_PIX_FMT_YUV444P16BE] = {
1634
        .name = "yuv444p16be",
1635
        .nb_components = 3,
1636
        .log2_chroma_w = 0,
1637
        .log2_chroma_h = 0,
1638
        .comp = {
1639
            { 0, 2, 0, 0, 16 },        /* Y */
1640
            { 1, 2, 0, 0, 16 },        /* U */
1641
            { 2, 2, 0, 0, 16 },        /* V */
1642
        },
1643
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1644
    },
1645
    [AV_PIX_FMT_YUV444P10LE] = {
1646
        .name = "yuv444p10le",
1647
        .nb_components = 3,
1648
        .log2_chroma_w = 0,
1649
        .log2_chroma_h = 0,
1650
        .comp = {
1651
            { 0, 2, 0, 0, 10 },        /* Y */
1652
            { 1, 2, 0, 0, 10 },        /* U */
1653
            { 2, 2, 0, 0, 10 },        /* V */
1654
        },
1655
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1656
    },
1657
    [AV_PIX_FMT_YUV444P10BE] = {
1658
        .name = "yuv444p10be",
1659
        .nb_components = 3,
1660
        .log2_chroma_w = 0,
1661
        .log2_chroma_h = 0,
1662
        .comp = {
1663
            { 0, 2, 0, 0, 10 },        /* Y */
1664
            { 1, 2, 0, 0, 10 },        /* U */
1665
            { 2, 2, 0, 0, 10 },        /* V */
1666
        },
1667
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1668
    },
1669
    [AV_PIX_FMT_YUV444P9LE] = {
1670
        .name = "yuv444p9le",
1671
        .nb_components = 3,
1672
        .log2_chroma_w = 0,
1673
        .log2_chroma_h = 0,
1674
        .comp = {
1675
            { 0, 2, 0, 0, 9 },        /* Y */
1676
            { 1, 2, 0, 0, 9 },        /* U */
1677
            { 2, 2, 0, 0, 9 },        /* V */
1678
        },
1679
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1680
    },
1681
    [AV_PIX_FMT_YUV444P9BE] = {
1682
        .name = "yuv444p9be",
1683
        .nb_components = 3,
1684
        .log2_chroma_w = 0,
1685
        .log2_chroma_h = 0,
1686
        .comp = {
1687
            { 0, 2, 0, 0, 9 },        /* Y */
1688
            { 1, 2, 0, 0, 9 },        /* U */
1689
            { 2, 2, 0, 0, 9 },        /* V */
1690
        },
1691
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1692
    },
1693
    [AV_PIX_FMT_YUV444P12LE] = {
1694
        .name = "yuv444p12le",
1695
        .nb_components = 3,
1696
        .log2_chroma_w = 0,
1697
        .log2_chroma_h = 0,
1698
        .comp = {
1699
            { 0, 2, 0, 0, 12 },        /* Y */
1700
            { 1, 2, 0, 0, 12 },        /* U */
1701
            { 2, 2, 0, 0, 12 },        /* V */
1702
        },
1703
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1704
    },
1705
    [AV_PIX_FMT_YUV444P12BE] = {
1706
        .name = "yuv444p12be",
1707
        .nb_components = 3,
1708
        .log2_chroma_w = 0,
1709
        .log2_chroma_h = 0,
1710
        .comp = {
1711
            { 0, 2, 0, 0, 12 },        /* Y */
1712
            { 1, 2, 0, 0, 12 },        /* U */
1713
            { 2, 2, 0, 0, 12 },        /* V */
1714
        },
1715
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1716
    },
1717
    [AV_PIX_FMT_YUV444P14LE] = {
1718
        .name = "yuv444p14le",
1719
        .nb_components = 3,
1720
        .log2_chroma_w = 0,
1721
        .log2_chroma_h = 0,
1722
        .comp = {
1723
            { 0, 2, 0, 0, 14 },        /* Y */
1724
            { 1, 2, 0, 0, 14 },        /* U */
1725
            { 2, 2, 0, 0, 14 },        /* V */
1726
        },
1727
        .flags = AV_PIX_FMT_FLAG_PLANAR,
1728
    },
1729
    [AV_PIX_FMT_YUV444P14BE] = {
1730
        .name = "yuv444p14be",
1731
        .nb_components = 3,
1732
        .log2_chroma_w = 0,
1733
        .log2_chroma_h = 0,
1734
        .comp = {
1735
            { 0, 2, 0, 0, 14 },        /* Y */
1736
            { 1, 2, 0, 0, 14 },        /* U */
1737
            { 2, 2, 0, 0, 14 },        /* V */
1738
        },
1739
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
1740
    },
1741
    [AV_PIX_FMT_D3D11VA_VLD] = {
1742
        .name = "d3d11va_vld",
1743
        .log2_chroma_w = 1,
1744
        .log2_chroma_h = 1,
1745
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
1746
    },
1747
    [AV_PIX_FMT_DXVA2_VLD] = {
1748
        .name = "dxva2_vld",
1749
        .log2_chroma_w = 1,
1750
        .log2_chroma_h = 1,
1751
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
1752
    },
1753
    [AV_PIX_FMT_YA8] = {
1754
        .name = "ya8",
1755
        .nb_components = 2,
1756
        .comp = {
1757
            { 0, 2, 0, 0, 8 },        /* Y */
1758
            { 0, 2, 1, 0, 8 },        /* A */
1759
        },
1760
        .flags = AV_PIX_FMT_FLAG_ALPHA,
1761
        .alias = "gray8a",
1762
    },
1763
    [AV_PIX_FMT_YA16LE] = {
1764
        .name = "ya16le",
1765
        .nb_components = 2,
1766
        .comp = {
1767
            { 0, 4, 0, 0, 16 },        /* Y */
1768
            { 0, 4, 2, 0, 16 },        /* A */
1769
        },
1770
        .flags = AV_PIX_FMT_FLAG_ALPHA,
1771
    },
1772
    [AV_PIX_FMT_YA16BE] = {
1773
        .name = "ya16be",
1774
        .nb_components = 2,
1775
        .comp = {
1776
            { 0, 4, 0, 0, 16 },        /* Y */
1777
            { 0, 4, 2, 0, 16 },        /* A */
1778
        },
1779
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
1780
    },
1781
    [AV_PIX_FMT_VIDEOTOOLBOX] = {
1782
        .name = "videotoolbox_vld",
1783
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
1784
    },
1785
    [AV_PIX_FMT_GBRP] = {
1786
        .name = "gbrp",
1787
        .nb_components = 3,
1788
        .log2_chroma_w = 0,
1789
        .log2_chroma_h = 0,
1790
        .comp = {
1791
            { 2, 1, 0, 0, 8 },        /* R */
1792
            { 0, 1, 0, 0, 8 },        /* G */
1793
            { 1, 1, 0, 0, 8 },        /* B */
1794
        },
1795
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1796
    },
1797
    [AV_PIX_FMT_GBRP9LE] = {
1798
        .name = "gbrp9le",
1799
        .nb_components = 3,
1800
        .log2_chroma_w = 0,
1801
        .log2_chroma_h = 0,
1802
        .comp = {
1803
            { 2, 2, 0, 0, 9 },        /* R */
1804
            { 0, 2, 0, 0, 9 },        /* G */
1805
            { 1, 2, 0, 0, 9 },        /* B */
1806
        },
1807
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1808
    },
1809
    [AV_PIX_FMT_GBRP9BE] = {
1810
        .name = "gbrp9be",
1811
        .nb_components = 3,
1812
        .log2_chroma_w = 0,
1813
        .log2_chroma_h = 0,
1814
        .comp = {
1815
            { 2, 2, 0, 0, 9 },        /* R */
1816
            { 0, 2, 0, 0, 9 },        /* G */
1817
            { 1, 2, 0, 0, 9 },        /* B */
1818
        },
1819
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1820
    },
1821
    [AV_PIX_FMT_GBRP10LE] = {
1822
        .name = "gbrp10le",
1823
        .nb_components = 3,
1824
        .log2_chroma_w = 0,
1825
        .log2_chroma_h = 0,
1826
        .comp = {
1827
            { 2, 2, 0, 0, 10 },        /* R */
1828
            { 0, 2, 0, 0, 10 },        /* G */
1829
            { 1, 2, 0, 0, 10 },        /* B */
1830
        },
1831
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1832
    },
1833
    [AV_PIX_FMT_GBRP10BE] = {
1834
        .name = "gbrp10be",
1835
        .nb_components = 3,
1836
        .log2_chroma_w = 0,
1837
        .log2_chroma_h = 0,
1838
        .comp = {
1839
            { 2, 2, 0, 0, 10 },        /* R */
1840
            { 0, 2, 0, 0, 10 },        /* G */
1841
            { 1, 2, 0, 0, 10 },        /* B */
1842
        },
1843
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1844
    },
1845
    [AV_PIX_FMT_GBRP12LE] = {
1846
        .name = "gbrp12le",
1847
        .nb_components = 3,
1848
        .log2_chroma_w = 0,
1849
        .log2_chroma_h = 0,
1850
        .comp = {
1851
            { 2, 2, 0, 0, 12 },        /* R */
1852
            { 0, 2, 0, 0, 12 },        /* G */
1853
            { 1, 2, 0, 0, 12 },        /* B */
1854
        },
1855
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1856
    },
1857
    [AV_PIX_FMT_GBRP12BE] = {
1858
        .name = "gbrp12be",
1859
        .nb_components = 3,
1860
        .log2_chroma_w = 0,
1861
        .log2_chroma_h = 0,
1862
        .comp = {
1863
            { 2, 2, 0, 0, 12 },        /* R */
1864
            { 0, 2, 0, 0, 12 },        /* G */
1865
            { 1, 2, 0, 0, 12 },        /* B */
1866
        },
1867
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1868
    },
1869
    [AV_PIX_FMT_GBRP14LE] = {
1870
        .name = "gbrp14le",
1871
        .nb_components = 3,
1872
        .log2_chroma_w = 0,
1873
        .log2_chroma_h = 0,
1874
        .comp = {
1875
            { 2, 2, 0, 0, 14 },        /* R */
1876
            { 0, 2, 0, 0, 14 },        /* G */
1877
            { 1, 2, 0, 0, 14 },        /* B */
1878
        },
1879
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1880
    },
1881
    [AV_PIX_FMT_GBRP14BE] = {
1882
        .name = "gbrp14be",
1883
        .nb_components = 3,
1884
        .log2_chroma_w = 0,
1885
        .log2_chroma_h = 0,
1886
        .comp = {
1887
            { 2, 2, 0, 0, 14 },        /* R */
1888
            { 0, 2, 0, 0, 14 },        /* G */
1889
            { 1, 2, 0, 0, 14 },        /* B */
1890
        },
1891
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1892
    },
1893
    [AV_PIX_FMT_GBRP16LE] = {
1894
        .name = "gbrp16le",
1895
        .nb_components = 3,
1896
        .log2_chroma_w = 0,
1897
        .log2_chroma_h = 0,
1898
        .comp = {
1899
            { 2, 2, 0, 0, 16 },       /* R */
1900
            { 0, 2, 0, 0, 16 },       /* G */
1901
            { 1, 2, 0, 0, 16 },       /* B */
1902
        },
1903
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1904
    },
1905
    [AV_PIX_FMT_GBRP16BE] = {
1906
        .name = "gbrp16be",
1907
        .nb_components = 3,
1908
        .log2_chroma_w = 0,
1909
        .log2_chroma_h = 0,
1910
        .comp = {
1911
            { 2, 2, 0, 0, 16 },       /* R */
1912
            { 0, 2, 0, 0, 16 },       /* G */
1913
            { 1, 2, 0, 0, 16 },       /* B */
1914
        },
1915
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB,
1916
    },
1917
    [AV_PIX_FMT_GBRAP] = {
1918
        .name = "gbrap",
1919
        .nb_components = 4,
1920
        .log2_chroma_w = 0,
1921
        .log2_chroma_h = 0,
1922
        .comp = {
1923
            { 2, 1, 0, 0, 8 },        /* R */
1924
            { 0, 1, 0, 0, 8 },        /* G */
1925
            { 1, 1, 0, 0, 8 },        /* B */
1926
            { 3, 1, 0, 0, 8 },        /* A */
1927
        },
1928
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
1929
                 AV_PIX_FMT_FLAG_ALPHA,
1930
    },
1931
    [AV_PIX_FMT_GBRAP16LE] = {
1932
        .name = "gbrap16le",
1933
        .nb_components = 4,
1934
        .log2_chroma_w = 0,
1935
        .log2_chroma_h = 0,
1936
        .comp = {
1937
            { 2, 2, 0, 0, 16 },       /* R */
1938
            { 0, 2, 0, 0, 16 },       /* G */
1939
            { 1, 2, 0, 0, 16 },       /* B */
1940
            { 3, 2, 0, 0, 16 },       /* A */
1941
        },
1942
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
1943
                 AV_PIX_FMT_FLAG_ALPHA,
1944
    },
1945
    [AV_PIX_FMT_GBRAP16BE] = {
1946
        .name = "gbrap16be",
1947
        .nb_components = 4,
1948
        .log2_chroma_w = 0,
1949
        .log2_chroma_h = 0,
1950
        .comp = {
1951
            { 2, 2, 0, 0, 16 },       /* R */
1952
            { 0, 2, 0, 0, 16 },       /* G */
1953
            { 1, 2, 0, 0, 16 },       /* B */
1954
            { 3, 2, 0, 0, 16 },       /* A */
1955
        },
1956
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
1957
                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
1958
    },
1959
    [AV_PIX_FMT_VDPAU] = {
1960
        .name = "vdpau",
1961
        .log2_chroma_w = 1,
1962
        .log2_chroma_h = 1,
1963
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
1964
    },
1965
    [AV_PIX_FMT_XYZ12LE] = {
1966
        .name = "xyz12le",
1967
        .nb_components = 3,
1968
        .log2_chroma_w = 0,
1969
        .log2_chroma_h = 0,
1970
        .comp = {
1971
            { 0, 6, 0, 4, 12 },       /* X */
1972
            { 0, 6, 2, 4, 12 },       /* Y */
1973
            { 0, 6, 4, 4, 12 },       /* Z */
1974
        },
1975
        .flags = AV_PIX_FMT_FLAG_XYZ,
1976
    },
1977
    [AV_PIX_FMT_XYZ12BE] = {
1978
        .name = "xyz12be",
1979
        .nb_components = 3,
1980
        .log2_chroma_w = 0,
1981
        .log2_chroma_h = 0,
1982
        .comp = {
1983
            { 0, 6, 0, 4, 12 },       /* X */
1984
            { 0, 6, 2, 4, 12 },       /* Y */
1985
            { 0, 6, 4, 4, 12 },       /* Z */
1986
       },
1987
        .flags = AV_PIX_FMT_FLAG_XYZ | AV_PIX_FMT_FLAG_BE,
1988
    },
1989
1990
#define BAYER8_DESC_COMMON \
1991
        .nb_components= 3, \
1992
        .log2_chroma_w= 0, \
1993
        .log2_chroma_h= 0, \
1994
        .comp = {          \
1995
            { 0, 1, 0, 0, 2 }, \
1996
            { 0, 1, 0, 0, 4 }, \
1997
            { 0, 1, 0, 0, 2 }, \
1998
        },                 \
1999
2000
#define BAYER16_DESC_COMMON \
2001
        .nb_components= 3, \
2002
        .log2_chroma_w= 0, \
2003
        .log2_chroma_h= 0, \
2004
        .comp = {          \
2005
            { 0, 2, 0, 0, 4 }, \
2006
            { 0, 2, 0, 0, 8 }, \
2007
            { 0, 2, 0, 0, 4 }, \
2008
        },                 \
2009
2010
    [AV_PIX_FMT_BAYER_BGGR8] = {
2011
        .name = "bayer_bggr8",
2012
        BAYER8_DESC_COMMON
2013
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2014
    },
2015
    [AV_PIX_FMT_BAYER_BGGR16LE] = {
2016
        .name = "bayer_bggr16le",
2017
        BAYER16_DESC_COMMON
2018
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2019
    },
2020
    [AV_PIX_FMT_BAYER_BGGR16BE] = {
2021
        .name = "bayer_bggr16be",
2022
        BAYER16_DESC_COMMON
2023
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2024
    },
2025
    [AV_PIX_FMT_BAYER_RGGB8] = {
2026
        .name = "bayer_rggb8",
2027
        BAYER8_DESC_COMMON
2028
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2029
    },
2030
    [AV_PIX_FMT_BAYER_RGGB16LE] = {
2031
        .name = "bayer_rggb16le",
2032
        BAYER16_DESC_COMMON
2033
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2034
    },
2035
    [AV_PIX_FMT_BAYER_RGGB16BE] = {
2036
        .name = "bayer_rggb16be",
2037
        BAYER16_DESC_COMMON
2038
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2039
    },
2040
    [AV_PIX_FMT_BAYER_GBRG8] = {
2041
        .name = "bayer_gbrg8",
2042
        BAYER8_DESC_COMMON
2043
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2044
    },
2045
    [AV_PIX_FMT_BAYER_GBRG16LE] = {
2046
        .name = "bayer_gbrg16le",
2047
        BAYER16_DESC_COMMON
2048
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2049
    },
2050
    [AV_PIX_FMT_BAYER_GBRG16BE] = {
2051
        .name = "bayer_gbrg16be",
2052
        BAYER16_DESC_COMMON
2053
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2054
    },
2055
    [AV_PIX_FMT_BAYER_GRBG8] = {
2056
        .name = "bayer_grbg8",
2057
        BAYER8_DESC_COMMON
2058
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2059
    },
2060
    [AV_PIX_FMT_BAYER_GRBG16LE] = {
2061
        .name = "bayer_grbg16le",
2062
        BAYER16_DESC_COMMON
2063
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2064
    },
2065
    [AV_PIX_FMT_BAYER_GRBG16BE] = {
2066
        .name = "bayer_grbg16be",
2067
        BAYER16_DESC_COMMON
2068
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BAYER,
2069
    },
2070
    [AV_PIX_FMT_NV16] = {
2071
        .name = "nv16",
2072
        .nb_components = 3,
2073
        .log2_chroma_w = 1,
2074
        .log2_chroma_h = 0,
2075
        .comp = {
2076
            { 0, 1, 0, 0, 8 },        /* Y */
2077
            { 1, 2, 0, 0, 8 },        /* U */
2078
            { 1, 2, 1, 0, 8 },        /* V */
2079
        },
2080
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2081
    },
2082
    [AV_PIX_FMT_NV20LE] = {
2083
        .name = "nv20le",
2084
        .nb_components = 3,
2085
        .log2_chroma_w = 1,
2086
        .log2_chroma_h = 0,
2087
        .comp = {
2088
            { 0, 2, 0, 0, 10 },        /* Y */
2089
            { 1, 4, 0, 0, 10 },        /* U */
2090
            { 1, 4, 2, 0, 10 },        /* V */
2091
        },
2092
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2093
    },
2094
    [AV_PIX_FMT_NV20BE] = {
2095
        .name = "nv20be",
2096
        .nb_components = 3,
2097
        .log2_chroma_w = 1,
2098
        .log2_chroma_h = 0,
2099
        .comp = {
2100
            { 0, 2, 0, 0, 10 },        /* Y */
2101
            { 1, 4, 0, 0, 10 },        /* U */
2102
            { 1, 4, 2, 0, 10 },        /* V */
2103
        },
2104
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2105
    },
2106
    [AV_PIX_FMT_QSV] = {
2107
        .name = "qsv",
2108
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2109
    },
2110
    [AV_PIX_FMT_MEDIACODEC] = {
2111
        .name = "mediacodec",
2112
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2113
    },
2114
    [AV_PIX_FMT_MMAL] = {
2115
        .name = "mmal",
2116
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2117
    },
2118
    [AV_PIX_FMT_CUDA] = {
2119
        .name = "cuda",
2120
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2121
    },
2122
    [AV_PIX_FMT_AYUV64LE] = {
2123
        .name = "ayuv64le",
2124
        .nb_components = 4,
2125
        .log2_chroma_w = 0,
2126
        .log2_chroma_h = 0,
2127
        .comp = {
2128
            { 0, 8, 2, 0, 16 },        /* Y */
2129
            { 0, 8, 4, 0, 16 },        /* U */
2130
            { 0, 8, 6, 0, 16 },        /* V */
2131
            { 0, 8, 0, 0, 16 },        /* A */
2132
        },
2133
        .flags = AV_PIX_FMT_FLAG_ALPHA,
2134
    },
2135
    [AV_PIX_FMT_AYUV64BE] = {
2136
        .name = "ayuv64be",
2137
        .nb_components = 4,
2138
        .log2_chroma_w = 0,
2139
        .log2_chroma_h = 0,
2140
        .comp = {
2141
            { 0, 8, 2, 0, 16 },        /* Y */
2142
            { 0, 8, 4, 0, 16 },        /* U */
2143
            { 0, 8, 6, 0, 16 },        /* V */
2144
            { 0, 8, 0, 0, 16 },        /* A */
2145
        },
2146
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
2147
    },
2148
    [AV_PIX_FMT_P010LE] = {
2149
        .name = "p010le",
2150
        .nb_components = 3,
2151
        .log2_chroma_w = 1,
2152
        .log2_chroma_h = 1,
2153
        .comp = {
2154
            { 0, 2, 0, 6, 10 },        /* Y */
2155
            { 1, 4, 0, 6, 10 },        /* U */
2156
            { 1, 4, 2, 6, 10 },        /* V */
2157
        },
2158
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2159
    },
2160
    [AV_PIX_FMT_P010BE] = {
2161
        .name = "p010be",
2162
        .nb_components = 3,
2163
        .log2_chroma_w = 1,
2164
        .log2_chroma_h = 1,
2165
        .comp = {
2166
            { 0, 2, 0, 6, 10 },        /* Y */
2167
            { 1, 4, 0, 6, 10 },        /* U */
2168
            { 1, 4, 2, 6, 10 },        /* V */
2169
        },
2170
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2171
    },
2172
    [AV_PIX_FMT_P012LE] = {
2173
        .name = "p012le",
2174
        .nb_components = 3,
2175
        .log2_chroma_w = 1,
2176
        .log2_chroma_h = 1,
2177
        .comp = {
2178
            { 0, 2, 0, 4, 12 },        /* Y */
2179
            { 1, 4, 0, 4, 12 },        /* U */
2180
            { 1, 4, 2, 4, 12 },        /* V */
2181
        },
2182
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2183
    },
2184
    [AV_PIX_FMT_P012BE] = {
2185
        .name = "p012be",
2186
        .nb_components = 3,
2187
        .log2_chroma_w = 1,
2188
        .log2_chroma_h = 1,
2189
        .comp = {
2190
            { 0, 2, 0, 4, 12 },        /* Y */
2191
            { 1, 4, 0, 4, 12 },        /* U */
2192
            { 1, 4, 2, 4, 12 },        /* V */
2193
        },
2194
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2195
    },
2196
    [AV_PIX_FMT_P016LE] = {
2197
        .name = "p016le",
2198
        .nb_components = 3,
2199
        .log2_chroma_w = 1,
2200
        .log2_chroma_h = 1,
2201
        .comp = {
2202
            { 0, 2, 0, 0, 16 },       /* Y */
2203
            { 1, 4, 0, 0, 16 },       /* U */
2204
            { 1, 4, 2, 0, 16 },       /* V */
2205
        },
2206
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2207
    },
2208
    [AV_PIX_FMT_P016BE] = {
2209
        .name = "p016be",
2210
        .nb_components = 3,
2211
        .log2_chroma_w = 1,
2212
        .log2_chroma_h = 1,
2213
        .comp = {
2214
            { 0, 2, 0, 0, 16 },       /* Y */
2215
            { 1, 4, 0, 0, 16 },       /* U */
2216
            { 1, 4, 2, 0, 16 },       /* V */
2217
        },
2218
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2219
    },
2220
    [AV_PIX_FMT_GBRAP14LE] = {
2221
        .name = "gbrap14le",
2222
        .nb_components = 4,
2223
        .log2_chroma_w = 0,
2224
        .log2_chroma_h = 0,
2225
        .comp = {
2226
            { 2, 2, 0, 0, 14 },       /* R */
2227
            { 0, 2, 0, 0, 14 },       /* G */
2228
            { 1, 2, 0, 0, 14 },       /* B */
2229
            { 3, 2, 0, 0, 14 },       /* A */
2230
        },
2231
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
2232
                 AV_PIX_FMT_FLAG_ALPHA,
2233
    },
2234
    [AV_PIX_FMT_GBRAP14BE] = {
2235
        .name = "gbrap14be",
2236
        .nb_components = 4,
2237
        .log2_chroma_w = 0,
2238
        .log2_chroma_h = 0,
2239
        .comp = {
2240
            { 2, 2, 0, 0, 14 },       /* R */
2241
            { 0, 2, 0, 0, 14 },       /* G */
2242
            { 1, 2, 0, 0, 14 },       /* B */
2243
            { 3, 2, 0, 0, 14 },       /* A */
2244
        },
2245
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
2246
                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
2247
    },
2248
    [AV_PIX_FMT_GBRAP12LE] = {
2249
        .name = "gbrap12le",
2250
        .nb_components = 4,
2251
        .log2_chroma_w = 0,
2252
        .log2_chroma_h = 0,
2253
        .comp = {
2254
            { 2, 2, 0, 0, 12 },       /* R */
2255
            { 0, 2, 0, 0, 12 },       /* G */
2256
            { 1, 2, 0, 0, 12 },       /* B */
2257
            { 3, 2, 0, 0, 12 },       /* A */
2258
        },
2259
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
2260
                 AV_PIX_FMT_FLAG_ALPHA,
2261
    },
2262
    [AV_PIX_FMT_GBRAP12BE] = {
2263
        .name = "gbrap12be",
2264
        .nb_components = 4,
2265
        .log2_chroma_w = 0,
2266
        .log2_chroma_h = 0,
2267
        .comp = {
2268
            { 2, 2, 0, 0, 12 },       /* R */
2269
            { 0, 2, 0, 0, 12 },       /* G */
2270
            { 1, 2, 0, 0, 12 },       /* B */
2271
            { 3, 2, 0, 0, 12 },       /* A */
2272
        },
2273
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
2274
                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
2275
    },
2276
    [AV_PIX_FMT_GBRAP10LE] = {
2277
        .name = "gbrap10le",
2278
        .nb_components = 4,
2279
        .log2_chroma_w = 0,
2280
        .log2_chroma_h = 0,
2281
        .comp = {
2282
            { 2, 2, 0, 0, 10 },       /* R */
2283
            { 0, 2, 0, 0, 10 },       /* G */
2284
            { 1, 2, 0, 0, 10 },       /* B */
2285
            { 3, 2, 0, 0, 10 },       /* A */
2286
        },
2287
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB |
2288
                 AV_PIX_FMT_FLAG_ALPHA,
2289
    },
2290
    [AV_PIX_FMT_GBRAP10BE] = {
2291
        .name = "gbrap10be",
2292
        .nb_components = 4,
2293
        .log2_chroma_w = 0,
2294
        .log2_chroma_h = 0,
2295
        .comp = {
2296
            { 2, 2, 0, 0, 10 },       /* R */
2297
            { 0, 2, 0, 0, 10 },       /* G */
2298
            { 1, 2, 0, 0, 10 },       /* B */
2299
            { 3, 2, 0, 0, 10 },       /* A */
2300
        },
2301
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
2302
                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
2303
    },
2304
    [AV_PIX_FMT_D3D11] = {
2305
        .name = "d3d11",
2306
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2307
    },
2308
    [AV_PIX_FMT_D3D12] = {
2309
        .name = "d3d12",
2310
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2311
    },
2312
    [AV_PIX_FMT_GBRPF32BE] = {
2313
        .name = "gbrpf32be",
2314
        .nb_components = 3,
2315
        .log2_chroma_w = 0,
2316
        .log2_chroma_h = 0,
2317
        .comp = {
2318
            { 2, 4, 0, 0, 32 },        /* R */
2319
            { 0, 4, 0, 0, 32 },        /* G */
2320
            { 1, 4, 0, 0, 32 },        /* B */
2321
        },
2322
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
2323
                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT,
2324
    },
2325
    [AV_PIX_FMT_GBRPF32LE] = {
2326
        .name = "gbrpf32le",
2327
        .nb_components = 3,
2328
        .log2_chroma_w = 0,
2329
        .log2_chroma_h = 0,
2330
        .comp = {
2331
            { 2, 4, 0, 0, 32 },        /* R */
2332
            { 0, 4, 0, 0, 32 },        /* G */
2333
            { 1, 4, 0, 0, 32 },        /* B */
2334
        },
2335
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_RGB,
2336
    },
2337
    [AV_PIX_FMT_GBRAPF32BE] = {
2338
        .name = "gbrapf32be",
2339
        .nb_components = 4,
2340
        .log2_chroma_w = 0,
2341
        .log2_chroma_h = 0,
2342
        .comp = {
2343
            { 2, 4, 0, 0, 32 },        /* R */
2344
            { 0, 4, 0, 0, 32 },        /* G */
2345
            { 1, 4, 0, 0, 32 },        /* B */
2346
            { 3, 4, 0, 0, 32 },        /* A */
2347
        },
2348
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
2349
                 AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_RGB |
2350
                 AV_PIX_FMT_FLAG_FLOAT,
2351
    },
2352
    [AV_PIX_FMT_GBRAPF32LE] = {
2353
        .name = "gbrapf32le",
2354
        .nb_components = 4,
2355
        .log2_chroma_w = 0,
2356
        .log2_chroma_h = 0,
2357
        .comp = {
2358
            { 2, 4, 0, 0, 32 },        /* R */
2359
            { 0, 4, 0, 0, 32 },        /* G */
2360
            { 1, 4, 0, 0, 32 },        /* B */
2361
            { 3, 4, 0, 0, 32 },        /* A */
2362
        },
2363
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA |
2364
                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT,
2365
    },
2366
    [AV_PIX_FMT_DRM_PRIME] = {
2367
        .name = "drm_prime",
2368
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2369
    },
2370
    [AV_PIX_FMT_OPENCL] = {
2371
        .name  = "opencl",
2372
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2373
    },
2374
    [AV_PIX_FMT_GRAYF32BE] = {
2375
        .name = "grayf32be",
2376
        .nb_components = 1,
2377
        .log2_chroma_w = 0,
2378
        .log2_chroma_h = 0,
2379
        .comp = {
2380
            { 0, 4, 0, 0, 32 },       /* Y */
2381
        },
2382
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT,
2383
        .alias = "yf32be",
2384
    },
2385
    [AV_PIX_FMT_GRAYF32LE] = {
2386
        .name = "grayf32le",
2387
        .nb_components = 1,
2388
        .log2_chroma_w = 0,
2389
        .log2_chroma_h = 0,
2390
        .comp = {
2391
            { 0, 4, 0, 0, 32 },       /* Y */
2392
        },
2393
        .flags = AV_PIX_FMT_FLAG_FLOAT,
2394
        .alias = "yf32le",
2395
    },
2396
    [AV_PIX_FMT_YUVA422P12BE] = {
2397
        .name = "yuva422p12be",
2398
        .nb_components = 4,
2399
        .log2_chroma_w = 1,
2400
        .log2_chroma_h = 0,
2401
        .comp = {
2402
            { 0, 2, 0, 0, 12 },        /* Y */
2403
            { 1, 2, 0, 0, 12 },        /* U */
2404
            { 2, 2, 0, 0, 12 },        /* V */
2405
            { 3, 2, 0, 0, 12 },        /* A */
2406
        },
2407
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
2408
    },
2409
    [AV_PIX_FMT_YUVA422P12LE] = {
2410
        .name = "yuva422p12le",
2411
        .nb_components = 4,
2412
        .log2_chroma_w = 1,
2413
        .log2_chroma_h = 0,
2414
        .comp = {
2415
            { 0, 2, 0, 0, 12 },        /* Y */
2416
            { 1, 2, 0, 0, 12 },        /* U */
2417
            { 2, 2, 0, 0, 12 },        /* V */
2418
            { 3, 2, 0, 0, 12 },        /* A */
2419
        },
2420
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
2421
    },
2422
    [AV_PIX_FMT_YUVA444P12BE] = {
2423
        .name = "yuva444p12be",
2424
        .nb_components = 4,
2425
        .log2_chroma_w = 0,
2426
        .log2_chroma_h = 0,
2427
        .comp = {
2428
            { 0, 2, 0, 0, 12 },        /* Y */
2429
            { 1, 2, 0, 0, 12 },        /* U */
2430
            { 2, 2, 0, 0, 12 },        /* V */
2431
            { 3, 2, 0, 0, 12 },        /* A */
2432
        },
2433
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
2434
    },
2435
    [AV_PIX_FMT_YUVA444P12LE] = {
2436
        .name = "yuva444p12le",
2437
        .nb_components = 4,
2438
        .log2_chroma_w = 0,
2439
        .log2_chroma_h = 0,
2440
        .comp = {
2441
            { 0, 2, 0, 0, 12 },        /* Y */
2442
            { 1, 2, 0, 0, 12 },        /* U */
2443
            { 2, 2, 0, 0, 12 },        /* V */
2444
            { 3, 2, 0, 0, 12 },        /* A */
2445
        },
2446
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
2447
    },
2448
    [AV_PIX_FMT_NV24] = {
2449
        .name = "nv24",
2450
        .nb_components = 3,
2451
        .log2_chroma_w = 0,
2452
        .log2_chroma_h = 0,
2453
        .comp = {
2454
            { 0, 1, 0, 0, 8 },        /* Y */
2455
            { 1, 2, 0, 0, 8 },        /* U */
2456
            { 1, 2, 1, 0, 8 },        /* V */
2457
        },
2458
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2459
    },
2460
    [AV_PIX_FMT_NV42] = {
2461
        .name = "nv42",
2462
        .nb_components = 3,
2463
        .log2_chroma_w = 0,
2464
        .log2_chroma_h = 0,
2465
        .comp = {
2466
            { 0, 1, 0, 0, 8 },        /* Y */
2467
            { 1, 2, 1, 0, 8 },        /* U */
2468
            { 1, 2, 0, 0, 8 },        /* V */
2469
        },
2470
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2471
    },
2472
    [AV_PIX_FMT_VULKAN] = {
2473
        .name = "vulkan",
2474
        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2475
    },
2476
    [AV_PIX_FMT_P210BE] = {
2477
        .name = "p210be",
2478
        .nb_components = 3,
2479
        .log2_chroma_w = 1,
2480
        .log2_chroma_h = 0,
2481
        .comp = {
2482
            { 0, 2, 0, 6, 10 },        /* Y */
2483
            { 1, 4, 0, 6, 10 },        /* U */
2484
            { 1, 4, 2, 6, 10 },        /* V */
2485
        },
2486
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2487
    },
2488
    [AV_PIX_FMT_P210LE] = {
2489
        .name = "p210le",
2490
        .nb_components = 3,
2491
        .log2_chroma_w = 1,
2492
        .log2_chroma_h = 0,
2493
        .comp = {
2494
            { 0, 2, 0, 6, 10 },        /* Y */
2495
            { 1, 4, 0, 6, 10 },        /* U */
2496
            { 1, 4, 2, 6, 10 },        /* V */
2497
        },
2498
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2499
    },
2500
    [AV_PIX_FMT_P410BE] = {
2501
        .name = "p410be",
2502
        .nb_components = 3,
2503
        .log2_chroma_w = 0,
2504
        .log2_chroma_h = 0,
2505
        .comp = {
2506
            { 0, 2, 0, 6, 10 },        /* Y */
2507
            { 1, 4, 0, 6, 10 },        /* U */
2508
            { 1, 4, 2, 6, 10 },        /* V */
2509
        },
2510
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2511
    },
2512
    [AV_PIX_FMT_P410LE] = {
2513
        .name = "p410le",
2514
        .nb_components = 3,
2515
        .log2_chroma_w = 0,
2516
        .log2_chroma_h = 0,
2517
        .comp = {
2518
            { 0, 2, 0, 6, 10 },        /* Y */
2519
            { 1, 4, 0, 6, 10 },        /* U */
2520
            { 1, 4, 2, 6, 10 },        /* V */
2521
        },
2522
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2523
    },
2524
    [AV_PIX_FMT_P216BE] = {
2525
        .name = "p216be",
2526
        .nb_components = 3,
2527
        .log2_chroma_w = 1,
2528
        .log2_chroma_h = 0,
2529
        .comp = {
2530
            { 0, 2, 0, 0, 16 },        /* Y */
2531
            { 1, 4, 0, 0, 16 },        /* U */
2532
            { 1, 4, 2, 0, 16 },        /* V */
2533
        },
2534
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2535
    },
2536
    [AV_PIX_FMT_P216LE] = {
2537
        .name = "p216le",
2538
        .nb_components = 3,
2539
        .log2_chroma_w = 1,
2540
        .log2_chroma_h = 0,
2541
        .comp = {
2542
            { 0, 2, 0, 0, 16 },        /* Y */
2543
            { 1, 4, 0, 0, 16 },        /* U */
2544
            { 1, 4, 2, 0, 16 },        /* V */
2545
        },
2546
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2547
    },
2548
    [AV_PIX_FMT_P416BE] = {
2549
        .name = "p416be",
2550
        .nb_components = 3,
2551
        .log2_chroma_w = 0,
2552
        .log2_chroma_h = 0,
2553
        .comp = {
2554
            { 0, 2, 0, 0, 16 },        /* Y */
2555
            { 1, 4, 0, 0, 16 },        /* U */
2556
            { 1, 4, 2, 0, 16 },        /* V */
2557
        },
2558
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2559
    },
2560
    [AV_PIX_FMT_P416LE] = {
2561
        .name = "p416le",
2562
        .nb_components = 3,
2563
        .log2_chroma_w = 0,
2564
        .log2_chroma_h = 0,
2565
        .comp = {
2566
            { 0, 2, 0, 0, 16 },        /* Y */
2567
            { 1, 4, 0, 0, 16 },        /* U */
2568
            { 1, 4, 2, 0, 16 },        /* V */
2569
        },
2570
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2571
    },
2572
    [AV_PIX_FMT_VUYA] = {
2573
        .name = "vuya",
2574
        .nb_components = 4,
2575
        .log2_chroma_w = 0,
2576
        .log2_chroma_h = 0,
2577
        .comp = {
2578
            { 0, 4, 2, 0, 8 },        /* Y */
2579
            { 0, 4, 1, 0, 8 },        /* U */
2580
            { 0, 4, 0, 0, 8 },        /* V */
2581
            { 0, 4, 3, 0, 8 },        /* A */
2582
        },
2583
        .flags = AV_PIX_FMT_FLAG_ALPHA,
2584
    },
2585
    [AV_PIX_FMT_VUYX] = {
2586
        .name = "vuyx",
2587
        .nb_components = 3,
2588
        .log2_chroma_w = 0,
2589
        .log2_chroma_h = 0,
2590
        .comp = {
2591
            { 0, 4, 2, 0, 8 },        /* Y */
2592
            { 0, 4, 1, 0, 8 },        /* U */
2593
            { 0, 4, 0, 0, 8 },        /* V */
2594
        },
2595
    },
2596
    [AV_PIX_FMT_RGBAF16BE] = {
2597
        .name = "rgbaf16be",
2598
        .nb_components = 4,
2599
        .log2_chroma_w = 0,
2600
        .log2_chroma_h = 0,
2601
        .comp = {
2602
            { 0, 8, 0, 0, 16 },       /* R */
2603
            { 0, 8, 2, 0, 16 },       /* G */
2604
            { 0, 8, 4, 0, 16 },       /* B */
2605
            { 0, 8, 6, 0, 16 },       /* A */
2606
        },
2607
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB |
2608
                 AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_FLOAT,
2609
    },
2610
    [AV_PIX_FMT_RGBAF16LE] = {
2611
        .name = "rgbaf16le",
2612
        .nb_components = 4,
2613
        .log2_chroma_w = 0,
2614
        .log2_chroma_h = 0,
2615
        .comp = {
2616
            { 0, 8, 0, 0, 16 },       /* R */
2617
            { 0, 8, 2, 0, 16 },       /* G */
2618
            { 0, 8, 4, 0, 16 },       /* B */
2619
            { 0, 8, 6, 0, 16 },       /* A */
2620
        },
2621
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA |
2622
                 AV_PIX_FMT_FLAG_FLOAT,
2623
    },
2624
    [AV_PIX_FMT_Y212LE] = {
2625
        .name = "y212le",
2626
        .nb_components = 3,
2627
        .log2_chroma_w = 1,
2628
        .log2_chroma_h = 0,
2629
        .comp = {
2630
            { 0, 4, 0, 4, 12 },        /* Y */
2631
            { 0, 8, 2, 4, 12 },        /* U */
2632
            { 0, 8, 6, 4, 12 },        /* V */
2633
        },
2634
    },
2635
    [AV_PIX_FMT_Y212BE] = {
2636
        .name = "y212be",
2637
        .nb_components = 3,
2638
        .log2_chroma_w = 1,
2639
        .log2_chroma_h = 0,
2640
        .comp = {
2641
            { 0, 4, 0, 4, 12 },        /* Y */
2642
            { 0, 8, 2, 4, 12 },        /* U */
2643
            { 0, 8, 6, 4, 12 },        /* V */
2644
        },
2645
        .flags = AV_PIX_FMT_FLAG_BE,
2646
    },
2647
    [AV_PIX_FMT_XV30LE] = {
2648
        .name = "xv30le",
2649
        .nb_components= 3,
2650
        .log2_chroma_w= 0,
2651
        .log2_chroma_h= 0,
2652
        .comp = {
2653
            { 0, 4, 1, 2, 10 },       /* Y */
2654
            { 0, 4, 0, 0, 10 },       /* U */
2655
            { 0, 4, 2, 4, 10 },       /* V */
2656
        },
2657
    },
2658
    [AV_PIX_FMT_XV30BE] = {
2659
        .name = "xv30be",
2660
        .nb_components= 3,
2661
        .log2_chroma_w= 0,
2662
        .log2_chroma_h= 0,
2663
        .comp = {
2664
            { 0, 32, 10, 0, 10 },       /* Y */
2665
            { 0, 32,  0, 0, 10 },       /* U */
2666
            { 0, 32, 20, 0, 10 },       /* V */
2667
        },
2668
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_BITSTREAM,
2669
    },
2670
    [AV_PIX_FMT_XV36LE] = {
2671
        .name = "xv36le",
2672
        .nb_components= 3,
2673
        .log2_chroma_w= 0,
2674
        .log2_chroma_h= 0,
2675
        .comp = {
2676
            { 0, 8, 2, 4, 12 },       /* Y */
2677
            { 0, 8, 0, 4, 12 },       /* U */
2678
            { 0, 8, 4, 4, 12 },       /* V */
2679
        },
2680
    },
2681
    [AV_PIX_FMT_XV36BE] = {
2682
        .name = "xv36be",
2683
        .nb_components= 3,
2684
        .log2_chroma_w= 0,
2685
        .log2_chroma_h= 0,
2686
        .comp = {
2687
            { 0, 8, 2, 4, 12 },       /* Y */
2688
            { 0, 8, 0, 4, 12 },       /* U */
2689
            { 0, 8, 4, 4, 12 },       /* V */
2690
        },
2691
        .flags = AV_PIX_FMT_FLAG_BE,
2692
    },
2693
    [AV_PIX_FMT_RGBF32BE] = {
2694
        .name = "rgbf32be",
2695
        .nb_components = 3,
2696
        .log2_chroma_w = 0,
2697
        .log2_chroma_h = 0,
2698
        .comp = {
2699
            { 0, 12, 0, 0, 32 },       /* R */
2700
            { 0, 12, 4, 0, 32 },       /* G */
2701
            { 0, 12, 8, 0, 32 },       /* B */
2702
        },
2703
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB |
2704
                 AV_PIX_FMT_FLAG_FLOAT,
2705
    },
2706
    [AV_PIX_FMT_RGBF32LE] = {
2707
        .name = "rgbf32le",
2708
        .nb_components = 3,
2709
        .log2_chroma_w = 0,
2710
        .log2_chroma_h = 0,
2711
        .comp = {
2712
            { 0, 12, 0, 0, 32 },       /* R */
2713
            { 0, 12, 4, 0, 32 },       /* G */
2714
            { 0, 12, 8, 0, 32 },       /* B */
2715
        },
2716
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT,
2717
    },
2718
    [AV_PIX_FMT_RGBAF32BE] = {
2719
        .name = "rgbaf32be",
2720
        .nb_components = 4,
2721
        .log2_chroma_w = 0,
2722
        .log2_chroma_h = 0,
2723
        .comp = {
2724
            { 0, 16,  0, 0, 32 },      /* R */
2725
            { 0, 16,  4, 0, 32 },      /* G */
2726
            { 0, 16,  8, 0, 32 },      /* B */
2727
            { 0, 16, 12, 0, 32 },      /* A */
2728
        },
2729
        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB |
2730
                 AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
2731
    },
2732
    [AV_PIX_FMT_RGBAF32LE] = {
2733
        .name = "rgbaf32le",
2734
        .nb_components = 4,
2735
        .log2_chroma_w = 0,
2736
        .log2_chroma_h = 0,
2737
        .comp = {
2738
            { 0, 16,  0, 0, 32 },      /* R */
2739
            { 0, 16,  4, 0, 32 },      /* G */
2740
            { 0, 16,  8, 0, 32 },      /* B */
2741
            { 0, 16, 12, 0, 32 },      /* A */
2742
        },
2743
        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT |
2744
                 AV_PIX_FMT_FLAG_ALPHA,
2745
    },
2746
    [AV_PIX_FMT_P212BE] = {
2747
        .name = "p212be",
2748
        .nb_components = 3,
2749
        .log2_chroma_w = 1,
2750
        .log2_chroma_h = 0,
2751
        .comp = {
2752
            { 0, 2, 0, 4, 12 },        /* Y */
2753
            { 1, 4, 0, 4, 12 },        /* U */
2754
            { 1, 4, 2, 4, 12 },        /* V */
2755
        },
2756
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2757
    },
2758
    [AV_PIX_FMT_P212LE] = {
2759
        .name = "p212le",
2760
        .nb_components = 3,
2761
        .log2_chroma_w = 1,
2762
        .log2_chroma_h = 0,
2763
        .comp = {
2764
            { 0, 2, 0, 4, 12 },        /* Y */
2765
            { 1, 4, 0, 4, 12 },        /* U */
2766
            { 1, 4, 2, 4, 12 },        /* V */
2767
        },
2768
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2769
    },
2770
    [AV_PIX_FMT_P412BE] = {
2771
        .name = "p412be",
2772
        .nb_components = 3,
2773
        .log2_chroma_w = 0,
2774
        .log2_chroma_h = 0,
2775
        .comp = {
2776
            { 0, 2, 0, 4, 12 },        /* Y */
2777
            { 1, 4, 0, 4, 12 },        /* U */
2778
            { 1, 4, 2, 4, 12 },        /* V */
2779
        },
2780
        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2781
    },
2782
    [AV_PIX_FMT_P412LE] = {
2783
        .name = "p412le",
2784
        .nb_components = 3,
2785
        .log2_chroma_w = 0,
2786
        .log2_chroma_h = 0,
2787
        .comp = {
2788
            { 0, 2, 0, 4, 12 },        /* Y */
2789
            { 1, 4, 0, 4, 12 },        /* U */
2790
            { 1, 4, 2, 4, 12 },        /* V */
2791
        },
2792
        .flags = AV_PIX_FMT_FLAG_PLANAR,
2793
    },
2794
};
2795
2796
static const char * const color_range_names[] = {
2797
    [AVCOL_RANGE_UNSPECIFIED] = "unknown",
2798
    [AVCOL_RANGE_MPEG] = "tv",
2799
    [AVCOL_RANGE_JPEG] = "pc",
2800
};
2801
2802
static const char * const color_primaries_names[AVCOL_PRI_NB] = {
2803
    [AVCOL_PRI_RESERVED0] = "reserved",
2804
    [AVCOL_PRI_BT709] = "bt709",
2805
    [AVCOL_PRI_UNSPECIFIED] = "unknown",
2806
    [AVCOL_PRI_RESERVED] = "reserved",
2807
    [AVCOL_PRI_BT470M] = "bt470m",
2808
    [AVCOL_PRI_BT470BG] = "bt470bg",
2809
    [AVCOL_PRI_SMPTE170M] = "smpte170m",
2810
    [AVCOL_PRI_SMPTE240M] = "smpte240m",
2811
    [AVCOL_PRI_FILM] = "film",
2812
    [AVCOL_PRI_BT2020] = "bt2020",
2813
    [AVCOL_PRI_SMPTE428] = "smpte428",
2814
    [AVCOL_PRI_SMPTE431] = "smpte431",
2815
    [AVCOL_PRI_SMPTE432] = "smpte432",
2816
    [AVCOL_PRI_EBU3213] = "ebu3213",
2817
};
2818
2819
static const char * const color_transfer_names[] = {
2820
    [AVCOL_TRC_RESERVED0] = "reserved",
2821
    [AVCOL_TRC_BT709] = "bt709",
2822
    [AVCOL_TRC_UNSPECIFIED] = "unknown",
2823
    [AVCOL_TRC_RESERVED] = "reserved",
2824
    [AVCOL_TRC_GAMMA22] = "bt470m",
2825
    [AVCOL_TRC_GAMMA28] = "bt470bg",
2826
    [AVCOL_TRC_SMPTE170M] = "smpte170m",
2827
    [AVCOL_TRC_SMPTE240M] = "smpte240m",
2828
    [AVCOL_TRC_LINEAR] = "linear",
2829
    [AVCOL_TRC_LOG] = "log100",
2830
    [AVCOL_TRC_LOG_SQRT] = "log316",
2831
    [AVCOL_TRC_IEC61966_2_4] = "iec61966-2-4",
2832
    [AVCOL_TRC_BT1361_ECG] = "bt1361e",
2833
    [AVCOL_TRC_IEC61966_2_1] = "iec61966-2-1",
2834
    [AVCOL_TRC_BT2020_10] = "bt2020-10",
2835
    [AVCOL_TRC_BT2020_12] = "bt2020-12",
2836
    [AVCOL_TRC_SMPTE2084] = "smpte2084",
2837
    [AVCOL_TRC_SMPTE428] = "smpte428",
2838
    [AVCOL_TRC_ARIB_STD_B67] = "arib-std-b67",
2839
};
2840
2841
static const char * const color_space_names[] = {
2842
    [AVCOL_SPC_RGB] = "gbr",
2843
    [AVCOL_SPC_BT709] = "bt709",
2844
    [AVCOL_SPC_UNSPECIFIED] = "unknown",
2845
    [AVCOL_SPC_RESERVED] = "reserved",
2846
    [AVCOL_SPC_FCC] = "fcc",
2847
    [AVCOL_SPC_BT470BG] = "bt470bg",
2848
    [AVCOL_SPC_SMPTE170M] = "smpte170m",
2849
    [AVCOL_SPC_SMPTE240M] = "smpte240m",
2850
    [AVCOL_SPC_YCGCO] = "ycgco",
2851
    [AVCOL_SPC_BT2020_NCL] = "bt2020nc",
2852
    [AVCOL_SPC_BT2020_CL] = "bt2020c",
2853
    [AVCOL_SPC_SMPTE2085] = "smpte2085",
2854
    [AVCOL_SPC_CHROMA_DERIVED_NCL] = "chroma-derived-nc",
2855
    [AVCOL_SPC_CHROMA_DERIVED_CL] = "chroma-derived-c",
2856
    [AVCOL_SPC_ICTCP] = "ictcp",
2857
    [AVCOL_SPC_IPT_C2] = "ipt-c2",
2858
    [AVCOL_SPC_YCGCO_RE] = "ycgco-re",
2859
    [AVCOL_SPC_YCGCO_RO] = "ycgco-ro",
2860
};
2861
2862
static const char * const chroma_location_names[] = {
2863
    [AVCHROMA_LOC_UNSPECIFIED] = "unspecified",
2864
    [AVCHROMA_LOC_LEFT] = "left",
2865
    [AVCHROMA_LOC_CENTER] = "center",
2866
    [AVCHROMA_LOC_TOPLEFT] = "topleft",
2867
    [AVCHROMA_LOC_TOP] = "top",
2868
    [AVCHROMA_LOC_BOTTOMLEFT] = "bottomleft",
2869
    [AVCHROMA_LOC_BOTTOM] = "bottom",
2870
};
2871
2872
static enum AVPixelFormat get_pix_fmt_internal(const char *name)
2873
10.1k
{
2874
10.1k
    enum AVPixelFormat pix_fmt;
2875
2876
25.5k
    for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
2877
25.5k
        if (av_pix_fmt_descriptors[pix_fmt].name &&
2878
25.5k
            (!strcmp(av_pix_fmt_descriptors[pix_fmt].name, name) ||
2879
25.5k
             av_match_name(name, av_pix_fmt_descriptors[pix_fmt].alias)))
2880
10.1k
            return pix_fmt;
2881
2882
0
    return AV_PIX_FMT_NONE;
2883
10.1k
}
2884
2885
const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
2886
722k
{
2887
722k
    return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
2888
722k
        av_pix_fmt_descriptors[pix_fmt].name : NULL;
2889
722k
}
2890
2891
#if HAVE_BIGENDIAN
2892
#   define X_NE(be, le) be
2893
#else
2894
0
#   define X_NE(be, le) le
2895
#endif
2896
2897
enum AVPixelFormat av_get_pix_fmt(const char *name)
2898
9.98k
{
2899
9.98k
    enum AVPixelFormat pix_fmt;
2900
2901
9.98k
    if (!strcmp(name, "rgb32"))
2902
0
        name = X_NE("argb", "bgra");
2903
9.98k
    else if (!strcmp(name, "bgr32"))
2904
0
        name = X_NE("abgr", "rgba");
2905
2906
9.98k
    pix_fmt = get_pix_fmt_internal(name);
2907
9.98k
    if (pix_fmt == AV_PIX_FMT_NONE) {
2908
0
        char name2[32];
2909
2910
0
        snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
2911
0
        pix_fmt = get_pix_fmt_internal(name2);
2912
0
    }
2913
2914
9.98k
    return pix_fmt;
2915
9.98k
}
2916
2917
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
2918
92.4k
{
2919
92.4k
    int c, bits = 0;
2920
92.4k
    int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
2921
2922
360k
    for (c = 0; c < pixdesc->nb_components; c++) {
2923
268k
        int s = c == 1 || c == 2 ? 0 : log2_pixels;
2924
268k
        bits += pixdesc->comp[c].depth << s;
2925
268k
    }
2926
2927
92.4k
    return bits >> log2_pixels;
2928
92.4k
}
2929
2930
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
2931
0
{
2932
0
    int c, bits = 0;
2933
0
    int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
2934
0
    int steps[4] = {0};
2935
2936
0
    for (c = 0; c < pixdesc->nb_components; c++) {
2937
0
        const AVComponentDescriptor *comp = &pixdesc->comp[c];
2938
0
        int s = c == 1 || c == 2 ? 0 : log2_pixels;
2939
0
        steps[comp->plane] = comp->step << s;
2940
0
    }
2941
0
    for (c = 0; c < 4; c++)
2942
0
        bits += steps[c];
2943
2944
0
    if(!(pixdesc->flags & AV_PIX_FMT_FLAG_BITSTREAM))
2945
0
        bits *= 8;
2946
2947
0
    return bits >> log2_pixels;
2948
0
}
2949
2950
char *av_get_pix_fmt_string(char *buf, int buf_size,
2951
                            enum AVPixelFormat pix_fmt)
2952
0
{
2953
    /* print header */
2954
0
    if (pix_fmt < 0) {
2955
0
       snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
2956
0
    } else {
2957
0
        const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
2958
0
        snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
2959
0
                 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
2960
0
    }
2961
2962
0
    return buf;
2963
0
}
2964
2965
const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
2966
180M
{
2967
180M
    if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
2968
33.6M
        return NULL;
2969
147M
    return &av_pix_fmt_descriptors[pix_fmt];
2970
180M
}
2971
2972
const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
2973
0
{
2974
0
    if (!prev)
2975
0
        return &av_pix_fmt_descriptors[0];
2976
0
    while (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) {
2977
0
        prev++;
2978
0
        if (prev->name)
2979
0
            return prev;
2980
0
    }
2981
0
    return NULL;
2982
0
}
2983
2984
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
2985
0
{
2986
0
    if (desc < av_pix_fmt_descriptors ||
2987
0
        desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
2988
0
        return AV_PIX_FMT_NONE;
2989
2990
0
    return desc - av_pix_fmt_descriptors;
2991
0
}
2992
2993
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
2994
                                     int *h_shift, int *v_shift)
2995
917k
{
2996
917k
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
2997
917k
    if (!desc)
2998
0
        return AVERROR(ENOSYS);
2999
917k
    *h_shift = desc->log2_chroma_w;
3000
917k
    *v_shift = desc->log2_chroma_h;
3001
3002
917k
    return 0;
3003
917k
}
3004
3005
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
3006
25.6M
{
3007
25.6M
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
3008
25.6M
    int i, planes[4] = { 0 }, ret = 0;
3009
3010
25.6M
    if (!desc)
3011
0
        return AVERROR(EINVAL);
3012
3013
86.0M
    for (i = 0; i < desc->nb_components; i++)
3014
60.3M
        planes[desc->comp[i].plane] = 1;
3015
128M
    for (i = 0; i < FF_ARRAY_ELEMS(planes); i++)
3016
102M
        ret += planes[i];
3017
25.6M
    return ret;
3018
25.6M
}
3019
3020
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
3021
147
{
3022
147
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
3023
147
    char name[16];
3024
147
    int i;
3025
3026
147
    if (!desc || strlen(desc->name) < 2)
3027
0
        return AV_PIX_FMT_NONE;
3028
147
    av_strlcpy(name, desc->name, sizeof(name));
3029
147
    i = strlen(name) - 2;
3030
147
    if (strcmp(name + i, "be") && strcmp(name + i, "le"))
3031
0
        return AV_PIX_FMT_NONE;
3032
3033
147
    name[i] ^= 'b' ^ 'l';
3034
3035
147
    return get_pix_fmt_internal(name);
3036
147
}
3037
3038
0
#define FF_COLOR_NA      -1
3039
0
#define FF_COLOR_RGB      0 /**< RGB color space */
3040
0
#define FF_COLOR_GRAY     1 /**< gray color space */
3041
0
#define FF_COLOR_YUV      2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
3042
0
#define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
3043
0
#define FF_COLOR_XYZ      4
3044
3045
#define pixdesc_has_alpha(pixdesc) \
3046
0
    ((pixdesc)->flags & AV_PIX_FMT_FLAG_ALPHA)
3047
3048
3049
0
static int get_color_type(const AVPixFmtDescriptor *desc) {
3050
0
    if (desc->flags & AV_PIX_FMT_FLAG_PAL)
3051
0
        return FF_COLOR_RGB;
3052
3053
0
    if(desc->nb_components == 1 || desc->nb_components == 2)
3054
0
        return FF_COLOR_GRAY;
3055
3056
0
    if (desc->name) {
3057
0
        if (av_strstart(desc->name, "yuvj", NULL))
3058
0
            return FF_COLOR_YUV_JPEG;
3059
0
    }
3060
3061
0
    if(desc->flags & AV_PIX_FMT_FLAG_RGB)
3062
0
        return FF_COLOR_RGB;
3063
3064
0
    if(desc->flags & AV_PIX_FMT_FLAG_XYZ)
3065
0
        return FF_COLOR_XYZ;
3066
3067
0
    if(desc->nb_components == 0)
3068
0
        return FF_COLOR_NA;
3069
3070
0
    return FF_COLOR_YUV;
3071
0
}
3072
3073
static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt)
3074
0
{
3075
0
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
3076
0
    int i;
3077
3078
0
    if (!desc || !desc->nb_components) {
3079
0
        *min = *max = 0;
3080
0
        return AVERROR(EINVAL);
3081
0
    }
3082
3083
0
    *min = INT_MAX, *max = -INT_MAX;
3084
0
    for (i = 0; i < desc->nb_components; i++) {
3085
0
        *min = FFMIN(desc->comp[i].depth, *min);
3086
0
        *max = FFMAX(desc->comp[i].depth, *max);
3087
0
    }
3088
0
    return 0;
3089
0
}
3090
3091
static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
3092
                              enum AVPixelFormat src_pix_fmt,
3093
                              unsigned *lossp, unsigned consider)
3094
0
{
3095
0
    const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt);
3096
0
    const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt);
3097
0
    int src_color, dst_color;
3098
0
    int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth;
3099
0
    int ret, loss, i, nb_components;
3100
0
    int score = INT_MAX - 1;
3101
3102
0
    if (!src_desc || !dst_desc)
3103
0
        return -4;
3104
3105
0
    if ((src_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) ||
3106
0
        (dst_desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
3107
0
        if (dst_pix_fmt == src_pix_fmt)
3108
0
            return -1;
3109
0
        else
3110
0
            return -2;
3111
0
    }
3112
3113
    /* compute loss */
3114
0
    *lossp = loss = 0;
3115
3116
0
    if (dst_pix_fmt == src_pix_fmt)
3117
0
        return INT_MAX;
3118
3119
0
    if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0)
3120
0
        return -3;
3121
0
    if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0)
3122
0
        return -3;
3123
3124
0
    src_color = get_color_type(src_desc);
3125
0
    dst_color = get_color_type(dst_desc);
3126
0
    if (dst_pix_fmt == AV_PIX_FMT_PAL8)
3127
0
        nb_components = FFMIN(src_desc->nb_components, 4);
3128
0
    else
3129
0
        nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
3130
3131
0
    for (i = 0; i < nb_components; i++) {
3132
0
        int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : (dst_desc->comp[i].depth - 1);
3133
0
        int depth_delta = src_desc->comp[i].depth - 1 - depth_minus1;
3134
0
        if (depth_delta > 0 && (consider & FF_LOSS_DEPTH)) {
3135
0
            loss |= FF_LOSS_DEPTH;
3136
0
            score -= 65536 >> depth_minus1;
3137
0
        } else if (depth_delta < 0 && (consider & FF_LOSS_EXCESS_DEPTH)) {
3138
            // Favour formats where bit depth exactly matches. If all other
3139
            // scoring is equal, we'd rather use the bit depth that most closely
3140
            // matches the source.
3141
0
            loss |= FF_LOSS_EXCESS_DEPTH;
3142
0
            score += depth_delta;
3143
0
        }
3144
0
    }
3145
3146
0
    if (consider & FF_LOSS_RESOLUTION) {
3147
0
        if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) {
3148
0
            loss |= FF_LOSS_RESOLUTION;
3149
0
            score -= 256 << dst_desc->log2_chroma_w;
3150
0
        }
3151
0
        if (dst_desc->log2_chroma_h > src_desc->log2_chroma_h) {
3152
0
            loss |= FF_LOSS_RESOLUTION;
3153
0
            score -= 256 << dst_desc->log2_chroma_h;
3154
0
        }
3155
        // don't favor 422 over 420 if downsampling is needed, because 420 has much better support on the decoder side
3156
0
        if (dst_desc->log2_chroma_w == 1 && src_desc->log2_chroma_w == 0 &&
3157
0
            dst_desc->log2_chroma_h == 1 && src_desc->log2_chroma_h == 0 ) {
3158
0
            score += 512;
3159
0
        }
3160
0
    }
3161
3162
0
    if (consider & FF_LOSS_EXCESS_RESOLUTION) {
3163
        // Favour formats where chroma subsampling exactly matches. If all other
3164
        // scoring is equal, we'd rather use the subsampling that most closely
3165
        // matches the source.
3166
0
        if (dst_desc->log2_chroma_w < src_desc->log2_chroma_w) {
3167
0
            loss |= FF_LOSS_EXCESS_RESOLUTION;
3168
0
            score -= 1 << (src_desc->log2_chroma_w - dst_desc->log2_chroma_w);
3169
0
        }
3170
3171
0
        if (dst_desc->log2_chroma_h < src_desc->log2_chroma_h) {
3172
0
            loss |= FF_LOSS_EXCESS_RESOLUTION;
3173
0
            score -= 1 << (src_desc->log2_chroma_h - dst_desc->log2_chroma_h);
3174
0
        }
3175
3176
        // don't favour 411 over 420, because 420 has much better support on the
3177
        // decoder side.
3178
0
        if (dst_desc->log2_chroma_w == 1 && src_desc->log2_chroma_w == 2 &&
3179
0
            dst_desc->log2_chroma_h == 1 && src_desc->log2_chroma_h == 2) {
3180
0
                score += 4;
3181
0
            }
3182
0
    }
3183
3184
0
    if(consider & FF_LOSS_COLORSPACE)
3185
0
    switch(dst_color) {
3186
0
    case FF_COLOR_RGB:
3187
0
        if (src_color != FF_COLOR_RGB &&
3188
0
            src_color != FF_COLOR_GRAY)
3189
0
            loss |= FF_LOSS_COLORSPACE;
3190
0
        break;
3191
0
    case FF_COLOR_GRAY:
3192
0
        if (src_color != FF_COLOR_GRAY)
3193
0
            loss |= FF_LOSS_COLORSPACE;
3194
0
        break;
3195
0
    case FF_COLOR_YUV:
3196
0
        if (src_color != FF_COLOR_YUV)
3197
0
            loss |= FF_LOSS_COLORSPACE;
3198
0
        break;
3199
0
    case FF_COLOR_YUV_JPEG:
3200
0
        if (src_color != FF_COLOR_YUV_JPEG &&
3201
0
            src_color != FF_COLOR_YUV &&
3202
0
            src_color != FF_COLOR_GRAY)
3203
0
            loss |= FF_LOSS_COLORSPACE;
3204
0
        break;
3205
0
    default:
3206
        /* fail safe test */
3207
0
        if (src_color != dst_color)
3208
0
            loss |= FF_LOSS_COLORSPACE;
3209
0
        break;
3210
0
    }
3211
0
    if(loss & FF_LOSS_COLORSPACE)
3212
0
        score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth - 1, src_desc->comp[0].depth - 1);
3213
3214
0
    if (dst_color == FF_COLOR_GRAY &&
3215
0
        src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) {
3216
0
        loss |= FF_LOSS_CHROMA;
3217
0
        score -= 2 * 65536;
3218
0
    }
3219
0
    if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) {
3220
0
        loss |= FF_LOSS_ALPHA;
3221
0
        score -= 65536;
3222
0
    }
3223
0
    if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) &&
3224
0
        (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) {
3225
0
        loss |= FF_LOSS_COLORQUANT;
3226
0
        score -= 65536;
3227
0
    }
3228
3229
0
    *lossp = loss;
3230
0
    return score;
3231
0
}
3232
3233
int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
3234
                            enum AVPixelFormat src_pix_fmt,
3235
                            int has_alpha)
3236
0
{
3237
0
    int loss;
3238
0
    int ret = get_pix_fmt_score(dst_pix_fmt, src_pix_fmt, &loss, has_alpha ? ~0 : ~FF_LOSS_ALPHA);
3239
0
    if (ret < 0)
3240
0
        return ret;
3241
0
    return loss;
3242
0
}
3243
3244
enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
3245
                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
3246
0
{
3247
0
    enum AVPixelFormat dst_pix_fmt;
3248
0
    int loss1, loss2, loss_mask;
3249
0
    const AVPixFmtDescriptor *desc1 = av_pix_fmt_desc_get(dst_pix_fmt1);
3250
0
    const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2);
3251
0
    int score1, score2;
3252
3253
0
    if (!desc1) {
3254
0
        dst_pix_fmt = dst_pix_fmt2;
3255
0
    } else if (!desc2) {
3256
0
        dst_pix_fmt = dst_pix_fmt1;
3257
0
    } else {
3258
0
        loss_mask= loss_ptr?~*loss_ptr:~0; /* use loss mask if provided */
3259
0
        if(!has_alpha)
3260
0
            loss_mask &= ~FF_LOSS_ALPHA;
3261
3262
0
        score1 = get_pix_fmt_score(dst_pix_fmt1, src_pix_fmt, &loss1, loss_mask);
3263
0
        score2 = get_pix_fmt_score(dst_pix_fmt2, src_pix_fmt, &loss2, loss_mask);
3264
3265
0
        if (score1 == score2) {
3266
0
            if(av_get_padded_bits_per_pixel(desc2) != av_get_padded_bits_per_pixel(desc1)) {
3267
0
                dst_pix_fmt = av_get_padded_bits_per_pixel(desc2) < av_get_padded_bits_per_pixel(desc1) ? dst_pix_fmt2 : dst_pix_fmt1;
3268
0
            } else {
3269
0
                dst_pix_fmt = desc2->nb_components < desc1->nb_components ? dst_pix_fmt2 : dst_pix_fmt1;
3270
0
            }
3271
0
        } else {
3272
0
            dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1;
3273
0
        }
3274
0
    }
3275
3276
0
    if (loss_ptr)
3277
0
        *loss_ptr = av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);
3278
0
    return dst_pix_fmt;
3279
0
}
3280
3281
const char *av_color_range_name(enum AVColorRange range)
3282
34.4k
{
3283
34.4k
    return (unsigned) range < AVCOL_RANGE_NB ?
3284
34.4k
        color_range_names[range] : NULL;
3285
34.4k
}
3286
3287
int av_color_range_from_name(const char *name)
3288
0
{
3289
0
    int i;
3290
3291
0
    for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
3292
0
        if (av_strstart(name, color_range_names[i], NULL))
3293
0
            return i;
3294
0
    }
3295
3296
0
    return AVERROR(EINVAL);
3297
0
}
3298
3299
const char *av_color_primaries_name(enum AVColorPrimaries primaries)
3300
78.7k
{
3301
78.7k
    return (unsigned) primaries < AVCOL_PRI_NB ?
3302
12.7k
        color_primaries_names[primaries] : NULL;
3303
78.7k
}
3304
3305
int av_color_primaries_from_name(const char *name)
3306
0
{
3307
0
    int i;
3308
3309
0
    for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) {
3310
0
        if (!color_primaries_names[i])
3311
0
            continue;
3312
3313
0
        if (av_strstart(name, color_primaries_names[i], NULL))
3314
0
            return i;
3315
0
    }
3316
3317
0
    return AVERROR(EINVAL);
3318
0
}
3319
3320
const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
3321
84.4k
{
3322
84.4k
    return (unsigned) transfer < AVCOL_TRC_NB ?
3323
21.8k
        color_transfer_names[transfer] : NULL;
3324
84.4k
}
3325
3326
int av_color_transfer_from_name(const char *name)
3327
0
{
3328
0
    int i;
3329
3330
0
    for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) {
3331
0
        if (!color_transfer_names[i])
3332
0
            continue;
3333
3334
0
        if (av_strstart(name, color_transfer_names[i], NULL))
3335
0
            return i;
3336
0
    }
3337
3338
0
    return AVERROR(EINVAL);
3339
0
}
3340
3341
const char *av_color_space_name(enum AVColorSpace space)
3342
78.7k
{
3343
78.7k
    return (unsigned) space < AVCOL_SPC_NB ?
3344
17.7k
        color_space_names[space] : NULL;
3345
78.7k
}
3346
3347
int av_color_space_from_name(const char *name)
3348
0
{
3349
0
    int i;
3350
3351
0
    for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) {
3352
0
        if (!color_space_names[i])
3353
0
            continue;
3354
3355
0
        if (av_strstart(name, color_space_names[i], NULL))
3356
0
            return i;
3357
0
    }
3358
3359
0
    return AVERROR(EINVAL);
3360
0
}
3361
3362
const char *av_chroma_location_name(enum AVChromaLocation location)
3363
146
{
3364
146
    return (unsigned) location < AVCHROMA_LOC_NB ?
3365
146
        chroma_location_names[location] : NULL;
3366
146
}
3367
3368
int av_chroma_location_from_name(const char *name)
3369
0
{
3370
0
    int i;
3371
3372
0
    for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) {
3373
0
        if (!chroma_location_names[i])
3374
0
            continue;
3375
3376
0
        if (av_strstart(name, chroma_location_names[i], NULL))
3377
0
            return i;
3378
0
    }
3379
3380
0
    return AVERROR(EINVAL);
3381
0
}
3382
3383
int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
3384
3.18k
{
3385
3.18k
    if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB)
3386
0
        return AVERROR(EINVAL);
3387
3.18k
    pos--;
3388
3389
3.18k
    *xpos = (pos&1) * 128;
3390
3.18k
    *ypos = ((pos>>1)^(pos<4)) * 128;
3391
3392
3.18k
    return 0;
3393
3.18k
}
3394
3395
enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos)
3396
2.41k
{
3397
2.41k
    int pos, xout, yout;
3398
3399
3.18k
    for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) {
3400
3.18k
        if (av_chroma_location_enum_to_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos)
3401
2.41k
            return pos;
3402
3.18k
    }
3403
0
    return AVCHROMA_LOC_UNSPECIFIED;
3404
2.41k
}