pixdesc.c 32.9 KB
Newer Older
1
/*
2
 * pixel format descriptor
3
4
 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
 *
5
 * This file is part of Libav.
6
 *
7
 * Libav is free software; you can redistribute it and/or
8
9
10
11
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
12
 * Libav is distributed in the hope that it will be useful,
13
14
15
16
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with Libav; if not, write to the Free Software
19
20
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

22
23
#include <stdio.h>
#include <string.h>
24
#include "pixfmt.h"
25
26
#include "pixdesc.h"

27
28
#include "intreadwrite.h"

29
void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
30
31
                        const AVPixFmtDescriptor *desc, int x, int y, int c, int w,
                        int read_pal_component)
32
{
33
34
35
36
37
38
39
    AVComponentDescriptor comp = desc->comp[c];
    int plane = comp.plane;
    int depth = comp.depth_minus1 + 1;
    int mask  = (1 << depth) - 1;
    int shift = comp.shift;
    int step  = comp.step_minus1 + 1;
    int flags = desc->flags;
40

41
42
43
44
    if (flags & PIX_FMT_BITSTREAM) {
        int skip = x * step + comp.offset_plus1 - 1;
        const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
        int shift = 8 - depth - (skip & 7);
45

46
        while (w--) {
47
            int val = (*p >> shift) & mask;
48
49
            if (read_pal_component)
                val = data[1][4*val + c];
50
            shift -= step;
51
            p -= shift >> 3;
52
            shift &= 7;
53
            *dst++ = val;
54
55
        }
    } else {
56
        const uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
57
        int is_8bit = shift + depth <= 8;
58

59
        if (is_8bit)
60
            p += !!(flags & PIX_FMT_BE);
61

62
        while (w--) {
63
64
            int val = is_8bit ? *p :
                flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
65
66
67
68
69
            val = (val >> shift) & mask;
            if (read_pal_component)
                val = data[1][4 * val + c];
            p += step;
            *dst++ = val;
70
71
72
73
        }
    }
}

74
void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
Stefano Sabatini's avatar
Stefano Sabatini committed
75
                         const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
76
77
78
{
    AVComponentDescriptor comp = desc->comp[c];
    int plane = comp.plane;
79
80
    int depth = comp.depth_minus1 + 1;
    int step  = comp.step_minus1 + 1;
81
82
83
    int flags = desc->flags;

    if (flags & PIX_FMT_BITSTREAM) {
84
85
86
        int skip = x * step + comp.offset_plus1 - 1;
        uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
        int shift = 8 - depth - (skip & 7);
87
88
89
90

        while (w--) {
            *p |= *src++ << shift;
            shift -= step;
91
            p -= shift >> 3;
92
93
94
95
            shift &= 7;
        }
    } else {
        int shift = comp.shift;
96
        uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
97

98
99
100
        if (shift + depth <= 8) {
            p += !!(flags & PIX_FMT_BE);
            while (w--) {
101
                *p |= (*src++ << shift);
102
103
104
                p += step;
            }
        } else {
Måns Rullgård's avatar
Måns Rullgård committed
105
106
            while (w--) {
                if (flags & PIX_FMT_BE) {
107
                    uint16_t val = AV_RB16(p) | (*src++ << shift);
Måns Rullgård's avatar
Måns Rullgård committed
108
109
                    AV_WB16(p, val);
                } else {
110
                    uint16_t val = AV_RL16(p) | (*src++ << shift);
Måns Rullgård's avatar
Måns Rullgård committed
111
112
                    AV_WL16(p, val);
                }
113
                p += step;
114
            }
115
        }
116
117
118
    }
}

119
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
120
121
    [PIX_FMT_YUV420P] = {
        .name = "yuv420p",
122
123
124
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
125
        .comp = {
126
127
128
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
129
        },
130
        .flags = PIX_FMT_PLANAR,
131
    },
132
133
    [PIX_FMT_YUYV422] = {
        .name = "yuyv422",
134
135
136
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 0,
137
        .comp = {
138
139
140
            { 0, 1, 1, 0, 7 },        /* Y */
            { 0, 3, 2, 0, 7 },        /* U */
            { 0, 3, 4, 0, 7 },        /* V */
141
142
143
144
        },
    },
    [PIX_FMT_RGB24] = {
        .name = "rgb24",
145
146
147
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
148
        .comp = {
149
150
151
            { 0, 2, 1, 0, 7 },        /* R */
            { 0, 2, 2, 0, 7 },        /* G */
            { 0, 2, 3, 0, 7 },        /* B */
152
        },
153
        .flags = PIX_FMT_RGB,
154
    },
155
156
    [PIX_FMT_BGR24] = {
        .name = "bgr24",
157
158
159
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
160
        .comp = {
161
162
163
            { 0, 2, 1, 0, 7 },        /* B */
            { 0, 2, 2, 0, 7 },        /* G */
            { 0, 2, 3, 0, 7 },        /* R */
164
        },
165
        .flags = PIX_FMT_RGB,
166
    },
167
168
    [PIX_FMT_YUV422P] = {
        .name = "yuv422p",
169
170
171
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 0,
172
        .comp = {
173
174
175
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
176
        },
177
        .flags = PIX_FMT_PLANAR,
178
    },
179
180
    [PIX_FMT_YUV444P] = {
        .name = "yuv444p",
181
182
183
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
184
        .comp = {
185
186
187
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
188
        },
189
        .flags = PIX_FMT_PLANAR,
190
    },
191
    [PIX_FMT_YUV410P] = {
192
        .name = "yuv410p",
193
194
195
        .nb_components = 3,
        .log2_chroma_w = 2,
        .log2_chroma_h = 2,
196
        .comp = {
197
198
199
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
200
        },
201
        .flags = PIX_FMT_PLANAR,
202
    },
203
204
    [PIX_FMT_YUV411P] = {
        .name = "yuv411p",
205
206
207
        .nb_components = 3,
        .log2_chroma_w = 2,
        .log2_chroma_h = 0,
208
        .comp = {
209
210
211
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
212
        },
213
        .flags = PIX_FMT_PLANAR,
214
215
    },
    [PIX_FMT_GRAY8] = {
216
        .name = "gray",
217
218
219
        .nb_components = 1,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
220
        .comp = {
221
            { 0, 0, 1, 0, 7 },        /* Y */
222
223
224
        },
    },
    [PIX_FMT_MONOWHITE] = {
225
        .name = "monow",
226
227
228
        .nb_components = 1,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
229
        .comp = {
230
            { 0, 0, 1, 0, 0 },        /* Y */
231
232
233
        },
        .flags = PIX_FMT_BITSTREAM,
    },
234
    [PIX_FMT_MONOBLACK] = {
235
        .name = "monob",
236
237
238
        .nb_components = 1,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
239
        .comp = {
240
            { 0, 0, 1, 7, 0 },        /* Y */
241
        },
242
        .flags = PIX_FMT_BITSTREAM,
243
    },
244
245
    [PIX_FMT_PAL8] = {
        .name = "pal8",
246
247
248
        .nb_components = 1,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
249
        .comp = {
250
            { 0, 0, 1, 0, 7 },
251
        },
252
        .flags = PIX_FMT_PAL,
253
    },
254
255
    [PIX_FMT_YUVJ420P] = {
        .name = "yuvj420p",
256
257
258
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
259
        .comp = {
260
261
262
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
263
        },
264
        .flags = PIX_FMT_PLANAR,
265
266
267
    },
    [PIX_FMT_YUVJ422P] = {
        .name = "yuvj422p",
268
269
270
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 0,
271
        .comp = {
272
273
274
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
275
        },
276
        .flags = PIX_FMT_PLANAR,
277
278
279
    },
    [PIX_FMT_YUVJ444P] = {
        .name = "yuvj444p",
280
281
282
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
283
        .comp = {
284
285
286
            {0, 0, 1, 0, 7},        /* Y */
            {1, 0, 1, 0, 7},        /* U */
            {2, 0, 1, 0, 7},        /* V */
287
        },
288
        .flags = PIX_FMT_PLANAR,
289
    },
290
    [PIX_FMT_XVMC_MPEG2_MC] = {
291
        .name = "xvmcmc",
292
293
294
        .flags = PIX_FMT_HWACCEL,
    },
    [PIX_FMT_XVMC_MPEG2_IDCT] = {
295
        .name = "xvmcidct",
296
297
        .flags = PIX_FMT_HWACCEL,
    },
298
    [PIX_FMT_UYVY422] = {
299
        .name = "uyvy422",
300
301
302
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 0,
303
        .comp = {
304
305
306
            { 0, 1, 2, 0, 7 },        /* Y */
            { 0, 3, 1, 0, 7 },        /* U */
            { 0, 3, 3, 0, 7 },        /* V */
307
308
        },
    },
309
310
    [PIX_FMT_UYYVYY411] = {
        .name = "uyyvyy411",
311
312
313
        .nb_components = 3,
        .log2_chroma_w = 2,
        .log2_chroma_h = 0,
314
        .comp = {
315
316
317
            { 0, 3, 2, 0, 7 },        /* Y */
            { 0, 5, 1, 0, 7 },        /* U */
            { 0, 5, 4, 0, 7 },        /* V */
318
319
320
321
        },
    },
    [PIX_FMT_BGR8] = {
        .name = "bgr8",
322
323
324
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
325
        .comp = {
326
327
328
            { 0, 0, 1, 6, 1 },        /* B */
            { 0, 0, 1, 3, 2 },        /* G */
            { 0, 0, 1, 0, 2 },        /* R */
329
        },
330
        .flags = PIX_FMT_PAL | PIX_FMT_RGB,
331
332
333
    },
    [PIX_FMT_BGR4] = {
        .name = "bgr4",
334
335
336
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
337
        .comp = {
338
339
340
            { 0, 3, 1, 0, 0 },        /* B */
            { 0, 3, 2, 0, 1 },        /* G */
            { 0, 3, 4, 0, 0 },        /* R */
341
        },
342
        .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
343
344
345
    },
    [PIX_FMT_BGR4_BYTE] = {
        .name = "bgr4_byte",
346
347
348
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
349
        .comp = {
350
351
352
            { 0, 0, 1, 3, 0 },        /* B */
            { 0, 0, 1, 1, 1 },        /* G */
            { 0, 0, 1, 0, 0 },        /* R */
353
        },
354
        .flags = PIX_FMT_PAL | PIX_FMT_RGB,
355
356
357
    },
    [PIX_FMT_RGB8] = {
        .name = "rgb8",
358
359
360
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
361
        .comp = {
362
363
364
            { 0, 0, 1, 6, 1 },        /* R */
            { 0, 0, 1, 3, 2 },        /* G */
            { 0, 0, 1, 0, 2 },        /* B */
365
        },
366
        .flags = PIX_FMT_PAL | PIX_FMT_RGB,
367
368
369
    },
    [PIX_FMT_RGB4] = {
        .name = "rgb4",
370
371
372
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
373
        .comp = {
374
375
376
            { 0, 3, 1, 0, 0 },        /* R */
            { 0, 3, 2, 0, 1 },        /* G */
            { 0, 3, 4, 0, 0 },        /* B */
377
        },
378
        .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
379
380
381
    },
    [PIX_FMT_RGB4_BYTE] = {
        .name = "rgb4_byte",
382
383
384
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
385
        .comp = {
386
387
388
            { 0, 0, 1, 3, 0 },        /* R */
            { 0, 0, 1, 1, 1 },        /* G */
            { 0, 0, 1, 0, 0 },        /* B */
389
        },
390
        .flags = PIX_FMT_PAL | PIX_FMT_RGB,
391
    },
392
393
    [PIX_FMT_NV12] = {
        .name = "nv12",
394
395
396
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
397
        .comp = {
398
399
400
            { 0,0,1,0,7 },        /* Y */
            { 1,1,1,0,7 },        /* U */
            { 1,1,2,0,7 },        /* V */
401
        },
402
        .flags = PIX_FMT_PLANAR,
403
    },
404
405
    [PIX_FMT_NV21] = {
        .name = "nv21",
406
407
408
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
409
        .comp = {
410
411
412
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 1, 1, 0, 7 },        /* V */
            { 1, 1, 2, 0, 7 },        /* U */
413
        },
414
        .flags = PIX_FMT_PLANAR,
415
416
417
    },
    [PIX_FMT_ARGB] = {
        .name = "argb",
418
419
420
        .nb_components = 4,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
421
        .comp = {
422
423
424
425
            { 0, 3, 1, 0, 7 },        /* A */
            { 0, 3, 2, 0, 7 },        /* R */
            { 0, 3, 3, 0, 7 },        /* G */
            { 0, 3, 4, 0, 7 },        /* B */
426
        },
427
        .flags = PIX_FMT_RGB,
428
    },
429
    [PIX_FMT_RGBA] = {
430
        .name = "rgba",
431
432
433
        .nb_components = 4,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
434
        .comp = {
435
436
437
438
            { 0, 3, 1, 0, 7 },        /* R */
            { 0, 3, 2, 0, 7 },        /* G */
            { 0, 3, 3, 0, 7 },        /* B */
            { 0, 3, 4, 0, 7 },        /* A */
439
        },
440
        .flags = PIX_FMT_RGB,
441
    },
442
443
    [PIX_FMT_ABGR] = {
        .name = "abgr",
444
445
446
        .nb_components = 4,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
447
        .comp = {
448
449
450
451
            { 0, 3, 1, 0, 7 },        /* A */
            { 0, 3, 2, 0, 7 },        /* B */
            { 0, 3, 3, 0, 7 },        /* G */
            { 0, 3, 4, 0, 7 },        /* R */
452
        },
453
        .flags = PIX_FMT_RGB,
454
455
456
    },
    [PIX_FMT_BGRA] = {
        .name = "bgra",
457
458
459
        .nb_components = 4,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
460
        .comp = {
461
462
463
464
            { 0, 3, 1, 0, 7 },        /* B */
            { 0, 3, 2, 0, 7 },        /* G */
            { 0, 3, 3, 0, 7 },        /* R */
            { 0, 3, 4, 0, 7 },        /* A */
465
        },
466
        .flags = PIX_FMT_RGB,
467
    },
468
469
    [PIX_FMT_GRAY16BE] = {
        .name = "gray16be",
470
471
472
        .nb_components = 1,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
473
        .comp = {
474
            { 0, 1, 1, 0, 15 },       /* Y */
475
476
477
478
479
        },
        .flags = PIX_FMT_BE,
    },
    [PIX_FMT_GRAY16LE] = {
        .name = "gray16le",
480
481
482
        .nb_components = 1,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
483
        .comp = {
484
            { 0, 1, 1, 0, 15 },       /* Y */
485
486
        },
    },
487
488
    [PIX_FMT_YUV440P] = {
        .name = "yuv440p",
489
490
491
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 1,
492
        .comp = {
493
494
495
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
496
        },
497
        .flags = PIX_FMT_PLANAR,
498
499
500
    },
    [PIX_FMT_YUVJ440P] = {
        .name = "yuvj440p",
501
502
503
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 1,
504
        .comp = {
505
506
507
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
508
        },
509
        .flags = PIX_FMT_PLANAR,
510
511
512
    },
    [PIX_FMT_YUVA420P] = {
        .name = "yuva420p",
513
514
515
        .nb_components = 4,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
516
        .comp = {
517
518
519
520
            { 0, 0, 1, 0, 7 },        /* Y */
            { 1, 0, 1, 0, 7 },        /* U */
            { 2, 0, 1, 0, 7 },        /* V */
            { 3, 0, 1, 0, 7 },        /* A */
521
        },
522
        .flags = PIX_FMT_PLANAR,
523
    },
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
    [PIX_FMT_VDPAU_H264] = {
        .name = "vdpau_h264",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
    [PIX_FMT_VDPAU_MPEG1] = {
        .name = "vdpau_mpeg1",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
    [PIX_FMT_VDPAU_MPEG2] = {
        .name = "vdpau_mpeg2",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
    [PIX_FMT_VDPAU_WMV3] = {
        .name = "vdpau_wmv3",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
    [PIX_FMT_VDPAU_VC1] = {
        .name = "vdpau_vc1",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
554
555
556
557
558
559
    [PIX_FMT_VDPAU_MPEG4] = {
        .name = "vdpau_mpeg4",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
560
    [PIX_FMT_RGB48BE] = {
561
        .name = "rgb48be",
562
563
564
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
565
        .comp = {
566
567
568
            { 0, 5, 1, 0, 15 },       /* R */
            { 0, 5, 3, 0, 15 },       /* G */
            { 0, 5, 5, 0, 15 },       /* B */
569
        },
570
        .flags = PIX_FMT_RGB | PIX_FMT_BE,
571
    },
572
573
    [PIX_FMT_RGB48LE] = {
        .name = "rgb48le",
574
575
576
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
577
        .comp = {
578
579
580
            { 0, 5, 1, 0, 15 },       /* R */
            { 0, 5, 3, 0, 15 },       /* G */
            { 0, 5, 5, 0, 15 },       /* B */
581
        },
582
        .flags = PIX_FMT_RGB,
583
    },
584
    [PIX_FMT_RGB565BE] = {
585
        .name = "rgb565be",
586
587
588
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
589
        .comp = {
590
591
592
            { 0, 1, 0, 3, 4 },        /* R */
            { 0, 1, 1, 5, 5 },        /* G */
            { 0, 1, 1, 0, 4 },        /* B */
593
        },
594
        .flags = PIX_FMT_BE | PIX_FMT_RGB,
595
    },
596
597
    [PIX_FMT_RGB565LE] = {
        .name = "rgb565le",
598
599
600
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
601
        .comp = {
602
603
604
            { 0, 1, 2, 3, 4 },        /* R */
            { 0, 1, 1, 5, 5 },        /* G */
            { 0, 1, 1, 0, 4 },        /* B */
605
        },
606
        .flags = PIX_FMT_RGB,
607
    },
608
609
    [PIX_FMT_RGB555BE] = {
        .name = "rgb555be",
610
611
612
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
613
        .comp = {
614
615
616
            { 0, 1, 0, 2, 4 },        /* R */
            { 0, 1, 1, 5, 4 },        /* G */
            { 0, 1, 1, 0, 4 },        /* B */
617
        },
618
        .flags = PIX_FMT_BE | PIX_FMT_RGB,
619
620
621
    },
    [PIX_FMT_RGB555LE] = {
        .name = "rgb555le",
622
623
624
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
625
        .comp = {
626
627
628
            { 0, 1, 2, 2, 4 },        /* R */
            { 0, 1, 1, 5, 4 },        /* G */
            { 0, 1, 1, 0, 4 },        /* B */
629
        },
630
        .flags = PIX_FMT_RGB,
631
    },
632
633
    [PIX_FMT_RGB444BE] = {
        .name = "rgb444be",
634
635
636
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
637
        .comp = {
638
639
640
            { 0, 1, 0, 0, 3 },        /* R */
            { 0, 1, 1, 4, 3 },        /* G */
            { 0, 1, 1, 0, 3 },        /* B */
641
        },
642
        .flags = PIX_FMT_BE | PIX_FMT_RGB,
643
644
645
    },
    [PIX_FMT_RGB444LE] = {
        .name = "rgb444le",
646
647
648
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
649
        .comp = {
650
651
652
            { 0, 1, 2, 0, 3 },        /* R */
            { 0, 1, 1, 4, 3 },        /* G */
            { 0, 1, 1, 0, 3 },        /* B */
653
        },
654
        .flags = PIX_FMT_RGB,
655
    },
656
657
    [PIX_FMT_BGR48BE] = {
        .name = "bgr48be",
658
659
660
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
661
        .comp = {
662
663
664
            { 0, 5, 1, 0, 15 },       /* B */
            { 0, 5, 3, 0, 15 },       /* G */
            { 0, 5, 5, 0, 15 },       /* R */
665
        },
666
        .flags = PIX_FMT_BE | PIX_FMT_RGB,
667
668
669
    },
    [PIX_FMT_BGR48LE] = {
        .name = "bgr48le",
670
671
672
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
673
        .comp = {
674
675
676
            { 0, 5, 1, 0, 15 },       /* B */
            { 0, 5, 3, 0, 15 },       /* G */
            { 0, 5, 5, 0, 15 },       /* R */
677
        },
678
        .flags = PIX_FMT_RGB,
679
    },
680
681
    [PIX_FMT_BGR565BE] = {
        .name = "bgr565be",
682
683
684
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
685
        .comp = {
686
687
688
            { 0, 1, 0, 3, 4 },        /* B */
            { 0, 1, 1, 5, 5 },        /* G */
            { 0, 1, 1, 0, 4 },        /* R */
689
        },
690
        .flags = PIX_FMT_BE | PIX_FMT_RGB,
691
692
693
    },
    [PIX_FMT_BGR565LE] = {
        .name = "bgr565le",
694
695
696
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
697
        .comp = {
698
699
700
            { 0, 1, 2, 3, 4 },        /* B */
            { 0, 1, 1, 5, 5 },        /* G */
            { 0, 1, 1, 0, 4 },        /* R */
701
        },
702
        .flags = PIX_FMT_RGB,
703
704
705
    },
    [PIX_FMT_BGR555BE] = {
        .name = "bgr555be",
706
707
708
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
709
        .comp = {
710
711
712
            { 0, 1, 0, 2, 4 },       /* B */
            { 0, 1, 1, 5, 4 },       /* G */
            { 0, 1, 1, 0, 4 },       /* R */
713
        },
714
        .flags = PIX_FMT_BE | PIX_FMT_RGB,
715
716
717
     },
    [PIX_FMT_BGR555LE] = {
        .name = "bgr555le",
718
719
720
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
721
        .comp = {
722
723
724
            { 0, 1, 2, 2, 4 },        /* B */
            { 0, 1, 1, 5, 4 },        /* G */
            { 0, 1, 1, 0, 4 },        /* R */
725
        },
726
        .flags = PIX_FMT_RGB,
727
    },
728
729
    [PIX_FMT_BGR444BE] = {
        .name = "bgr444be",
730
731
732
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
733
        .comp = {
734
735
736
            { 0, 1, 0, 0, 3 },       /* B */
            { 0, 1, 1, 4, 3 },       /* G */
            { 0, 1, 1, 0, 3 },       /* R */
737
        },
738
        .flags = PIX_FMT_BE | PIX_FMT_RGB,
739
740
741
     },
    [PIX_FMT_BGR444LE] = {
        .name = "bgr444le",
742
743
744
        .nb_components = 3,
        .log2_chroma_w = 0,
        .log2_chroma_h = 0,
745
        .comp = {
746
747
748
            { 0, 1, 2, 0, 3 },        /* B */
            { 0, 1, 1, 4, 3 },        /* G */
            { 0, 1, 1, 0, 3 },        /* R */
749
        },
750
        .flags = PIX_FMT_RGB,
751
    },
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
    [PIX_FMT_VAAPI_MOCO] = {
        .name = "vaapi_moco",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
    [PIX_FMT_VAAPI_IDCT] = {
        .name = "vaapi_idct",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
    [PIX_FMT_VAAPI_VLD] = {
        .name = "vaapi_vld",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
770
771
772
773
774
775
    [PIX_FMT_VDA_VLD] = {
        .name = "vda_vld",
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
        .flags = PIX_FMT_HWACCEL,
    },
776
777
    [PIX_FMT_YUV420P9LE] = {
        .name = "yuv420p9le",
778
779
780
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
781
        .comp = {
782
783
784
            { 0, 1, 1, 0, 8 },        /* Y */
            { 1, 1, 1, 0, 8 },        /* U */
            { 2, 1, 1, 0, 8 },        /* V */
785
        },
786
        .flags = PIX_FMT_PLANAR,
787
788
789
    },
    [PIX_FMT_YUV420P9BE] = {
        .name = "yuv420p9be",
790
791
792
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
793
        .comp = {
794
795
796
            { 0, 1, 1, 0, 8 },        /* Y */
            { 1, 1, 1, 0, 8 },        /* U */
            { 2, 1, 1, 0, 8 },        /* V */
797
        },
798
        .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
799
800
801
    },
    [PIX_FMT_YUV420P10LE] = {
        .name = "yuv420p10le",
802
803
804
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
805
        .comp = {
806
807
808
            { 0, 1, 1, 0, 9 },        /* Y */
            { 1, 1, 1, 0, 9 },        /* U */
            { 2, 1, 1, 0, 9 },        /* V */
809
        },
810
        .flags = PIX_FMT_PLANAR,
811
812
813
    },
    [PIX_FMT_YUV420P10BE] = {
        .name = "yuv420p10be",
814
815
816
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
817
        .comp = {
818
819
820
            { 0, 1, 1, 0, 9 },        /* Y */
            { 1, 1, 1, 0, 9 },        /* U */
            { 2, 1, 1, 0, 9 },        /* V */
821
        },
822
        .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
823
    },
824
825
    [PIX_FMT_YUV420P16LE] = {
        .name = "yuv420p16le",
826
827
828
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
829
        .comp = {
830
831
832
            { 0, 1, 1, 0, 15 },        /* Y */
            { 1, 1, 1, 0, 15 },        /* U */
            { 2, 1, 1, 0, 15 },        /* V */
833
        },
834
        .flags = PIX_FMT_PLANAR,
835
    },
836
837
    [PIX_FMT_YUV420P16BE] = {
        .name = "yuv420p16be",
838
839
840
        .nb_components = 3,
        .log2_chroma_w = 1,
        .log2_chroma_h = 1,
841
        .comp = {
842
843
844
            { 0, 1, 1, 0, 15 },        /* Y */
            { 1, 1, 1, 0, 15 },        /* U */
            { 2, 1, 1, 0, 15 },        /* V */
845
        },
846
        .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
Stefano Sabatini's avatar