2 * pixel format descriptor
3 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
5 * This file is part of FFmpeg.
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.
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.
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
29 #include "intreadwrite.h"
31 void av_read_image_line(uint16_t *dst,
32 const uint8_t *data[4], const int linesize[4],
33 const AVPixFmtDescriptor *desc,
34 int x, int y, int c, int w,
35 int read_pal_component)
37 AVComponentDescriptor comp = desc->comp[c];
38 int plane = comp.plane;
39 int depth = comp.depth_minus1 + 1;
40 int mask = (1 << depth) - 1;
41 int shift = comp.shift;
42 int step = comp.step_minus1 + 1;
43 int flags = desc->flags;
45 if (flags & PIX_FMT_BITSTREAM) {
46 int skip = x * step + comp.offset_plus1 - 1;
47 const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
48 int shift = 8 - depth - (skip & 7);
51 int val = (*p >> shift) & mask;
52 if (read_pal_component)
53 val = data[1][4*val + c];
60 const uint8_t *p = data[plane] + y * linesize[plane] +
61 x * step + comp.offset_plus1 - 1;
62 int is_8bit = shift + depth <= 8;
65 p += !!(flags & PIX_FMT_BE);
68 int val = is_8bit ? *p :
69 flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
70 val = (val >> shift) & mask;
71 if (read_pal_component)
72 val = data[1][4 * val + c];
79 void av_write_image_line(const uint16_t *src,
80 uint8_t *data[4], const int linesize[4],
81 const AVPixFmtDescriptor *desc,
82 int x, int y, int c, int w)
84 AVComponentDescriptor comp = desc->comp[c];
85 int plane = comp.plane;
86 int depth = comp.depth_minus1 + 1;
87 int step = comp.step_minus1 + 1;
88 int flags = desc->flags;
90 if (flags & PIX_FMT_BITSTREAM) {
91 int skip = x * step + comp.offset_plus1 - 1;
92 uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
93 int shift = 8 - depth - (skip & 7);
96 *p |= *src++ << shift;
102 int shift = comp.shift;
103 uint8_t *p = data[plane] + y * linesize[plane] +
104 x * step + comp.offset_plus1 - 1;
106 if (shift + depth <= 8) {
107 p += !!(flags & PIX_FMT_BE);
109 *p |= (*src++ << shift);
114 if (flags & PIX_FMT_BE) {
115 uint16_t val = AV_RB16(p) | (*src++ << shift);
118 uint16_t val = AV_RL16(p) | (*src++ << shift);
127 #if !FF_API_PIX_FMT_DESC
130 const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
131 [AV_PIX_FMT_YUV420P] = {
137 { 0, 0, 1, 0, 7 }, /* Y */
138 { 1, 0, 1, 0, 7 }, /* U */
139 { 2, 0, 1, 0, 7 }, /* V */
141 .flags = PIX_FMT_PLANAR,
143 [AV_PIX_FMT_YUYV422] = {
149 { 0, 1, 1, 0, 7 }, /* Y */
150 { 0, 3, 2, 0, 7 }, /* U */
151 { 0, 3, 4, 0, 7 }, /* V */
154 [AV_PIX_FMT_RGB24] = {
160 { 0, 2, 1, 0, 7 }, /* R */
161 { 0, 2, 2, 0, 7 }, /* G */
162 { 0, 2, 3, 0, 7 }, /* B */
164 .flags = PIX_FMT_RGB,
166 [AV_PIX_FMT_BGR24] = {
172 { 0, 2, 3, 0, 7 }, /* R */
173 { 0, 2, 2, 0, 7 }, /* G */
174 { 0, 2, 1, 0, 7 }, /* B */
176 .flags = PIX_FMT_RGB,
178 [AV_PIX_FMT_YUV422P] = {
184 { 0, 0, 1, 0, 7 }, /* Y */
185 { 1, 0, 1, 0, 7 }, /* U */
186 { 2, 0, 1, 0, 7 }, /* V */
188 .flags = PIX_FMT_PLANAR,
190 [AV_PIX_FMT_YUV444P] = {
196 { 0, 0, 1, 0, 7 }, /* Y */
197 { 1, 0, 1, 0, 7 }, /* U */
198 { 2, 0, 1, 0, 7 }, /* V */
200 .flags = PIX_FMT_PLANAR,
202 [AV_PIX_FMT_YUV410P] = {
208 { 0, 0, 1, 0, 7 }, /* Y */
209 { 1, 0, 1, 0, 7 }, /* U */
210 { 2, 0, 1, 0, 7 }, /* V */
212 .flags = PIX_FMT_PLANAR,
214 [AV_PIX_FMT_YUV411P] = {
220 { 0, 0, 1, 0, 7 }, /* Y */
221 { 1, 0, 1, 0, 7 }, /* U */
222 { 2, 0, 1, 0, 7 }, /* V */
224 .flags = PIX_FMT_PLANAR,
226 [AV_PIX_FMT_GRAY8] = {
232 { 0, 0, 1, 0, 7 }, /* Y */
234 .flags = PIX_FMT_PSEUDOPAL,
236 [AV_PIX_FMT_MONOWHITE] = {
242 { 0, 0, 1, 0, 0 }, /* Y */
244 .flags = PIX_FMT_BITSTREAM,
246 [AV_PIX_FMT_MONOBLACK] = {
252 { 0, 0, 1, 7, 0 }, /* Y */
254 .flags = PIX_FMT_BITSTREAM,
256 [AV_PIX_FMT_PAL8] = {
264 .flags = PIX_FMT_PAL,
266 [AV_PIX_FMT_YUVJ420P] = {
272 { 0, 0, 1, 0, 7 }, /* Y */
273 { 1, 0, 1, 0, 7 }, /* U */
274 { 2, 0, 1, 0, 7 }, /* V */
276 .flags = PIX_FMT_PLANAR,
278 [AV_PIX_FMT_YUVJ422P] = {
284 { 0, 0, 1, 0, 7 }, /* Y */
285 { 1, 0, 1, 0, 7 }, /* U */
286 { 2, 0, 1, 0, 7 }, /* V */
288 .flags = PIX_FMT_PLANAR,
290 [AV_PIX_FMT_YUVJ444P] = {
296 { 0, 0, 1, 0, 7 }, /* Y */
297 { 1, 0, 1, 0, 7 }, /* U */
298 { 2, 0, 1, 0, 7 }, /* V */
300 .flags = PIX_FMT_PLANAR,
302 [AV_PIX_FMT_XVMC_MPEG2_MC] = {
304 .flags = PIX_FMT_HWACCEL,
306 [AV_PIX_FMT_XVMC_MPEG2_IDCT] = {
308 .flags = PIX_FMT_HWACCEL,
310 [AV_PIX_FMT_UYVY422] = {
316 { 0, 1, 2, 0, 7 }, /* Y */
317 { 0, 3, 1, 0, 7 }, /* U */
318 { 0, 3, 3, 0, 7 }, /* V */
321 [AV_PIX_FMT_UYYVYY411] = {
327 { 0, 3, 2, 0, 7 }, /* Y */
328 { 0, 5, 1, 0, 7 }, /* U */
329 { 0, 5, 4, 0, 7 }, /* V */
332 [AV_PIX_FMT_BGR8] = {
338 { 0, 0, 1, 0, 2 }, /* R */
339 { 0, 0, 1, 3, 2 }, /* G */
340 { 0, 0, 1, 6, 1 }, /* B */
342 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
344 [AV_PIX_FMT_BGR4] = {
350 { 0, 3, 4, 0, 0 }, /* R */
351 { 0, 3, 2, 0, 1 }, /* G */
352 { 0, 3, 1, 0, 0 }, /* B */
354 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
356 [AV_PIX_FMT_BGR4_BYTE] = {
362 { 0, 0, 1, 0, 0 }, /* R */
363 { 0, 0, 1, 1, 1 }, /* G */
364 { 0, 0, 1, 3, 0 }, /* B */
366 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
368 [AV_PIX_FMT_RGB8] = {
374 { 0, 0, 1, 6, 1 }, /* R */
375 { 0, 0, 1, 3, 2 }, /* G */
376 { 0, 0, 1, 0, 2 }, /* B */
378 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
380 [AV_PIX_FMT_RGB4] = {
386 { 0, 3, 1, 0, 0 }, /* R */
387 { 0, 3, 2, 0, 1 }, /* G */
388 { 0, 3, 4, 0, 0 }, /* B */
390 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
392 [AV_PIX_FMT_RGB4_BYTE] = {
398 { 0, 0, 1, 3, 0 }, /* R */
399 { 0, 0, 1, 1, 1 }, /* G */
400 { 0, 0, 1, 0, 0 }, /* B */
402 .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
404 [AV_PIX_FMT_NV12] = {
410 { 0, 0, 1, 0, 7 }, /* Y */
411 { 1, 1, 1, 0, 7 }, /* U */
412 { 1, 1, 2, 0, 7 }, /* V */
414 .flags = PIX_FMT_PLANAR,
416 [AV_PIX_FMT_NV21] = {
422 { 0, 0, 1, 0, 7 }, /* Y */
423 { 1, 1, 2, 0, 7 }, /* U */
424 { 1, 1, 1, 0, 7 }, /* V */
426 .flags = PIX_FMT_PLANAR,
428 [AV_PIX_FMT_ARGB] = {
434 { 0, 3, 2, 0, 7 }, /* R */
435 { 0, 3, 3, 0, 7 }, /* G */
436 { 0, 3, 4, 0, 7 }, /* B */
437 { 0, 3, 1, 0, 7 }, /* A */
439 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
441 [AV_PIX_FMT_RGBA] = {
447 { 0, 3, 1, 0, 7 }, /* R */
448 { 0, 3, 2, 0, 7 }, /* G */
449 { 0, 3, 3, 0, 7 }, /* B */
450 { 0, 3, 4, 0, 7 }, /* A */
452 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
454 [AV_PIX_FMT_ABGR] = {
460 { 0, 3, 4, 0, 7 }, /* R */
461 { 0, 3, 3, 0, 7 }, /* G */
462 { 0, 3, 2, 0, 7 }, /* B */
463 { 0, 3, 1, 0, 7 }, /* A */
465 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
467 [AV_PIX_FMT_BGRA] = {
473 { 0, 3, 3, 0, 7 }, /* R */
474 { 0, 3, 2, 0, 7 }, /* G */
475 { 0, 3, 1, 0, 7 }, /* B */
476 { 0, 3, 4, 0, 7 }, /* A */
478 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
480 [AV_PIX_FMT_0RGB] = {
486 { 0, 3, 2, 0, 7 }, /* R */
487 { 0, 3, 3, 0, 7 }, /* G */
488 { 0, 3, 4, 0, 7 }, /* B */
490 .flags = PIX_FMT_RGB,
492 [AV_PIX_FMT_RGB0] = {
498 { 0, 3, 1, 0, 7 }, /* R */
499 { 0, 3, 2, 0, 7 }, /* G */
500 { 0, 3, 3, 0, 7 }, /* B */
501 { 0, 3, 4, 0, 7 }, /* A */
503 .flags = PIX_FMT_RGB,
505 [AV_PIX_FMT_0BGR] = {
511 { 0, 3, 4, 0, 7 }, /* R */
512 { 0, 3, 3, 0, 7 }, /* G */
513 { 0, 3, 2, 0, 7 }, /* B */
515 .flags = PIX_FMT_RGB,
517 [AV_PIX_FMT_BGR0] = {
523 { 0, 3, 3, 0, 7 }, /* R */
524 { 0, 3, 2, 0, 7 }, /* G */
525 { 0, 3, 1, 0, 7 }, /* B */
526 { 0, 3, 4, 0, 7 }, /* A */
528 .flags = PIX_FMT_RGB,
530 [AV_PIX_FMT_GRAY16BE] = {
536 { 0, 1, 1, 0, 15 }, /* Y */
540 [AV_PIX_FMT_GRAY16LE] = {
546 { 0, 1, 1, 0, 15 }, /* Y */
549 [AV_PIX_FMT_YUV440P] = {
555 { 0, 0, 1, 0, 7 }, /* Y */
556 { 1, 0, 1, 0, 7 }, /* U */
557 { 2, 0, 1, 0, 7 }, /* V */
559 .flags = PIX_FMT_PLANAR,
561 [AV_PIX_FMT_YUVJ440P] = {
567 { 0, 0, 1, 0, 7 }, /* Y */
568 { 1, 0, 1, 0, 7 }, /* U */
569 { 2, 0, 1, 0, 7 }, /* V */
571 .flags = PIX_FMT_PLANAR,
573 [AV_PIX_FMT_YUVA420P] = {
579 { 0, 0, 1, 0, 7 }, /* Y */
580 { 1, 0, 1, 0, 7 }, /* U */
581 { 2, 0, 1, 0, 7 }, /* V */
582 { 3, 0, 1, 0, 7 }, /* A */
584 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
586 [AV_PIX_FMT_YUVA422P] = {
592 { 0, 0, 1, 0, 7 }, /* Y */
593 { 1, 0, 1, 0, 7 }, /* U */
594 { 2, 0, 1, 0, 7 }, /* V */
595 { 3, 0, 1, 0, 7 }, /* A */
597 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
599 [AV_PIX_FMT_YUVA444P] = {
605 { 0, 0, 1, 0, 7 }, /* Y */
606 { 1, 0, 1, 0, 7 }, /* U */
607 { 2, 0, 1, 0, 7 }, /* V */
608 { 3, 0, 1, 0, 7 }, /* A */
610 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
612 [AV_PIX_FMT_YUVA420P9BE] = {
613 .name = "yuva420p9be",
618 { 0, 1, 1, 0, 8 }, /* Y */
619 { 1, 1, 1, 0, 8 }, /* U */
620 { 2, 1, 1, 0, 8 }, /* V */
621 { 3, 1, 1, 0, 8 }, /* A */
623 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
625 [AV_PIX_FMT_YUVA420P9LE] = {
626 .name = "yuva420p9le",
631 { 0, 1, 1, 0, 8 }, /* Y */
632 { 1, 1, 1, 0, 8 }, /* U */
633 { 2, 1, 1, 0, 8 }, /* V */
634 { 3, 1, 1, 0, 8 }, /* A */
636 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
638 [AV_PIX_FMT_YUVA422P9BE] = {
639 .name = "yuva422p9be",
644 { 0, 1, 1, 0, 8 }, /* Y */
645 { 1, 1, 1, 0, 8 }, /* U */
646 { 2, 1, 1, 0, 8 }, /* V */
647 { 3, 1, 1, 0, 8 }, /* A */
649 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
651 [AV_PIX_FMT_YUVA422P9LE] = {
652 .name = "yuva422p9le",
657 { 0, 1, 1, 0, 8 }, /* Y */
658 { 1, 1, 1, 0, 8 }, /* U */
659 { 2, 1, 1, 0, 8 }, /* V */
660 { 3, 1, 1, 0, 8 }, /* A */
662 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
664 [AV_PIX_FMT_YUVA444P9BE] = {
665 .name = "yuva444p9be",
670 { 0, 1, 1, 0, 8 }, /* Y */
671 { 1, 1, 1, 0, 8 }, /* U */
672 { 2, 1, 1, 0, 8 }, /* V */
673 { 3, 1, 1, 0, 8 }, /* A */
675 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
677 [AV_PIX_FMT_YUVA444P9LE] = {
678 .name = "yuva444p9le",
683 { 0, 1, 1, 0, 8 }, /* Y */
684 { 1, 1, 1, 0, 8 }, /* U */
685 { 2, 1, 1, 0, 8 }, /* V */
686 { 3, 1, 1, 0, 8 }, /* A */
688 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
690 [AV_PIX_FMT_YUVA420P10BE] = {
691 .name = "yuva420p10be",
696 { 0, 1, 1, 0, 9 }, /* Y */
697 { 1, 1, 1, 0, 9 }, /* U */
698 { 2, 1, 1, 0, 9 }, /* V */
699 { 3, 1, 1, 0, 9 }, /* A */
701 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
703 [AV_PIX_FMT_YUVA420P10LE] = {
704 .name = "yuva420p10le",
709 { 0, 1, 1, 0, 9 }, /* Y */
710 { 1, 1, 1, 0, 9 }, /* U */
711 { 2, 1, 1, 0, 9 }, /* V */
712 { 3, 1, 1, 0, 9 }, /* A */
714 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
716 [AV_PIX_FMT_YUVA422P10BE] = {
717 .name = "yuva422p10be",
722 { 0, 1, 1, 0, 9 }, /* Y */
723 { 1, 1, 1, 0, 9 }, /* U */
724 { 2, 1, 1, 0, 9 }, /* V */
725 { 3, 1, 1, 0, 9 }, /* A */
727 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
729 [AV_PIX_FMT_YUVA422P10LE] = {
730 .name = "yuva422p10le",
735 { 0, 1, 1, 0, 9 }, /* Y */
736 { 1, 1, 1, 0, 9 }, /* U */
737 { 2, 1, 1, 0, 9 }, /* V */
738 { 3, 1, 1, 0, 9 }, /* A */
740 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
742 [AV_PIX_FMT_YUVA444P10BE] = {
743 .name = "yuva444p10be",
748 { 0, 1, 1, 0, 9 }, /* Y */
749 { 1, 1, 1, 0, 9 }, /* U */
750 { 2, 1, 1, 0, 9 }, /* V */
751 { 3, 1, 1, 0, 9 }, /* A */
753 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
755 [AV_PIX_FMT_YUVA444P10LE] = {
756 .name = "yuva444p10le",
761 { 0, 1, 1, 0, 9 }, /* Y */
762 { 1, 1, 1, 0, 9 }, /* U */
763 { 2, 1, 1, 0, 9 }, /* V */
764 { 3, 1, 1, 0, 9 }, /* A */
766 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
768 [AV_PIX_FMT_YUVA420P16BE] = {
769 .name = "yuva420p16be",
774 { 0, 1, 1, 0, 15 }, /* Y */
775 { 1, 1, 1, 0, 15 }, /* U */
776 { 2, 1, 1, 0, 15 }, /* V */
777 { 3, 1, 1, 0, 15 }, /* A */
779 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
781 [AV_PIX_FMT_YUVA420P16LE] = {
782 .name = "yuva420p16le",
787 { 0, 1, 1, 0, 15 }, /* Y */
788 { 1, 1, 1, 0, 15 }, /* U */
789 { 2, 1, 1, 0, 15 }, /* V */
790 { 3, 1, 1, 0, 15 }, /* A */
792 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
794 [AV_PIX_FMT_YUVA422P16BE] = {
795 .name = "yuva422p16be",
800 { 0, 1, 1, 0, 15 }, /* Y */
801 { 1, 1, 1, 0, 15 }, /* U */
802 { 2, 1, 1, 0, 15 }, /* V */
803 { 3, 1, 1, 0, 15 }, /* A */
805 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
807 [AV_PIX_FMT_YUVA422P16LE] = {
808 .name = "yuva422p16le",
813 { 0, 1, 1, 0, 15 }, /* Y */
814 { 1, 1, 1, 0, 15 }, /* U */
815 { 2, 1, 1, 0, 15 }, /* V */
816 { 3, 1, 1, 0, 15 }, /* A */
818 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
820 [AV_PIX_FMT_YUVA444P16BE] = {
821 .name = "yuva444p16be",
826 { 0, 1, 1, 0, 15 }, /* Y */
827 { 1, 1, 1, 0, 15 }, /* U */
828 { 2, 1, 1, 0, 15 }, /* V */
829 { 3, 1, 1, 0, 15 }, /* A */
831 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
833 [AV_PIX_FMT_YUVA444P16LE] = {
834 .name = "yuva444p16le",
839 { 0, 1, 1, 0, 15 }, /* Y */
840 { 1, 1, 1, 0, 15 }, /* U */
841 { 2, 1, 1, 0, 15 }, /* V */
842 { 3, 1, 1, 0, 15 }, /* A */
844 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
846 [AV_PIX_FMT_VDPAU_H264] = {
847 .name = "vdpau_h264",
850 .flags = PIX_FMT_HWACCEL,
852 [AV_PIX_FMT_VDPAU_MPEG1] = {
853 .name = "vdpau_mpeg1",
856 .flags = PIX_FMT_HWACCEL,
858 [AV_PIX_FMT_VDPAU_MPEG2] = {
859 .name = "vdpau_mpeg2",
862 .flags = PIX_FMT_HWACCEL,
864 [AV_PIX_FMT_VDPAU_WMV3] = {
865 .name = "vdpau_wmv3",
868 .flags = PIX_FMT_HWACCEL,
870 [AV_PIX_FMT_VDPAU_VC1] = {
874 .flags = PIX_FMT_HWACCEL,
876 [AV_PIX_FMT_VDPAU_MPEG4] = {
877 .name = "vdpau_mpeg4",
880 .flags = PIX_FMT_HWACCEL,
882 [AV_PIX_FMT_RGB48BE] = {
888 { 0, 5, 1, 0, 15 }, /* R */
889 { 0, 5, 3, 0, 15 }, /* G */
890 { 0, 5, 5, 0, 15 }, /* B */
892 .flags = PIX_FMT_RGB | PIX_FMT_BE,
894 [AV_PIX_FMT_RGB48LE] = {
900 { 0, 5, 1, 0, 15 }, /* R */
901 { 0, 5, 3, 0, 15 }, /* G */
902 { 0, 5, 5, 0, 15 }, /* B */
904 .flags = PIX_FMT_RGB,
906 [AV_PIX_FMT_RGBA64BE] = {
912 { 0, 7, 1, 0, 15 }, /* R */
913 { 0, 7, 3, 0, 15 }, /* G */
914 { 0, 7, 5, 0, 15 }, /* B */
915 { 0, 7, 7, 0, 15 }, /* A */
917 .flags = PIX_FMT_RGB | PIX_FMT_BE | PIX_FMT_ALPHA,
919 [AV_PIX_FMT_RGBA64LE] = {
925 { 0, 7, 1, 0, 15 }, /* R */
926 { 0, 7, 3, 0, 15 }, /* G */
927 { 0, 7, 5, 0, 15 }, /* B */
928 { 0, 7, 7, 0, 15 }, /* A */
930 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
932 [AV_PIX_FMT_RGB565BE] = {
938 { 0, 1, 0, 3, 4 }, /* R */
939 { 0, 1, 1, 5, 5 }, /* G */
940 { 0, 1, 1, 0, 4 }, /* B */
942 .flags = PIX_FMT_BE | PIX_FMT_RGB,
944 [AV_PIX_FMT_RGB565LE] = {
950 { 0, 1, 2, 3, 4 }, /* R */
951 { 0, 1, 1, 5, 5 }, /* G */
952 { 0, 1, 1, 0, 4 }, /* B */
954 .flags = PIX_FMT_RGB,
956 [AV_PIX_FMT_RGB555BE] = {
962 { 0, 1, 0, 2, 4 }, /* R */
963 { 0, 1, 1, 5, 4 }, /* G */
964 { 0, 1, 1, 0, 4 }, /* B */
966 .flags = PIX_FMT_BE | PIX_FMT_RGB,
968 [AV_PIX_FMT_RGB555LE] = {
974 { 0, 1, 2, 2, 4 }, /* R */
975 { 0, 1, 1, 5, 4 }, /* G */
976 { 0, 1, 1, 0, 4 }, /* B */
978 .flags = PIX_FMT_RGB,
980 [AV_PIX_FMT_RGB444BE] = {
986 { 0, 1, 0, 0, 3 }, /* R */
987 { 0, 1, 1, 4, 3 }, /* G */
988 { 0, 1, 1, 0, 3 }, /* B */
990 .flags = PIX_FMT_BE | PIX_FMT_RGB,
992 [AV_PIX_FMT_RGB444LE] = {
998 { 0, 1, 2, 0, 3 }, /* R */
999 { 0, 1, 1, 4, 3 }, /* G */
1000 { 0, 1, 1, 0, 3 }, /* B */
1002 .flags = PIX_FMT_RGB,
1004 [AV_PIX_FMT_BGR48BE] = {
1010 { 0, 5, 5, 0, 15 }, /* R */
1011 { 0, 5, 3, 0, 15 }, /* G */
1012 { 0, 5, 1, 0, 15 }, /* B */
1014 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1016 [AV_PIX_FMT_BGR48LE] = {
1022 { 0, 5, 5, 0, 15 }, /* R */
1023 { 0, 5, 3, 0, 15 }, /* G */
1024 { 0, 5, 1, 0, 15 }, /* B */
1026 .flags = PIX_FMT_RGB,
1028 [AV_PIX_FMT_BGRA64BE] = {
1034 { 0, 7, 5, 0, 15 }, /* R */
1035 { 0, 7, 3, 0, 15 }, /* G */
1036 { 0, 7, 1, 0, 15 }, /* B */
1037 { 0, 7, 7, 0, 15 }, /* A */
1039 .flags = PIX_FMT_BE | PIX_FMT_RGB | PIX_FMT_ALPHA,
1041 [AV_PIX_FMT_BGRA64LE] = {
1047 { 0, 7, 5, 0, 15 }, /* R */
1048 { 0, 7, 3, 0, 15 }, /* G */
1049 { 0, 7, 1, 0, 15 }, /* B */
1050 { 0, 7, 7, 0, 15 }, /* A */
1052 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
1054 [AV_PIX_FMT_BGR565BE] = {
1060 { 0, 1, 1, 0, 4 }, /* R */
1061 { 0, 1, 1, 5, 5 }, /* G */
1062 { 0, 1, 0, 3, 4 }, /* B */
1064 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1066 [AV_PIX_FMT_BGR565LE] = {
1072 { 0, 1, 1, 0, 4 }, /* R */
1073 { 0, 1, 1, 5, 5 }, /* G */
1074 { 0, 1, 2, 3, 4 }, /* B */
1076 .flags = PIX_FMT_RGB,
1078 [AV_PIX_FMT_BGR555BE] = {
1084 { 0, 1, 1, 0, 4 }, /* R */
1085 { 0, 1, 1, 5, 4 }, /* G */
1086 { 0, 1, 0, 2, 4 }, /* B */
1088 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1090 [AV_PIX_FMT_BGR555LE] = {
1096 { 0, 1, 1, 0, 4 }, /* R */
1097 { 0, 1, 1, 5, 4 }, /* G */
1098 { 0, 1, 2, 2, 4 }, /* B */
1100 .flags = PIX_FMT_RGB,
1102 [AV_PIX_FMT_BGR444BE] = {
1108 { 0, 1, 1, 0, 3 }, /* R */
1109 { 0, 1, 1, 4, 3 }, /* G */
1110 { 0, 1, 0, 0, 3 }, /* B */
1112 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1114 [AV_PIX_FMT_BGR444LE] = {
1120 { 0, 1, 1, 0, 3 }, /* R */
1121 { 0, 1, 1, 4, 3 }, /* G */
1122 { 0, 1, 2, 0, 3 }, /* B */
1124 .flags = PIX_FMT_RGB,
1126 [AV_PIX_FMT_VAAPI_MOCO] = {
1127 .name = "vaapi_moco",
1130 .flags = PIX_FMT_HWACCEL,
1132 [AV_PIX_FMT_VAAPI_IDCT] = {
1133 .name = "vaapi_idct",
1136 .flags = PIX_FMT_HWACCEL,
1138 [AV_PIX_FMT_VAAPI_VLD] = {
1139 .name = "vaapi_vld",
1142 .flags = PIX_FMT_HWACCEL,
1144 [AV_PIX_FMT_YUV420P9LE] = {
1145 .name = "yuv420p9le",
1150 { 0, 1, 1, 0, 8 }, /* Y */
1151 { 1, 1, 1, 0, 8 }, /* U */
1152 { 2, 1, 1, 0, 8 }, /* V */
1154 .flags = PIX_FMT_PLANAR,
1156 [AV_PIX_FMT_YUV420P9BE] = {
1157 .name = "yuv420p9be",
1162 { 0, 1, 1, 0, 8 }, /* Y */
1163 { 1, 1, 1, 0, 8 }, /* U */
1164 { 2, 1, 1, 0, 8 }, /* V */
1166 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1168 [AV_PIX_FMT_YUV420P10LE] = {
1169 .name = "yuv420p10le",
1174 { 0, 1, 1, 0, 9 }, /* Y */
1175 { 1, 1, 1, 0, 9 }, /* U */
1176 { 2, 1, 1, 0, 9 }, /* V */
1178 .flags = PIX_FMT_PLANAR,
1180 [AV_PIX_FMT_YUV420P10BE] = {
1181 .name = "yuv420p10be",
1186 { 0, 1, 1, 0, 9 }, /* Y */
1187 { 1, 1, 1, 0, 9 }, /* U */
1188 { 2, 1, 1, 0, 9 }, /* V */
1190 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1192 [AV_PIX_FMT_YUV420P12LE] = {
1193 .name = "yuv420p12le",
1198 { 0, 1, 1, 0, 11 }, /* Y */
1199 { 1, 1, 1, 0, 11 }, /* U */
1200 { 2, 1, 1, 0, 11 }, /* V */
1202 .flags = PIX_FMT_PLANAR,
1204 [AV_PIX_FMT_YUV420P12BE] = {
1205 .name = "yuv420p12be",
1210 { 0, 1, 1, 0, 11 }, /* Y */
1211 { 1, 1, 1, 0, 11 }, /* U */
1212 { 2, 1, 1, 0, 11 }, /* V */
1214 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1216 [AV_PIX_FMT_YUV420P14LE] = {
1217 .name = "yuv420p14le",
1222 { 0, 1, 1, 0, 13 }, /* Y */
1223 { 1, 1, 1, 0, 13 }, /* U */
1224 { 2, 1, 1, 0, 13 }, /* V */
1226 .flags = PIX_FMT_PLANAR,
1228 [AV_PIX_FMT_YUV420P14BE] = {
1229 .name = "yuv420p14be",
1234 { 0, 1, 1, 0, 13 }, /* Y */
1235 { 1, 1, 1, 0, 13 }, /* U */
1236 { 2, 1, 1, 0, 13 }, /* V */
1238 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1240 [AV_PIX_FMT_YUV420P16LE] = {
1241 .name = "yuv420p16le",
1246 { 0, 1, 1, 0, 15 }, /* Y */
1247 { 1, 1, 1, 0, 15 }, /* U */
1248 { 2, 1, 1, 0, 15 }, /* V */
1250 .flags = PIX_FMT_PLANAR,
1252 [AV_PIX_FMT_YUV420P16BE] = {
1253 .name = "yuv420p16be",
1258 { 0, 1, 1, 0, 15 }, /* Y */
1259 { 1, 1, 1, 0, 15 }, /* U */
1260 { 2, 1, 1, 0, 15 }, /* V */
1262 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1264 [AV_PIX_FMT_YUV422P9LE] = {
1265 .name = "yuv422p9le",
1270 { 0, 1, 1, 0, 8 }, /* Y */
1271 { 1, 1, 1, 0, 8 }, /* U */
1272 { 2, 1, 1, 0, 8 }, /* V */
1274 .flags = PIX_FMT_PLANAR,
1276 [AV_PIX_FMT_YUV422P9BE] = {
1277 .name = "yuv422p9be",
1282 { 0, 1, 1, 0, 8 }, /* Y */
1283 { 1, 1, 1, 0, 8 }, /* U */
1284 { 2, 1, 1, 0, 8 }, /* V */
1286 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1288 [AV_PIX_FMT_YUV422P10LE] = {
1289 .name = "yuv422p10le",
1294 { 0, 1, 1, 0, 9 }, /* Y */
1295 { 1, 1, 1, 0, 9 }, /* U */
1296 { 2, 1, 1, 0, 9 }, /* V */
1298 .flags = PIX_FMT_PLANAR,
1300 [AV_PIX_FMT_YUV422P10BE] = {
1301 .name = "yuv422p10be",
1306 { 0, 1, 1, 0, 9 }, /* Y */
1307 { 1, 1, 1, 0, 9 }, /* U */
1308 { 2, 1, 1, 0, 9 }, /* V */
1310 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1312 [AV_PIX_FMT_YUV422P12LE] = {
1313 .name = "yuv422p12le",
1318 { 0, 1, 1, 0, 11 }, /* Y */
1319 { 1, 1, 1, 0, 11 }, /* U */
1320 { 2, 1, 1, 0, 11 }, /* V */
1322 .flags = PIX_FMT_PLANAR,
1324 [AV_PIX_FMT_YUV422P12BE] = {
1325 .name = "yuv422p12be",
1330 { 0, 1, 1, 0, 11 }, /* Y */
1331 { 1, 1, 1, 0, 11 }, /* U */
1332 { 2, 1, 1, 0, 11 }, /* V */
1334 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1336 [AV_PIX_FMT_YUV422P14LE] = {
1337 .name = "yuv422p14le",
1342 { 0, 1, 1, 0, 13 }, /* Y */
1343 { 1, 1, 1, 0, 13 }, /* U */
1344 { 2, 1, 1, 0, 13 }, /* V */
1346 .flags = PIX_FMT_PLANAR,
1348 [AV_PIX_FMT_YUV422P14BE] = {
1349 .name = "yuv422p14be",
1354 { 0, 1, 1, 0, 13 }, /* Y */
1355 { 1, 1, 1, 0, 13 }, /* U */
1356 { 2, 1, 1, 0, 13 }, /* V */
1358 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1360 [AV_PIX_FMT_YUV422P16LE] = {
1361 .name = "yuv422p16le",
1366 { 0, 1, 1, 0, 15 }, /* Y */
1367 { 1, 1, 1, 0, 15 }, /* U */
1368 { 2, 1, 1, 0, 15 }, /* V */
1370 .flags = PIX_FMT_PLANAR,
1372 [AV_PIX_FMT_YUV422P16BE] = {
1373 .name = "yuv422p16be",
1378 { 0, 1, 1, 0, 15 }, /* Y */
1379 { 1, 1, 1, 0, 15 }, /* U */
1380 { 2, 1, 1, 0, 15 }, /* V */
1382 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1384 [AV_PIX_FMT_YUV444P16LE] = {
1385 .name = "yuv444p16le",
1390 { 0, 1, 1, 0, 15 }, /* Y */
1391 { 1, 1, 1, 0, 15 }, /* U */
1392 { 2, 1, 1, 0, 15 }, /* V */
1394 .flags = PIX_FMT_PLANAR,
1396 [AV_PIX_FMT_YUV444P16BE] = {
1397 .name = "yuv444p16be",
1402 { 0, 1, 1, 0, 15 }, /* Y */
1403 { 1, 1, 1, 0, 15 }, /* U */
1404 { 2, 1, 1, 0, 15 }, /* V */
1406 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1408 [AV_PIX_FMT_YUV444P10LE] = {
1409 .name = "yuv444p10le",
1414 { 0, 1, 1, 0, 9 }, /* Y */
1415 { 1, 1, 1, 0, 9 }, /* U */
1416 { 2, 1, 1, 0, 9 }, /* V */
1418 .flags = PIX_FMT_PLANAR,
1420 [AV_PIX_FMT_YUV444P10BE] = {
1421 .name = "yuv444p10be",
1426 { 0, 1, 1, 0, 9 }, /* Y */
1427 { 1, 1, 1, 0, 9 }, /* U */
1428 { 2, 1, 1, 0, 9 }, /* V */
1430 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1432 [AV_PIX_FMT_YUV444P9LE] = {
1433 .name = "yuv444p9le",
1438 { 0, 1, 1, 0, 8 }, /* Y */
1439 { 1, 1, 1, 0, 8 }, /* U */
1440 { 2, 1, 1, 0, 8 }, /* V */
1442 .flags = PIX_FMT_PLANAR,
1444 [AV_PIX_FMT_YUV444P9BE] = {
1445 .name = "yuv444p9be",
1450 { 0, 1, 1, 0, 8 }, /* Y */
1451 { 1, 1, 1, 0, 8 }, /* U */
1452 { 2, 1, 1, 0, 8 }, /* V */
1454 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1456 [AV_PIX_FMT_YUV444P12LE] = {
1457 .name = "yuv444p12le",
1462 { 0, 1, 1, 0, 11 }, /* Y */
1463 { 1, 1, 1, 0, 11 }, /* U */
1464 { 2, 1, 1, 0, 11 }, /* V */
1466 .flags = PIX_FMT_PLANAR,
1468 [AV_PIX_FMT_YUV444P12BE] = {
1469 .name = "yuv444p12be",
1474 { 0, 1, 1, 0, 11 }, /* Y */
1475 { 1, 1, 1, 0, 11 }, /* U */
1476 { 2, 1, 1, 0, 11 }, /* V */
1478 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1480 [AV_PIX_FMT_YUV444P14LE] = {
1481 .name = "yuv444p14le",
1486 { 0, 1, 1, 0, 13 }, /* Y */
1487 { 1, 1, 1, 0, 13 }, /* U */
1488 { 2, 1, 1, 0, 13 }, /* V */
1490 .flags = PIX_FMT_PLANAR,
1492 [AV_PIX_FMT_YUV444P14BE] = {
1493 .name = "yuv444p14be",
1498 { 0, 1, 1, 0, 13 }, /* Y */
1499 { 1, 1, 1, 0, 13 }, /* U */
1500 { 2, 1, 1, 0, 13 }, /* V */
1502 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1504 [AV_PIX_FMT_DXVA2_VLD] = {
1505 .name = "dxva2_vld",
1508 .flags = PIX_FMT_HWACCEL,
1510 [AV_PIX_FMT_VDA_VLD] = {
1514 .flags = PIX_FMT_HWACCEL,
1516 [AV_PIX_FMT_GRAY8A] = {
1520 { 0, 1, 1, 0, 7 }, /* Y */
1521 { 0, 1, 2, 0, 7 }, /* A */
1523 .flags = PIX_FMT_ALPHA,
1525 [AV_PIX_FMT_GBRP] = {
1531 { 2, 0, 1, 0, 7 }, /* R */
1532 { 0, 0, 1, 0, 7 }, /* G */
1533 { 1, 0, 1, 0, 7 }, /* B */
1535 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1537 [AV_PIX_FMT_GBRP9LE] = {
1543 { 2, 1, 1, 0, 8 }, /* R */
1544 { 0, 1, 1, 0, 8 }, /* G */
1545 { 1, 1, 1, 0, 8 }, /* B */
1547 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1549 [AV_PIX_FMT_GBRP9BE] = {
1555 { 2, 1, 1, 0, 8 }, /* R */
1556 { 0, 1, 1, 0, 8 }, /* G */
1557 { 1, 1, 1, 0, 8 }, /* B */
1559 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1561 [AV_PIX_FMT_GBRP10LE] = {
1567 { 2, 1, 1, 0, 9 }, /* R */
1568 { 0, 1, 1, 0, 9 }, /* G */
1569 { 1, 1, 1, 0, 9 }, /* B */
1571 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1573 [AV_PIX_FMT_GBRP10BE] = {
1579 { 2, 1, 1, 0, 9 }, /* R */
1580 { 0, 1, 1, 0, 9 }, /* G */
1581 { 1, 1, 1, 0, 9 }, /* B */
1583 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1585 [AV_PIX_FMT_GBRP12LE] = {
1591 { 2, 1, 1, 0, 11 }, /* R */
1592 { 0, 1, 1, 0, 11 }, /* G */
1593 { 1, 1, 1, 0, 11 }, /* B */
1595 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1597 [AV_PIX_FMT_GBRP12BE] = {
1603 { 2, 1, 1, 0, 11 }, /* R */
1604 { 0, 1, 1, 0, 11 }, /* G */
1605 { 1, 1, 1, 0, 11 }, /* B */
1607 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1609 [AV_PIX_FMT_GBRP14LE] = {
1615 { 2, 1, 1, 0, 13 }, /* R */
1616 { 0, 1, 1, 0, 13 }, /* G */
1617 { 1, 1, 1, 0, 13 }, /* B */
1619 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1621 [AV_PIX_FMT_GBRP14BE] = {
1627 { 2, 1, 1, 0, 13 }, /* R */
1628 { 0, 1, 1, 0, 13 }, /* G */
1629 { 1, 1, 1, 0, 13 }, /* B */
1631 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1633 [AV_PIX_FMT_GBRP16LE] = {
1639 { 2, 1, 1, 0, 15 }, /* R */
1640 { 0, 1, 1, 0, 15 }, /* G */
1641 { 1, 1, 1, 0, 15 }, /* B */
1643 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1645 [AV_PIX_FMT_GBRP16BE] = {
1651 { 2, 1, 1, 0, 15 }, /* R */
1652 { 0, 1, 1, 0, 15 }, /* G */
1653 { 1, 1, 1, 0, 15 }, /* B */
1655 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1657 [AV_PIX_FMT_VDPAU] = {
1661 .flags = PIX_FMT_HWACCEL,
1663 [AV_PIX_FMT_XYZ12LE] = {
1669 { 0, 5, 1, 4, 11 }, /* X */
1670 { 0, 5, 3, 4, 11 }, /* Y */
1671 { 0, 5, 5, 4, 11 }, /* Z */
1673 /*.flags = -- not used*/
1675 [AV_PIX_FMT_XYZ12BE] = {
1681 { 0, 5, 1, 4, 11 }, /* X */
1682 { 0, 5, 3, 4, 11 }, /* Y */
1683 { 0, 5, 5, 4, 11 }, /* Z */
1685 .flags = PIX_FMT_BE,
1689 static enum AVPixelFormat get_pix_fmt_internal(const char *name)
1691 enum AVPixelFormat pix_fmt;
1693 for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
1694 if (av_pix_fmt_descriptors[pix_fmt].name &&
1695 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1698 return AV_PIX_FMT_NONE;
1701 const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
1703 return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
1704 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1708 # define X_NE(be, le) be
1710 # define X_NE(be, le) le
1713 enum AVPixelFormat av_get_pix_fmt(const char *name)
1715 enum AVPixelFormat pix_fmt;
1717 if (!strcmp(name, "rgb32"))
1718 name = X_NE("argb", "bgra");
1719 else if (!strcmp(name, "bgr32"))
1720 name = X_NE("abgr", "rgba");
1722 pix_fmt = get_pix_fmt_internal(name);
1723 if (pix_fmt == AV_PIX_FMT_NONE) {
1726 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1727 pix_fmt = get_pix_fmt_internal(name2);
1732 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1735 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1737 for (c = 0; c < pixdesc->nb_components; c++) {
1738 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1739 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
1742 return bits >> log2_pixels;
1745 int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1748 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1751 for (c = 0; c < pixdesc->nb_components; c++) {
1752 const AVComponentDescriptor *comp = &pixdesc->comp[c];
1753 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1754 steps[comp->plane] = (comp->step_minus1 + 1) << s;
1756 for (c = 0; c < 4; c++)
1759 if(!(pixdesc->flags & PIX_FMT_BITSTREAM))
1762 return bits >> log2_pixels;
1765 char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt)
1769 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
1771 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
1772 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1773 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
1779 const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
1781 if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
1783 return &av_pix_fmt_descriptors[pix_fmt];
1786 const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
1789 return &av_pix_fmt_descriptors[0];
1790 while (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) {
1798 enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
1800 if (desc < av_pix_fmt_descriptors ||
1801 desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
1802 return AV_PIX_FMT_NONE;
1804 return desc - av_pix_fmt_descriptors;
1807 int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
1808 int *h_shift, int *v_shift)
1810 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
1812 return AVERROR(ENOSYS);
1813 *h_shift = desc->log2_chroma_w;
1814 *v_shift = desc->log2_chroma_h;
1819 int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
1821 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
1822 int i, planes[4] = { 0 }, ret = 0;
1825 return AVERROR(EINVAL);
1827 for (i = 0; i < desc->nb_components; i++)
1828 planes[desc->comp[i].plane] = 1;
1829 for (i = 0; i < FF_ARRAY_ELEMS(planes); i++)