00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "libavutil/mathematics.h"
00023 #include "libavcodec/avcodec.h"
00024 #include "avformat.h"
00025 #include "avio_internal.h"
00026 #include "riff.h"
00027 #include "libavcodec/bytestream.h"
00028
00029
00030
00031 const AVCodecTag ff_codec_bmp_tags[] = {
00032 { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
00033 { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
00034 { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
00035 { CODEC_ID_H264, MKTAG('x', '2', '6', '4') },
00036 { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
00037 { CODEC_ID_H264, MKTAG('D', 'A', 'V', 'C') },
00038 { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') },
00039 { CODEC_ID_H264, MKTAG('Q', '2', '6', '4') },
00040 { CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
00041 { CODEC_ID_H263, MKTAG('X', '2', '6', '3') },
00042 { CODEC_ID_H263, MKTAG('T', '2', '6', '3') },
00043 { CODEC_ID_H263, MKTAG('L', '2', '6', '3') },
00044 { CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') },
00045 { CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') },
00046 { CODEC_ID_H263, MKTAG('M', '2', '6', '3') },
00047 { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
00048 { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') },
00049 { CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
00050 { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
00051 { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
00052 { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
00053 { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
00054 { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
00055 { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
00056 { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
00057 { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
00058 { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 0 ) },
00059 { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') },
00060 { CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') },
00061 { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
00062 { CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') },
00063 { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') },
00064 { CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') },
00065 { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
00066 { CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') },
00067 { CODEC_ID_MPEG4, MKTAG('W', 'A', 'W', 'V') },
00068 { CODEC_ID_MPEG4, MKTAG('F', 'F', 'D', 'S') },
00069 { CODEC_ID_MPEG4, MKTAG('F', 'V', 'F', 'W') },
00070 { CODEC_ID_MPEG4, MKTAG('D', 'C', 'O', 'D') },
00071 { CODEC_ID_MPEG4, MKTAG('M', 'V', 'X', 'M') },
00072 { CODEC_ID_MPEG4, MKTAG('P', 'M', '4', 'V') },
00073 { CODEC_ID_MPEG4, MKTAG('S', 'M', 'P', '4') },
00074 { CODEC_ID_MPEG4, MKTAG('D', 'X', 'G', 'M') },
00075 { CODEC_ID_MPEG4, MKTAG('V', 'I', 'D', 'M') },
00076 { CODEC_ID_MPEG4, MKTAG('M', '4', 'T', '3') },
00077 { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'X') },
00078 { CODEC_ID_MPEG4, MKTAG('H', 'D', 'X', '4') },
00079 { CODEC_ID_MPEG4, MKTAG('D', 'M', 'K', '2') },
00080 { CODEC_ID_MPEG4, MKTAG('D', 'I', 'G', 'I') },
00081 { CODEC_ID_MPEG4, MKTAG('I', 'N', 'M', 'C') },
00082 { CODEC_ID_MPEG4, MKTAG('E', 'P', 'H', 'V') },
00083 { CODEC_ID_MPEG4, MKTAG('E', 'M', '4', 'A') },
00084 { CODEC_ID_MPEG4, MKTAG('M', '4', 'C', 'C') },
00085 { CODEC_ID_MPEG4, MKTAG('S', 'N', '4', '0') },
00086 { CODEC_ID_MPEG4, MKTAG('V', 'S', 'P', 'X') },
00087 { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') },
00088 { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') },
00089 { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') },
00090 { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'X') },
00091 { CODEC_ID_MPEG4, MKTAG('D', 'r', 'e', 'X') },
00092 { CODEC_ID_MPEG4, MKTAG('Q', 'M', 'P', '4') },
00093 { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
00094 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') },
00095 { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') },
00096 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') },
00097 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') },
00098 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') },
00099 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'V', 'X', '3') },
00100 { CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') },
00101 { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') },
00102 { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') },
00103 { CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') },
00104 { CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') },
00105 { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') },
00106 { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', '4', '1') },
00107 { CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') },
00108 { CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') },
00109 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') },
00110 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') },
00111 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
00112 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') },
00113 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') },
00114 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') },
00115 { CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') },
00116 { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') },
00117 { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', '5') },
00118 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') },
00119 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') },
00120 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
00121 { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') },
00122 { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') },
00123 { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') },
00124 { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') },
00125 { CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') },
00126 { CODEC_ID_MPEG2VIDEO, MKTAG('P', 'I', 'M', '2') },
00127 { CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') },
00128 { CODEC_ID_MPEG1VIDEO, MKTAG( 1 , 0 , 0 , 16) },
00129 { CODEC_ID_MPEG2VIDEO, MKTAG( 2 , 0 , 0 , 16) },
00130 { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 16) },
00131 { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') },
00132 { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') },
00133 { CODEC_ID_MPEG2VIDEO, MKTAG('L', 'M', 'P', '2') },
00134 { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') },
00135 { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') },
00136 { CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') },
00137 { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', 'v') },
00138 { CODEC_ID_MPEG1VIDEO, MKTAG('B', 'W', '1', '0') },
00139 { CODEC_ID_MPEG1VIDEO, MKTAG('X', 'M', 'P', 'G') },
00140 { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') },
00141 { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') },
00142 { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') },
00143 { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') },
00144 { CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
00145 { CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') },
00146 { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'L', 'S') },
00147 { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'P', 'G') },
00148 { CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') },
00149 { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
00150 { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') },
00151 { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') },
00152 { CODEC_ID_MJPEG, MKTAG('A', 'C', 'D', 'V') },
00153 { CODEC_ID_MJPEG, MKTAG('Q', 'I', 'V', 'G') },
00154 { CODEC_ID_MJPEG, MKTAG('S', 'L', 'M', 'J') },
00155 { CODEC_ID_MJPEG, MKTAG('C', 'J', 'P', 'G') },
00156 { CODEC_ID_MJPEG, MKTAG('I', 'J', 'L', 'V') },
00157 { CODEC_ID_MJPEG, MKTAG('M', 'V', 'J', 'P') },
00158 { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '1') },
00159 { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') },
00160 { CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') },
00161 { CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') },
00162 { CODEC_ID_MJPEG, MKTAG('M', 'M', 'J', 'P') },
00163 { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
00164 { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
00165 { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
00166 { CODEC_ID_RAWVIDEO, MKTAG( 0 , 0 , 0 , 0 ) },
00167 { CODEC_ID_RAWVIDEO, MKTAG( 3 , 0 , 0 , 0 ) },
00168 { CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') },
00169 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') },
00170 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') },
00171 { CODEC_ID_RAWVIDEO, MKTAG('V', '4', '2', '2') },
00172 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'N', 'V') },
00173 { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'V') },
00174 { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'Y') },
00175 { CODEC_ID_RAWVIDEO, MKTAG('u', 'y', 'v', '1') },
00176 { CODEC_ID_RAWVIDEO, MKTAG('2', 'V', 'u', '1') },
00177 { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') },
00178 { CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') },
00179 { CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', '2') },
00180 { CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') },
00181 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') },
00182 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '6') },
00183 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '2', '4') },
00184 { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
00185 { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') },
00186 { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
00187 { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
00188 { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', ' ', ' ') },
00189 { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
00190 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') },
00191 { CODEC_ID_RAWVIDEO, MKTAG('V', 'D', 'T', 'Z') },
00192 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', '1') },
00193 { CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '1', '2') },
00194 { CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '2', '1') },
00195 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', 'B') },
00196 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', 'B') },
00197 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'V', '9') },
00198 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') },
00199 { CODEC_ID_RAWVIDEO, MKTAG('a', 'u', 'v', '2') },
00200 { CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') },
00201 { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') },
00202 { CODEC_ID_R210, MKTAG('r', '2', '1', '0') },
00203 { CODEC_ID_V210, MKTAG('v', '2', '1', '0') },
00204 { CODEC_ID_V308, MKTAG('v', '3', '0', '8') },
00205 { CODEC_ID_V410, MKTAG('v', '4', '1', '0') },
00206 { CODEC_ID_YUV4, MKTAG('y', 'u', 'v', '4') },
00207 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },
00208 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
00209 { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') },
00210 { CODEC_ID_INDEO5, MKTAG('I', 'V', '5', '0') },
00211 { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
00212 { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
00213 { CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
00214 { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
00215 { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
00216 { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
00217 { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') },
00218 { CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') },
00219 { CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') },
00220 { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
00221 { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
00222 { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
00223 { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
00224 { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') },
00225 { CODEC_ID_MIMIC, MKTAG('L', 'M', '2', '0') },
00226 { CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') },
00227 { CODEC_ID_MSRLE, MKTAG( 1 , 0 , 0 , 0 ) },
00228 { CODEC_ID_MSRLE, MKTAG( 2 , 0 , 0 , 0 ) },
00229 { CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') },
00230 { CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') },
00231 { CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') },
00232 { CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') },
00233 { CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') },
00234 { CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') },
00235 { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') },
00236 { CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') },
00237 { CODEC_ID_TRUEMOTION1, MKTAG('P', 'V', 'E', 'Z') },
00238 { CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') },
00239 { CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') },
00240 { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') },
00241 { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
00242 { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
00243 { CODEC_ID_FLV1, MKTAG('S', '2', '6', '3') },
00244 { CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') },
00245 { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
00246 { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
00247 { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
00248 { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
00249 { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') },
00250 { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') },
00251 { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
00252 { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
00253 { CODEC_ID_WMV3IMAGE, MKTAG('W', 'M', 'V', 'P') },
00254 { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
00255 { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
00256 { CODEC_ID_VC1IMAGE, MKTAG('W', 'V', 'P', '2') },
00257 { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
00258 { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
00259 { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
00260 { CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') },
00261 { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') },
00262 { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') },
00263 { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') },
00264 { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') },
00265 { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') },
00266 { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') },
00267 { CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') },
00268 { CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') },
00269 { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') },
00270 { CODEC_ID_JPEG2000, MKTAG('L', 'J', '2', 'C') },
00271 { CODEC_ID_JPEG2000, MKTAG('L', 'J', '2', 'K') },
00272 { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') },
00273 { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') },
00274 { CODEC_ID_PNG, MKTAG('M', 'P', 'N', 'G') },
00275 { CODEC_ID_PNG, MKTAG('P', 'N', 'G', '1') },
00276 { CODEC_ID_CLJR, MKTAG('C', 'L', 'J', 'R') },
00277 { CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
00278 { CODEC_ID_RPZA, MKTAG('a', 'z', 'p', 'r') },
00279 { CODEC_ID_RPZA, MKTAG('R', 'P', 'Z', 'A') },
00280 { CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') },
00281 { CODEC_ID_SP5X, MKTAG('S', 'P', '5', '4') },
00282 { CODEC_ID_AURA, MKTAG('A', 'U', 'R', 'A') },
00283 { CODEC_ID_AURA2, MKTAG('A', 'U', 'R', '2') },
00284 { CODEC_ID_DPX, MKTAG('d', 'p', 'x', ' ') },
00285 { CODEC_ID_KGV1, MKTAG('K', 'G', 'V', '1') },
00286 { CODEC_ID_LAGARITH, MKTAG('L', 'A', 'G', 'S') },
00287 { CODEC_ID_G2M, MKTAG('G', '2', 'M', '2') },
00288 { CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') },
00289 { CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') },
00290 { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') },
00291 { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'A') },
00292 { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'G') },
00293 { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '0') },
00294 { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '2') },
00295 { CODEC_ID_VBLE, MKTAG('V', 'B', 'L', 'E') },
00296 { CODEC_ID_ESCAPE130, MKTAG('E', '1', '3', '0') },
00297 { CODEC_ID_DXTORY, MKTAG('x', 't', 'o', 'r') },
00298 { CODEC_ID_Y41P, MKTAG('Y', '4', '1', 'P') },
00299 { CODEC_ID_NONE, 0 }
00300 };
00301
00302 const AVCodecTag ff_codec_wav_tags[] = {
00303 { CODEC_ID_PCM_S16LE, 0x0001 },
00304 { CODEC_ID_PCM_U8, 0x0001 },
00305 { CODEC_ID_PCM_S24LE, 0x0001 },
00306 { CODEC_ID_PCM_S32LE, 0x0001 },
00307 { CODEC_ID_ADPCM_MS, 0x0002 },
00308 { CODEC_ID_PCM_F32LE, 0x0003 },
00309 { CODEC_ID_PCM_F64LE, 0x0003 },
00310 { CODEC_ID_PCM_ALAW, 0x0006 },
00311 { CODEC_ID_PCM_MULAW, 0x0007 },
00312 { CODEC_ID_WMAVOICE, 0x000A },
00313 { CODEC_ID_ADPCM_IMA_WAV, 0x0011 },
00314 { CODEC_ID_PCM_ZORK, 0x0011 },
00315 { CODEC_ID_ADPCM_YAMAHA, 0x0020 },
00316 { CODEC_ID_TRUESPEECH, 0x0022 },
00317 { CODEC_ID_GSM_MS, 0x0031 },
00318 { CODEC_ID_AMR_NB, 0x0038 },
00319 { CODEC_ID_ADPCM_G726, 0x0045 },
00320 { CODEC_ID_MP2, 0x0050 },
00321 { CODEC_ID_MP3, 0x0055 },
00322 { CODEC_ID_AMR_NB, 0x0057 },
00323 { CODEC_ID_AMR_WB, 0x0058 },
00324 { CODEC_ID_ADPCM_IMA_DK4, 0x0061 },
00325 { CODEC_ID_ADPCM_IMA_DK3, 0x0062 },
00326 { CODEC_ID_ADPCM_IMA_WAV, 0x0069 },
00327 { CODEC_ID_VOXWARE, 0x0075 },
00328 { CODEC_ID_AAC, 0x00ff },
00329 { CODEC_ID_SIPR, 0x0130 },
00330 { CODEC_ID_WMAV1, 0x0160 },
00331 { CODEC_ID_WMAV2, 0x0161 },
00332 { CODEC_ID_WMAPRO, 0x0162 },
00333 { CODEC_ID_WMALOSSLESS, 0x0163 },
00334 { CODEC_ID_ADPCM_CT, 0x0200 },
00335 { CODEC_ID_ATRAC3, 0x0270 },
00336 { CODEC_ID_ADPCM_G722, 0x028F },
00337 { CODEC_ID_IMC, 0x0401 },
00338 { CODEC_ID_GSM_MS, 0x1500 },
00339 { CODEC_ID_TRUESPEECH, 0x1501 },
00340 { CODEC_ID_AAC, 0x1600 },
00341 { CODEC_ID_AAC_LATM, 0x1602 },
00342 { CODEC_ID_AC3, 0x2000 },
00343 { CODEC_ID_DTS, 0x2001 },
00344 { CODEC_ID_SONIC, 0x2048 },
00345 { CODEC_ID_SONIC_LS, 0x2048 },
00346 { CODEC_ID_PCM_MULAW, 0x6c75 },
00347 { CODEC_ID_AAC, 0x706d },
00348 { CODEC_ID_AAC, 0x4143 },
00349 { CODEC_ID_SPEEX, 0xA109 },
00350 { CODEC_ID_FLAC, 0xF1AC },
00351 { CODEC_ID_ADPCM_SWF, ('S'<<8)+'F' },
00352 { CODEC_ID_VORBIS, ('V'<<8)+'o' },
00353
00354
00355
00356 { CODEC_ID_PCM_S16LE, MKTAG('R', 'A', 'W', 'A') },
00357 { CODEC_ID_MP3, MKTAG('L', 'A', 'M', 'E') },
00358 { CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') },
00359 { CODEC_ID_NONE, 0 },
00360 };
00361
00362 const AVCodecGuid ff_codec_wav_guids[] = {
00363 {CODEC_ID_AC3, {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
00364 {CODEC_ID_ATRAC3P, {0xBF,0xAA,0x23,0xE9,0x58,0xCB,0x71,0x44,0xA1,0x19,0xFF,0xFA,0x01,0xE4,0xCE,0x62}},
00365 {CODEC_ID_EAC3, {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}},
00366 {CODEC_ID_MP2, {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
00367 {CODEC_ID_NONE}
00368 };
00369
00370 const AVMetadataConv ff_riff_info_conv[] = {
00371 { "IART", "artist" },
00372 { "ICMT", "comment" },
00373 { "ICOP", "copyright" },
00374 { "ICRD", "date" },
00375 { "IGNR", "genre" },
00376 { "ILNG", "language" },
00377 { "INAM", "title" },
00378 { "IPRD", "album" },
00379 { "IPRT", "track" },
00380 { "ISFT", "encoder" },
00381 { "ITCH", "encoded_by"},
00382 { 0 },
00383 };
00384
00385 const char ff_riff_tags[][5] = {
00386 "IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI",
00387 "IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD",
00388 "IPRT", "ISBJ", "ISFT", "ISHP", "ISRC", "ISRF", "ITCH",
00389 {0}
00390 };
00391
00392 #if CONFIG_MUXERS
00393 int64_t ff_start_tag(AVIOContext *pb, const char *tag)
00394 {
00395 ffio_wfourcc(pb, tag);
00396 avio_wl32(pb, 0);
00397 return avio_tell(pb);
00398 }
00399
00400 void ff_end_tag(AVIOContext *pb, int64_t start)
00401 {
00402 int64_t pos;
00403
00404 pos = avio_tell(pb);
00405 avio_seek(pb, start - 4, SEEK_SET);
00406 avio_wl32(pb, (uint32_t)(pos - start));
00407 avio_seek(pb, pos, SEEK_SET);
00408 }
00409
00410
00411
00412 int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
00413 {
00414 int bps, blkalign, bytespersec;
00415 int hdrsize = 18;
00416 int waveformatextensible;
00417 uint8_t temp[256];
00418 uint8_t *riff_extradata= temp;
00419 uint8_t *riff_extradata_start= temp;
00420
00421 if(!enc->codec_tag || enc->codec_tag > 0xffff)
00422 return -1;
00423 waveformatextensible = (enc->channels > 2 && enc->channel_layout)
00424 || enc->sample_rate > 48000
00425 || av_get_bits_per_sample(enc->codec_id) > 16;
00426
00427 if (waveformatextensible) {
00428 avio_wl16(pb, 0xfffe);
00429 } else {
00430 avio_wl16(pb, enc->codec_tag);
00431 }
00432 avio_wl16(pb, enc->channels);
00433 avio_wl32(pb, enc->sample_rate);
00434 if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) {
00435 bps = 0;
00436 } else {
00437 if (!(bps = av_get_bits_per_sample(enc->codec_id))) {
00438 if (enc->bits_per_coded_sample)
00439 bps = enc->bits_per_coded_sample;
00440 else
00441 bps = 16;
00442 }
00443 }
00444 if(bps != enc->bits_per_coded_sample && enc->bits_per_coded_sample){
00445 av_log(enc, AV_LOG_WARNING, "requested bits_per_coded_sample (%d) and actually stored (%d) differ\n", enc->bits_per_coded_sample, bps);
00446 }
00447
00448 if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
00449 blkalign = enc->frame_size;
00450
00451 } else if (enc->codec_id == CODEC_ID_AC3) {
00452 blkalign = 3840;
00453 } else if (enc->block_align != 0) {
00454 blkalign = enc->block_align;
00455 } else
00456 blkalign = bps * enc->channels / av_gcd(8, bps);
00457 if (enc->codec_id == CODEC_ID_PCM_U8 ||
00458 enc->codec_id == CODEC_ID_PCM_S24LE ||
00459 enc->codec_id == CODEC_ID_PCM_S32LE ||
00460 enc->codec_id == CODEC_ID_PCM_F32LE ||
00461 enc->codec_id == CODEC_ID_PCM_F64LE ||
00462 enc->codec_id == CODEC_ID_PCM_S16LE) {
00463 bytespersec = enc->sample_rate * blkalign;
00464 } else {
00465 bytespersec = enc->bit_rate / 8;
00466 }
00467 avio_wl32(pb, bytespersec);
00468 avio_wl16(pb, blkalign);
00469 avio_wl16(pb, bps);
00470 if (enc->codec_id == CODEC_ID_MP3) {
00471 hdrsize += 12;
00472 bytestream_put_le16(&riff_extradata, 1);
00473 bytestream_put_le32(&riff_extradata, 2);
00474 bytestream_put_le16(&riff_extradata, 1152);
00475 bytestream_put_le16(&riff_extradata, 1);
00476 bytestream_put_le16(&riff_extradata, 1393);
00477 } else if (enc->codec_id == CODEC_ID_MP2) {
00478 hdrsize += 22;
00479 bytestream_put_le16(&riff_extradata, 2);
00480 bytestream_put_le32(&riff_extradata, enc->bit_rate);
00481 bytestream_put_le16(&riff_extradata, enc->channels == 2 ? 1 : 8);
00482 bytestream_put_le16(&riff_extradata, 0);
00483 bytestream_put_le16(&riff_extradata, 1);
00484 bytestream_put_le16(&riff_extradata, 16);
00485 bytestream_put_le32(&riff_extradata, 0);
00486 bytestream_put_le32(&riff_extradata, 0);
00487 } else if (enc->codec_id == CODEC_ID_GSM_MS || enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
00488 hdrsize += 2;
00489 bytestream_put_le16(&riff_extradata, enc->frame_size);
00490 } else if(enc->extradata_size){
00491 riff_extradata_start= enc->extradata;
00492 riff_extradata= enc->extradata + enc->extradata_size;
00493 hdrsize += enc->extradata_size;
00494 }
00495 if(waveformatextensible) {
00496 hdrsize += 22;
00497 avio_wl16(pb, riff_extradata - riff_extradata_start + 22);
00498 avio_wl16(pb, bps);
00499 avio_wl32(pb, enc->channel_layout);
00500 avio_wl32(pb, enc->codec_tag);
00501 avio_wl32(pb, 0x00100000);
00502 avio_wl32(pb, 0xAA000080);
00503 avio_wl32(pb, 0x719B3800);
00504 } else {
00505 avio_wl16(pb, riff_extradata - riff_extradata_start);
00506 }
00507 avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
00508 if(hdrsize&1){
00509 hdrsize++;
00510 avio_w8(pb, 0);
00511 }
00512
00513 return hdrsize;
00514 }
00515
00516
00517 void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
00518 {
00519 avio_wl32(pb, 40 + enc->extradata_size);
00520 avio_wl32(pb, enc->width);
00521
00522 avio_wl32(pb, enc->codec_tag ? enc->height : -enc->height);
00523 avio_wl16(pb, 1);
00524
00525 avio_wl16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24);
00526
00527 avio_wl32(pb, enc->codec_tag);
00528 avio_wl32(pb, (enc->width * enc->height * (enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24)+7) / 8);
00529 avio_wl32(pb, 0);
00530 avio_wl32(pb, 0);
00531 avio_wl32(pb, 0);
00532 avio_wl32(pb, 0);
00533
00534 avio_write(pb, enc->extradata, enc->extradata_size);
00535
00536 if (!for_asf && enc->extradata_size & 1)
00537 avio_w8(pb, 0);
00538 }
00539 #endif //CONFIG_MUXERS
00540
00541 #if CONFIG_DEMUXERS
00542
00543
00544
00545
00546
00547
00548
00549 int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
00550 {
00551 int id;
00552
00553 id = avio_rl16(pb);
00554 codec->codec_type = AVMEDIA_TYPE_AUDIO;
00555 codec->channels = avio_rl16(pb);
00556 codec->sample_rate = avio_rl32(pb);
00557 codec->bit_rate = avio_rl32(pb) * 8;
00558 codec->block_align = avio_rl16(pb);
00559 if (size == 14) {
00560 codec->bits_per_coded_sample = 8;
00561 }else
00562 codec->bits_per_coded_sample = avio_rl16(pb);
00563 if (id == 0xFFFE) {
00564 codec->codec_tag = 0;
00565 } else {
00566 codec->codec_tag = id;
00567 codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
00568 }
00569 if (size >= 18) {
00570 int cbSize = avio_rl16(pb);
00571 size -= 18;
00572 cbSize = FFMIN(size, cbSize);
00573 if (cbSize >= 22 && id == 0xfffe) {
00574 ff_asf_guid subformat;
00575 codec->bits_per_coded_sample = avio_rl16(pb);
00576 codec->channel_layout = avio_rl32(pb);
00577 ff_get_guid(pb, &subformat);
00578 if (!memcmp(subformat + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
00579 codec->codec_tag = AV_RL32(subformat);
00580 codec->codec_id = ff_wav_codec_get_id(codec->codec_tag, codec->bits_per_coded_sample);
00581 } else {
00582 codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
00583 if (!codec->codec_id)
00584 av_log(codec, AV_LOG_WARNING, "unknown subformat:"FF_PRI_GUID"\n", FF_ARG_GUID(subformat));
00585 }
00586 cbSize -= 22;
00587 size -= 22;
00588 }
00589 codec->extradata_size = cbSize;
00590 if (cbSize > 0) {
00591 av_free(codec->extradata);
00592 codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
00593 if (!codec->extradata)
00594 return AVERROR(ENOMEM);
00595 avio_read(pb, codec->extradata, codec->extradata_size);
00596 size -= cbSize;
00597 }
00598
00599
00600 if (size > 0)
00601 avio_skip(pb, size);
00602 }
00603 if (codec->codec_id == CODEC_ID_AAC_LATM) {
00604
00605 codec->channels = 0;
00606 codec->sample_rate = 0;
00607 }
00608
00609 if (codec->codec_id == CODEC_ID_ADPCM_G726)
00610 codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate;
00611
00612 return 0;
00613 }
00614
00615
00616 enum CodecID ff_wav_codec_get_id(unsigned int tag, int bps)
00617 {
00618 enum CodecID id;
00619 id = ff_codec_get_id(ff_codec_wav_tags, tag);
00620 if (id <= 0)
00621 return id;
00622
00623 if (id == CODEC_ID_PCM_S16LE && bps == 8)
00624 id = CODEC_ID_PCM_U8;
00625 if (id == CODEC_ID_PCM_S16LE && bps == 24)
00626 id = CODEC_ID_PCM_S24LE;
00627 if (id == CODEC_ID_PCM_S16LE && bps == 32)
00628 id = CODEC_ID_PCM_S32LE;
00629 if (id == CODEC_ID_PCM_F32LE && bps == 64)
00630 id = CODEC_ID_PCM_F64LE;
00631 if (id == CODEC_ID_ADPCM_IMA_WAV && bps == 8)
00632 id = CODEC_ID_PCM_ZORK;
00633 return id;
00634 }
00635
00636 int ff_get_bmp_header(AVIOContext *pb, AVStream *st)
00637 {
00638 int tag1;
00639 avio_rl32(pb);
00640 st->codec->width = avio_rl32(pb);
00641 st->codec->height = (int32_t)avio_rl32(pb);
00642 avio_rl16(pb);
00643 st->codec->bits_per_coded_sample= avio_rl16(pb);
00644 tag1 = avio_rl32(pb);
00645 avio_rl32(pb);
00646 avio_rl32(pb);
00647 avio_rl32(pb);
00648 avio_rl32(pb);
00649 avio_rl32(pb);
00650 return tag1;
00651 }
00652 #endif // CONFIG_DEMUXERS
00653
00654 void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale)
00655 {
00656 int gcd;
00657
00658 *au_ssize= stream->block_align;
00659 if(stream->frame_size && stream->sample_rate){
00660 *au_scale=stream->frame_size;
00661 *au_rate= stream->sample_rate;
00662 }else if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
00663 stream->codec_type == AVMEDIA_TYPE_DATA ||
00664 stream->codec_type == AVMEDIA_TYPE_SUBTITLE){
00665 *au_scale= stream->time_base.num;
00666 *au_rate = stream->time_base.den;
00667 }else{
00668 *au_scale= stream->block_align ? stream->block_align*8 : 8;
00669 *au_rate = stream->bit_rate ? stream->bit_rate : 8*stream->sample_rate;
00670 }
00671 gcd= av_gcd(*au_scale, *au_rate);
00672 *au_scale /= gcd;
00673 *au_rate /= gcd;
00674 }
00675
00676 void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
00677 {
00678 assert(sizeof(*g) == 16);
00679 if (avio_read(s, *g, sizeof(*g)) < (int)sizeof(*g))
00680 memset(*g, 0, sizeof(*g));
00681 }
00682
00683 enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
00684 {
00685 int i;
00686 for (i = 0; guids[i].id != CODEC_ID_NONE; i++) {
00687 if (!ff_guidcmp(guids[i].guid, guid))
00688 return guids[i].id;
00689 }
00690 return CODEC_ID_NONE;
00691 }
00692
00693 int ff_read_riff_info(AVFormatContext *s, int64_t size)
00694 {
00695 int64_t start, end, cur;
00696 AVIOContext *pb = s->pb;
00697
00698 start = avio_tell(pb);
00699 end = start + size;
00700
00701 while ((cur = avio_tell(pb)) >= 0 && cur <= end - 8 ) {
00702 uint32_t chunk_code;
00703 int64_t chunk_size;
00704 char key[5] = {0};
00705 char *value;
00706
00707 chunk_code = avio_rl32(pb);
00708 chunk_size = avio_rl32(pb);
00709 if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) {
00710 av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n");
00711 return AVERROR_INVALIDDATA;
00712 }
00713
00714 chunk_size += (chunk_size & 1);
00715
00716 value = av_malloc(chunk_size + 1);
00717 if (!value) {
00718 av_log(s, AV_LOG_ERROR, "out of memory, unable to read INFO tag\n");
00719 return AVERROR(ENOMEM);
00720 }
00721
00722 AV_WL32(key, chunk_code);
00723
00724 if (avio_read(pb, value, chunk_size) != chunk_size) {
00725 av_freep(&value);
00726 av_log(s, AV_LOG_ERROR, "premature end of file while reading INFO tag\n");
00727 return AVERROR_INVALIDDATA;
00728 }
00729
00730 value[chunk_size] = 0;
00731
00732 av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
00733 }
00734
00735 return 0;
00736 }