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_RGB | PIX_FMT_PSEUDOPAL,
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_RGB | PIX_FMT_PSEUDOPAL,
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_RGB | PIX_FMT_PSEUDOPAL,
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_RGB | PIX_FMT_PSEUDOPAL,
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,
474 { 0, 3, 2, 0, 7 }, /* R */
475 { 0, 3, 3, 0, 7 }, /* G */
476 { 0, 3, 4, 0, 7 }, /* B */
478 .flags = PIX_FMT_RGB,
486 { 0, 3, 1, 0, 7 }, /* R */
487 { 0, 3, 2, 0, 7 }, /* G */
488 { 0, 3, 3, 0, 7 }, /* B */
489 { 0, 3, 4, 0, 7 }, /* A */
491 .flags = PIX_FMT_RGB,
499 { 0, 3, 2, 0, 7 }, /* B */
500 { 0, 3, 3, 0, 7 }, /* G */
501 { 0, 3, 4, 0, 7 }, /* R */
503 .flags = PIX_FMT_RGB,
511 { 0, 3, 1, 0, 7 }, /* B */
512 { 0, 3, 2, 0, 7 }, /* G */
513 { 0, 3, 3, 0, 7 }, /* R */
514 { 0, 3, 4, 0, 7 }, /* A */
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_YUVA444P] = {
580 { 0, 0, 1, 0, 7 }, /* Y */
581 { 1, 0, 1, 0, 7 }, /* U */
582 { 2, 0, 1, 0, 7 }, /* V */
583 { 3, 0, 1, 0, 7 }, /* A */
585 .flags = PIX_FMT_PLANAR,
587 [PIX_FMT_VDPAU_H264] = {
588 .name = "vdpau_h264",
591 .flags = PIX_FMT_HWACCEL,
593 [PIX_FMT_VDPAU_MPEG1] = {
594 .name = "vdpau_mpeg1",
597 .flags = PIX_FMT_HWACCEL,
599 [PIX_FMT_VDPAU_MPEG2] = {
600 .name = "vdpau_mpeg2",
603 .flags = PIX_FMT_HWACCEL,
605 [PIX_FMT_VDPAU_WMV3] = {
606 .name = "vdpau_wmv3",
609 .flags = PIX_FMT_HWACCEL,
611 [PIX_FMT_VDPAU_VC1] = {
615 .flags = PIX_FMT_HWACCEL,
617 [PIX_FMT_VDPAU_MPEG4] = {
618 .name = "vdpau_mpeg4",
621 .flags = PIX_FMT_HWACCEL,
623 [PIX_FMT_RGB48BE] = {
629 { 0, 5, 1, 0, 15 }, /* R */
630 { 0, 5, 3, 0, 15 }, /* G */
631 { 0, 5, 5, 0, 15 }, /* B */
633 .flags = PIX_FMT_RGB | PIX_FMT_BE,
635 [PIX_FMT_RGB48LE] = {
641 { 0, 5, 1, 0, 15 }, /* R */
642 { 0, 5, 3, 0, 15 }, /* G */
643 { 0, 5, 5, 0, 15 }, /* B */
645 .flags = PIX_FMT_RGB,
647 [PIX_FMT_RGBA64BE] = {
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 }, /* A */
658 .flags = PIX_FMT_RGB | PIX_FMT_BE,
660 [PIX_FMT_RGBA64LE] = {
666 { 0, 7, 1, 0, 15 }, /* R */
667 { 0, 7, 3, 0, 15 }, /* G */
668 { 0, 7, 5, 0, 15 }, /* B */
669 { 0, 7, 7, 0, 15 }, /* B */
671 .flags = PIX_FMT_RGB,
673 [PIX_FMT_RGB565BE] = {
679 { 0, 1, 0, 3, 4 }, /* R */
680 { 0, 1, 1, 5, 5 }, /* G */
681 { 0, 1, 1, 0, 4 }, /* B */
683 .flags = PIX_FMT_BE | PIX_FMT_RGB,
685 [PIX_FMT_RGB565LE] = {
691 { 0, 1, 2, 3, 4 }, /* R */
692 { 0, 1, 1, 5, 5 }, /* G */
693 { 0, 1, 1, 0, 4 }, /* B */
695 .flags = PIX_FMT_RGB,
697 [PIX_FMT_RGB555BE] = {
703 { 0, 1, 0, 2, 4 }, /* R */
704 { 0, 1, 1, 5, 4 }, /* G */
705 { 0, 1, 1, 0, 4 }, /* B */
707 .flags = PIX_FMT_BE | PIX_FMT_RGB,
709 [PIX_FMT_RGB555LE] = {
715 { 0, 1, 2, 2, 4 }, /* R */
716 { 0, 1, 1, 5, 4 }, /* G */
717 { 0, 1, 1, 0, 4 }, /* B */
719 .flags = PIX_FMT_RGB,
721 [PIX_FMT_RGB444BE] = {
727 { 0, 1, 0, 0, 3 }, /* R */
728 { 0, 1, 1, 4, 3 }, /* G */
729 { 0, 1, 1, 0, 3 }, /* B */
731 .flags = PIX_FMT_BE | PIX_FMT_RGB,
733 [PIX_FMT_RGB444LE] = {
739 { 0, 1, 2, 0, 3 }, /* R */
740 { 0, 1, 1, 4, 3 }, /* G */
741 { 0, 1, 1, 0, 3 }, /* B */
743 .flags = PIX_FMT_RGB,
745 [PIX_FMT_BGR48BE] = {
751 { 0, 5, 1, 0, 15 }, /* B */
752 { 0, 5, 3, 0, 15 }, /* G */
753 { 0, 5, 5, 0, 15 }, /* R */
755 .flags = PIX_FMT_BE | PIX_FMT_RGB,
757 [PIX_FMT_BGR48LE] = {
763 { 0, 5, 1, 0, 15 }, /* B */
764 { 0, 5, 3, 0, 15 }, /* G */
765 { 0, 5, 5, 0, 15 }, /* R */
767 .flags = PIX_FMT_RGB,
769 [PIX_FMT_BGRA64BE] = {
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 */
782 [PIX_FMT_BGRA64LE] = {
788 { 0, 7, 1, 0, 15 }, /* B */
789 { 0, 7, 3, 0, 15 }, /* G */
790 { 0, 7, 5, 0, 15 }, /* R */
791 { 0, 7, 7, 0, 15 }, /* A */
794 [PIX_FMT_BGR565BE] = {
800 { 0, 1, 0, 3, 4 }, /* B */
801 { 0, 1, 1, 5, 5 }, /* G */
802 { 0, 1, 1, 0, 4 }, /* R */
804 .flags = PIX_FMT_BE | PIX_FMT_RGB,
806 [PIX_FMT_BGR565LE] = {
812 { 0, 1, 2, 3, 4 }, /* B */
813 { 0, 1, 1, 5, 5 }, /* G */
814 { 0, 1, 1, 0, 4 }, /* R */
816 .flags = PIX_FMT_RGB,
818 [PIX_FMT_BGR555BE] = {
824 { 0, 1, 0, 2, 4 }, /* B */
825 { 0, 1, 1, 5, 4 }, /* G */
826 { 0, 1, 1, 0, 4 }, /* R */
828 .flags = PIX_FMT_BE | PIX_FMT_RGB,
830 [PIX_FMT_BGR555LE] = {
836 { 0, 1, 2, 2, 4 }, /* B */
837 { 0, 1, 1, 5, 4 }, /* G */
838 { 0, 1, 1, 0, 4 }, /* R */
840 .flags = PIX_FMT_RGB,
842 [PIX_FMT_BGR444BE] = {
848 { 0, 1, 0, 0, 3 }, /* B */
849 { 0, 1, 1, 4, 3 }, /* G */
850 { 0, 1, 1, 0, 3 }, /* R */
852 .flags = PIX_FMT_BE | PIX_FMT_RGB,
854 [PIX_FMT_BGR444LE] = {
860 { 0, 1, 2, 0, 3 }, /* B */
861 { 0, 1, 1, 4, 3 }, /* G */
862 { 0, 1, 1, 0, 3 }, /* R */
864 .flags = PIX_FMT_RGB,
866 [PIX_FMT_VAAPI_MOCO] = {
867 .name = "vaapi_moco",
870 .flags = PIX_FMT_HWACCEL,
872 [PIX_FMT_VAAPI_IDCT] = {
873 .name = "vaapi_idct",
876 .flags = PIX_FMT_HWACCEL,
878 [PIX_FMT_VAAPI_VLD] = {
882 .flags = PIX_FMT_HWACCEL,
884 [PIX_FMT_YUV420P9LE] = {
885 .name = "yuv420p9le",
890 { 0, 1, 1, 0, 8 }, /* Y */
891 { 1, 1, 1, 0, 8 }, /* U */
892 { 2, 1, 1, 0, 8 }, /* V */
894 .flags = PIX_FMT_PLANAR,
896 [PIX_FMT_YUV420P9BE] = {
897 .name = "yuv420p9be",
902 { 0, 1, 1, 0, 8 }, /* Y */
903 { 1, 1, 1, 0, 8 }, /* U */
904 { 2, 1, 1, 0, 8 }, /* V */
906 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
908 [PIX_FMT_YUV420P10LE] = {
909 .name = "yuv420p10le",
914 { 0, 1, 1, 0, 9 }, /* Y */
915 { 1, 1, 1, 0, 9 }, /* U */
916 { 2, 1, 1, 0, 9 }, /* V */
918 .flags = PIX_FMT_PLANAR,
920 [PIX_FMT_YUV420P10BE] = {
921 .name = "yuv420p10be",
926 { 0, 1, 1, 0, 9 }, /* Y */
927 { 1, 1, 1, 0, 9 }, /* U */
928 { 2, 1, 1, 0, 9 }, /* V */
930 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
932 [PIX_FMT_YUV420P16LE] = {
933 .name = "yuv420p16le",
938 { 0, 1, 1, 0, 15 }, /* Y */
939 { 1, 1, 1, 0, 15 }, /* U */
940 { 2, 1, 1, 0, 15 }, /* V */
942 .flags = PIX_FMT_PLANAR,
944 [PIX_FMT_YUV420P16BE] = {
945 .name = "yuv420p16be",
950 { 0, 1, 1, 0, 15 }, /* Y */
951 { 1, 1, 1, 0, 15 }, /* U */
952 { 2, 1, 1, 0, 15 }, /* V */
954 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
956 [PIX_FMT_YUV422P9LE] = {
957 .name = "yuv422p9le",
962 { 0, 1, 1, 0, 8 }, /* Y */
963 { 1, 1, 1, 0, 8 }, /* U */
964 { 2, 1, 1, 0, 8 }, /* V */
966 .flags = PIX_FMT_PLANAR,
968 [PIX_FMT_YUV422P9BE] = {
969 .name = "yuv422p9be",
974 { 0, 1, 1, 0, 8 }, /* Y */
975 { 1, 1, 1, 0, 8 }, /* U */
976 { 2, 1, 1, 0, 8 }, /* V */
978 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
980 [PIX_FMT_YUV422P10LE] = {
981 .name = "yuv422p10le",
986 { 0, 1, 1, 0, 9 }, /* Y */
987 { 1, 1, 1, 0, 9 }, /* U */
988 { 2, 1, 1, 0, 9 }, /* V */
990 .flags = PIX_FMT_PLANAR,
992 [PIX_FMT_YUV422P10BE] = {
993 .name = "yuv422p10be",
998 { 0, 1, 1, 0, 9 }, /* Y */
999 { 1, 1, 1, 0, 9 }, /* U */
1000 { 2, 1, 1, 0, 9 }, /* V */
1002 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1004 [PIX_FMT_YUV422P16LE] = {
1005 .name = "yuv422p16le",
1010 { 0, 1, 1, 0, 15 }, /* Y */
1011 { 1, 1, 1, 0, 15 }, /* U */
1012 { 2, 1, 1, 0, 15 }, /* V */
1014 .flags = PIX_FMT_PLANAR,
1016 [PIX_FMT_YUV422P16BE] = {
1017 .name = "yuv422p16be",
1022 { 0, 1, 1, 0, 15 }, /* Y */
1023 { 1, 1, 1, 0, 15 }, /* U */
1024 { 2, 1, 1, 0, 15 }, /* V */
1026 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1028 [PIX_FMT_YUV444P16LE] = {
1029 .name = "yuv444p16le",
1034 { 0, 1, 1, 0, 15 }, /* Y */
1035 { 1, 1, 1, 0, 15 }, /* U */
1036 { 2, 1, 1, 0, 15 }, /* V */
1038 .flags = PIX_FMT_PLANAR,
1040 [PIX_FMT_YUV444P16BE] = {
1041 .name = "yuv444p16be",
1046 { 0, 1, 1, 0, 15 }, /* Y */
1047 { 1, 1, 1, 0, 15 }, /* U */
1048 { 2, 1, 1, 0, 15 }, /* V */
1050 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1052 [PIX_FMT_YUV444P10LE] = {
1053 .name = "yuv444p10le",
1058 { 0, 1, 1, 0, 9 }, /* Y */
1059 { 1, 1, 1, 0, 9 }, /* U */
1060 { 2, 1, 1, 0, 9 }, /* V */
1062 .flags = PIX_FMT_PLANAR,
1064 [PIX_FMT_YUV444P10BE] = {
1065 .name = "yuv444p10be",
1070 { 0, 1, 1, 0, 9 }, /* Y */
1071 { 1, 1, 1, 0, 9 }, /* U */
1072 { 2, 1, 1, 0, 9 }, /* V */
1074 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1076 [PIX_FMT_YUV444P9LE] = {
1077 .name = "yuv444p9le",
1082 { 0, 1, 1, 0, 8 }, /* Y */
1083 { 1, 1, 1, 0, 8 }, /* U */
1084 { 2, 1, 1, 0, 8 }, /* V */
1086 .flags = PIX_FMT_PLANAR,
1088 [PIX_FMT_YUV444P9BE] = {
1089 .name = "yuv444p9be",
1094 { 0, 1, 1, 0, 8 }, /* Y */
1095 { 1, 1, 1, 0, 8 }, /* U */
1096 { 2, 1, 1, 0, 8 }, /* V */
1098 .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
1100 [PIX_FMT_DXVA2_VLD] = {
1101 .name = "dxva2_vld",
1104 .flags = PIX_FMT_HWACCEL,
1106 [PIX_FMT_VDA_VLD] = {
1110 .flags = PIX_FMT_HWACCEL,
1112 [PIX_FMT_GRAY8A] = {
1116 { 0, 1, 1, 0, 7 }, /* Y */
1117 { 0, 1, 2, 0, 7 }, /* A */
1126 { 0, 0, 1, 0, 7 }, /* G */
1127 { 1, 0, 1, 0, 7 }, /* B */
1128 { 2, 0, 1, 0, 7 }, /* R */
1130 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1132 [PIX_FMT_GBRP9LE] = {
1138 { 0, 1, 1, 0, 8 }, /* G */
1139 { 1, 1, 1, 0, 8 }, /* B */
1140 { 2, 1, 1, 0, 8 }, /* R */
1142 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1144 [PIX_FMT_GBRP9BE] = {
1150 { 0, 1, 1, 0, 8 }, /* G */
1151 { 1, 1, 1, 0, 8 }, /* B */
1152 { 2, 1, 1, 0, 8 }, /* R */
1154 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1156 [PIX_FMT_GBRP10LE] = {
1162 { 0, 1, 1, 0, 9 }, /* G */
1163 { 1, 1, 1, 0, 9 }, /* B */
1164 { 2, 1, 1, 0, 9 }, /* R */
1166 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1168 [PIX_FMT_GBRP10BE] = {
1174 { 0, 1, 1, 0, 9 }, /* G */
1175 { 1, 1, 1, 0, 9 }, /* B */
1176 { 2, 1, 1, 0, 9 }, /* R */
1178 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1180 [PIX_FMT_GBRP16LE] = {
1186 { 0, 1, 1, 0, 15 }, /* G */
1187 { 1, 1, 1, 0, 15 }, /* B */
1188 { 2, 1, 1, 0, 15 }, /* R */
1190 .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
1192 [PIX_FMT_GBRP16BE] = {
1198 { 0, 1, 1, 0, 15 }, /* G */
1199 { 1, 1, 1, 0, 15 }, /* B */
1200 { 2, 1, 1, 0, 15 }, /* R */
1202 .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
1206 static enum PixelFormat get_pix_fmt_internal(const char *name)
1208 enum PixelFormat pix_fmt;
1210 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
1211 if (av_pix_fmt_descriptors[pix_fmt].name &&
1212 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
1215 return PIX_FMT_NONE;
1218 const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
1220 return (unsigned)pix_fmt < PIX_FMT_NB ?
1221 av_pix_fmt_descriptors[pix_fmt].name : NULL;
1225 # define X_NE(be, le) be
1227 # define X_NE(be, le) le
1230 enum PixelFormat av_get_pix_fmt(const char *name)
1232 enum PixelFormat pix_fmt;
1234 if (!strcmp(name, "rgb32"))
1235 name = X_NE("argb", "bgra");
1236 else if (!strcmp(name, "bgr32"))
1237 name = X_NE("abgr", "rgba");
1239 pix_fmt = get_pix_fmt_internal(name);
1240 if (pix_fmt == PIX_FMT_NONE) {
1243 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
1244 pix_fmt = get_pix_fmt_internal(name2);
1249 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
1252 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
1254 for (c = 0; c < pixdesc->nb_components; c++) {
1255 int s = c == 1 || c == 2 ? 0 : log2_pixels;
1256 bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
1259 return bits >> log2_pixels;
1262 char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
1266 snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
1268 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
1269 snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
1270 pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));