1 /*M/////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 // 5 // By downloading, copying, installing or using the software you agree to this license. 6 // If you do not agree to this license, do not download, install, 7 // copy or use the software. 8 // 9 // 10 // License Agreement 11 // For Open Source Computer Vision Library 12 // 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 15 // Third party copyrights are property of their respective owners. 16 // 17 // Redistribution and use in source and binary forms, with or without modification, 18 // are permitted provided that the following conditions are met: 19 // 20 // * Redistribution's of source code must retain the above copyright notice, 21 // this list of conditions and the following disclaimer. 22 // 23 // * Redistribution's in binary form must reproduce the above copyright notice, 24 // this list of conditions and the following disclaimer in the documentation 25 // and/or other materials provided with the distribution. 26 // 27 // * The name of the copyright holders may not be used to endorse or promote products 28 // derived from this software without specific prior written permission. 29 // 30 // This software is provided by the copyright holders and contributors "as is" and 31 // any express or implied warranties, including, but not limited to, the implied 32 // warranties of merchantability and fitness for a particular purpose are disclaimed. 33 // In no event shall the Intel Corporation or contributors be liable for any direct, 34 // indirect, incidental, special, exemplary, or consequential damages 35 // (including, but not limited to, procurement of substitute goods or services; 36 // loss of use, data, or profits; or business interruption) however caused 37 // and on any theory of liability, whether in contract, strict liability, 38 // or tort (including negligence or otherwise) arising in any way out of 39 // the use of this software, even if advised of the possibility of such damage. 40 // 41 //M*/ 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 #if !defined(WIN32) || defined(__MINGW32__) 48 // some versions of FFMPEG assume a C99 compiler, and don't define INT64_C 49 #include <stdint.h> 50 51 // some versions of FFMPEG assume a C99 compiler, and don't define INT64_C 52 #ifndef INT64_C 53 #define INT64_C(c) (c##LL) 54 #endif 55 56 #ifndef UINT64_C 57 #define UINT64_C(c) (c##ULL) 58 #endif 59 60 #include <errno.h> 61 #endif 62 63 // if the header path is not specified explicitly, let's deduce it 64 #if !defined HAVE_FFMPEG_AVCODEC_H && !defined HAVE_LIBAVCODEC_AVCODEC_H 65 66 #if defined(HAVE_GENTOO_FFMPEG) 67 #define HAVE_LIBAVFORMAT_AVFORMAT_H 1 68 #elif defined HAVE_FFMPEG 69 #define HAVE_FFMPEG_AVFORMAT_H 1 70 #endif 71 72 #if defined(HAVE_FFMPEG_AVFORMAT_H) 73 #include <ffmpeg/avformat.h> 74 #endif 75 76 #if defined(HAVE_LIBAVFORMAT_AVFORMAT_H) || defined(WIN32) 77 #include <libavformat/avformat.h> 78 #endif 79 80 #endif 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #ifndef MKTAG 87 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) 88 #endif 89 90 // required to look up the correct codec ID depending on the FOURCC code, 91 // this is just a snipped from the file riff.c from ffmpeg/libavformat 92 typedef struct AVCodecTag { 93 int id; 94 unsigned int tag; 95 } AVCodecTag; 96 97 #if (LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(54, 51, 100)) 98 #define AV_CODEC_ID_H264 CODEC_ID_H264 99 #define AV_CODEC_ID_H263 CODEC_ID_H263 100 #define AV_CODEC_ID_H263P CODEC_ID_H263P 101 #define AV_CODEC_ID_H263I CODEC_ID_H263I 102 #define AV_CODEC_ID_H261 CODEC_ID_H261 103 #define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4 104 #define AV_CODEC_ID_MSMPEG4V3 CODEC_ID_MSMPEG4V3 105 #define AV_CODEC_ID_MSMPEG4V2 CODEC_ID_MSMPEG4V2 106 #define AV_CODEC_ID_MSMPEG4V1 CODEC_ID_MSMPEG4V1 107 #define AV_CODEC_ID_WMV1 CODEC_ID_WMV1 108 #define AV_CODEC_ID_WMV2 CODEC_ID_WMV1 109 #define AV_CODEC_ID_DVVIDEO CODEC_ID_DVVIDEO 110 #define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO 111 #define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO 112 #define AV_CODEC_ID_MJPEG CODEC_ID_MJPEG 113 #define AV_CODEC_ID_LJPEG CODEC_ID_LJPEG 114 #define AV_CODEC_ID_HUFFYUV CODEC_ID_HUFFYUV 115 #define AV_CODEC_ID_FFVHUFF CODEC_ID_FFVHUFF 116 #define AV_CODEC_ID_CYUV CODEC_ID_CYUV 117 #define AV_CODEC_ID_RAWVIDEO CODEC_ID_RAWVIDEO 118 #define AV_CODEC_ID_INDEO3 CODEC_ID_INDEO3 119 #define AV_CODEC_ID_VP3 CODEC_ID_VP3 120 #define AV_CODEC_ID_ASV1 CODEC_ID_ASV1 121 #define AV_CODEC_ID_ASV2 CODEC_ID_ASV2 122 #define AV_CODEC_ID_VCR1 CODEC_ID_VCR1 123 #define AV_CODEC_ID_FFV1 CODEC_ID_FFV1 124 #define AV_CODEC_ID_XAN_WC4 CODEC_ID_XAN_WC4 125 #define AV_CODEC_ID_MSRLE CODEC_ID_MSRLE 126 #define AV_CODEC_ID_MSVIDEO1 CODEC_ID_MSVIDEO1 127 #define AV_CODEC_ID_CINEPAK CODEC_ID_CINEPAK 128 #define AV_CODEC_ID_TRUEMOTION1 CODEC_ID_TRUEMOTION1 129 #define AV_CODEC_ID_MSZH CODEC_ID_MSZH 130 #define AV_CODEC_ID_ZLIB CODEC_ID_ZLIB 131 #define AV_CODEC_ID_SNOW CODEC_ID_SNOW 132 #define AV_CODEC_ID_4XM CODEC_ID_4XM 133 #define AV_CODEC_ID_FLV1 CODEC_ID_FLV1 134 #define AV_CODEC_ID_SVQ1 CODEC_ID_SVQ1 135 #define AV_CODEC_ID_TSCC CODEC_ID_TSCC 136 #define AV_CODEC_ID_ULTI CODEC_ID_ULTI 137 #define AV_CODEC_ID_VIXL CODEC_ID_VIXL 138 #define AV_CODEC_ID_QPEG CODEC_ID_QPEG 139 #define AV_CODEC_ID_WMV3 CODEC_ID_WMV3 140 #define AV_CODEC_ID_LOCO CODEC_ID_LOCO 141 #define AV_CODEC_ID_THEORA CODEC_ID_THEORA 142 #define AV_CODEC_ID_WNV1 CODEC_ID_WNV1 143 #define AV_CODEC_ID_AASC CODEC_ID_AASC 144 #define AV_CODEC_ID_INDEO2 CODEC_ID_INDEO2 145 #define AV_CODEC_ID_FRAPS CODEC_ID_FRAPS 146 #define AV_CODEC_ID_TRUEMOTION2 CODEC_ID_TRUEMOTION2 147 #define AV_CODEC_ID_FLASHSV CODEC_ID_FLASHSV 148 #define AV_CODEC_ID_JPEGLS CODEC_ID_JPEGLS 149 #define AV_CODEC_ID_VC1 CODEC_ID_VC1 150 #define AV_CODEC_ID_CSCD CODEC_ID_CSCD 151 #define AV_CODEC_ID_ZMBV CODEC_ID_ZMBV 152 #define AV_CODEC_ID_KMVC CODEC_ID_KMVC 153 #define AV_CODEC_ID_VP5 CODEC_ID_VP5 154 #define AV_CODEC_ID_VP6 CODEC_ID_VP6 155 #define AV_CODEC_ID_VP6F CODEC_ID_VP6F 156 #define AV_CODEC_ID_JPEG2000 CODEC_ID_JPEG2000 157 #define AV_CODEC_ID_VMNC CODEC_ID_VMNC 158 #define AV_CODEC_ID_TARGA CODEC_ID_TARGA 159 #define AV_CODEC_ID_NONE CODEC_ID_NONE 160 #endif 161 162 const AVCodecTag codec_bmp_tags[] = { 163 { AV_CODEC_ID_H264, MKTAG('H', '2', '6', '4') }, 164 { AV_CODEC_ID_H264, MKTAG('h', '2', '6', '4') }, 165 { AV_CODEC_ID_H264, MKTAG('X', '2', '6', '4') }, 166 { AV_CODEC_ID_H264, MKTAG('x', '2', '6', '4') }, 167 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, 168 { AV_CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') }, 169 170 { AV_CODEC_ID_H263, MKTAG('H', '2', '6', '3') }, 171 { AV_CODEC_ID_H263P, MKTAG('H', '2', '6', '3') }, 172 { AV_CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */ 173 { AV_CODEC_ID_H261, MKTAG('H', '2', '6', '1') }, 174 175 /* added based on MPlayer */ 176 { AV_CODEC_ID_H263P, MKTAG('U', '2', '6', '3') }, 177 { AV_CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') }, 178 179 { AV_CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') }, 180 { AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, 181 { AV_CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') }, 182 { AV_CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') }, 183 { AV_CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') }, 184 { AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') }, 185 { AV_CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */ 186 187 /* added based on MPlayer */ 188 { AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') }, 189 { AV_CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') }, 190 { AV_CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') }, 191 { AV_CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') }, 192 { AV_CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') }, 193 { AV_CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') }, 194 195 { AV_CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') }, 196 197 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */ 198 { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, 199 200 /* added based on MPlayer */ 201 { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, 202 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') }, 203 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') }, 204 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') }, 205 { AV_CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') }, 206 { AV_CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') }, 207 { AV_CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') }, 208 209 { AV_CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') }, 210 211 /* added based on MPlayer */ 212 { AV_CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') }, 213 214 { AV_CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') }, 215 216 { AV_CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') }, 217 218 /* added based on MPlayer */ 219 { AV_CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') }, 220 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') }, 221 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') }, 222 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') }, 223 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') }, 224 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') }, 225 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') }, 226 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') }, 227 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') }, 228 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') }, 229 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') }, 230 { AV_CODEC_ID_MPEG1VIDEO, 0x10000001 }, 231 { AV_CODEC_ID_MPEG2VIDEO, 0x10000002 }, 232 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') }, 233 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') }, 234 { AV_CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') }, 235 { AV_CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') }, 236 { AV_CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') }, 237 { AV_CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */ 238 { AV_CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - decoder */ 239 { AV_CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, 240 { AV_CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') }, 241 { AV_CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') }, 242 { AV_CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') }, 243 { AV_CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') }, 244 { AV_CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') }, 245 { AV_CODEC_ID_RAWVIDEO, 0 }, 246 { AV_CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') }, 247 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') }, 248 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') }, 249 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') }, 250 { AV_CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') }, 251 { AV_CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') }, 252 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') }, 253 { AV_CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') }, 254 { AV_CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') }, 255 { AV_CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') }, 256 { AV_CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, 257 { AV_CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') }, 258 { AV_CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') }, 259 { AV_CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') }, 260 { AV_CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') }, 261 { AV_CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') }, 262 { AV_CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') }, 263 { AV_CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') }, 264 { AV_CODEC_ID_MSRLE, MKTAG(0x1, 0x0, 0x0, 0x0) }, 265 { AV_CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') }, 266 { AV_CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') }, 267 { AV_CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') }, 268 { AV_CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') }, 269 { AV_CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') }, 270 { AV_CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') }, 271 { AV_CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, 272 { AV_CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') }, 273 { AV_CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') }, 274 { AV_CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') }, 275 { AV_CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') }, 276 { AV_CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') }, 277 { AV_CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, 278 { AV_CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') }, 279 { AV_CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') }, 280 { AV_CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') }, 281 { AV_CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') }, 282 { AV_CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') }, 283 { AV_CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') }, 284 { AV_CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') }, 285 { AV_CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') }, 286 { AV_CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') }, 287 #if LIBAVCODEC_VERSION_INT>0x000409 288 { AV_CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') }, 289 { AV_CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') }, 290 { AV_CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') }, 291 { AV_CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') }, 292 { AV_CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') }, 293 #endif 294 #if LIBAVCODEC_VERSION_INT>((50<<16)+(1<<8)+0) 295 { AV_CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') }, 296 { AV_CODEC_ID_JPEGLS,MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - encoder */ 297 { AV_CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') }, 298 { AV_CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') }, 299 { AV_CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') }, 300 { AV_CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') }, 301 { AV_CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') }, 302 #endif 303 #if LIBAVCODEC_VERSION_INT>((51<<16)+(11<<8)+0) 304 { AV_CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') }, 305 { AV_CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') }, 306 { AV_CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') }, 307 { AV_CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') }, 308 { AV_CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') }, 309 { AV_CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') }, 310 { AV_CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') }, 311 #endif 312 #if LIBAVCODEC_VERSION_INT>=((51<<16)+(49<<8)+0) 313 // this tag seems not to exist in older versions of FFMPEG 314 { AV_CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, 315 #endif 316 { AV_CODEC_ID_NONE, 0 }, 317 }; 318