libweed  0.6.0
 All Data Structures Files Functions Variables Typedefs Macros
weed-compat.h
Go to the documentation of this file.
1 /* WEED is free software; you can redistribute it and/or
2  modify it under the terms of the GNU Lesser General Public
3  License as published by the Free Software Foundation; either
4  version 3 of the License, or (at your option) any later version.
5 
6  Weed is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9  Lesser General Public License for more details.
10 
11  You should have received a copy of the GNU Lesser General Public
12  License along with this source code; if not, write to the Free Software
13  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
14 
15 
16  Weed is developed by:
17 
18  Gabriel "Salsaman" Finch - http://lives.sourceforge.net
19 
20  mainly based on LiViDO, which is developed by:
21 
22 
23  Niels Elburg - http://veejay.sf.net
24 
25  Gabriel "Salsaman" Finch - http://lives.sourceforge.net
26 
27  Denis "Jaromil" Rojo - http://freej.dyne.org
28 
29  Tom Schouten - http://zwizwa.fartit.com
30 
31  Andraz Tori - http://cvs.cinelerra.org
32 
33  reviewed with suggestions and contributions from:
34 
35  Silvano "Kysucix" Galliani - http://freej.dyne.org
36 
37  Kentaro Fukuchi - http://megaui.net/fukuchi
38 
39  Jun Iio - http://www.malib.net
40 
41  Carlo Prelz - http://www2.fluido.as:8080/
42 
43 */
44 
45 /* (C) Gabriel "Salsaman" Finch, 2005 - 2012 */
46 
47 #ifndef __WEED_COMPAT_H__
48 #define __WEED_COMPAT_H__
49 
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif /* __cplusplus */
54 
55 
56 #ifdef NEED_FOURCC_COMPAT
57 
58 #ifndef __WEED_PALETTES_H__
59 #include <weed/weed-palettes.h>
60 #endif
61 
62 int fourccp_to_weedp(unsigned int fourcc, int bpp, int *interlaced, int *sampling,
63  int *sspace, int *clamping) {
64  // inputs are fourcc and bpp
65  // returns int weed_palette
66 
67  // optionally sets interlaced (0 = none, 1 = interlaced), sampling, subspace and clamping
68 
69 
70 
71  // TODO - this is probably wrong for some formats and needs testing/verifying with various devices
72  // fourcc colorcodes are a nasty mess, and should be avoided whenever possible
73 
74  // data from http://www.fourcc.org
75 
76  if (clamping!=NULL) *clamping=WEED_YUV_CLAMPING_CLAMPED;
77  if (interlaced!=NULL) *interlaced=0;
78  if (sspace!=NULL) *sspace=WEED_YUV_SUBSPACE_YCBCR;
79  if (sampling!=NULL) *sampling=WEED_YUV_SAMPLING_DEFAULT;
80 
81  switch (fourcc) {
82 
83  // RGB formats
84 
85  case 0x32524742: // BGR3
86  case 0x33524742: // BGR3 - tested and OK
87  case 0x34524742: // BGR4
88  if (bpp==24) return WEED_PALETTE_BGR24;
89  if (bpp==32) return WEED_PALETTE_BGRA32;
90  break;
91 
92  case 0x00000000: // BI_RGB - RGB or BGR ???
93  case 0x32776172: // raw2 - RGB or BGR ???
94 
95  case 0x32424752: // RGB2
96  case 0x33424752: // RGB3
97  case 0x34424752: // RGB4
98  if (bpp==24) return WEED_PALETTE_RGB24;
99  if (bpp==32) return WEED_PALETTE_RGBA32;
100  break;
101  case 0x41424752: // RGBA
102  if (bpp==32) return WEED_PALETTE_RGBA32;
103  break;
104 
105 
106  // YUV packed formats
107 
108  case 0x56595549: // IUYV
109  if (interlaced!=NULL) *interlaced=1;
110  return WEED_PALETTE_UYVY;
111  case 0x31555949: // IYU1
112  case 0x31313459: // Y411
113  return WEED_PALETTE_YUV411;
114  case 0x32555949: // IYU2
115  return WEED_PALETTE_YUV888;
116  case 0x43594448: // HDYC
117  if (sspace!=NULL) *sspace=WEED_YUV_SUBSPACE_BT709;
118  return WEED_PALETTE_UYVY;
119  case 0x564E5955: // UYNV
120  case 0x59565955: // UYVY
121  case 0x32323459: // Y422
122  case 0x76757963: // cyuv - ???
123  return WEED_PALETTE_UYVY;
124  case 0x32595559: // YUY2
125  case 0x56595559: // YUYV - tested and OK
126  case 0x564E5559: // YUNV
127  case 0x31313259: // Y211 - ???
128  return WEED_PALETTE_YUYV;
129  case 0x59455247: // grey
130  if (clamping!=NULL) *clamping=WEED_YUV_CLAMPING_UNCLAMPED;
131  case 0x30303859: // Y800
132  case 0x20203859: // Y8
133  return WEED_PALETTE_A8;
134 
135 
136  // YUV planar formats
137  case 0x41565559: // YUVA
138  return WEED_PALETTE_YUVA4444P;
139  break;
140  case 0x34343449: // I444
141  return WEED_PALETTE_YUV444P;
142  break;
143  case 0x50323234: // 422P ??
144  return WEED_PALETTE_YUV422P;
145  break;
146  case 0x32315659: // YV12
147  return WEED_PALETTE_YVU420P;
148  case 0x30323449: // I420
149  case 0x56555949: // IYUV
150  case 0x32315559: // YU12 ??
151  return WEED_PALETTE_YUV420P;
152 
153  case 0x3032344a: // J420
154  if (clamping!=NULL) *clamping=WEED_YUV_CLAMPING_UNCLAMPED;
155  return WEED_PALETTE_YUV420P;
156  case 0x3232344a: // J422
157  if (clamping!=NULL) *clamping=WEED_YUV_CLAMPING_UNCLAMPED;
158  return WEED_PALETTE_YUV422P;
159  case 0x3434344a: // J444
160  if (clamping!=NULL) *clamping=WEED_YUV_CLAMPING_UNCLAMPED;
161  return WEED_PALETTE_YUV444P;
162 
163 
164  // known formats we cannot use
165  case 0x50424752: // RGBP - palettised RGB
166  case 0x4f424752: // RGB0 - 15 or 16 bit RGB
167  case 0x51424752: // RGBQ - 15 or 16 bit RGB
168  case 0x52424752: // RGBR - ???
169 
170  case 0x3231564e: // NV12 - planar Y, packed UV
171  case 0x30313276: // v210 - 10 bit 422, packed
172 
173  case 0x39565559: // YUV9 - 410 planar palette
174  case 0x30313449: // I410 - 410 planar palette
175 
176  case 0x31313449: // I411 - 411 planar palette
177  case 0x30343449: // I440 - 440 planar palette
178  case 0x30343450: // J440 - 440 planar palette unclamped
179 
180  // no match
181  default:
182  return WEED_PALETTE_END;
183  }
184  return WEED_PALETTE_END;
185 }
186 
187 
188 
189 
190 #endif
191 
192 
193 
194 
195 
196 
197 
198 
199 #ifdef HAVE_AVCODEC
200 #ifdef HAVE_AVUTIL
201 
202 // compatibility with libavcodec
203 
204 #include <libavcodec/avcodec.h>
205 #include <libavutil/pixfmt.h>
206 
207 typedef struct AVCodecTag {
208  int id;
209  unsigned int tag;
210 } AVCodecTag;
211 
212 #ifndef MKTAG
213 #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
214 #endif
215 
216 
217 #if (LIBAVCODEC_VERSION_MAJOR > 54)
218 #define CodecID AVCodecID
219 
220 #define CODEC_ID_NONE AV_CODEC_ID_NONE
221 #define CODEC_ID_H264 AV_CODEC_ID_H264
222 #define CODEC_ID_H263 AV_CODEC_ID_H263
223 #define CODEC_ID_H263P AV_CODEC_ID_H263P
224 #define CODEC_ID_H263I AV_CODEC_ID_H263I
225 #define CODEC_ID_H261 AV_CODEC_ID_H261
226 #define CODEC_ID_MPEG4 AV_CODEC_ID_MPEG4
227 #define CODEC_ID_MSMPEG4V3 AV_CODEC_ID_MSMPEG4V3
228 #define CODEC_ID_MSMPEG4V2 AV_CODEC_ID_MSMPEG4V2
229 #define CODEC_ID_MSMPEG4V1 AV_CODEC_ID_MSMPEG4V1
230 #define CODEC_ID_WMV1 AV_CODEC_ID_WMV1
231 #define CODEC_ID_WMV2 AV_CODEC_ID_WMV2
232 #define CODEC_ID_DVVIDEO AV_CODEC_ID_DVVIDEO
233 #define CODEC_ID_MPEG1VIDEO AV_CODEC_ID_MPEG1VIDEO
234 #define CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO
235 #define CODEC_ID_MJPEG AV_CODEC_ID_MJPEG
236 #define CODEC_ID_LJPEG AV_CODEC_ID_LJPEG
237 #define CODEC_ID_JPEGLS AV_CODEC_ID_JPEGLS
238 #define CODEC_ID_HUFFYUV AV_CODEC_ID_HUFFYUV
239 #define CODEC_ID_FFVHUFF AV_CODEC_ID_FFVHUFF
240 #define CODEC_ID_CYUV AV_CODEC_ID_CYUV
241 #define CODEC_ID_RAWVIDEO AV_CODEC_ID_RAWVIDEO
242 #define CODEC_ID_INDEO2 AV_CODEC_ID_INDEO2
243 #define CODEC_ID_INDEO3 AV_CODEC_ID_INDEO3
244 #define CODEC_ID_INDEO4 AV_CODEC_ID_INDEO4
245 #define CODEC_ID_INDEO5 AV_CODEC_ID_INDEO5
246 #define CODEC_ID_VP3 AV_CODEC_ID_VP3
247 #define CODEC_ID_VP5 AV_CODEC_ID_VP5
248 #define CODEC_ID_VP6 AV_CODEC_ID_VP6
249 #define CODEC_ID_VP6F AV_CODEC_ID_VP6F
250 #define CODEC_ID_ASV1 AV_CODEC_ID_ASV1
251 #define CODEC_ID_ASV2 AV_CODEC_ID_ASV2
252 #define CODEC_ID_VCR1 AV_CODEC_ID_VCR1
253 #define CODEC_ID_FFV1 AV_CODEC_ID_FFV1
254 #define CODEC_ID_XAN_WC4 AV_CODEC_ID_XAN_WC4
255 #define CODEC_ID_MIMIC AV_CODEC_ID_MIMIC
256 #define CODEC_ID_MSRLE AV_CODEC_ID_MSRLE
257 #define CODEC_ID_MSVIDEO1 AV_CODEC_ID_MSVIDEO1
258 #define CODEC_ID_CINEPAK AV_CODEC_ID_CINEPAK
259 #define CODEC_ID_TRUEMOTION1 AV_CODEC_ID_TRUEMOTION1
260 #define CODEC_ID_TRUEMOTION2 AV_CODEC_ID_TRUEMOTION2
261 #define CODEC_ID_MSZH AV_CODEC_ID_MSZH
262 #define CODEC_ID_ZLIB AV_CODEC_ID_ZLIB
263 
264 #if FF_API_SNOW
265 #define CODEC_ID_SNOW AV_CODEC_ID_SNOW
266 #endif
267 
268 #define CODEC_ID_4XM AV_CODEC_ID_4XM
269 #define CODEC_ID_FLV1 AV_CODEC_ID_FLV1
270 #define CODEC_ID_FLASHSV AV_CODEC_ID_FLASHSV
271 #define CODEC_ID_SVQ1 AV_CODEC_ID_SVQ1
272 #define CODEC_ID_TSCC AV_CODEC_ID_TSCC
273 #define CODEC_ID_ULTI AV_CODEC_ID_ULTI
274 #define CODEC_ID_VIXL AV_CODEC_ID_VIXL
275 #define CODEC_ID_QPEG AV_CODEC_ID_QPEG
276 #define CODEC_ID_WMV3 AV_CODEC_ID_WMV3
277 #define CODEC_ID_VC1 AV_CODEC_ID_VC1
278 #define CODEC_ID_LOCO AV_CODEC_ID_LOCO
279 #define CODEC_ID_WNV1 AV_CODEC_ID_WNV1
280 #define CODEC_ID_AASC AV_CODEC_ID_AASC
281 #define CODEC_ID_FRAPS AV_CODEC_ID_FRAPS
282 #define CODEC_ID_THEORA AV_CODEC_ID_THEORA
283 #define CODEC_ID_CSCD AV_CODEC_ID_CSCD
284 #define CODEC_ID_ZMBV AV_CODEC_ID_ZMBV
285 #define CODEC_ID_KMVC AV_CODEC_ID_KMVC
286 #define CODEC_ID_CAVS AV_CODEC_ID_CAVS
287 #define CODEC_ID_JPEG2000 AV_CODEC_ID_JPEG2000
288 #define CODEC_ID_VMNC AV_CODEC_ID_VMNC
289 #define CODEC_ID_TARGA AV_CODEC_ID_TARGA
290 #define CODEC_ID_PNG AV_CODEC_ID_PNG
291 #define CODEC_ID_GIF AV_CODEC_ID_GIF
292 #define CODEC_ID_TIFF AV_CODEC_ID_TIFF
293 #define CODEC_ID_CLJR AV_CODEC_ID_CLJR
294 #define CODEC_ID_DIRAC AV_CODEC_ID_DIRAC
295 #define CODEC_ID_RPZA AV_CODEC_ID_RPZA
296 #define CODEC_ID_SP5X AV_CODEC_ID_SP5X
297 
298 #define CODEC_ID_FLASHSV2 AV_CODEC_ID_FLASHSV2
299 #define CODEC_ID_TEXT AV_CODEC_ID_TEXT
300 #define CODEC_ID_SSA AV_CODEC_ID_SSA
301 #define CODEC_ID_SSA AV_CODEC_ID_SRT
302 #define CODEC_ID_VP8 AV_CODEC_ID_VP8
303 #define CODEC_ID_RV10 AV_CODEC_ID_RV10
304 #define CODEC_ID_RV20 AV_CODEC_ID_RV20
305 #define CODEC_ID_RV30 AV_CODEC_ID_RV30
306 #define CODEC_ID_RV40 AV_CODEC_ID_RV40
307 #define CODEC_ID_MP3 AV_CODEC_ID_MP3
308 #define CODEC_ID_MP3 AV_CODEC_ID_MP2
309 #define CODEC_ID_AAC AV_CODEC_ID_AAC
310 #define CODEC_ID_PCM_BLURAY AV_CODEC_ID_PCM_BLURAY
311 #define CODEC_ID_AC3 AV_CODEC_ID_AC3
312 #define CODEC_ID_VORBIS AV_CODEC_ID_VORBIS
313 #define CODEC_ID_EAC3 AV_CODEC_ID_EAC3
314 #define CODEC_ID_DTS AV_CODEC_ID_DTS
315 #define CODEC_ID_TRUEHD AV_CODEC_ID_TRUEHD
316 #define CODEC_ID_S302M AV_CODEC_ID_S302M
317 #define CODEC_ID_DVB_TELETEXT AV_CODEC_ID_DVB_TELETEXT
318 #define CODEC_ID_DVB_SUBTITLE AV_CODEC_ID_DVB_SUBTITLE
319 #define CODEC_ID_DVD_SUBTITLE AV_CODEC_ID_DVD_SUBTITLE
320 
321 #define CODEC_ID_MOV_TEXT AV_CODEC_ID_MOV_TEXT
322 #define CODEC_ID_MP4ALS AV_CODEC_ID_MP4ALS
323 #define CODEC_ID_QCELP AV_CODEC_ID_QCELP
324 #define CODEC_ID_MPEG4SYSTEMS AV_CODEC_ID_MPEG4SYSTEMS
325 
326 #define CODEC_ID_MPEG2TS AV_CODEC_ID_MPEG2TS
327 #define CODEC_ID_AAC_LATM AV_CODEC_ID_AAC_LATM
328 #define CODEC_ID_HDMV_PGS_SUBTITLE AV_CODEC_ID_HDMV_PGS_SUBTITLE
329 
330 #define CODEC_ID_FLAC AV_CODEC_ID_FLAC
331 #define CODEC_ID_MLP AV_CODEC_ID_MLP
332 
333 #define CODEC_ID_PCM_F32LE AV_CODEC_ID_PCM_F32LE
334 #define CODEC_ID_PCM_F64LE AV_CODEC_ID_PCM_F64LE
335 
336 #define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE
337 #define CODEC_ID_PCM_S24BE AV_CODEC_ID_PCM_S24BE
338 #define CODEC_ID_PCM_S32BE AV_CODEC_ID_PCM_S32BE
339 
340 #define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE
341 #define CODEC_ID_PCM_S24LE AV_CODEC_ID_PCM_S24LE
342 #define CODEC_ID_PCM_S32LE AV_CODEC_ID_PCM_S32LE
343 
344 #define CODEC_ID_PCM_U8 AV_CODEC_ID_PCM_U8
345 
346 #define CODEC_ID_PCM_QDM2 AV_CODEC_ID_QDM2
347 #define CODEC_ID_RA_144 AV_CODEC_ID_RA_144
348 #define CODEC_ID_RA_288 AV_CODEC_ID_RA_288
349 #define CODEC_ID_ATRAC3 AV_CODEC_ID_ATRAC3
350 #define CODEC_ID_COOK AV_CODEC_ID_COOK
351 #define CODEC_ID_SIPR AV_CODEC_ID_SIPR
352 #define CODEC_ID_TTA AV_CODEC_ID_TTA
353 #define CODEC_ID_WAVPACK AV_CODEC_ID_WAVPACK
354 
355 #define CODEC_ID_TTF AV_CODEC_ID_TTF
356 
357 #endif
358 
359 const AVCodecTag codec_bmp_tags[] = {
360  { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
361  { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
362  { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
363  { CODEC_ID_H264, MKTAG('x', '2', '6', '4') },
364  { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
365  { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') },
366  { CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
367  { CODEC_ID_H263, MKTAG('X', '2', '6', '3') },
368  { CODEC_ID_H263, MKTAG('T', '2', '6', '3') },
369  { CODEC_ID_H263, MKTAG('L', '2', '6', '3') },
370  { CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') },
371  { CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') },
372  { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
373  { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */
374  { CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
375  { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
376  { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
377  { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
378  { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
379  { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
380  { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
381  { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
382  { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
383  { CODEC_ID_MPEG4, MKTAG(4 , 0 , 0 , 0) }, /* some broken avi use this */
384  { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') },
385  { CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') },
386  { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
387  { CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') },
388  { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') },
389  { CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') },
390  { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
391  { CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') },
392  { CODEC_ID_MPEG4, MKTAG('F', 'F', 'D', 'S') },
393  { CODEC_ID_MPEG4, MKTAG('F', 'V', 'F', 'W') },
394  { CODEC_ID_MPEG4, MKTAG('D', 'C', 'O', 'D') },
395  { CODEC_ID_MPEG4, MKTAG('M', 'V', 'X', 'M') },
396  { CODEC_ID_MPEG4, MKTAG('P', 'M', '4', 'V') },
397  { CODEC_ID_MPEG4, MKTAG('S', 'M', 'P', '4') },
398  { CODEC_ID_MPEG4, MKTAG('D', 'X', 'G', 'M') },
399  { CODEC_ID_MPEG4, MKTAG('V', 'I', 'D', 'M') },
400  { CODEC_ID_MPEG4, MKTAG('M', '4', 'T', '3') },
401  { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'X') },
402  { CODEC_ID_MPEG4, MKTAG('H', 'D', 'X', '4') }, /* flipped video */
403  { CODEC_ID_MPEG4, MKTAG('D', 'M', 'K', '2') },
404  { CODEC_ID_MPEG4, MKTAG('D', 'I', 'G', 'I') },
405  { CODEC_ID_MPEG4, MKTAG('I', 'N', 'M', 'C') },
406  { CODEC_ID_MPEG4, MKTAG('E', 'P', 'H', 'V') }, /* Ephv MPEG-4 */
407  { CODEC_ID_MPEG4, MKTAG('E', 'M', '4', 'A') },
408  { CODEC_ID_MPEG4, MKTAG('M', '4', 'C', 'C') }, /* Divio MPEG-4 */
409  { CODEC_ID_MPEG4, MKTAG('S', 'N', '4', '0') },
410  { CODEC_ID_MPEG4, MKTAG('V', 'S', 'P', 'X') },
411  { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') },
412  { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') },
413  { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */
414  { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
415  { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
416  { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') },
417  { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') },
418  { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') },
419  { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') },
420  { CODEC_ID_MSMPEG4V3, MKTAG('D', 'V', 'X', '3') },
421  { CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') },
422  { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') },
423  { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') },
424  { CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') },
425  { CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') },
426  { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') },
427  { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', '4', '1') },
428  { CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') },
429  { CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') },
430  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') },
431  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') },
432  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
433  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') },
434  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') },
435  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') },
436  { CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') }, /* Canopus DV */
437  { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') }, /* Canopus DV */
438  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') },
439  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') },
440  { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
441  { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') },
442  { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') },
443  { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') },
444  { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') },
445  { CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') },
446  { CODEC_ID_MPEG2VIDEO, MKTAG('P', 'I', 'M', '2') },
447  { CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') },
448  { CODEC_ID_MPEG1VIDEO, MKTAG(1 , 0 , 0 , 16) },
449  { CODEC_ID_MPEG2VIDEO, MKTAG(2 , 0 , 0 , 16) },
450  { CODEC_ID_MPEG4, MKTAG(4 , 0 , 0 , 16) },
451  { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') },
452  { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') },
453  { CODEC_ID_MPEG2VIDEO, MKTAG('L', 'M', 'P', '2') }, /* Lead MPEG2 in avi */
454  { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') },
455  { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') },
456  { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') },
457  { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') },
458  { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') },
459  { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') },
460  { CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
461  { CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */
462  { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - encoder */
463  { CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - decoder */
464  { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
465  { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') },
466  { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') },
467  { CODEC_ID_MJPEG, MKTAG('A', 'C', 'D', 'V') },
468  { CODEC_ID_MJPEG, MKTAG('Q', 'I', 'V', 'G') },
469  { CODEC_ID_MJPEG, MKTAG('S', 'L', 'M', 'J') }, /* SL M-JPEG */
470  { CODEC_ID_MJPEG, MKTAG('C', 'J', 'P', 'G') }, /* Creative Webcam JPEG */
471  { CODEC_ID_MJPEG, MKTAG('I', 'J', 'L', 'V') }, /* Intel JPEG Library Video Codec */
472  { CODEC_ID_MJPEG, MKTAG('M', 'V', 'J', 'P') }, /* Midvid JPEG Video Codec */
473  { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '1') },
474  { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') },
475  { CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') },
476  { CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') }, /* Paradigm Matrix M-JPEG Codec */
477  { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
478  { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
479  { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
480  { CODEC_ID_RAWVIDEO, MKTAG(0 , 0 , 0 , 0) },
481  { CODEC_ID_RAWVIDEO, MKTAG(3 , 0 , 0 , 0) },
482  { CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') },
483  { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') },
484  { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') },
485  { CODEC_ID_RAWVIDEO, MKTAG('V', '4', '2', '2') },
486  { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'N', 'V') },
487  { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'V') },
488  { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'Y') },
489  { CODEC_ID_RAWVIDEO, MKTAG('u', 'y', 'v', '1') },
490  { CODEC_ID_RAWVIDEO, MKTAG('2', 'V', 'u', '1') },
491  { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') },
492  { CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') },
493  { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') },
494  { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
495  { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') },
496  { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
497  { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
498  { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
499  { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') },
500  { CODEC_ID_RAWVIDEO, MKTAG('V', 'D', 'T', 'Z') }, /* SoftLab-NSK VideoTizer */
501  { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },
502  { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
503  { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') },
504  { CODEC_ID_INDEO5, MKTAG('I', 'V', '5', '0') },
505  { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
506  { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
507  { CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
508  { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
509  { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
510  { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
511  { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') },
512  { CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') },
513  { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
514  { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
515  { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
516  { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
517  { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') },
518  { CODEC_ID_MIMIC, MKTAG('L', 'M', '2', '0') },
519  { CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') },
520  { CODEC_ID_MSRLE, MKTAG(1 , 0 , 0 , 0) },
521  { CODEC_ID_MSRLE, MKTAG(2 , 0 , 0 , 0) },
522  { CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') },
523  { CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') },
524  { CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') },
525  { CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') },
526  { CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') },
527  { CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') },
528  { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') },
529  { CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') },
530  { CODEC_ID_TRUEMOTION1, MKTAG('P', 'V', 'E', 'Z') },
531  { CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') },
532  { CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') },
533 #if FF_API_SNOW
534  { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') },
535 #endif
536  { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
537  { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
538  { CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') },
539  { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
540  { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
541  { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
542  { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
543  { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') },
544  { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') },
545  { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
546  { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
547  { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
548  { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
549  { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
550  { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
551  { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
552  { CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') },
553  { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') },
554  { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') },
555  { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') },
556  { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') },
557  { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') },
558  { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') },
559  { CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') },
560  { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') },
561  { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') },
562  { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') },
563  { CODEC_ID_PNG, MKTAG('M', 'P', 'N', 'G') },
564  { CODEC_ID_PNG, MKTAG('P', 'N', 'G', '1') },
565  { CODEC_ID_CLJR, MKTAG('c', 'l', 'j', 'r') },
566  { CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
567  { CODEC_ID_RPZA, MKTAG('a', 'z', 'p', 'r') },
568  { CODEC_ID_RPZA, MKTAG('R', 'P', 'Z', 'A') },
569  { CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') },
570  { CODEC_ID_SP5X, MKTAG('S', 'P', '5', '4') },
571  { CODEC_ID_NONE, 0 }
572 };
573 
574 
575 #ifndef __WEED_PALETTES_H__
576 #include <weed/weed-palettes.h>
577 #endif
578 
579 int avi_pix_fmt_to_weed_palette(enum PixelFormat pix_fmt, int *clamped) {
580  // clamped may be set to NULL if you are not interested in the value
581 
582  switch (pix_fmt) {
583  case PIX_FMT_RGB24:
584  return WEED_PALETTE_RGB24;
585  case PIX_FMT_BGR24:
586  return WEED_PALETTE_BGR24;
587  case PIX_FMT_RGBA:
588  return WEED_PALETTE_RGBA32;
589  case PIX_FMT_BGRA:
590  return WEED_PALETTE_BGRA32;
591  case PIX_FMT_ARGB:
592  return WEED_PALETTE_ARGB32;
593  case PIX_FMT_YUV444P:
594  return WEED_PALETTE_YUV444P;
595  case PIX_FMT_YUV422P:
596  return WEED_PALETTE_YUV422P;
597  case PIX_FMT_YUV420P:
598  return WEED_PALETTE_YUV420P;
599  case PIX_FMT_YUYV422:
600  return WEED_PALETTE_YUYV;
601  case PIX_FMT_UYVY422:
602  return WEED_PALETTE_UYVY;
603  case PIX_FMT_UYYVYY411:
604  return WEED_PALETTE_YUV411;
605  case PIX_FMT_GRAY8:
606  return WEED_PALETTE_A8;
607  case PIX_FMT_MONOWHITE:
608  case PIX_FMT_MONOBLACK:
609  return WEED_PALETTE_A1;
610  case PIX_FMT_YUVJ422P:
611  if (clamped) *clamped=WEED_YUV_CLAMPING_UNCLAMPED;
612  return WEED_PALETTE_YUV422P;
613  case PIX_FMT_YUVJ444P:
614  if (clamped) *clamped=WEED_YUV_CLAMPING_UNCLAMPED;
615  return WEED_PALETTE_YUV444P;
616  case PIX_FMT_YUVJ420P:
617  if (clamped) *clamped=WEED_YUV_CLAMPING_UNCLAMPED;
618  return WEED_PALETTE_YUV420P;
619 
620  default:
621  return WEED_PALETTE_END;
622  }
623 }
624 
625 
626 
627 
628 enum PixelFormat weed_palette_to_avi_pix_fmt(int pal, int *clamped) {
629 
630  switch (pal) {
631  case WEED_PALETTE_RGB24:
632  return PIX_FMT_RGB24;
633  case WEED_PALETTE_BGR24:
634  return PIX_FMT_BGR24;
635  case WEED_PALETTE_RGBA32:
636  return PIX_FMT_RGBA;
637  case WEED_PALETTE_BGRA32:
638  return PIX_FMT_BGRA;
639  case WEED_PALETTE_ARGB32:
640  return PIX_FMT_ARGB;
642  if (clamped && *clamped==WEED_YUV_CLAMPING_UNCLAMPED)
643  return PIX_FMT_YUVJ444P;
644  return PIX_FMT_YUV444P;
646  if (clamped && *clamped==WEED_YUV_CLAMPING_UNCLAMPED)
647  return PIX_FMT_YUVJ422P;
648  return PIX_FMT_YUV422P;
650  if (clamped && *clamped==WEED_YUV_CLAMPING_UNCLAMPED)
651  return PIX_FMT_YUVJ420P;
652  return PIX_FMT_YUV420P;
653  case WEED_PALETTE_YUYV:
654  return PIX_FMT_YUYV422;
655  case WEED_PALETTE_UYVY:
656  return PIX_FMT_UYVY422;
657  case WEED_PALETTE_YUV411:
658  return PIX_FMT_UYYVYY411;
659 
660  case WEED_PALETTE_A8:
661  return PIX_FMT_GRAY8;
662  case WEED_PALETTE_A1:
663  return PIX_FMT_MONOBLACK;
664 
665  default:
666  return PIX_FMT_NONE;
667  }
668 
669  return PIX_FMT_NONE;
670 
671 }
672 
673 #endif // HAVE_AVUTIL
674 #endif // HAVE_AVCODEC
675 
676 #ifdef __cplusplus
677 }
678 #endif /* __cplusplus */
679 
680 #endif // #ifndef __WEED_COMPAT_H__
#define WEED_PALETTE_YUV420P
Definition: weed-palettes.h:76
#define WEED_PALETTE_YUV888
Definition: weed-palettes.h:90
#define WEED_PALETTE_A8
Definition: weed-palettes.h:96
#define WEED_YUV_SUBSPACE_BT709
Definition: weed-palettes.h:115
#define WEED_PALETTE_YUV411
Definition: weed-palettes.h:88
#define WEED_PALETTE_A1
Definition: weed-palettes.h:95
#define WEED_PALETTE_YUV444P
Definition: weed-palettes.h:81
#define WEED_YUV_CLAMPING_CLAMPED
Definition: weed-palettes.h:109
#define WEED_PALETTE_UYVY
Definition: weed-palettes.h:87
#define WEED_PALETTE_END
Definition: weed-palettes.h:59
#define WEED_PALETTE_YUV422P
Definition: weed-palettes.h:74
#define WEED_PALETTE_BGRA32
Definition: weed-palettes.h:71
#define WEED_PALETTE_RGBA32
Definition: weed-palettes.h:65
#define WEED_YUV_CLAMPING_UNCLAMPED
Definition: weed-palettes.h:110
#define WEED_PALETTE_ARGB32
Definition: weed-palettes.h:67
#define WEED_PALETTE_BGR24
Definition: weed-palettes.h:63
#define WEED_YUV_SAMPLING_DEFAULT
Definition: weed-palettes.h:102
#define WEED_PALETTE_YUYV
Definition: weed-palettes.h:84
#define WEED_PALETTE_YVU420P
Definition: weed-palettes.h:78
#define WEED_PALETTE_YUVA4444P
Definition: weed-palettes.h:82
#define WEED_PALETTE_RGB24
Definition: weed-palettes.h:61
#define WEED_YUV_SUBSPACE_YCBCR
Definition: weed-palettes.h:114