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
27 #include "intreadwrite.h"
29 void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
30 const AVPixFmtDescriptor *desc, int x, int y, int c, int w,
31 int read_pal_component)
33 AVComponentDescriptor comp = desc->comp[c];
34 int plane = comp.plane;
35 int depth = comp.depth_minus1 + 1;
36 int mask = (1 << depth) - 1;
37 int shift = comp.shift;
38 int step = comp.step_minus1 + 1;
39 int flags = desc->flags;
41 if (flags & PIX_FMT_BITSTREAM) {
42 int skip = x * step + comp.offset_plus1 - 1;
43 const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
44 int shift = 8 - depth - (skip & 7);
47 int val = (*p >> shift) & mask;
48 if (read_pal_component)
49 val = data[1][4*val + c];
56 const uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
57 int is_8bit = shift + depth <= 8;
60 p += !!(flags & PIX_FMT_BE);
63 int val = is_8bit ? *p :
64 flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
65 val = (val >> shift) & mask;
66 if (read_pal_component)
67 val = data[1][4 * val + c];
74 void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
75 const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
77 AVComponentDescriptor comp = desc->comp[c];
78 int plane = comp.plane;
79 int depth = comp.depth_minus1 + 1;
80 int step = comp.step_minus1 + 1;
81 int flags = desc->flags;
83 if (flags & PIX_FMT_BITSTREAM) {
84 int skip = x * step + comp.offset_plus1 - 1;
85 uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
86 int shift = 8 - depth - (skip & 7);
89 *p |= *src++ << shift;
95 int shift = comp.shift;
96 uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
98 if (shift + depth <= 8) {
99 p += !!(flags & PIX_FMT_BE);
101 *p |= (*src++ << shift);
106 if (flags & PIX_FMT_BE) {
107 uint16_t val = AV_RB16(p) | (*src++ << shift);
110 uint16_t val = AV_RL16(p) | (*src++ << shift);
119 const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
120 [PIX_FMT_YUV420P] = {
126 { 0, 0, 1, 0, 7 }, /* Y */
127 { 1, 0, 1, 0, 7 }, /* U */
128 { 2, 0, 1, 0, 7 }, /* V */
130 .flags = PIX_FMT_PLANAR,
132 [PIX_FMT_YUYV422] = {
138 { 0, 1, 1, 0, 7 }, /* Y */
139 { 0, 3, 2, 0, 7 }, /* U */
140 { 0, 3, 4, 0, 7 }, /* V */
149 { 0, 2, 1, 0, 7 }, /* R */
150 { 0, 2, 2, 0, 7 }, /* G */
151 { 0, 2, 3, 0, 7 }, /* B */
153 .flags = PIX_FMT_RGB,
161 { 0, 2, 1, 0, 7 }, /* B */
162 { 0, 2, 2, 0, 7 }, /* G */
163 { 0, 2, 3, 0, 7 }, /* R */
165 .flags = PIX_FMT_RGB,
167 [PIX_FMT_YUV422P] = {
173 { 0, 0, 1, 0, 7 }, /* Y */
174 { 1, 0, 1, 0, 7 }, /* U */
175 { 2, 0, 1, 0, 7 }, /* V */
177 .flags = PIX_FMT_PLANAR,
179 [PIX_FMT_YUV444P] = {
185 { 0, 0, 1, 0, 7 }, /* Y */
186 { 1, 0, 1, 0, 7 }, /* U */
187 { 2, 0, 1, 0, 7 }, /* V */
189 .flags = PIX_FMT_PLANAR,
191 [PIX_FMT_YUV410P] = {
197 { 0, 0, 1, 0, 7 }, /* Y */
198 { 1, 0, 1, 0, 7 }, /* U */
199 { 2, 0, 1, 0, 7 }, /* V */
201 .flags = PIX_FMT_PLANAR,
203 [PIX_FMT_YUV411P] = {
209 { 0, 0, 1, 0, 7 }, /* Y */
210 { 1, 0, 1, 0, 7 }, /* U */
211 { 2, 0, 1, 0, 7 }, /* V */
213 .flags = PIX_FMT_PLANAR,
221 { 0, 0, 1, 0, 7 }, /* Y */
224 [PIX_FMT_MONOWHITE] = {
230 { 0, 0, 1, 0, 0 }, /* Y */
232 .flags = PIX_FMT_BITSTREAM,
234 [PIX_FMT_MONOBLACK] = {
240 { 0, 0, 1, 7, 0 }, /* Y */
242 .flags = PIX_FMT_BITSTREAM,
252 .flags = PIX_FMT_PAL,
254 [PIX_FMT_YUVJ420P] = {
260 { 0, 0, 1, 0, 7 }, /* Y */
261 { 1, 0, 1, 0, 7 }, /* U */
262 { 2, 0, 1, 0, 7 }, /* V */
264 .flags = PIX_FMT_PLANAR,
266 [PIX_FMT_YUVJ422P] = {
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 [PIX_FMT_YUVJ444P] = {
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 [PIX_FMT_XVMC_MPEG2_MC] = {
292 .flags = PIX_FMT_HWACCEL,
294 [PIX_FMT_XVMC_MPEG2_IDCT] = {
296 .flags = PIX_FMT_HWACCEL,
298 [PIX_FMT_UYVY422] = {
304 { 0, 1, 2, 0, 7 }, /* Y */
305 { 0, 3, 1, 0, 7 }, /* U */
306 { 0, 3, 3, 0, 7 }, /* V */
309 [PIX_FMT_UYYVYY411] = {
315 { 0, 3, 2, 0, 7 }, /* Y */
316 { 0, 5, 1, 0, 7 }, /* U */
317 { 0, 5, 4, 0, 7 }, /* V */
326 { 0, 0, 1, 6, 1 }, /* B */
327 { 0, 0, 1, 3, 2 }, /* G */
328 { 0, 0, 1, 0, 2 }, /* R */
330 .flags = PIX_FMT_PAL | PIX_FMT_RGB,
338 { 0, 3, 1, 0, 0 }, /* B */
339 { 0, 3, 2, 0, 1 }, /* G */
340 { 0, 3, 4, 0, 0 }, /* R */
342 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
344 [PIX_FMT_BGR4_BYTE] = {
350 { 0, 0, 1, 3, 0 }, /* B */
351 { 0, 0, 1, 1, 1 }, /* G */
352 { 0, 0, 1, 0, 0 }, /* R */
354 .flags = PIX_FMT_PAL | PIX_FMT_RGB,
362 { 0, 0, 1, 6, 1 }, /* R */
363 { 0, 0, 1, 3, 2 }, /* G */
364 { 0, 0, 1, 0, 2 }, /* B */
366 .flags = PIX_FMT_PAL | PIX_FMT_RGB,
374 { 0, 3, 1, 0, 0 }, /* R */
375 { 0, 3, 2, 0, 1 }, /* G */
376 { 0, 3, 4, 0, 0 }, /* B */
378 .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
380 [PIX_FMT_RGB4_BYTE] = {
386 { 0, 0, 1, 3, 0 }, /* R */
387 { 0, 0, 1, 1, 1 }, /* G */
388 { 0, 0, 1, 0, 0 }, /* B */
390 .flags = PIX_FMT_PAL | PIX_FMT_RGB,
398 { 0,0,1,0,7 }, /* Y */
399 { 1,1,1,0,7 }, /* U */
400 { 1,1,2,0,7 }, /* V */
402 .flags = PIX_FMT_PLANAR,
410 { 0, 0, 1, 0, 7 }, /* Y */
411 { 1, 1, 1, 0, 7 }, /* V */
412 { 1, 1, 2, 0, 7 }, /* U */
414 .flags = PIX_FMT_PLANAR,
422 { 0, 3, 1, 0, 7 }, /* A */
423 { 0, 3, 2, 0, 7 }, /* R */
424 { 0, 3, 3, 0, 7 }, /* G */
425 { 0, 3, 4, 0, 7 }, /* B */
427 .flags = PIX_FMT_RGB,
435 { 0, 3, 1, 0, 7 }, /* R */
436 { 0, 3, 2, 0, 7 }, /* G */
437 { 0, 3, 3, 0, 7 }, /* B */
438 { 0, 3, 4, 0, 7 }, /* A */
440 .flags = PIX_FMT_RGB,
448 { 0, 3, 1, 0, 7 }, /* A */
449 { 0, 3, 2, 0, 7 }, /* B */
450 { 0, 3, 3, 0, 7 }, /* G */
451 { 0, 3, 4, 0, 7 }, /* R */
453 .flags = PIX_FMT_RGB,
461 { 0, 3, 1, 0, 7 }, /* B */
462 { 0, 3, 2, 0, 7 }, /* G */
463 { 0, 3, 3, 0, 7 }, /* R */
464 { 0, 3, 4, 0, 7 }, /* A */
466 .flags = PIX_FMT_RGB,
478 .flags = PIX_FMT_RGB,
491 .flags = PIX_FMT_RGB,
503 .flags = PIX_FMT_RGB,
516 .flags = PIX_FMT_RGB,
518 [PIX_FMT_GRAY16BE] = {
524 { 0, 1, 1, 0, 15 }, /* Y */
528 [PIX_FMT_GRAY16LE] = {
534 { 0, 1, 1, 0, 15 }, /* Y */
537 [PIX_FMT_YUV440P] = {
543 { 0, 0, 1, 0, 7 }, /* Y */
544 { 1, 0, 1, 0, 7 }, /* U */
545 { 2, 0, 1, 0, 7 }, /* V */
547 .flags = PIX_FMT_PLANAR,
549 [PIX_FMT_YUVJ440P] = {
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 [PIX_FMT_YUVA420P] = {
567 { 0, 0, 1, 0, 7 }, /* Y */
568 { 1, 0, 1, 0, 7 }, /* U */
569 { 2, 0, 1, 0, 7 }, /* V */
570 { 3, 0, 1, 0, 7 }, /* A */
572 .flags = PIX_FMT_PLANAR,
574 [PIX_FMT_VDPAU_H264] = {
575 .name = "vdpau_h264",
578 .flags = PIX_FMT_HWACCEL,
580 [PIX_FMT_VDPAU_MPEG1] = {
581 .name = "vdpau_mpeg1",
584 .flags = PIX_FMT_HWACCEL,
586 [PIX_FMT_VDPAU_MPEG2] = {
587 .name = "vdpau_mpeg2",
590 .flags = PIX_FMT_HWACCEL,
592 [PIX_FMT_VDPAU_WMV3] = {
593 .name = "vdpau_wmv3",
596 .flags = PIX_FMT_HWACCEL,
598 [PIX_FMT_VDPAU_VC1] = {
602 .flags = PIX_FMT_HWACCEL,
604 [PIX_FMT_VDPAU_MPEG4] = {
605 .name = "vdpau_mpeg4",
608 .flags = PIX_FMT_HWACCEL,
610 [PIX_FMT_RGB48BE] = {
616 { 0, 5, 1, 0, 15 }, /* R */
617 { 0, 5, 3, 0, 15 }, /* G */
618 { 0, 5, 5, 0, 15 }, /* B */
620 .flags = PIX_FMT_RGB | PIX_FMT_BE,
622 [PIX_FMT_RGB48LE] = {
628 { 0, 5, 1, 0, 15 }, /* R */
629 { 0, 5, 3, 0, 15 }, /* G */
630 { 0, 5, 5, 0, 15 }, /* B */
632 .flags = PIX_FMT_RGB,
634 [PIX_FMT_RGBA64BE] = {
640 {0,7,1,0,15}, /* R */
641 {0,7,3,0,15}, /* G */
642 {0,7,5,0,15}, /* B */
643 {0,7,7,0,15}, /* A */
645 .flags = PIX_FMT_RGB | PIX_FMT_BE,
647 [PIX_FMT_RGBA64LE] = {
653 {0,7,1,0,15}, /* R */
654 {0,7,3,0,15}, /* G */
655 {0,7,5,0,15}, /* B */
656 {0,7,7,0,15}, /* B */
658 .flags = PIX_FMT_RGB,
660 [PIX_FMT_RGB565BE] = {
666 { 0, 1, 0, 3, 4 }, /* R */
667 { 0, 1, 1, 5, 5 }, /* G */
668 { 0, 1, 1, 0, 4 }, /* B */
670 .flags = PIX_FMT_BE | PIX_FMT_RGB,
672 [PIX_FMT_RGB565LE] = {
678 { 0, 1, 2, 3, 4 }, /* R */
679 { 0, 1, 1, 5, 5 }, /* G */
680 { 0, 1, 1, 0, 4 }, /* B */
682 .flags = PIX_FMT_RGB,
684 [PIX_FMT_RGB555BE] = {
690 { 0, 1, 0, 2, 4 }, /* R */
691 { 0, 1, 1, 5, 4 }, /* G */
692 { 0, 1, 1, 0, 4 }, /* B */
694 .flags = PIX_FMT_BE | PIX_FMT_RGB,
696 [PIX_FMT_RGB555LE] = {
702 { 0, 1, 2, 2, 4 }, /* R */
703 { 0, 1, 1, 5, 4 }, /* G */
704 { 0, 1, 1, 0, 4 }, /* B */
706 .flags = PIX_FMT_RGB,
708 [PIX_FMT_RGB444BE] = {
714 { 0, 1, 0, 0, 3 }, /* R */
715 { 0, 1, 1, 4, 3 }, /* G */
716 { 0, 1, 1, 0, 3 }, /* B */
718 .flags = PIX_FMT_BE | PIX_FMT_RGB,
720 [PIX_FMT_RGB444LE] = {
726 { 0, 1, 2, 0, 3 }, /* R */
727 { 0, 1, 1, 4, 3 }, /* G */
728 { 0, 1, 1, 0, 3 }, /* B */
730 .flags = PIX_FMT_RGB,
732 [PIX_FMT_BGR48BE] = {
738 { 0, 5, 1, 0, 15 }, /* B */
739 { 0, 5, 3, 0, 15 }, /* G */
740 { 0, 5, 5, 0, 15 }, /* R */
742 .flags = PIX_FMT_BE | PIX_FMT_RGB,
744 [PIX_FMT_BGR48LE] = {
750 { 0, 5, 1, 0, 15 }, /* B */
751 { 0, 5, 3, 0, 15 }, /* G */
752 { 0, 5, 5, 0, 15 }, /* R */
754 .flags = PIX_FMT_RGB,
756 [PIX_FMT_BGRA64BE] = {
762 {0,7,1,0,15}, /* B */
763 {0,7,3,0,15}, /* G */
764 {0,7,5,0,15}, /* R */
765 {0,7,7,0,15}, /* A */
769 [PIX_FMT_BGRA64LE] = {
775 {0,7,1,0,15}, /* B */
776 {0,7,3,0,15}, /* G */
777 {0,7,5,0,15}, /* R */
778 {0,7,7,0,15}, /* A */
781 [PIX_FMT_BGR565BE] = {
787 { 0, 1, 0, 3, 4 }, /* B */
788 { 0, 1, 1, 5, 5 }, /* G */
789 { 0, 1, 1, 0, 4 }, /* R */
791 .flags = PIX_FMT_BE | PIX_FMT_RGB,
793 [PIX_FMT_BGR565LE] = {
799 { 0, 1, 2, 3, 4 }, /* B */
800 { 0, 1, 1, 5, 5 }, /* G */
801 { 0, 1, 1, 0, 4 }, /* R */
803 .flags = PIX_FMT_RGB,
805 [PIX_FMT_BGR555BE] = {
811 { 0, 1, 0, 2, 4 }, /* B */
812 { 0, 1, 1, 5, 4 }, /* G */
813 { 0, 1, 1, 0, 4 }, /* R */
815 .flags = PIX_FMT_BE | PIX_FMT_RGB,
817 [PIX_FMT_BGR555LE] = {
823 { 0, 1, 2, 2, 4 }, /* B */
824 { 0, 1, 1, 5, 4 }, /* G */
825 { 0, 1, 1, 0, 4 }, /* R */
827 .flags = PIX_FMT_RGB,
829 [PIX_FMT_BGR444BE] = {
835 { 0, 1, 0, 0, 3 }, /* B */
836 { 0, 1, 1, 4, 3 }, /* G */
837 { 0, 1, 1, 0, 3 }, /* R */
839 .flags = PIX_FMT_BE | PIX_FMT_RGB,
841 [PIX_FMT_BGR444LE] = {
847 { 0, 1, 2, 0, 3 }, /* B */
848 { 0, 1, 1, 4, 3 }, /* G */
849 { 0, 1, 1, 0, 3 }, /* R */
851 .flags = PIX_FMT_RGB,
853 [PIX_FMT_VAAPI_MOCO] = {
854 .name = "vaapi_moco",
857 .flags = PIX_FMT_HWACCEL,
859 [PIX_FMT_VAAPI_IDCT] = {
860 .name = "vaapi_idct",
863 .flags = PIX_FMT_HWACCEL,
865 [PIX_FMT_VAAPI_VLD] = {
869 .flags = PIX_FMT_HWACCEL,
871 [PIX_FMT_VDA_VLD] = {
875 .flags = PIX_FMT_HWACCEL,
877 [PIX_FMT_YUV420P9LE] = {
878 .name = "yuv420p9le",
883 { 0, 1, 1, 0, 8 }, /* Y */
884 { 1, 1, 1, 0, 8 }, /* U */
885 { 2, 1, 1, 0, 8 }, /* V */
887 .flags = PIX_FMT_PLANAR,
889 [PIX_FMT_YUV420P9BE] = {
890 .name = "yuv420p9be",
895 { 0, 1, 1, 0, 8 }, /* Y */
896 { 1, 1, 1, 0, 8 }, /* U */
897 { 2, 1, 1, 0, 8 }, /* V */
899 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
901 [PIX_FMT_YUV420P10LE] = {
902 .name = "yuv420p10le",
907 { 0, 1, 1, 0, 9 }, /* Y */
908 { 1, 1, 1, 0, 9 }, /* U */
909 { 2, 1, 1, 0, 9 }, /* V */
911 .flags = PIX_FMT_PLANAR,
913 [PIX_FMT_YUV420P10BE] = {
914 .name = "yuv420p10be",
919 { 0, 1, 1, 0, 9 }, /* Y */
920 { 1, 1, 1, 0, 9 }, /* U */
921 { 2, 1, 1, 0, 9 }, /* V */
923 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
925 [PIX_FMT_YUV420P16LE] = {
926 .name = "yuv420p16le",
931 { 0, 1, 1, 0, 15 }, /* Y */
932 { 1, 1, 1, 0, 15 }, /* U */
933 { 2, 1, 1, 0, 15 }, /* V */
935 .flags = PIX_FMT_PLANAR,
937 [PIX_FMT_YUV420P16BE] = {
938 .name = "yuv420p16be",
943 { 0, 1, 1, 0, 15 }, /* Y */
944 { 1, 1, 1, 0, 15 }, /* U */
945 { 2, 1, 1, 0, 15 }, /* V */
947 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
949 [PIX_FMT_YUV422P9LE] = {
950 .name = "yuv422p9le",
955 { 0, 1, 1, 0, 8 }, /* Y */
956 { 1, 1, 1, 0, 8 }, /* U */
957 { 2, 1, 1, 0, 8 }, /* V */
959 .flags = PIX_FMT_PLANAR,
961 [PIX_FMT_YUV422P9BE] = {
962 .name = "yuv422p9be",
971 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
973 [PIX_FMT_YUV422P10LE] = {
974 .name = "yuv422p10le",
979 { 0, 1, 1, 0, 9 }, /* Y */
980 { 1, 1, 1, 0, 9 }, /* U */
981 { 2, 1, 1, 0, 9 }, /* V */
983 .flags = PIX_FMT_PLANAR,
985 [PIX_FMT_YUV422P10BE] = {
986 .name = "yuv422p10be",
991 { 0, 1, 1, 0, 9 }, /* Y */
992 { 1, 1, 1, 0, 9 }, /* U */
993 { 2, 1, 1, 0, 9 }, /* V */
995 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
997 [PIX_FMT_YUV422P16LE] = {
998 .name = "yuv422p16le",
1003 { 0, 1, 1, 0, 15 }, /* Y */
1004 { 1, 1, 1, 0, 15 }, /* U */
1005 { 2, 1, 1, 0, 15 }, /* V */
1007 .flags = PIX_FMT_PLANAR,
1009 [PIX_FMT_YUV422P16BE] = {
1010 .name = "yuv422p16be",
1015 { 0, 1, 1, 0, 15 }, /* Y */
1016 { 1, 1, 1, 0, 15 }, /* U */
1017 { 2, 1, 1, 0, 15 }, /* V */
1019 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1021 [PIX_FMT_YUV444P16LE] = {
1022 .name = "yuv444p16le",
1027 { 0, 1, 1, 0, 15 }, /* Y */
1028 { 1, 1, 1, 0, 15 }, /* U */
1029 { 2, 1, 1, 0, 15 }, /* V */
1031 .flags = PIX_FMT_PLANAR,
1033 [PIX_FMT_YUV444P16BE] = {
1034 .name = "yuv444p16be",
1039 { 0, 1, 1, 0, 15 }, /* Y */
1040 { 1, 1, 1, 0, 15 }, /* U */
1041 { 2, 1, 1, 0, 15 }, /* V */
1043 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1045 [PIX_FMT_YUV444P10LE] = {
1046 .name = "yuv444p10le",
1051 { 0, 1, 1, 0, 9 }, /* Y */
1052 { 1, 1, 1, 0, 9 }, /* U */
1053 { 2, 1, 1, 0, 9 }, /* V */
1055 .flags = PIX_FMT_PLANAR,
1057 [PIX_FMT_YUV444P10BE] = {
1058 .name = "yuv444p10be",
1063 { 0, 1, 1, 0, 9 }, /* Y */
1064 { 1, 1, 1, 0, 9 }, /* U */
1065 { 2, 1, 1, 0, 9 }, /* V */
1067 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1069 [PIX_FMT_YUV444P9LE] = {
1070 .name = "yuv444p9le",
1075 { 0, 1, 1, 0, 8 }, /* Y */
1076 { 1, 1, 1, 0, 8 }, /* U */
1077 { 2, 1, 1, 0, 8 }, /* V */
1079 .flags = PIX_FMT_PLANAR,
1081 [PIX_FMT_YUV444P9BE] = {
1082 .name = "yuv444p9be",
1087 { 0, 1, 1, 0, 8 }, /* Y */
1088 { 1, 1, 1, 0, 8 }, /* U */
1089 { 2, 1, 1, 0, 8 }, /* V */
1091 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1093 [PIX_FMT_DXVA2_VLD] = {
1094 .name = "dxva2_vld",
1097 .flags = PIX_FMT_HWACCEL,
1099 [PIX_FMT_VDA_VLD] = {
1103 .flags = PIX_FMT_HWACCEL,
1105 [PIX_FMT_GRAY8A] = {
1109 { 0, 1, 1, 0, 7 }, /* Y */
1110 { 0, 1, 2, 0, 7 }, /* A */
1113 [PIX_FMT_GBR24P] = {
1117 {1,0,1,0,7}, /* B */
1118 {0,0,1,0,7}, /* G */
1119 {2,0,1,0,7}, /* R */
1121 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1129 { 0, 0, 1, 0, 7 }, /* G */
1130 { 1, 0, 1, 0, 7 }, /* B */
1131 { 2, 0, 1, 0, 7 }, /* R */
1133 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1135 [PIX_FMT_GBRP9LE] = {
1141 { 0, 1, 1, 0, 8 }, /* G */
1142 { 1, 1, 1, 0, 8 }, /* B */
1143 { 2, 1, 1, 0, 8 }, /* R */
1145 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1147 [PIX_FMT_GBRP9BE] = {
1153 { 0, 1, 1, 0, 8 }, /* G */
1154 { 1, 1, 1, 0, 8 }, /* B */
1155 { 2, 1, 1, 0, 8 }, /* R */
1157 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1159 [PIX_FMT_GBRP10LE] = {
1165 { 0, 1, 1, 0, 9 }, /* G */
1166 { 1, 1, 1, 0, 9 }, /* B */
1167 { 2, 1, 1, 0, 9 }, /* R */
1169 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1171 [PIX_FMT_GBRP10BE] = {
1177 { 0, 1, 1, 0, 9 }, /* G */
1178 { 1, 1, 1, 0, 9 }, /* B */
1179 { 2, 1, 1, 0, 9 }, /* R */
1181 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1183 [PIX_FMT_GBRP16LE] = {
1189 { 0, 1, 1, 0, 15 }, /* G */
1190 { 1, 1, 1, 0, 15 }, /* B */
1191 { 2, 1, 1, 0, 15 }, /* R */
1193 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1195 [PIX_FMT_GBRP16BE] = {
1201 { 0, 1, 1, 0, 15 }, /* G */
1202 { 1, 1, 1, 0, 15 }, /* B */
1203 { 2, 1, 1, 0, 15 }, /* R */
1205 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1209 static enum PixelFormat get_pix_fmt_internal(const char *name)
1211 enum PixelFormat pix_fmt;
1213 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
1214 if (av_pix_fmt_descriptors[pix_fmt].name &&
1215 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1218 return PIX_FMT_NONE;
1221 const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
1223 return (unsigned)pix_fmt < PIX_FMT_NB ?
1224 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1228 # define X_NE(be, le) be
1230 # define X_NE(be, le) le
1233 enum PixelFormat av_get_pix_fmt(const char *name)
1235 enum PixelFormat pix_fmt;
1237 if (!strcmp(name, "rgb32"))
1238 name = X_NE("argb", "bgra");
1239 else if (!strcmp(name, "bgr32"))
1240 name = X_NE("abgr", "rgba");
1242 pix_fmt = get_pix_fmt_internal(name);
1243 if (pix_fmt == PIX_FMT_NONE) {
1246 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1247 pix_fmt = get_pix_fmt_internal(name2);
1252 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1255 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1257 for (c = 0; c < pixdesc->nb_components; c++) {
1258 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1259 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
1262 return bits >> log2_pixels;
1265 char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
1269 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
1271 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
1272 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1273 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));