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 "riff.h"
00025 #include "libavcodec/bytestream.h"
00026
00027
00028
00029 const AVCodecTag ff_codec_bmp_tags[] = {
00030 { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
00031 { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
00032 { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
00033 { CODEC_ID_H264, MKTAG('x', '2', '6', '4') },
00034 { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
00035 { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') },
00036 { CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
00037 { CODEC_ID_H263, MKTAG('X', '2', '6', '3') },
00038 { CODEC_ID_H263, MKTAG('T', '2', '6', '3') },
00039 { CODEC_ID_H263, MKTAG('L', '2', '6', '3') },
00040 { CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') },
00041 { CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') },
00042 { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
00043 { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') },
00044 { CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
00045 { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
00046 { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
00047 { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
00048 { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
00049 { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
00050 { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
00051 { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
00052 { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
00053 { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 0 ) },
00054 { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') },
00055 { CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') },
00056 { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
00057 { CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') },
00058 { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') },
00059 { CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') },
00060 { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
00061 { CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') },
00062 { CODEC_ID_MPEG4, MKTAG('F', 'F', 'D', 'S') },
00063 { CODEC_ID_MPEG4, MKTAG('F', 'V', 'F', 'W') },
00064 { CODEC_ID_MPEG4, MKTAG('D', 'C', 'O', 'D') },
00065 { CODEC_ID_MPEG4, MKTAG('M', 'V', 'X', 'M') },
00066 { CODEC_ID_MPEG4, MKTAG('P', 'M', '4', 'V') },
00067 { CODEC_ID_MPEG4, MKTAG('S', 'M', 'P', '4') },
00068 { CODEC_ID_MPEG4, MKTAG('D', 'X', 'G', 'M') },
00069 { CODEC_ID_MPEG4, MKTAG('V', 'I', 'D', 'M') },
00070 { CODEC_ID_MPEG4, MKTAG('M', '4', 'T', '3') },
00071 { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'X') },
00072 { CODEC_ID_MPEG4, MKTAG('H', 'D', 'X', '4') },
00073 { CODEC_ID_MPEG4, MKTAG('D', 'M', 'K', '2') },
00074 { CODEC_ID_MPEG4, MKTAG('D', 'I', 'G', 'I') },
00075 { CODEC_ID_MPEG4, MKTAG('I', 'N', 'M', 'C') },
00076 { CODEC_ID_MPEG4, MKTAG('E', 'P', 'H', 'V') },
00077 { CODEC_ID_MPEG4, MKTAG('E', 'M', '4', 'A') },
00078 { CODEC_ID_MPEG4, MKTAG('M', '4', 'C', 'C') },
00079 { CODEC_ID_MPEG4, MKTAG('S', 'N', '4', '0') },
00080 { CODEC_ID_MPEG4, MKTAG('V', 'S', 'P', 'X') },
00081 { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') },
00082 { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') },
00083 { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') },
00084 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') },
00085 { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
00086 { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') },
00087 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') },
00088 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') },
00089 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') },
00090 { CODEC_ID_MSMPEG4V3, MKTAG('D', 'V', 'X', '3') },
00091 { CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') },
00092 { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') },
00093 { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') },
00094 { CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') },
00095 { CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') },
00096 { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') },
00097 { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', '4', '1') },
00098 { CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') },
00099 { CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') },
00100 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') },
00101 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') },
00102 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
00103 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') },
00104 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') },
00105 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') },
00106 { CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') },
00107 { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') },
00108 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') },
00109 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') },
00110 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
00111 { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') },
00112 { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') },
00113 { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') },
00114 { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') },
00115 { CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') },
00116 { CODEC_ID_MPEG2VIDEO, MKTAG('P', 'I', 'M', '2') },
00117 { CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') },
00118 { CODEC_ID_MPEG1VIDEO, MKTAG( 1 , 0 , 0 , 16) },
00119 { CODEC_ID_MPEG2VIDEO, MKTAG( 2 , 0 , 0 , 16) },
00120 { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 16) },
00121 { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') },
00122 { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') },
00123 { CODEC_ID_MPEG2VIDEO, MKTAG('L', 'M', 'P', '2') },
00124 { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') },
00125 { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') },
00126 { CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') },
00127 { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', 'v') },
00128 { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') },
00129 { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') },
00130 { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') },
00131 { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') },
00132 { CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
00133 { CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') },
00134 { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'L', 'S') },
00135 { CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') },
00136 { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
00137 { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') },
00138 { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') },
00139 { CODEC_ID_MJPEG, MKTAG('A', 'C', 'D', 'V') },
00140 { CODEC_ID_MJPEG, MKTAG('Q', 'I', 'V', 'G') },
00141 { CODEC_ID_MJPEG, MKTAG('S', 'L', 'M', 'J') },
00142 { CODEC_ID_MJPEG, MKTAG('C', 'J', 'P', 'G') },
00143 { CODEC_ID_MJPEG, MKTAG('I', 'J', 'L', 'V') },
00144 { CODEC_ID_MJPEG, MKTAG('M', 'V', 'J', 'P') },
00145 { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '1') },
00146 { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') },
00147 { CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') },
00148 { CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') },
00149 { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
00150 { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
00151 { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
00152 { CODEC_ID_RAWVIDEO, MKTAG( 0 , 0 , 0 , 0 ) },
00153 { CODEC_ID_RAWVIDEO, MKTAG( 3 , 0 , 0 , 0 ) },
00154 { CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') },
00155 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') },
00156 { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') },
00157 { CODEC_ID_RAWVIDEO, MKTAG('V', '4', '2', '2') },
00158 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'N', 'V') },
00159 { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'V') },
00160 { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'Y') },
00161 { CODEC_ID_RAWVIDEO, MKTAG('u', 'y', 'v', '1') },
00162 { CODEC_ID_RAWVIDEO, MKTAG('2', 'V', 'u', '1') },
00163 { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') },
00164 { CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') },
00165 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') },
00166 { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
00167 { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') },
00168 { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
00169 { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
00170 { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
00171 { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') },
00172 { CODEC_ID_RAWVIDEO, MKTAG('V', 'D', 'T', 'Z') },
00173 { CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') },
00174 { CODEC_ID_R210, MKTAG('r', '2', '1', '0') },
00175 { CODEC_ID_V210, MKTAG('v', '2', '1', '0') },
00176 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },
00177 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
00178 { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') },
00179 { CODEC_ID_INDEO5, MKTAG('I', 'V', '5', '0') },
00180 { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
00181 { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
00182 { CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
00183 { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
00184 { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
00185 { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
00186 { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') },
00187 { CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') },
00188 { CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') },
00189 { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
00190 { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
00191 { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
00192 { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
00193 { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') },
00194 { CODEC_ID_MIMIC, MKTAG('L', 'M', '2', '0') },
00195 { CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') },
00196 { CODEC_ID_MSRLE, MKTAG( 1 , 0 , 0 , 0 ) },
00197 { CODEC_ID_MSRLE, MKTAG( 2 , 0 , 0 , 0 ) },
00198 { CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') },
00199 { CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') },
00200 { CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') },
00201 { CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') },
00202 { CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') },
00203 { CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') },
00204 { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') },
00205 { CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') },
00206 { CODEC_ID_TRUEMOTION1, MKTAG('P', 'V', 'E', 'Z') },
00207 { CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') },
00208 { CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') },
00209 { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') },
00210 { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
00211 { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
00212 { CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') },
00213 { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
00214 { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
00215 { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
00216 { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
00217 { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') },
00218 { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') },
00219 { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
00220 { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
00221 { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
00222 { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
00223 { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
00224 { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
00225 { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
00226 { CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') },
00227 { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') },
00228 { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') },
00229 { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') },
00230 { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') },
00231 { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') },
00232 { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') },
00233 { CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') },
00234 { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') },
00235 { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') },
00236 { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') },
00237 { CODEC_ID_PNG, MKTAG('M', 'P', 'N', 'G') },
00238 { CODEC_ID_PNG, MKTAG('P', 'N', 'G', '1') },
00239 { CODEC_ID_CLJR, MKTAG('c', 'l', 'j', 'r') },
00240 { CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
00241 { CODEC_ID_RPZA, MKTAG('a', 'z', 'p', 'r') },
00242 { CODEC_ID_RPZA, MKTAG('R', 'P', 'Z', 'A') },
00243 { CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') },
00244 { CODEC_ID_SP5X, MKTAG('S', 'P', '5', '4') },
00245 { CODEC_ID_AURA, MKTAG('A', 'U', 'R', 'A') },
00246 { CODEC_ID_AURA2, MKTAG('A', 'U', 'R', '2') },
00247 { CODEC_ID_DPX, MKTAG('d', 'p', 'x', ' ') },
00248 { CODEC_ID_KGV1, MKTAG('K', 'G', 'V', '1') },
00249 { CODEC_ID_NONE, 0 }
00250 };
00251
00252 const AVCodecTag ff_codec_wav_tags[] = {
00253 { CODEC_ID_PCM_S16LE, 0x0001 },
00254 { CODEC_ID_PCM_U8, 0x0001 },
00255 { CODEC_ID_PCM_S24LE, 0x0001 },
00256 { CODEC_ID_PCM_S32LE, 0x0001 },
00257 { CODEC_ID_ADPCM_MS, 0x0002 },
00258 { CODEC_ID_PCM_F32LE, 0x0003 },
00259 { CODEC_ID_PCM_F64LE, 0x0003 },
00260 { CODEC_ID_PCM_ALAW, 0x0006 },
00261 { CODEC_ID_PCM_MULAW, 0x0007 },
00262 { CODEC_ID_WMAVOICE, 0x000A },
00263 { CODEC_ID_ADPCM_IMA_WAV, 0x0011 },
00264 { CODEC_ID_PCM_ZORK, 0x0011 },
00265 { CODEC_ID_ADPCM_YAMAHA, 0x0020 },
00266 { CODEC_ID_TRUESPEECH, 0x0022 },
00267 { CODEC_ID_GSM_MS, 0x0031 },
00268 { CODEC_ID_ADPCM_G726, 0x0045 },
00269 { CODEC_ID_MP2, 0x0050 },
00270 { CODEC_ID_MP3, 0x0055 },
00271 { CODEC_ID_AMR_NB, 0x0057 },
00272 { CODEC_ID_AMR_WB, 0x0058 },
00273 { CODEC_ID_ADPCM_IMA_DK4, 0x0061 },
00274 { CODEC_ID_ADPCM_IMA_DK3, 0x0062 },
00275 { CODEC_ID_ADPCM_IMA_WAV, 0x0069 },
00276 { CODEC_ID_VOXWARE, 0x0075 },
00277 { CODEC_ID_AAC, 0x00ff },
00278 { CODEC_ID_SIPR, 0x0130 },
00279 { CODEC_ID_WMAV1, 0x0160 },
00280 { CODEC_ID_WMAV2, 0x0161 },
00281 { CODEC_ID_WMAPRO, 0x0162 },
00282 { CODEC_ID_WMALOSSLESS, 0x0163 },
00283 { CODEC_ID_ADPCM_CT, 0x0200 },
00284 { CODEC_ID_ATRAC3, 0x0270 },
00285 { CODEC_ID_IMC, 0x0401 },
00286 { CODEC_ID_GSM_MS, 0x1500 },
00287 { CODEC_ID_TRUESPEECH, 0x1501 },
00288 { CODEC_ID_AC3, 0x2000 },
00289 { CODEC_ID_DTS, 0x2001 },
00290 { CODEC_ID_SONIC, 0x2048 },
00291 { CODEC_ID_SONIC_LS, 0x2048 },
00292 { CODEC_ID_PCM_MULAW, 0x6c75 },
00293 { CODEC_ID_AAC, 0x706d },
00294 { CODEC_ID_AAC, 0x4143 },
00295 { CODEC_ID_FLAC, 0xF1AC },
00296 { CODEC_ID_ADPCM_SWF, ('S'<<8)+'F' },
00297 { CODEC_ID_VORBIS, ('V'<<8)+'o' },
00298
00299
00300
00301 { CODEC_ID_PCM_S16LE, MKTAG('R', 'A', 'W', 'A') },
00302 { CODEC_ID_MP3, MKTAG('L', 'A', 'M', 'E') },
00303 { CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') },
00304 { CODEC_ID_NONE, 0 },
00305 };
00306
00307 #if CONFIG_MUXERS
00308 int64_t ff_start_tag(ByteIOContext *pb, const char *tag)
00309 {
00310 put_tag(pb, tag);
00311 put_le32(pb, 0);
00312 return url_ftell(pb);
00313 }
00314
00315 void ff_end_tag(ByteIOContext *pb, int64_t start)
00316 {
00317 int64_t pos;
00318
00319 pos = url_ftell(pb);
00320 url_fseek(pb, start - 4, SEEK_SET);
00321 put_le32(pb, (uint32_t)(pos - start));
00322 url_fseek(pb, pos, SEEK_SET);
00323 }
00324
00325
00326
00327 int ff_put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
00328 {
00329 int bps, blkalign, bytespersec;
00330 int hdrsize = 18;
00331 int waveformatextensible;
00332 uint8_t temp[256];
00333 uint8_t *riff_extradata= temp;
00334 uint8_t *riff_extradata_start= temp;
00335
00336 if(!enc->codec_tag || enc->codec_tag > 0xffff)
00337 return -1;
00338 waveformatextensible = (enc->channels > 2 && enc->channel_layout)
00339 || enc->sample_rate > 48000
00340 || av_get_bits_per_sample(enc->codec_id) > 16;
00341
00342 if (waveformatextensible) {
00343 put_le16(pb, 0xfffe);
00344 } else {
00345 put_le16(pb, enc->codec_tag);
00346 }
00347 put_le16(pb, enc->channels);
00348 put_le32(pb, enc->sample_rate);
00349 if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) {
00350 bps = 0;
00351 } else if (enc->codec_id == CODEC_ID_ADPCM_G726) {
00352 bps = 4;
00353 } else {
00354 if (!(bps = av_get_bits_per_sample(enc->codec_id)))
00355 bps = 16;
00356 }
00357 if(bps != enc->bits_per_coded_sample && enc->bits_per_coded_sample){
00358 av_log(enc, AV_LOG_WARNING, "requested bits_per_coded_sample (%d) and actually stored (%d) differ\n", enc->bits_per_coded_sample, bps);
00359 }
00360
00361 if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_AC3) {
00362 blkalign = enc->frame_size;
00363
00364 } else if (enc->codec_id == CODEC_ID_ADPCM_G726) {
00365 blkalign = 1;
00366 } else if (enc->block_align != 0) {
00367 blkalign = enc->block_align;
00368 } else
00369 blkalign = enc->channels*bps >> 3;
00370 if (enc->codec_id == CODEC_ID_PCM_U8 ||
00371 enc->codec_id == CODEC_ID_PCM_S24LE ||
00372 enc->codec_id == CODEC_ID_PCM_S32LE ||
00373 enc->codec_id == CODEC_ID_PCM_F32LE ||
00374 enc->codec_id == CODEC_ID_PCM_F64LE ||
00375 enc->codec_id == CODEC_ID_PCM_S16LE) {
00376 bytespersec = enc->sample_rate * blkalign;
00377 } else {
00378 bytespersec = enc->bit_rate / 8;
00379 }
00380 put_le32(pb, bytespersec);
00381 put_le16(pb, blkalign);
00382 put_le16(pb, bps);
00383 if (enc->codec_id == CODEC_ID_MP3) {
00384 hdrsize += 12;
00385 bytestream_put_le16(&riff_extradata, 1);
00386 bytestream_put_le32(&riff_extradata, 2);
00387 bytestream_put_le16(&riff_extradata, 1152);
00388 bytestream_put_le16(&riff_extradata, 1);
00389 bytestream_put_le16(&riff_extradata, 1393);
00390 } else if (enc->codec_id == CODEC_ID_MP2) {
00391 hdrsize += 22;
00392 bytestream_put_le16(&riff_extradata, 2);
00393 bytestream_put_le32(&riff_extradata, enc->bit_rate);
00394 bytestream_put_le16(&riff_extradata, enc->channels == 2 ? 1 : 8);
00395 bytestream_put_le16(&riff_extradata, 0);
00396 bytestream_put_le16(&riff_extradata, 1);
00397 bytestream_put_le16(&riff_extradata, 16);
00398 bytestream_put_le32(&riff_extradata, 0);
00399 bytestream_put_le32(&riff_extradata, 0);
00400 } else if (enc->codec_id == CODEC_ID_GSM_MS || enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
00401 hdrsize += 2;
00402 bytestream_put_le16(&riff_extradata, enc->frame_size);
00403 } else if(enc->extradata_size){
00404 riff_extradata_start= enc->extradata;
00405 riff_extradata= enc->extradata + enc->extradata_size;
00406 hdrsize += enc->extradata_size;
00407 } else if (!waveformatextensible){
00408 hdrsize -= 2;
00409 }
00410 if(waveformatextensible) {
00411 hdrsize += 22;
00412 put_le16(pb, riff_extradata - riff_extradata_start + 22);
00413 put_le16(pb, enc->bits_per_coded_sample);
00414 put_le32(pb, enc->channel_layout);
00415 put_le32(pb, enc->codec_tag);
00416 put_le32(pb, 0x00100000);
00417 put_le32(pb, 0xAA000080);
00418 put_le32(pb, 0x719B3800);
00419 } else if(riff_extradata - riff_extradata_start) {
00420 put_le16(pb, riff_extradata - riff_extradata_start);
00421 }
00422 put_buffer(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
00423 if(hdrsize&1){
00424 hdrsize++;
00425 put_byte(pb, 0);
00426 }
00427
00428 return hdrsize;
00429 }
00430
00431
00432 void ff_put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
00433 {
00434 put_le32(pb, 40 + enc->extradata_size);
00435 put_le32(pb, enc->width);
00436
00437 put_le32(pb, enc->codec_tag ? enc->height : -enc->height);
00438 put_le16(pb, 1);
00439
00440 put_le16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24);
00441
00442 put_le32(pb, enc->codec_tag);
00443 put_le32(pb, enc->width * enc->height * 3);
00444 put_le32(pb, 0);
00445 put_le32(pb, 0);
00446 put_le32(pb, 0);
00447 put_le32(pb, 0);
00448
00449 put_buffer(pb, enc->extradata, enc->extradata_size);
00450
00451 if (!for_asf && enc->extradata_size & 1)
00452 put_byte(pb, 0);
00453 }
00454 #endif //CONFIG_MUXERS
00455
00456 #if CONFIG_DEMUXERS
00457
00458
00459
00460
00461
00462
00463
00464 void ff_get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size)
00465 {
00466 int id;
00467
00468 id = get_le16(pb);
00469 codec->codec_type = AVMEDIA_TYPE_AUDIO;
00470 codec->codec_tag = id;
00471 codec->channels = get_le16(pb);
00472 codec->sample_rate = get_le32(pb);
00473 codec->bit_rate = get_le32(pb) * 8;
00474 codec->block_align = get_le16(pb);
00475 if (size == 14) {
00476 codec->bits_per_coded_sample = 8;
00477 }else
00478 codec->bits_per_coded_sample = get_le16(pb);
00479 if (size >= 18) {
00480 int cbSize = get_le16(pb);
00481 size -= 18;
00482 cbSize = FFMIN(size, cbSize);
00483 if (cbSize >= 22 && id == 0xfffe) {
00484 codec->bits_per_coded_sample = get_le16(pb);
00485 codec->channel_layout = get_le32(pb);
00486 id = get_le32(pb);
00487 url_fskip(pb, 12);
00488 cbSize -= 22;
00489 size -= 22;
00490 }
00491 codec->extradata_size = cbSize;
00492 if (cbSize > 0) {
00493 codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
00494 get_buffer(pb, codec->extradata, codec->extradata_size);
00495 size -= cbSize;
00496 }
00497
00498
00499 if (size > 0)
00500 url_fskip(pb, size);
00501 }
00502 codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
00503 }
00504
00505
00506 enum CodecID ff_wav_codec_get_id(unsigned int tag, int bps)
00507 {
00508 enum CodecID id;
00509 id = ff_codec_get_id(ff_codec_wav_tags, tag);
00510 if (id <= 0)
00511 return id;
00512
00513 if (id == CODEC_ID_PCM_S16LE && bps == 8)
00514 id = CODEC_ID_PCM_U8;
00515 if (id == CODEC_ID_PCM_S16LE && bps == 24)
00516 id = CODEC_ID_PCM_S24LE;
00517 if (id == CODEC_ID_PCM_S16LE && bps == 32)
00518 id = CODEC_ID_PCM_S32LE;
00519 if (id == CODEC_ID_PCM_F32LE && bps == 64)
00520 id = CODEC_ID_PCM_F64LE;
00521 if (id == CODEC_ID_ADPCM_IMA_WAV && bps == 8)
00522 id = CODEC_ID_PCM_ZORK;
00523 return id;
00524 }
00525 #endif // CONFIG_DEMUXERS
00526
00527 void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale)
00528 {
00529 int gcd;
00530
00531 *au_ssize= stream->block_align;
00532 if(stream->frame_size && stream->sample_rate){
00533 *au_scale=stream->frame_size;
00534 *au_rate= stream->sample_rate;
00535 }else if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
00536 stream->codec_type == AVMEDIA_TYPE_SUBTITLE){
00537 *au_scale= stream->time_base.num;
00538 *au_rate = stream->time_base.den;
00539 }else{
00540 *au_scale= stream->block_align ? stream->block_align*8 : 8;
00541 *au_rate = stream->bit_rate ? stream->bit_rate : 8*stream->sample_rate;
00542 }
00543 gcd= av_gcd(*au_scale, *au_rate);
00544 *au_scale /= gcd;
00545 *au_rate /= gcd;
00546 }