rawvideo: Support decoding YVYU422 FourCC
[libav.git] / libavcodec / raw.c
CommitLineData
e8750b00
FR
1/*
2 * Raw Video Codec
406792e7 3 * Copyright (c) 2001 Fabrice Bellard
e8750b00 4 *
2912e87a 5 * This file is part of Libav.
b78e7197 6 *
2912e87a 7 * Libav is free software; you can redistribute it and/or
e8750b00
FR
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
b78e7197 10 * version 2.1 of the License, or (at your option) any later version.
e8750b00 11 *
2912e87a 12 * Libav is distributed in the hope that it will be useful,
e8750b00
FR
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.
16 *
17 * You should have received a copy of the GNU Lesser General Public
2912e87a 18 * License along with Libav; if not, write to the Free Software
5509bffa 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e8750b00 20 */
115329f1 21
e8750b00 22/**
ba87f080 23 * @file
e8750b00
FR
24 * Raw Video Codec
25 */
115329f1 26
e8750b00 27#include "avcodec.h"
3a763f0f 28#include "raw.h"
1d9c2dc8 29#include "libavutil/common.h"
e8750b00 30
6531b5c9 31const PixelFormatTag ff_raw_pix_fmt_tags[] = {
716d413c
AK
32 { AV_PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
33 { AV_PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') },
34 { AV_PIX_FMT_YUV420P, MKTAG('Y', 'V', '1', '2') },
35 { AV_PIX_FMT_YUV410P, MKTAG('Y', 'U', 'V', '9') },
36 { AV_PIX_FMT_YUV410P, MKTAG('Y', 'V', 'U', '9') },
37 { AV_PIX_FMT_YUV411P, MKTAG('Y', '4', '1', 'B') },
38 { AV_PIX_FMT_YUV422P, MKTAG('Y', '4', '2', 'B') },
39 { AV_PIX_FMT_YUV422P, MKTAG('P', '4', '2', '2') },
40 { AV_PIX_FMT_YUV422P, MKTAG('Y', 'V', '1', '6') },
934edecd
SS
41 /* yuvjXXX formats are deprecated hacks specific to libav*,
42 they are identical to yuvXXX */
716d413c
AK
43 { AV_PIX_FMT_YUVJ420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
44 { AV_PIX_FMT_YUVJ420P, MKTAG('I', 'Y', 'U', 'V') },
45 { AV_PIX_FMT_YUVJ420P, MKTAG('Y', 'V', '1', '2') },
46 { AV_PIX_FMT_YUVJ422P, MKTAG('Y', '4', '2', 'B') },
47 { AV_PIX_FMT_YUVJ422P, MKTAG('P', '4', '2', '2') },
48 { AV_PIX_FMT_GRAY8, MKTAG('Y', '8', '0', '0') },
49 { AV_PIX_FMT_GRAY8, MKTAG('Y', '8', ' ', ' ') },
63167088 50
716d413c
AK
51 { AV_PIX_FMT_YUYV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */
52 { AV_PIX_FMT_YUYV422, MKTAG('Y', '4', '2', '2') },
53 { AV_PIX_FMT_YUYV422, MKTAG('V', '4', '2', '2') },
54 { AV_PIX_FMT_YUYV422, MKTAG('V', 'Y', 'U', 'Y') },
55 { AV_PIX_FMT_YUYV422, MKTAG('Y', 'U', 'N', 'V') },
b6a09ef7 56 { AV_PIX_FMT_YVYU422, MKTAG('Y', 'V', 'Y', 'U') }, /* Philips */
716d413c
AK
57 { AV_PIX_FMT_UYVY422, MKTAG('U', 'Y', 'V', 'Y') },
58 { AV_PIX_FMT_UYVY422, MKTAG('H', 'D', 'Y', 'C') },
59 { AV_PIX_FMT_UYVY422, MKTAG('U', 'Y', 'N', 'V') },
60 { AV_PIX_FMT_UYVY422, MKTAG('U', 'Y', 'N', 'Y') },
61 { AV_PIX_FMT_UYVY422, MKTAG('u', 'y', 'v', '1') },
62 { AV_PIX_FMT_UYVY422, MKTAG('2', 'V', 'u', '1') },
63 { AV_PIX_FMT_UYVY422, MKTAG('A', 'V', 'R', 'n') }, /* Avid AVI Codec 1:1 */
64 { AV_PIX_FMT_UYVY422, MKTAG('A', 'V', '1', 'x') }, /* Avid 1:1x */
65 { AV_PIX_FMT_UYVY422, MKTAG('A', 'V', 'u', 'p') },
66 { AV_PIX_FMT_UYVY422, MKTAG('V', 'D', 'T', 'Z') }, /* SoftLab-NSK VideoTizer */
67 { AV_PIX_FMT_UYVY422, MKTAG('a', 'u', 'v', '2') },
68 { AV_PIX_FMT_UYYVYY411, MKTAG('Y', '4', '1', '1') },
69 { AV_PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') },
70 { AV_PIX_FMT_NV12, MKTAG('N', 'V', '1', '2') },
71 { AV_PIX_FMT_NV21, MKTAG('N', 'V', '2', '1') },
658e7576
SS
72
73 /* nut */
716d413c
AK
74 { AV_PIX_FMT_RGB555LE, MKTAG('R', 'G', 'B', 15) },
75 { AV_PIX_FMT_BGR555LE, MKTAG('B', 'G', 'R', 15) },
76 { AV_PIX_FMT_RGB565LE, MKTAG('R', 'G', 'B', 16) },
77 { AV_PIX_FMT_BGR565LE, MKTAG('B', 'G', 'R', 16) },
78 { AV_PIX_FMT_RGB555BE, MKTAG(15 , 'B', 'G', 'R') },
79 { AV_PIX_FMT_BGR555BE, MKTAG(15 , 'R', 'G', 'B') },
80 { AV_PIX_FMT_RGB565BE, MKTAG(16 , 'B', 'G', 'R') },
81 { AV_PIX_FMT_BGR565BE, MKTAG(16 , 'R', 'G', 'B') },
82 { AV_PIX_FMT_RGB444LE, MKTAG('R', 'G', 'B', 12) },
83 { AV_PIX_FMT_BGR444LE, MKTAG('B', 'G', 'R', 12) },
84 { AV_PIX_FMT_RGB444BE, MKTAG(12 , 'B', 'G', 'R') },
85 { AV_PIX_FMT_BGR444BE, MKTAG(12 , 'R', 'G', 'B') },
86 { AV_PIX_FMT_RGBA, MKTAG('R', 'G', 'B', 'A') },
87 { AV_PIX_FMT_BGRA, MKTAG('B', 'G', 'R', 'A') },
58c21596
CEH
88 { AV_PIX_FMT_RGBA64LE, MKTAG('R', 'B', 'A', 64 ) },
89 { AV_PIX_FMT_BGRA64LE, MKTAG('B', 'R', 'A', 64 ) },
90 { AV_PIX_FMT_RGBA64BE, MKTAG(64 , 'R', 'B', 'A') },
91 { AV_PIX_FMT_BGRA64BE, MKTAG(64 , 'B', 'R', 'A') },
716d413c
AK
92 { AV_PIX_FMT_ABGR, MKTAG('A', 'B', 'G', 'R') },
93 { AV_PIX_FMT_ARGB, MKTAG('A', 'R', 'G', 'B') },
94 { AV_PIX_FMT_RGB24, MKTAG('R', 'G', 'B', 24 ) },
95 { AV_PIX_FMT_BGR24, MKTAG('B', 'G', 'R', 24 ) },
96 { AV_PIX_FMT_YUV411P, MKTAG('4', '1', '1', 'P') },
97 { AV_PIX_FMT_YUV422P, MKTAG('4', '2', '2', 'P') },
98 { AV_PIX_FMT_YUVJ422P, MKTAG('4', '2', '2', 'P') },
99 { AV_PIX_FMT_YUV440P, MKTAG('4', '4', '0', 'P') },
100 { AV_PIX_FMT_YUVJ440P, MKTAG('4', '4', '0', 'P') },
101 { AV_PIX_FMT_YUV444P, MKTAG('4', '4', '4', 'P') },
102 { AV_PIX_FMT_YUVJ444P, MKTAG('4', '4', '4', 'P') },
103 { AV_PIX_FMT_MONOWHITE,MKTAG('B', '1', 'W', '0') },
104 { AV_PIX_FMT_MONOBLACK,MKTAG('B', '0', 'W', '1') },
105 { AV_PIX_FMT_BGR8, MKTAG('B', 'G', 'R', 8 ) },
106 { AV_PIX_FMT_RGB8, MKTAG('R', 'G', 'B', 8 ) },
107 { AV_PIX_FMT_BGR4, MKTAG('B', 'G', 'R', 4 ) },
108 { AV_PIX_FMT_RGB4, MKTAG('R', 'G', 'B', 4 ) },
109 { AV_PIX_FMT_RGB4_BYTE,MKTAG('B', '4', 'B', 'Y') },
110 { AV_PIX_FMT_BGR4_BYTE,MKTAG('R', '4', 'B', 'Y') },
111 { AV_PIX_FMT_RGB48LE, MKTAG('R', 'G', 'B', 48 ) },
112 { AV_PIX_FMT_RGB48BE, MKTAG( 48, 'R', 'G', 'B') },
113 { AV_PIX_FMT_BGR48LE, MKTAG('B', 'G', 'R', 48 ) },
114 { AV_PIX_FMT_BGR48BE, MKTAG( 48, 'B', 'G', 'R') },
115 { AV_PIX_FMT_GRAY16LE, MKTAG('Y', '1', 0 , 16 ) },
116 { AV_PIX_FMT_GRAY16BE, MKTAG(16 , 0 , '1', 'Y') },
117 { AV_PIX_FMT_YUV420P10LE, MKTAG('Y', '3', 11 , 10 ) },
118 { AV_PIX_FMT_YUV420P10BE, MKTAG(10 , 11 , '3', 'Y') },
119 { AV_PIX_FMT_YUV422P10LE, MKTAG('Y', '3', 10 , 10 ) },
120 { AV_PIX_FMT_YUV422P10BE, MKTAG(10 , 10 , '3', 'Y') },
121 { AV_PIX_FMT_YUV444P10LE, MKTAG('Y', '3', 0 , 10 ) },
122 { AV_PIX_FMT_YUV444P10BE, MKTAG(10 , 0 , '3', 'Y') },
123 { AV_PIX_FMT_YUV420P16LE, MKTAG('Y', '3', 11 , 16 ) },
124 { AV_PIX_FMT_YUV420P16BE, MKTAG(16 , 11 , '3', 'Y') },
125 { AV_PIX_FMT_YUV422P16LE, MKTAG('Y', '3', 10 , 16 ) },
126 { AV_PIX_FMT_YUV422P16BE, MKTAG(16 , 10 , '3', 'Y') },
127 { AV_PIX_FMT_YUV444P16LE, MKTAG('Y', '3', 0 , 16 ) },
128 { AV_PIX_FMT_YUV444P16BE, MKTAG(16 , 0 , '3', 'Y') },
129 { AV_PIX_FMT_YUVA420P, MKTAG('Y', '4', 11 , 8 ) },
130 { AV_PIX_FMT_Y400A, MKTAG('Y', '2', 0 , 8 ) },
63167088 131
7658295b
LB
132 { AV_PIX_FMT_YUVA420P9LE, MKTAG('Y', '4', 11 , 9 ) },
133 { AV_PIX_FMT_YUVA420P9BE, MKTAG( 9 , 11 , '4', 'Y') },
134 { AV_PIX_FMT_YUVA422P9LE, MKTAG('Y', '4', 10 , 9 ) },
135 { AV_PIX_FMT_YUVA422P9BE, MKTAG( 9 , 10 , '4', 'Y') },
136 { AV_PIX_FMT_YUVA444P9LE, MKTAG('Y', '4', 0 , 9 ) },
137 { AV_PIX_FMT_YUVA444P9BE, MKTAG( 9 , 0 , '4', 'Y') },
138 { AV_PIX_FMT_YUVA420P10LE, MKTAG('Y', '4', 11 , 10 ) },
139 { AV_PIX_FMT_YUVA420P10BE, MKTAG(10 , 11 , '4', 'Y') },
140 { AV_PIX_FMT_YUVA422P10LE, MKTAG('Y', '4', 10 , 10 ) },
141 { AV_PIX_FMT_YUVA422P10BE, MKTAG(10 , 10 , '4', 'Y') },
142 { AV_PIX_FMT_YUVA444P10LE, MKTAG('Y', '4', 0 , 10 ) },
143 { AV_PIX_FMT_YUVA444P10BE, MKTAG(10 , 0 , '4', 'Y') },
144 { AV_PIX_FMT_YUVA420P16LE, MKTAG('Y', '4', 11 , 16 ) },
145 { AV_PIX_FMT_YUVA420P16BE, MKTAG(16 , 11 , '4', 'Y') },
146 { AV_PIX_FMT_YUVA422P16LE, MKTAG('Y', '4', 10 , 16 ) },
147 { AV_PIX_FMT_YUVA422P16BE, MKTAG(16 , 10 , '4', 'Y') },
148 { AV_PIX_FMT_YUVA444P16LE, MKTAG('Y', '4', 0 , 16 ) },
149 { AV_PIX_FMT_YUVA444P16BE, MKTAG(16 , 0 , '4', 'Y') },
150
ed70a509 151 /* quicktime */
716d413c
AK
152 { AV_PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
153 { AV_PIX_FMT_UYVY422, MKTAG('2', 'V', 'u', 'y') },
154 { AV_PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */
155 { AV_PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', '2') },
156 { AV_PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', 's') },
157 { AV_PIX_FMT_YUYV422, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */
158 { AV_PIX_FMT_RGB555LE,MKTAG('L', '5', '5', '5') },
159 { AV_PIX_FMT_RGB565LE,MKTAG('L', '5', '6', '5') },
160 { AV_PIX_FMT_RGB565BE,MKTAG('B', '5', '6', '5') },
161 { AV_PIX_FMT_BGR24, MKTAG('2', '4', 'B', 'G') },
162 { AV_PIX_FMT_BGRA, MKTAG('B', 'G', 'R', 'A') },
163 { AV_PIX_FMT_RGBA, MKTAG('R', 'G', 'B', 'A') },
164 { AV_PIX_FMT_ABGR, MKTAG('A', 'B', 'G', 'R') },
165 { AV_PIX_FMT_GRAY16BE,MKTAG('b', '1', '6', 'g') },
166 { AV_PIX_FMT_RGB48BE, MKTAG('b', '4', '8', 'r') },
ed70a509 167
658e7576 168 /* special */
716d413c
AK
169 { AV_PIX_FMT_RGB565LE,MKTAG( 3 , 0 , 0 , 0 ) }, /* flipped RGB565LE */
170 { AV_PIX_FMT_YUV444P, MKTAG('Y', 'V', '2', '4') }, /* YUV444P, swapped UV */
658e7576 171
716d413c 172 { AV_PIX_FMT_NONE, 0 },
e8750b00
FR
173};
174
716d413c 175unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
63167088 176{
6531b5c9 177 const PixelFormatTag *tags = ff_raw_pix_fmt_tags;
63167088
RS
178 while (tags->pix_fmt >= 0) {
179 if (tags->pix_fmt == fmt)
bb270c08
DB
180 return tags->fourcc;
181 tags++;
63167088
RS
182 }
183 return 0;
184}