pixdesc.c 33 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"

Luca Barbato's avatar
Luca Barbato committed
29 30 31 32
void av_read_image_line(uint16_t *dst,
                        const uint8_t *data[4], const int linesize[4],
                        const AVPixFmtDescriptor *desc,
                        int x, int y, int c, int w,
33
                        int read_pal_component)
34
{
35 36 37 38 39 40 41
    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;
42

43 44 45 46
    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);
47

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

62
        if (is_8bit)
63
            p += !!(flags & PIX_FMT_BE);
64

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

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

    if (flags & PIX_FMT_BITSTREAM) {
89 90 91
        int skip = x * step + comp.offset_plus1 - 1;
        uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
        int shift = 8 - depth - (skip & 7);
92 93 94 95

        while (w--) {
            *p |= *src++ << shift;
            shift -= step;
96
            p -= shift >> 3;
97 98 99 100
            shift &= 7;
        }
    } else {
        int shift = comp.shift;
Luca Barbato's avatar
Luca Barbato committed
101 102
        uint8_t *p = data[plane] + y * linesize[plane] +
                     x * step + comp.offset_plus1 - 1;
103

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

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