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 */
502 .flags = PIX_FMT_RGB,
504 [AV_PIX_FMT_0BGR] = {
510 { 0, 3, 4, 0, 7 }, /* R */
511 { 0, 3, 3, 0, 7 }, /* G */
512 { 0, 3, 2, 0, 7 }, /* B */
514 .flags = PIX_FMT_RGB,
516 [AV_PIX_FMT_BGR0] = {
522 { 0, 3, 3, 0, 7 }, /* R */
523 { 0, 3, 2, 0, 7 }, /* G */
524 { 0, 3, 1, 0, 7 }, /* B */
526 .flags = PIX_FMT_RGB,
528 [AV_PIX_FMT_GRAY16BE] = {
534 { 0, 1, 1, 0, 15 }, /* Y */
538 [AV_PIX_FMT_GRAY16LE] = {
544 { 0, 1, 1, 0, 15 }, /* Y */
547 [AV_PIX_FMT_YUV440P] = {
553 { 0, 0, 1, 0, 7 }, /* Y */
554 { 1, 0, 1, 0, 7 }, /* U */
555 { 2, 0, 1, 0, 7 }, /* V */
557 .flags = PIX_FMT_PLANAR,
559 [AV_PIX_FMT_YUVJ440P] = {
565 { 0, 0, 1, 0, 7 }, /* Y */
566 { 1, 0, 1, 0, 7 }, /* U */
567 { 2, 0, 1, 0, 7 }, /* V */
569 .flags = PIX_FMT_PLANAR,
571 [AV_PIX_FMT_YUVA420P] = {
577 { 0, 0, 1, 0, 7 }, /* Y */
578 { 1, 0, 1, 0, 7 }, /* U */
579 { 2, 0, 1, 0, 7 }, /* V */
580 { 3, 0, 1, 0, 7 }, /* A */
582 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
584 [AV_PIX_FMT_YUVA422P] = {
590 { 0, 0, 1, 0, 7 }, /* Y */
591 { 1, 0, 1, 0, 7 }, /* U */
592 { 2, 0, 1, 0, 7 }, /* V */
593 { 3, 0, 1, 0, 7 }, /* A */
595 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
597 [AV_PIX_FMT_YUVA444P] = {
603 { 0, 0, 1, 0, 7 }, /* Y */
604 { 1, 0, 1, 0, 7 }, /* U */
605 { 2, 0, 1, 0, 7 }, /* V */
606 { 3, 0, 1, 0, 7 }, /* A */
608 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
610 [AV_PIX_FMT_YUVA420P9BE] = {
611 .name = "yuva420p9be",
616 { 0, 1, 1, 0, 8 }, /* Y */
617 { 1, 1, 1, 0, 8 }, /* U */
618 { 2, 1, 1, 0, 8 }, /* V */
619 { 3, 1, 1, 0, 8 }, /* A */
621 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
623 [AV_PIX_FMT_YUVA420P9LE] = {
624 .name = "yuva420p9le",
629 { 0, 1, 1, 0, 8 }, /* Y */
630 { 1, 1, 1, 0, 8 }, /* U */
631 { 2, 1, 1, 0, 8 }, /* V */
632 { 3, 1, 1, 0, 8 }, /* A */
634 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
636 [AV_PIX_FMT_YUVA422P9BE] = {
637 .name = "yuva422p9be",
642 { 0, 1, 1, 0, 8 }, /* Y */
643 { 1, 1, 1, 0, 8 }, /* U */
644 { 2, 1, 1, 0, 8 }, /* V */
645 { 3, 1, 1, 0, 8 }, /* A */
647 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
649 [AV_PIX_FMT_YUVA422P9LE] = {
650 .name = "yuva422p9le",
655 { 0, 1, 1, 0, 8 }, /* Y */
656 { 1, 1, 1, 0, 8 }, /* U */
657 { 2, 1, 1, 0, 8 }, /* V */
658 { 3, 1, 1, 0, 8 }, /* A */
660 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
662 [AV_PIX_FMT_YUVA444P9BE] = {
663 .name = "yuva444p9be",
668 { 0, 1, 1, 0, 8 }, /* Y */
669 { 1, 1, 1, 0, 8 }, /* U */
670 { 2, 1, 1, 0, 8 }, /* V */
671 { 3, 1, 1, 0, 8 }, /* A */
673 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
675 [AV_PIX_FMT_YUVA444P9LE] = {
676 .name = "yuva444p9le",
681 { 0, 1, 1, 0, 8 }, /* Y */
682 { 1, 1, 1, 0, 8 }, /* U */
683 { 2, 1, 1, 0, 8 }, /* V */
684 { 3, 1, 1, 0, 8 }, /* A */
686 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
688 [AV_PIX_FMT_YUVA420P10BE] = {
689 .name = "yuva420p10be",
694 { 0, 1, 1, 0, 9 }, /* Y */
695 { 1, 1, 1, 0, 9 }, /* U */
696 { 2, 1, 1, 0, 9 }, /* V */
697 { 3, 1, 1, 0, 9 }, /* A */
699 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
701 [AV_PIX_FMT_YUVA420P10LE] = {
702 .name = "yuva420p10le",
707 { 0, 1, 1, 0, 9 }, /* Y */
708 { 1, 1, 1, 0, 9 }, /* U */
709 { 2, 1, 1, 0, 9 }, /* V */
710 { 3, 1, 1, 0, 9 }, /* A */
712 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
714 [AV_PIX_FMT_YUVA422P10BE] = {
715 .name = "yuva422p10be",
720 { 0, 1, 1, 0, 9 }, /* Y */
721 { 1, 1, 1, 0, 9 }, /* U */
722 { 2, 1, 1, 0, 9 }, /* V */
723 { 3, 1, 1, 0, 9 }, /* A */
725 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
727 [AV_PIX_FMT_YUVA422P10LE] = {
728 .name = "yuva422p10le",
733 { 0, 1, 1, 0, 9 }, /* Y */
734 { 1, 1, 1, 0, 9 }, /* U */
735 { 2, 1, 1, 0, 9 }, /* V */
736 { 3, 1, 1, 0, 9 }, /* A */
738 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
740 [AV_PIX_FMT_YUVA444P10BE] = {
741 .name = "yuva444p10be",
746 { 0, 1, 1, 0, 9 }, /* Y */
747 { 1, 1, 1, 0, 9 }, /* U */
748 { 2, 1, 1, 0, 9 }, /* V */
749 { 3, 1, 1, 0, 9 }, /* A */
751 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
753 [AV_PIX_FMT_YUVA444P10LE] = {
754 .name = "yuva444p10le",
759 { 0, 1, 1, 0, 9 }, /* Y */
760 { 1, 1, 1, 0, 9 }, /* U */
761 { 2, 1, 1, 0, 9 }, /* V */
762 { 3, 1, 1, 0, 9 }, /* A */
764 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
766 [AV_PIX_FMT_YUVA420P16BE] = {
767 .name = "yuva420p16be",
772 { 0, 1, 1, 0, 15 }, /* Y */
773 { 1, 1, 1, 0, 15 }, /* U */
774 { 2, 1, 1, 0, 15 }, /* V */
775 { 3, 1, 1, 0, 15 }, /* A */
777 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
779 [AV_PIX_FMT_YUVA420P16LE] = {
780 .name = "yuva420p16le",
785 { 0, 1, 1, 0, 15 }, /* Y */
786 { 1, 1, 1, 0, 15 }, /* U */
787 { 2, 1, 1, 0, 15 }, /* V */
788 { 3, 1, 1, 0, 15 }, /* A */
790 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
792 [AV_PIX_FMT_YUVA422P16BE] = {
793 .name = "yuva422p16be",
798 { 0, 1, 1, 0, 15 }, /* Y */
799 { 1, 1, 1, 0, 15 }, /* U */
800 { 2, 1, 1, 0, 15 }, /* V */
801 { 3, 1, 1, 0, 15 }, /* A */
803 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
805 [AV_PIX_FMT_YUVA422P16LE] = {
806 .name = "yuva422p16le",
811 { 0, 1, 1, 0, 15 }, /* Y */
812 { 1, 1, 1, 0, 15 }, /* U */
813 { 2, 1, 1, 0, 15 }, /* V */
814 { 3, 1, 1, 0, 15 }, /* A */
816 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
818 [AV_PIX_FMT_YUVA444P16BE] = {
819 .name = "yuva444p16be",
824 { 0, 1, 1, 0, 15 }, /* Y */
825 { 1, 1, 1, 0, 15 }, /* U */
826 { 2, 1, 1, 0, 15 }, /* V */
827 { 3, 1, 1, 0, 15 }, /* A */
829 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
831 [AV_PIX_FMT_YUVA444P16LE] = {
832 .name = "yuva444p16le",
837 { 0, 1, 1, 0, 15 }, /* Y */
838 { 1, 1, 1, 0, 15 }, /* U */
839 { 2, 1, 1, 0, 15 }, /* V */
840 { 3, 1, 1, 0, 15 }, /* A */
842 .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
844 [AV_PIX_FMT_VDPAU_H264] = {
845 .name = "vdpau_h264",
848 .flags = PIX_FMT_HWACCEL,
850 [AV_PIX_FMT_VDPAU_MPEG1] = {
851 .name = "vdpau_mpeg1",
854 .flags = PIX_FMT_HWACCEL,
856 [AV_PIX_FMT_VDPAU_MPEG2] = {
857 .name = "vdpau_mpeg2",
860 .flags = PIX_FMT_HWACCEL,
862 [AV_PIX_FMT_VDPAU_WMV3] = {
863 .name = "vdpau_wmv3",
866 .flags = PIX_FMT_HWACCEL,
868 [AV_PIX_FMT_VDPAU_VC1] = {
872 .flags = PIX_FMT_HWACCEL,
874 [AV_PIX_FMT_VDPAU_MPEG4] = {
875 .name = "vdpau_mpeg4",
878 .flags = PIX_FMT_HWACCEL,
880 [AV_PIX_FMT_RGB48BE] = {
886 { 0, 5, 1, 0, 15 }, /* R */
887 { 0, 5, 3, 0, 15 }, /* G */
888 { 0, 5, 5, 0, 15 }, /* B */
890 .flags = PIX_FMT_RGB | PIX_FMT_BE,
892 [AV_PIX_FMT_RGB48LE] = {
898 { 0, 5, 1, 0, 15 }, /* R */
899 { 0, 5, 3, 0, 15 }, /* G */
900 { 0, 5, 5, 0, 15 }, /* B */
902 .flags = PIX_FMT_RGB,
904 [AV_PIX_FMT_RGBA64BE] = {
910 { 0, 7, 1, 0, 15 }, /* R */
911 { 0, 7, 3, 0, 15 }, /* G */
912 { 0, 7, 5, 0, 15 }, /* B */
913 { 0, 7, 7, 0, 15 }, /* A */
915 .flags = PIX_FMT_RGB | PIX_FMT_BE | PIX_FMT_ALPHA,
917 [AV_PIX_FMT_RGBA64LE] = {
923 { 0, 7, 1, 0, 15 }, /* R */
924 { 0, 7, 3, 0, 15 }, /* G */
925 { 0, 7, 5, 0, 15 }, /* B */
926 { 0, 7, 7, 0, 15 }, /* A */
928 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
930 [AV_PIX_FMT_RGB565BE] = {
936 { 0, 1, 0, 3, 4 }, /* R */
937 { 0, 1, 1, 5, 5 }, /* G */
938 { 0, 1, 1, 0, 4 }, /* B */
940 .flags = PIX_FMT_BE | PIX_FMT_RGB,
942 [AV_PIX_FMT_RGB565LE] = {
948 { 0, 1, 2, 3, 4 }, /* R */
949 { 0, 1, 1, 5, 5 }, /* G */
950 { 0, 1, 1, 0, 4 }, /* B */
952 .flags = PIX_FMT_RGB,
954 [AV_PIX_FMT_RGB555BE] = {
960 { 0, 1, 0, 2, 4 }, /* R */
961 { 0, 1, 1, 5, 4 }, /* G */
962 { 0, 1, 1, 0, 4 }, /* B */
964 .flags = PIX_FMT_BE | PIX_FMT_RGB,
966 [AV_PIX_FMT_RGB555LE] = {
972 { 0, 1, 2, 2, 4 }, /* R */
973 { 0, 1, 1, 5, 4 }, /* G */
974 { 0, 1, 1, 0, 4 }, /* B */
976 .flags = PIX_FMT_RGB,
978 [AV_PIX_FMT_RGB444BE] = {
984 { 0, 1, 0, 0, 3 }, /* R */
985 { 0, 1, 1, 4, 3 }, /* G */
986 { 0, 1, 1, 0, 3 }, /* B */
988 .flags = PIX_FMT_BE | PIX_FMT_RGB,
990 [AV_PIX_FMT_RGB444LE] = {
996 { 0, 1, 2, 0, 3 }, /* R */
997 { 0, 1, 1, 4, 3 }, /* G */
998 { 0, 1, 1, 0, 3 }, /* B */
1000 .flags = PIX_FMT_RGB,
1002 [AV_PIX_FMT_BGR48BE] = {
1008 { 0, 5, 5, 0, 15 }, /* R */
1009 { 0, 5, 3, 0, 15 }, /* G */
1010 { 0, 5, 1, 0, 15 }, /* B */
1012 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1014 [AV_PIX_FMT_BGR48LE] = {
1020 { 0, 5, 5, 0, 15 }, /* R */
1021 { 0, 5, 3, 0, 15 }, /* G */
1022 { 0, 5, 1, 0, 15 }, /* B */
1024 .flags = PIX_FMT_RGB,
1026 [AV_PIX_FMT_BGRA64BE] = {
1032 { 0, 7, 5, 0, 15 }, /* R */
1033 { 0, 7, 3, 0, 15 }, /* G */
1034 { 0, 7, 1, 0, 15 }, /* B */
1035 { 0, 7, 7, 0, 15 }, /* A */
1037 .flags = PIX_FMT_BE | PIX_FMT_RGB | PIX_FMT_ALPHA,
1039 [AV_PIX_FMT_BGRA64LE] = {
1045 { 0, 7, 5, 0, 15 }, /* R */
1046 { 0, 7, 3, 0, 15 }, /* G */
1047 { 0, 7, 1, 0, 15 }, /* B */
1048 { 0, 7, 7, 0, 15 }, /* A */
1050 .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
1052 [AV_PIX_FMT_BGR565BE] = {
1058 { 0, 1, 1, 0, 4 }, /* R */
1059 { 0, 1, 1, 5, 5 }, /* G */
1060 { 0, 1, 0, 3, 4 }, /* B */
1062 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1064 [AV_PIX_FMT_BGR565LE] = {
1070 { 0, 1, 1, 0, 4 }, /* R */
1071 { 0, 1, 1, 5, 5 }, /* G */
1072 { 0, 1, 2, 3, 4 }, /* B */
1074 .flags = PIX_FMT_RGB,
1076 [AV_PIX_FMT_BGR555BE] = {
1082 { 0, 1, 1, 0, 4 }, /* R */
1083 { 0, 1, 1, 5, 4 }, /* G */
1084 { 0, 1, 0, 2, 4 }, /* B */
1086 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1088 [AV_PIX_FMT_BGR555LE] = {
1094 { 0, 1, 1, 0, 4 }, /* R */
1095 { 0, 1, 1, 5, 4 }, /* G */
1096 { 0, 1, 2, 2, 4 }, /* B */
1098 .flags = PIX_FMT_RGB,
1100 [AV_PIX_FMT_BGR444BE] = {
1106 { 0, 1, 1, 0, 3 }, /* R */
1107 { 0, 1, 1, 4, 3 }, /* G */
1108 { 0, 1, 0, 0, 3 }, /* B */
1110 .flags = PIX_FMT_BE | PIX_FMT_RGB,
1112 [AV_PIX_FMT_BGR444LE] = {
1118 { 0, 1, 1, 0, 3 }, /* R */
1119 { 0, 1, 1, 4, 3 }, /* G */
1120 { 0, 1, 2, 0, 3 }, /* B */
1122 .flags = PIX_FMT_RGB,
1124 [AV_PIX_FMT_VAAPI_MOCO] = {
1125 .name = "vaapi_moco",
1128 .flags = PIX_FMT_HWACCEL,
1130 [AV_PIX_FMT_VAAPI_IDCT] = {
1131 .name = "vaapi_idct",
1134 .flags = PIX_FMT_HWACCEL,
1136 [AV_PIX_FMT_VAAPI_VLD] = {
1137 .name = "vaapi_vld",
1140 .flags = PIX_FMT_HWACCEL,
1142 [AV_PIX_FMT_YUV420P9LE] = {
1143 .name = "yuv420p9le",
1148 { 0, 1, 1, 0, 8 }, /* Y */
1149 { 1, 1, 1, 0, 8 }, /* U */
1150 { 2, 1, 1, 0, 8 }, /* V */
1152 .flags = PIX_FMT_PLANAR,
1154 [AV_PIX_FMT_YUV420P9BE] = {
1155 .name = "yuv420p9be",
1160 { 0, 1, 1, 0, 8 }, /* Y */
1161 { 1, 1, 1, 0, 8 }, /* U */
1162 { 2, 1, 1, 0, 8 }, /* V */
1164 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1166 [AV_PIX_FMT_YUV420P10LE] = {
1167 .name = "yuv420p10le",
1172 { 0, 1, 1, 0, 9 }, /* Y */
1173 { 1, 1, 1, 0, 9 }, /* U */
1174 { 2, 1, 1, 0, 9 }, /* V */
1176 .flags = PIX_FMT_PLANAR,
1178 [AV_PIX_FMT_YUV420P10BE] = {
1179 .name = "yuv420p10be",
1184 { 0, 1, 1, 0, 9 }, /* Y */
1185 { 1, 1, 1, 0, 9 }, /* U */
1186 { 2, 1, 1, 0, 9 }, /* V */
1188 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1190 [AV_PIX_FMT_YUV420P12LE] = {
1191 .name = "yuv420p12le",
1196 { 0, 1, 1, 0, 11 }, /* Y */
1197 { 1, 1, 1, 0, 11 }, /* U */
1198 { 2, 1, 1, 0, 11 }, /* V */
1200 .flags = PIX_FMT_PLANAR,
1202 [AV_PIX_FMT_YUV420P12BE] = {
1203 .name = "yuv420p12be",
1208 { 0, 1, 1, 0, 11 }, /* Y */
1209 { 1, 1, 1, 0, 11 }, /* U */
1210 { 2, 1, 1, 0, 11 }, /* V */
1212 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1214 [AV_PIX_FMT_YUV420P14LE] = {
1215 .name = "yuv420p14le",
1220 { 0, 1, 1, 0, 13 }, /* Y */
1221 { 1, 1, 1, 0, 13 }, /* U */
1222 { 2, 1, 1, 0, 13 }, /* V */
1224 .flags = PIX_FMT_PLANAR,
1226 [AV_PIX_FMT_YUV420P14BE] = {
1227 .name = "yuv420p14be",
1232 { 0, 1, 1, 0, 13 }, /* Y */
1233 { 1, 1, 1, 0, 13 }, /* U */
1234 { 2, 1, 1, 0, 13 }, /* V */
1236 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1238 [AV_PIX_FMT_YUV420P16LE] = {
1239 .name = "yuv420p16le",
1244 { 0, 1, 1, 0, 15 }, /* Y */
1245 { 1, 1, 1, 0, 15 }, /* U */
1246 { 2, 1, 1, 0, 15 }, /* V */
1248 .flags = PIX_FMT_PLANAR,
1250 [AV_PIX_FMT_YUV420P16BE] = {
1251 .name = "yuv420p16be",
1256 { 0, 1, 1, 0, 15 }, /* Y */
1257 { 1, 1, 1, 0, 15 }, /* U */
1258 { 2, 1, 1, 0, 15 }, /* V */
1260 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1262 [AV_PIX_FMT_YUV422P9LE] = {
1263 .name = "yuv422p9le",
1268 { 0, 1, 1, 0, 8 }, /* Y */
1269 { 1, 1, 1, 0, 8 }, /* U */
1270 { 2, 1, 1, 0, 8 }, /* V */
1272 .flags = PIX_FMT_PLANAR,
1274 [AV_PIX_FMT_YUV422P9BE] = {
1275 .name = "yuv422p9be",
1280 { 0, 1, 1, 0, 8 }, /* Y */
1281 { 1, 1, 1, 0, 8 }, /* U */
1282 { 2, 1, 1, 0, 8 }, /* V */
1284 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1286 [AV_PIX_FMT_YUV422P10LE] = {
1287 .name = "yuv422p10le",
1292 { 0, 1, 1, 0, 9 }, /* Y */
1293 { 1, 1, 1, 0, 9 }, /* U */
1294 { 2, 1, 1, 0, 9 }, /* V */
1296 .flags = PIX_FMT_PLANAR,
1298 [AV_PIX_FMT_YUV422P10BE] = {
1299 .name = "yuv422p10be",
1304 { 0, 1, 1, 0, 9 }, /* Y */
1305 { 1, 1, 1, 0, 9 }, /* U */
1306 { 2, 1, 1, 0, 9 }, /* V */
1308 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1310 [AV_PIX_FMT_YUV422P12LE] = {
1311 .name = "yuv422p12le",
1316 { 0, 1, 1, 0, 11 }, /* Y */
1317 { 1, 1, 1, 0, 11 }, /* U */
1318 { 2, 1, 1, 0, 11 }, /* V */
1320 .flags = PIX_FMT_PLANAR,
1322 [AV_PIX_FMT_YUV422P12BE] = {
1323 .name = "yuv422p12be",
1328 { 0, 1, 1, 0, 11 }, /* Y */
1329 { 1, 1, 1, 0, 11 }, /* U */
1330 { 2, 1, 1, 0, 11 }, /* V */
1332 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1334 [AV_PIX_FMT_YUV422P14LE] = {
1335 .name = "yuv422p14le",
1340 { 0, 1, 1, 0, 13 }, /* Y */
1341 { 1, 1, 1, 0, 13 }, /* U */
1342 { 2, 1, 1, 0, 13 }, /* V */
1344 .flags = PIX_FMT_PLANAR,
1346 [AV_PIX_FMT_YUV422P14BE] = {
1347 .name = "yuv422p14be",
1352 { 0, 1, 1, 0, 13 }, /* Y */
1353 { 1, 1, 1, 0, 13 }, /* U */
1354 { 2, 1, 1, 0, 13 }, /* V */
1356 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1358 [AV_PIX_FMT_YUV422P16LE] = {
1359 .name = "yuv422p16le",
1364 { 0, 1, 1, 0, 15 }, /* Y */
1365 { 1, 1, 1, 0, 15 }, /* U */
1366 { 2, 1, 1, 0, 15 }, /* V */
1368 .flags = PIX_FMT_PLANAR,
1370 [AV_PIX_FMT_YUV422P16BE] = {
1371 .name = "yuv422p16be",
1376 { 0, 1, 1, 0, 15 }, /* Y */
1377 { 1, 1, 1, 0, 15 }, /* U */
1378 { 2, 1, 1, 0, 15 }, /* V */
1380 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1382 [AV_PIX_FMT_YUV444P16LE] = {
1383 .name = "yuv444p16le",
1388 { 0, 1, 1, 0, 15 }, /* Y */
1389 { 1, 1, 1, 0, 15 }, /* U */
1390 { 2, 1, 1, 0, 15 }, /* V */
1392 .flags = PIX_FMT_PLANAR,
1394 [AV_PIX_FMT_YUV444P16BE] = {
1395 .name = "yuv444p16be",
1400 { 0, 1, 1, 0, 15 }, /* Y */
1401 { 1, 1, 1, 0, 15 }, /* U */
1402 { 2, 1, 1, 0, 15 }, /* V */
1404 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1406 [AV_PIX_FMT_YUV444P10LE] = {
1407 .name = "yuv444p10le",
1412 { 0, 1, 1, 0, 9 }, /* Y */
1413 { 1, 1, 1, 0, 9 }, /* U */
1414 { 2, 1, 1, 0, 9 }, /* V */
1416 .flags = PIX_FMT_PLANAR,
1418 [AV_PIX_FMT_YUV444P10BE] = {
1419 .name = "yuv444p10be",
1424 { 0, 1, 1, 0, 9 }, /* Y */
1425 { 1, 1, 1, 0, 9 }, /* U */
1426 { 2, 1, 1, 0, 9 }, /* V */
1428 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1430 [AV_PIX_FMT_YUV444P9LE] = {
1431 .name = "yuv444p9le",
1436 { 0, 1, 1, 0, 8 }, /* Y */
1437 { 1, 1, 1, 0, 8 }, /* U */
1438 { 2, 1, 1, 0, 8 }, /* V */
1440 .flags = PIX_FMT_PLANAR,
1442 [AV_PIX_FMT_YUV444P9BE] = {
1443 .name = "yuv444p9be",
1448 { 0, 1, 1, 0, 8 }, /* Y */
1449 { 1, 1, 1, 0, 8 }, /* U */
1450 { 2, 1, 1, 0, 8 }, /* V */
1452 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1454 [AV_PIX_FMT_YUV444P12LE] = {
1455 .name = "yuv444p12le",
1460 { 0, 1, 1, 0, 11 }, /* Y */
1461 { 1, 1, 1, 0, 11 }, /* U */
1462 { 2, 1, 1, 0, 11 }, /* V */
1464 .flags = PIX_FMT_PLANAR,
1466 [AV_PIX_FMT_YUV444P12BE] = {
1467 .name = "yuv444p12be",
1472 { 0, 1, 1, 0, 11 }, /* Y */
1473 { 1, 1, 1, 0, 11 }, /* U */
1474 { 2, 1, 1, 0, 11 }, /* V */
1476 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1478 [AV_PIX_FMT_YUV444P14LE] = {
1479 .name = "yuv444p14le",
1484 { 0, 1, 1, 0, 13 }, /* Y */
1485 { 1, 1, 1, 0, 13 }, /* U */
1486 { 2, 1, 1, 0, 13 }, /* V */
1488 .flags = PIX_FMT_PLANAR,
1490 [AV_PIX_FMT_YUV444P14BE] = {
1491 .name = "yuv444p14be",
1496 { 0, 1, 1, 0, 13 }, /* Y */
1497 { 1, 1, 1, 0, 13 }, /* U */
1498 { 2, 1, 1, 0, 13 }, /* V */
1500 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1502 [AV_PIX_FMT_DXVA2_VLD] = {
1503 .name = "dxva2_vld",
1506 .flags = PIX_FMT_HWACCEL,
1508 [AV_PIX_FMT_VDA_VLD] = {
1512 .flags = PIX_FMT_HWACCEL,
1514 [AV_PIX_FMT_GRAY8A] = {
1518 { 0, 1, 1, 0, 7 }, /* Y */
1519 { 0, 1, 2, 0, 7 }, /* A */
1521 .flags = PIX_FMT_ALPHA,
1523 [AV_PIX_FMT_GBRP] = {
1529 { 2, 0, 1, 0, 7 }, /* R */
1530 { 0, 0, 1, 0, 7 }, /* G */
1531 { 1, 0, 1, 0, 7 }, /* B */
1533 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1535 [AV_PIX_FMT_GBRP9LE] = {
1541 { 2, 1, 1, 0, 8 }, /* R */
1542 { 0, 1, 1, 0, 8 }, /* G */
1543 { 1, 1, 1, 0, 8 }, /* B */
1545 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1547 [AV_PIX_FMT_GBRP9BE] = {
1553 { 2, 1, 1, 0, 8 }, /* R */
1554 { 0, 1, 1, 0, 8 }, /* G */
1555 { 1, 1, 1, 0, 8 }, /* B */
1557 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1559 [AV_PIX_FMT_GBRP10LE] = {
1565 { 2, 1, 1, 0, 9 }, /* R */
1566 { 0, 1, 1, 0, 9 }, /* G */
1567 { 1, 1, 1, 0, 9 }, /* B */
1569 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1571 [AV_PIX_FMT_GBRP10BE] = {
1577 { 2, 1, 1, 0, 9 }, /* R */
1578 { 0, 1, 1, 0, 9 }, /* G */
1579 { 1, 1, 1, 0, 9 }, /* B */
1581 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1583 [AV_PIX_FMT_GBRP12LE] = {
1589 { 2, 1, 1, 0, 11 }, /* R */
1590 { 0, 1, 1, 0, 11 }, /* G */
1591 { 1, 1, 1, 0, 11 }, /* B */
1593 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1595 [AV_PIX_FMT_GBRP12BE] = {
1601 { 2, 1, 1, 0, 11 }, /* R */
1602 { 0, 1, 1, 0, 11 }, /* G */
1603 { 1, 1, 1, 0, 11 }, /* B */
1605 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1607 [AV_PIX_FMT_GBRP14LE] = {
1613 { 2, 1, 1, 0, 13 }, /* R */
1614 { 0, 1, 1, 0, 13 }, /* G */
1615 { 1, 1, 1, 0, 13 }, /* B */
1617 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1619 [AV_PIX_FMT_GBRP14BE] = {
1625 { 2, 1, 1, 0, 13 }, /* R */
1626 { 0, 1, 1, 0, 13 }, /* G */
1627 { 1, 1, 1, 0, 13 }, /* B */
1629 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1631 [AV_PIX_FMT_GBRP16LE] = {
1637 { 2, 1, 1, 0, 15 }, /* R */
1638 { 0, 1, 1, 0, 15 }, /* G */
1639 { 1, 1, 1, 0, 15 }, /* B */
1641 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1643 [AV_PIX_FMT_GBRP16BE] = {
1649 { 2, 1, 1, 0, 15 }, /* R */
1650 { 0, 1, 1, 0, 15 }, /* G */
1651 { 1, 1, 1, 0, 15 }, /* B */
1653 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1655 [AV_PIX_FMT_VDPAU] = {
1659 .flags = PIX_FMT_HWACCEL,
1661 [AV_PIX_FMT_XYZ12LE] = {
1667 { 0, 5, 1, 4, 11 }, /* X */
1668 { 0, 5, 3, 4, 11 }, /* Y */
1669 { 0, 5, 5, 4, 11 }, /* Z */
1671 /*.flags = -- not used*/
1673 [AV_PIX_FMT_XYZ12BE] = {
1679 { 0, 5, 1, 4, 11 }, /* X */
1680 { 0, 5, 3, 4, 11 }, /* Y */
1681 { 0, 5, 5, 4, 11 }, /* Z */
1683 .flags = PIX_FMT_BE,
1687 static enum AVPixelFormat get_pix_fmt_internal(const char *name)
1689 enum AVPixelFormat pix_fmt;
1691 for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
1692 if (av_pix_fmt_descriptors[pix_fmt].name &&
1693 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1696 return AV_PIX_FMT_NONE;
1699 const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
1701 return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
1702 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1706 # define X_NE(be, le) be
1708 # define X_NE(be, le) le
1711 enum AVPixelFormat av_get_pix_fmt(const char *name)
1713 enum AVPixelFormat pix_fmt;
1715 if (!strcmp(name, "rgb32"))
1716 name = X_NE("argb", "bgra");
1717 else if (!strcmp(name, "bgr32"))
1718 name = X_NE("abgr", "rgba");
1720 pix_fmt = get_pix_fmt_internal(name);
1721 if (pix_fmt == AV_PIX_FMT_NONE) {
1724 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1725 pix_fmt = get_pix_fmt_internal(name2);
1730 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1733 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1735 for (c = 0; c < pixdesc->nb_components; c++) {
1736 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1737 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
1740 return bits >> log2_pixels;
1743 int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1746 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1749 for (c = 0; c < pixdesc->nb_components; c++) {
1750 const AVComponentDescriptor *comp = &pixdesc->comp[c];
1751 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1752 steps[comp->plane] = (comp->step_minus1 + 1) << s;
1754 for (c = 0; c < 4; c++)
1757 if(!(pixdesc->flags & PIX_FMT_BITSTREAM))
1760 return bits >> log2_pixels;
1763 char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt)
1767 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
1769 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
1770 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1771 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
1777 const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
1779 if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
1781 return &av_pix_fmt_descriptors[pix_fmt];
1784 const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
1787 return &av_pix_fmt_descriptors[0];
1788 while (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) {
1796 enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
1798 if (desc < av_pix_fmt_descriptors ||
1799 desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
1800 return AV_PIX_FMT_NONE;
1802 return desc - av_pix_fmt_descriptors;
1805 int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
1806 int *h_shift, int *v_shift)
1808 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
1810 return AVERROR(ENOSYS);
1811 *h_shift = desc->log2_chroma_w;
1812 *v_shift = desc->log2_chroma_h;
1817 int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
1819 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
1820 int i, planes[4] = { 0 }, ret = 0;
1823 return AVERROR(EINVAL);
1825 for (i = 0; i < desc->nb_components; i++)
1826 planes[desc->comp[i].plane] = 1;
1827 for (i = 0; i < FF_ARRAY_ELEMS(planes); i++)