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