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 #include "libavutil/avassert.h"
00029
00030
00031
00032
00033
00034
00035 const AVCodecTag ff_codec_bmp_tags[] = {
00036 { AV_CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
00037 { AV_CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
00038 { AV_CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
00039 { AV_CODEC_ID_H264, MKTAG('x', '2', '6', '4') },
00040 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
00041 { AV_CODEC_ID_H264, MKTAG('D', 'A', 'V', 'C') },
00042 { AV_CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') },
00043 { AV_CODEC_ID_H264, MKTAG('Q', '2', '6', '4') },
00044 { AV_CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
00045 { AV_CODEC_ID_H263, MKTAG('X', '2', '6', '3') },
00046 { AV_CODEC_ID_H263, MKTAG('T', '2', '6', '3') },
00047 { AV_CODEC_ID_H263, MKTAG('L', '2', '6', '3') },
00048 { AV_CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') },
00049 { AV_CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') },
00050 { AV_CODEC_ID_H263, MKTAG('M', '2', '6', '3') },
00051 { AV_CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
00052 { AV_CODEC_ID_H263I, MKTAG('I', '2', '6', '3') },
00053 { AV_CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
00054 { AV_CODEC_ID_H263, MKTAG('U', '2', '6', '3') },
00055 { AV_CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
00056 { AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
00057 { AV_CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
00058 { AV_CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
00059 { AV_CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
00060 { AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
00061 { AV_CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 0 ) },
00062 { AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') },
00063 { AV_CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') },
00064 { AV_CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
00065 { AV_CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') },
00066 { AV_CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') },
00067 { AV_CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') },
00068 { AV_CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
00069 { AV_CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') },
00070 { AV_CODEC_ID_MPEG4, MKTAG('W', 'A', 'W', 'V') },
00071 { AV_CODEC_ID_MPEG4, MKTAG('F', 'F', 'D', 'S') },
00072 { AV_CODEC_ID_MPEG4, MKTAG('F', 'V', 'F', 'W') },
00073 { AV_CODEC_ID_MPEG4, MKTAG('D', 'C', 'O', 'D') },
00074 { AV_CODEC_ID_MPEG4, MKTAG('M', 'V', 'X', 'M') },
00075 { AV_CODEC_ID_MPEG4, MKTAG('P', 'M', '4', 'V') },
00076 { AV_CODEC_ID_MPEG4, MKTAG('S', 'M', 'P', '4') },
00077 { AV_CODEC_ID_MPEG4, MKTAG('D', 'X', 'G', 'M') },
00078 { AV_CODEC_ID_MPEG4, MKTAG('V', 'I', 'D', 'M') },
00079 { AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'T', '3') },
00080 { AV_CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'X') },
00081 { AV_CODEC_ID_MPEG4, MKTAG('H', 'D', 'X', '4') },
00082 { AV_CODEC_ID_MPEG4, MKTAG('D', 'M', 'K', '2') },
00083 { AV_CODEC_ID_MPEG4, MKTAG('D', 'I', 'G', 'I') },
00084 { AV_CODEC_ID_MPEG4, MKTAG('I', 'N', 'M', 'C') },
00085 { AV_CODEC_ID_MPEG4, MKTAG('E', 'P', 'H', 'V') },
00086 { AV_CODEC_ID_MPEG4, MKTAG('E', 'M', '4', 'A') },
00087 { AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'C', 'C') },
00088 { AV_CODEC_ID_MPEG4, MKTAG('S', 'N', '4', '0') },
00089 { AV_CODEC_ID_MPEG4, MKTAG('V', 'S', 'P', 'X') },
00090 { AV_CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') },
00091 { AV_CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') },
00092 { AV_CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') },
00093 { AV_CODEC_ID_MPEG4, MKTAG('S', 'M', '4', 'V') },
00094 { AV_CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'X') },
00095 { AV_CODEC_ID_MPEG4, MKTAG('D', 'r', 'e', 'X') },
00096 { AV_CODEC_ID_MPEG4, MKTAG('Q', 'M', 'P', '4') },
00097 { AV_CODEC_ID_MPEG4, MKTAG('P', 'L', 'V', '1') },
00098 { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
00099 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') },
00100 { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') },
00101 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') },
00102 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') },
00103 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') },
00104 { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'V', 'X', '3') },
00105 { AV_CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') },
00106 { AV_CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') },
00107 { AV_CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') },
00108 { AV_CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') },
00109 { AV_CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') },
00110 { AV_CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') },
00111 { AV_CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', '4', '1') },
00112 { AV_CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') },
00113 { AV_CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') },
00114 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') },
00115 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') },
00116 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
00117 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') },
00118 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') },
00119 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') },
00120 { AV_CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') },
00121 { AV_CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') },
00122 { AV_CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', '5') },
00123 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') },
00124 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') },
00125 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
00126 { AV_CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'i', 's') },
00127 { AV_CODEC_ID_DVVIDEO, MKTAG('p', 'd', 'v', 'c') },
00128 { AV_CODEC_ID_DVVIDEO, MKTAG('S', 'L', '2', '5') },
00129 { AV_CODEC_ID_DVVIDEO, MKTAG('S', 'L', 'D', 'V') },
00130 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') },
00131 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') },
00132 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') },
00133 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') },
00134 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') },
00135 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('P', 'I', 'M', '2') },
00136 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') },
00137 { AV_CODEC_ID_MPEG1VIDEO, MKTAG( 1 , 0 , 0 , 16) },
00138 { AV_CODEC_ID_MPEG2VIDEO, MKTAG( 2 , 0 , 0 , 16) },
00139 { AV_CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 16) },
00140 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') },
00141 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') },
00142 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('L', 'M', 'P', '2') },
00143 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') },
00144 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') },
00145 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') },
00146 { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', 'v') },
00147 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('B', 'W', '1', '0') },
00148 { AV_CODEC_ID_MPEG1VIDEO, MKTAG('X', 'M', 'P', 'G') },
00149 { AV_CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') },
00150 { AV_CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') },
00151 { AV_CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') },
00152 { AV_CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') },
00153 { AV_CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
00154 { AV_CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') },
00155 { AV_CODEC_ID_JPEGLS, MKTAG('M', 'J', 'L', 'S') },
00156 { AV_CODEC_ID_JPEGLS, MKTAG('M', 'J', 'P', 'G') },
00157 { AV_CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') },
00158 { AV_CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
00159 { AV_CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') },
00160 { AV_CODEC_ID_AVRN, MKTAG('A', 'V', 'R', 'n') },
00161 { AV_CODEC_ID_MJPEG, MKTAG('A', 'C', 'D', 'V') },
00162 { AV_CODEC_ID_MJPEG, MKTAG('Q', 'I', 'V', 'G') },
00163 { AV_CODEC_ID_MJPEG, MKTAG('S', 'L', 'M', 'J') },
00164 { AV_CODEC_ID_MJPEG, MKTAG('C', 'J', 'P', 'G') },
00165 { AV_CODEC_ID_MJPEG, MKTAG('I', 'J', 'L', 'V') },
00166 { AV_CODEC_ID_MJPEG, MKTAG('M', 'V', 'J', 'P') },
00167 { AV_CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '1') },
00168 { AV_CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') },
00169 { AV_CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') },
00170 { AV_CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') },
00171 { AV_CODEC_ID_MJPEG, MKTAG('M', 'M', 'J', 'P') },
00172 { AV_CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
00173 { AV_CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
00174 { AV_CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
00175 { AV_CODEC_ID_RAWVIDEO, MKTAG( 0 , 0 , 0 , 0 ) },
00176 { AV_CODEC_ID_RAWVIDEO, MKTAG( 3 , 0 , 0 , 0 ) },
00177 { AV_CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') },
00178 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') },
00179 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') },
00180 { AV_CODEC_ID_RAWVIDEO, MKTAG('V', '4', '2', '2') },
00181 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'N', 'V') },
00182 { AV_CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'V') },
00183 { AV_CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'Y') },
00184 { AV_CODEC_ID_RAWVIDEO, MKTAG('u', 'y', 'v', '1') },
00185 { AV_CODEC_ID_RAWVIDEO, MKTAG('2', 'V', 'u', '1') },
00186 { AV_CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') },
00187 { AV_CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') },
00188 { AV_CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', '2') },
00189 { AV_CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') },
00190 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') },
00191 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '6') },
00192 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '2', '4') },
00193 { AV_CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
00194 { AV_CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') },
00195 { AV_CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
00196 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
00197 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '8', ' ', ' ') },
00198 { AV_CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
00199 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') },
00200 { AV_CODEC_ID_RAWVIDEO, MKTAG('V', 'D', 'T', 'Z') },
00201 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', '1') },
00202 { AV_CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '1', '2') },
00203 { AV_CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '2', '1') },
00204 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', 'B') },
00205 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', 'B') },
00206 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'V', '9') },
00207 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') },
00208 { AV_CODEC_ID_RAWVIDEO, MKTAG('a', 'u', 'v', '2') },
00209 { AV_CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'Y', 'U') },
00210 { AV_CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') },
00211 { AV_CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') },
00212 { AV_CODEC_ID_R210, MKTAG('r', '2', '1', '0') },
00213 { AV_CODEC_ID_V210, MKTAG('v', '2', '1', '0') },
00214 { AV_CODEC_ID_V308, MKTAG('v', '3', '0', '8') },
00215 { AV_CODEC_ID_V408, MKTAG('v', '4', '0', '8') },
00216 { AV_CODEC_ID_AYUV, MKTAG('A', 'Y', 'U', 'V') },
00217 { AV_CODEC_ID_V410, MKTAG('v', '4', '1', '0') },
00218 { AV_CODEC_ID_YUV4, MKTAG('y', 'u', 'v', '4') },
00219 { AV_CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },
00220 { AV_CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
00221 { AV_CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') },
00222 { AV_CODEC_ID_INDEO5, MKTAG('I', 'V', '5', '0') },
00223 { AV_CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
00224 { AV_CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
00225 { AV_CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
00226 { AV_CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
00227 { AV_CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
00228 { AV_CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
00229 { AV_CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') },
00230 { AV_CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') },
00231 { AV_CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') },
00232 { AV_CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
00233 { AV_CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
00234 { AV_CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
00235 { AV_CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
00236 { AV_CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') },
00237 { AV_CODEC_ID_MIMIC, MKTAG('L', 'M', '2', '0') },
00238 { AV_CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') },
00239 { AV_CODEC_ID_MSRLE, MKTAG( 1 , 0 , 0 , 0 ) },
00240 { AV_CODEC_ID_MSRLE, MKTAG( 2 , 0 , 0 , 0 ) },
00241 { AV_CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') },
00242 { AV_CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') },
00243 { AV_CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') },
00244 { AV_CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') },
00245 { AV_CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') },
00246 { AV_CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') },
00247 { AV_CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') },
00248 { AV_CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') },
00249 { AV_CODEC_ID_TRUEMOTION1, MKTAG('P', 'V', 'E', 'Z') },
00250 { AV_CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') },
00251 { AV_CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') },
00252 { AV_CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') },
00253 { AV_CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
00254 { AV_CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
00255 { AV_CODEC_ID_FLV1, MKTAG('S', '2', '6', '3') },
00256 { AV_CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') },
00257 { AV_CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
00258 { AV_CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
00259 { AV_CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
00260 { AV_CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
00261 { AV_CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') },
00262 { AV_CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') },
00263 { AV_CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
00264 { AV_CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
00265 { AV_CODEC_ID_WMV3IMAGE, MKTAG('W', 'M', 'V', 'P') },
00266 { AV_CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
00267 { AV_CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
00268 { AV_CODEC_ID_VC1IMAGE, MKTAG('W', 'V', 'P', '2') },
00269 { AV_CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
00270 { AV_CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
00271 { AV_CODEC_ID_WNV1, MKTAG('Y', 'U', 'V', '8') },
00272 { AV_CODEC_ID_AASC, MKTAG('A', 'A', 'S', '4') },
00273 { AV_CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
00274 { AV_CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') },
00275 { AV_CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') },
00276 { AV_CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') },
00277 { AV_CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') },
00278 { AV_CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') },
00279 { AV_CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') },
00280 { AV_CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') },
00281 { AV_CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') },
00282 { AV_CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') },
00283 { AV_CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') },
00284 { AV_CODEC_ID_JPEG2000, MKTAG('L', 'J', '2', 'C') },
00285 { AV_CODEC_ID_JPEG2000, MKTAG('L', 'J', '2', 'K') },
00286 { AV_CODEC_ID_JPEG2000, MKTAG('I', 'P', 'J', '2') },
00287 { AV_CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') },
00288 { AV_CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') },
00289 { AV_CODEC_ID_PNG, MKTAG('M', 'P', 'N', 'G') },
00290 { AV_CODEC_ID_PNG, MKTAG('P', 'N', 'G', '1') },
00291 { AV_CODEC_ID_CLJR, MKTAG('C', 'L', 'J', 'R') },
00292 { AV_CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') },
00293 { AV_CODEC_ID_RPZA, MKTAG('a', 'z', 'p', 'r') },
00294 { AV_CODEC_ID_RPZA, MKTAG('R', 'P', 'Z', 'A') },
00295 { AV_CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') },
00296 { AV_CODEC_ID_SP5X, MKTAG('S', 'P', '5', '4') },
00297 { AV_CODEC_ID_AURA, MKTAG('A', 'U', 'R', 'A') },
00298 { AV_CODEC_ID_AURA2, MKTAG('A', 'U', 'R', '2') },
00299 { AV_CODEC_ID_DPX, MKTAG('d', 'p', 'x', ' ') },
00300 { AV_CODEC_ID_KGV1, MKTAG('K', 'G', 'V', '1') },
00301 { AV_CODEC_ID_LAGARITH, MKTAG('L', 'A', 'G', 'S') },
00302 { AV_CODEC_ID_G2M, MKTAG('G', '2', 'M', '2') },
00303 { AV_CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') },
00304 { AV_CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') },
00305 { AV_CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') },
00306 { AV_CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'A') },
00307 { AV_CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'G') },
00308 { AV_CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '0') },
00309 { AV_CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '2') },
00310 { AV_CODEC_ID_VBLE, MKTAG('V', 'B', 'L', 'E') },
00311 { AV_CODEC_ID_ESCAPE130, MKTAG('E', '1', '3', '0') },
00312 { AV_CODEC_ID_DXTORY, MKTAG('x', 't', 'o', 'r') },
00313 { AV_CODEC_ID_ZEROCODEC, MKTAG('Z', 'E', 'C', 'O') },
00314 { AV_CODEC_ID_Y41P, MKTAG('Y', '4', '1', 'P') },
00315 { AV_CODEC_ID_FLIC, MKTAG('A', 'F', 'L', 'C') },
00316 { AV_CODEC_ID_EXR, MKTAG('e', 'x', 'r', ' ') },
00317 { AV_CODEC_ID_MSS1, MKTAG('M', 'S', 'S', '1') },
00318 { AV_CODEC_ID_MSA1, MKTAG('M', 'S', 'A', '1') },
00319 { AV_CODEC_ID_TSCC2, MKTAG('T', 'S', 'C', '2') },
00320 { AV_CODEC_ID_MTS2, MKTAG('M', 'T', 'S', '2') },
00321 { AV_CODEC_ID_CLLC, MKTAG('C', 'L', 'L', 'C') },
00322 { AV_CODEC_ID_MSS2, MKTAG('M', 'S', 'S', '2') },
00323 { AV_CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') },
00324 { AV_CODEC_ID_NONE, 0 }
00325 };
00326
00327 const AVCodecTag ff_codec_wav_tags[] = {
00328 { AV_CODEC_ID_PCM_S16LE, 0x0001 },
00329 { AV_CODEC_ID_PCM_U8, 0x0001 },
00330 { AV_CODEC_ID_PCM_S24LE, 0x0001 },
00331 { AV_CODEC_ID_PCM_S32LE, 0x0001 },
00332 { AV_CODEC_ID_ADPCM_MS, 0x0002 },
00333 { AV_CODEC_ID_PCM_F32LE, 0x0003 },
00334 { AV_CODEC_ID_PCM_F64LE, 0x0003 },
00335 { AV_CODEC_ID_PCM_ALAW, 0x0006 },
00336 { AV_CODEC_ID_PCM_MULAW, 0x0007 },
00337 { AV_CODEC_ID_WMAVOICE, 0x000A },
00338 { AV_CODEC_ID_ADPCM_IMA_WAV, 0x0011 },
00339 { AV_CODEC_ID_PCM_ZORK, 0x0011 },
00340 { AV_CODEC_ID_ADPCM_YAMAHA, 0x0020 },
00341 { AV_CODEC_ID_TRUESPEECH, 0x0022 },
00342 { AV_CODEC_ID_GSM_MS, 0x0031 },
00343 { AV_CODEC_ID_AMR_NB, 0x0038 },
00344 { AV_CODEC_ID_G723_1, 0x0042 },
00345 { AV_CODEC_ID_ADPCM_G726, 0x0045 },
00346 { AV_CODEC_ID_MP2, 0x0050 },
00347 { AV_CODEC_ID_MP3, 0x0055 },
00348 { AV_CODEC_ID_AMR_NB, 0x0057 },
00349 { AV_CODEC_ID_AMR_WB, 0x0058 },
00350 { AV_CODEC_ID_ADPCM_IMA_DK4, 0x0061 },
00351 { AV_CODEC_ID_ADPCM_IMA_DK3, 0x0062 },
00352 { AV_CODEC_ID_ADPCM_IMA_WAV, 0x0069 },
00353 { AV_CODEC_ID_VOXWARE, 0x0075 },
00354 { AV_CODEC_ID_AAC, 0x00ff },
00355 { AV_CODEC_ID_SIPR, 0x0130 },
00356 { AV_CODEC_ID_WMAV1, 0x0160 },
00357 { AV_CODEC_ID_WMAV2, 0x0161 },
00358 { AV_CODEC_ID_WMAPRO, 0x0162 },
00359 { AV_CODEC_ID_WMALOSSLESS, 0x0163 },
00360 { AV_CODEC_ID_ADPCM_CT, 0x0200 },
00361 { AV_CODEC_ID_ATRAC3, 0x0270 },
00362 { AV_CODEC_ID_ADPCM_G722, 0x028F },
00363 { AV_CODEC_ID_IMC, 0x0401 },
00364 { AV_CODEC_ID_IAC, 0x0402 },
00365 { AV_CODEC_ID_GSM_MS, 0x1500 },
00366 { AV_CODEC_ID_TRUESPEECH, 0x1501 },
00367 { AV_CODEC_ID_AAC, 0x1600 },
00368 { AV_CODEC_ID_AAC_LATM, 0x1602 },
00369 { AV_CODEC_ID_AC3, 0x2000 },
00370 { AV_CODEC_ID_DTS, 0x2001 },
00371 { AV_CODEC_ID_SONIC, 0x2048 },
00372 { AV_CODEC_ID_SONIC_LS, 0x2048 },
00373 { AV_CODEC_ID_PCM_MULAW, 0x6c75 },
00374 { AV_CODEC_ID_AAC, 0x706d },
00375 { AV_CODEC_ID_AAC, 0x4143 },
00376 { AV_CODEC_ID_SPEEX, 0xA109 },
00377 { AV_CODEC_ID_FLAC, 0xF1AC },
00378 { AV_CODEC_ID_ADPCM_SWF, ('S'<<8)+'F' },
00379 { AV_CODEC_ID_VORBIS, ('V'<<8)+'o' },
00380
00381
00382
00383 { AV_CODEC_ID_PCM_S16LE, MKTAG('R', 'A', 'W', 'A') },
00384 { AV_CODEC_ID_MP3, MKTAG('L', 'A', 'M', 'E') },
00385 { AV_CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') },
00386 { AV_CODEC_ID_NONE, 0 },
00387 };
00388
00389 const AVCodecGuid ff_codec_wav_guids[] = {
00390 {AV_CODEC_ID_AC3, {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
00391 {AV_CODEC_ID_ATRAC3P, {0xBF,0xAA,0x23,0xE9,0x58,0xCB,0x71,0x44,0xA1,0x19,0xFF,0xFA,0x01,0xE4,0xCE,0x62}},
00392 {AV_CODEC_ID_EAC3, {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}},
00393 {AV_CODEC_ID_MP2, {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
00394 {AV_CODEC_ID_NONE}
00395 };
00396
00397 const AVMetadataConv ff_riff_info_conv[] = {
00398 { "IART", "artist" },
00399 { "ICMT", "comment" },
00400 { "ICOP", "copyright" },
00401 { "ICRD", "date" },
00402 { "IGNR", "genre" },
00403 { "ILNG", "language" },
00404 { "INAM", "title" },
00405 { "IPRD", "album" },
00406 { "IPRT", "track" },
00407 { "ISFT", "encoder" },
00408 { "ISMP", "timecode" },
00409 { "ITCH", "encoded_by"},
00410 { 0 },
00411 };
00412
00413 const char ff_riff_tags[][5] = {
00414 "IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI",
00415 "IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD",
00416 "IPRT", "ISBJ", "ISFT", "ISHP", "ISMP", "ISRC", "ISRF", "ITCH",
00417 {0}
00418 };
00419
00420 #if CONFIG_MUXERS
00421 int64_t ff_start_tag(AVIOContext *pb, const char *tag)
00422 {
00423 ffio_wfourcc(pb, tag);
00424 avio_wl32(pb, 0);
00425 return avio_tell(pb);
00426 }
00427
00428 void ff_end_tag(AVIOContext *pb, int64_t start)
00429 {
00430 int64_t pos;
00431
00432 pos = avio_tell(pb);
00433 avio_seek(pb, start - 4, SEEK_SET);
00434 avio_wl32(pb, (uint32_t)(pos - start));
00435 avio_seek(pb, pos, SEEK_SET);
00436 }
00437
00438
00439
00440 int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
00441 {
00442 int bps, blkalign, bytespersec, frame_size;
00443 int hdrsize = 18;
00444 int waveformatextensible;
00445 uint8_t temp[256];
00446 uint8_t *riff_extradata= temp;
00447 uint8_t *riff_extradata_start= temp;
00448
00449 if(!enc->codec_tag || enc->codec_tag > 0xffff)
00450 return -1;
00451
00452
00453
00454
00455 frame_size = av_get_audio_frame_duration(enc, 0);
00456 if (!frame_size)
00457 frame_size = enc->frame_size;
00458
00459 waveformatextensible = (enc->channels > 2 && enc->channel_layout)
00460 || enc->sample_rate > 48000
00461 || av_get_bits_per_sample(enc->codec_id) > 16;
00462
00463 if (waveformatextensible) {
00464 avio_wl16(pb, 0xfffe);
00465 } else {
00466 avio_wl16(pb, enc->codec_tag);
00467 }
00468 avio_wl16(pb, enc->channels);
00469 avio_wl32(pb, enc->sample_rate);
00470 if (enc->codec_id == CODEC_ID_ATRAC3 ||
00471 enc->codec_id == CODEC_ID_G723_1 ||
00472 enc->codec_id == CODEC_ID_GSM_MS ||
00473 enc->codec_id == CODEC_ID_MP2 ||
00474 enc->codec_id == CODEC_ID_MP3) {
00475 bps = 0;
00476 } else {
00477 if (!(bps = av_get_bits_per_sample(enc->codec_id))) {
00478 if (enc->bits_per_coded_sample)
00479 bps = enc->bits_per_coded_sample;
00480 else
00481 bps = 16;
00482 }
00483 }
00484 if(bps != enc->bits_per_coded_sample && enc->bits_per_coded_sample){
00485 av_log(enc, AV_LOG_WARNING, "requested bits_per_coded_sample (%d) and actually stored (%d) differ\n", enc->bits_per_coded_sample, bps);
00486 }
00487
00488 if (enc->codec_id == AV_CODEC_ID_MP2 || enc->codec_id == AV_CODEC_ID_MP3) {
00489
00490
00491 blkalign = frame_size;
00492
00493 } else if (enc->codec_id == AV_CODEC_ID_AC3) {
00494 blkalign = 3840;
00495 } else if (enc->codec_id == AV_CODEC_ID_AAC) {
00496 blkalign = 768 * enc->channels;
00497 } else if (enc->codec_id == AV_CODEC_ID_G723_1) {
00498 blkalign = 24;
00499 } else if (enc->block_align != 0) {
00500 blkalign = enc->block_align;
00501 } else
00502 blkalign = bps * enc->channels / av_gcd(8, bps);
00503 if (enc->codec_id == AV_CODEC_ID_PCM_U8 ||
00504 enc->codec_id == AV_CODEC_ID_PCM_S24LE ||
00505 enc->codec_id == AV_CODEC_ID_PCM_S32LE ||
00506 enc->codec_id == AV_CODEC_ID_PCM_F32LE ||
00507 enc->codec_id == AV_CODEC_ID_PCM_F64LE ||
00508 enc->codec_id == AV_CODEC_ID_PCM_S16LE) {
00509 bytespersec = enc->sample_rate * blkalign;
00510 } else if (enc->codec_id == AV_CODEC_ID_G723_1) {
00511 bytespersec = 800;
00512 } else {
00513 bytespersec = enc->bit_rate / 8;
00514 }
00515 avio_wl32(pb, bytespersec);
00516 avio_wl16(pb, blkalign);
00517 avio_wl16(pb, bps);
00518 if (enc->codec_id == AV_CODEC_ID_MP3) {
00519 hdrsize += 12;
00520 bytestream_put_le16(&riff_extradata, 1);
00521 bytestream_put_le32(&riff_extradata, 2);
00522 bytestream_put_le16(&riff_extradata, 1152);
00523 bytestream_put_le16(&riff_extradata, 1);
00524 bytestream_put_le16(&riff_extradata, 1393);
00525 } else if (enc->codec_id == AV_CODEC_ID_MP2) {
00526 hdrsize += 22;
00527 bytestream_put_le16(&riff_extradata, 2);
00528 bytestream_put_le32(&riff_extradata, enc->bit_rate);
00529 bytestream_put_le16(&riff_extradata, enc->channels == 2 ? 1 : 8);
00530 bytestream_put_le16(&riff_extradata, 0);
00531 bytestream_put_le16(&riff_extradata, 1);
00532 bytestream_put_le16(&riff_extradata, 16);
00533 bytestream_put_le32(&riff_extradata, 0);
00534 bytestream_put_le32(&riff_extradata, 0);
00535 } else if (enc->codec_id == AV_CODEC_ID_G723_1) {
00536 hdrsize += 20;
00537 bytestream_put_le32(&riff_extradata, 0x9ace0002);
00538 bytestream_put_le32(&riff_extradata, 0xaea2f732);
00539 bytestream_put_le16(&riff_extradata, 0xacde);
00540 } else if (enc->codec_id == AV_CODEC_ID_GSM_MS || enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
00541 hdrsize += 2;
00542 bytestream_put_le16(&riff_extradata, frame_size);
00543 } else if(enc->extradata_size){
00544 riff_extradata_start= enc->extradata;
00545 riff_extradata= enc->extradata + enc->extradata_size;
00546 hdrsize += enc->extradata_size;
00547 }
00548 if(waveformatextensible) {
00549 hdrsize += 22;
00550 avio_wl16(pb, riff_extradata - riff_extradata_start + 22);
00551 avio_wl16(pb, bps);
00552 avio_wl32(pb, enc->channel_layout);
00553 avio_wl32(pb, enc->codec_tag);
00554 avio_wl32(pb, 0x00100000);
00555 avio_wl32(pb, 0xAA000080);
00556 avio_wl32(pb, 0x719B3800);
00557 } else {
00558 avio_wl16(pb, riff_extradata - riff_extradata_start);
00559 }
00560 avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
00561 if(hdrsize&1){
00562 hdrsize++;
00563 avio_w8(pb, 0);
00564 }
00565
00566 return hdrsize;
00567 }
00568
00569
00570 void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
00571 {
00572 avio_wl32(pb, 40 + enc->extradata_size);
00573 avio_wl32(pb, enc->width);
00574
00575 avio_wl32(pb, enc->codec_tag ? enc->height : -enc->height);
00576 avio_wl16(pb, 1);
00577
00578 avio_wl16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24);
00579
00580 avio_wl32(pb, enc->codec_tag);
00581 avio_wl32(pb, (enc->width * enc->height * (enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24)+7) / 8);
00582 avio_wl32(pb, 0);
00583 avio_wl32(pb, 0);
00584 avio_wl32(pb, 0);
00585 avio_wl32(pb, 0);
00586
00587 avio_write(pb, enc->extradata, enc->extradata_size);
00588
00589 if (!for_asf && enc->extradata_size & 1)
00590 avio_w8(pb, 0);
00591 }
00592 #endif //CONFIG_MUXERS
00593
00594 #if CONFIG_DEMUXERS
00595
00596
00597
00598
00599
00600
00601
00602 int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
00603 {
00604 int id;
00605
00606 id = avio_rl16(pb);
00607 codec->codec_type = AVMEDIA_TYPE_AUDIO;
00608 codec->channels = avio_rl16(pb);
00609 codec->sample_rate = avio_rl32(pb);
00610 codec->bit_rate = avio_rl32(pb) * 8;
00611 codec->block_align = avio_rl16(pb);
00612 if (size == 14) {
00613 codec->bits_per_coded_sample = 8;
00614 }else
00615 codec->bits_per_coded_sample = avio_rl16(pb);
00616 if (id == 0xFFFE) {
00617 codec->codec_tag = 0;
00618 } else {
00619 codec->codec_tag = id;
00620 codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
00621 }
00622 if (size >= 18) {
00623 int cbSize = avio_rl16(pb);
00624 size -= 18;
00625 cbSize = FFMIN(size, cbSize);
00626 if (cbSize >= 22 && id == 0xfffe) {
00627 ff_asf_guid subformat;
00628 int bps = avio_rl16(pb);
00629 if (bps)
00630 codec->bits_per_coded_sample = bps;
00631 codec->channel_layout = avio_rl32(pb);
00632 ff_get_guid(pb, &subformat);
00633 if (!memcmp(subformat + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
00634 codec->codec_tag = AV_RL32(subformat);
00635 codec->codec_id = ff_wav_codec_get_id(codec->codec_tag, codec->bits_per_coded_sample);
00636 } else {
00637 codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
00638 if (!codec->codec_id)
00639 av_log(codec, AV_LOG_WARNING, "unknown subformat:"FF_PRI_GUID"\n", FF_ARG_GUID(subformat));
00640 }
00641 cbSize -= 22;
00642 size -= 22;
00643 }
00644 codec->extradata_size = cbSize;
00645 if (cbSize > 0) {
00646 av_free(codec->extradata);
00647 codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
00648 if (!codec->extradata)
00649 return AVERROR(ENOMEM);
00650 avio_read(pb, codec->extradata, codec->extradata_size);
00651 size -= cbSize;
00652 }
00653
00654
00655 if (size > 0)
00656 avio_skip(pb, size);
00657 }
00658 if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {
00659
00660 codec->channels = 0;
00661 codec->sample_rate = 0;
00662 }
00663
00664 if (codec->codec_id == AV_CODEC_ID_ADPCM_G726)
00665 codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate;
00666
00667 return 0;
00668 }
00669
00670
00671 enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps)
00672 {
00673 enum AVCodecID id;
00674 id = ff_codec_get_id(ff_codec_wav_tags, tag);
00675 if (id <= 0)
00676 return id;
00677
00678 if (id == AV_CODEC_ID_PCM_S16LE && bps == 8)
00679 id = AV_CODEC_ID_PCM_U8;
00680 if (id == AV_CODEC_ID_PCM_S16LE && bps == 24)
00681 id = AV_CODEC_ID_PCM_S24LE;
00682 if (id == AV_CODEC_ID_PCM_S16LE && bps == 32)
00683 id = AV_CODEC_ID_PCM_S32LE;
00684 if (id == AV_CODEC_ID_PCM_F32LE && bps == 64)
00685 id = AV_CODEC_ID_PCM_F64LE;
00686 if (id == AV_CODEC_ID_ADPCM_IMA_WAV && bps == 8)
00687 id = AV_CODEC_ID_PCM_ZORK;
00688 return id;
00689 }
00690
00691 int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize)
00692 {
00693 int tag1;
00694 if(esize) *esize = avio_rl32(pb);
00695 else avio_rl32(pb);
00696 st->codec->width = avio_rl32(pb);
00697 st->codec->height = (int32_t)avio_rl32(pb);
00698 avio_rl16(pb);
00699 st->codec->bits_per_coded_sample= avio_rl16(pb);
00700 tag1 = avio_rl32(pb);
00701 avio_rl32(pb);
00702 avio_rl32(pb);
00703 avio_rl32(pb);
00704 avio_rl32(pb);
00705 avio_rl32(pb);
00706 return tag1;
00707 }
00708 #endif // CONFIG_DEMUXERS
00709
00710 void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale)
00711 {
00712 int gcd;
00713 int audio_frame_size;
00714
00715
00716
00717
00718 audio_frame_size = av_get_audio_frame_duration(stream, 0);
00719 if (!audio_frame_size)
00720 audio_frame_size = stream->frame_size;
00721
00722 *au_ssize= stream->block_align;
00723 if (audio_frame_size && stream->sample_rate) {
00724 *au_scale = audio_frame_size;
00725 *au_rate= stream->sample_rate;
00726 }else if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
00727 stream->codec_type == AVMEDIA_TYPE_DATA ||
00728 stream->codec_type == AVMEDIA_TYPE_SUBTITLE){
00729 *au_scale= stream->time_base.num;
00730 *au_rate = stream->time_base.den;
00731 }else{
00732 *au_scale= stream->block_align ? stream->block_align*8 : 8;
00733 *au_rate = stream->bit_rate ? stream->bit_rate : 8*stream->sample_rate;
00734 }
00735 gcd= av_gcd(*au_scale, *au_rate);
00736 *au_scale /= gcd;
00737 *au_rate /= gcd;
00738 }
00739
00740 void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
00741 {
00742 av_assert0(sizeof(*g) == 16);
00743 if (avio_read(s, *g, sizeof(*g)) < (int)sizeof(*g))
00744 memset(*g, 0, sizeof(*g));
00745 }
00746
00747 enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
00748 {
00749 int i;
00750 for (i = 0; guids[i].id != AV_CODEC_ID_NONE; i++) {
00751 if (!ff_guidcmp(guids[i].guid, guid))
00752 return guids[i].id;
00753 }
00754 return AV_CODEC_ID_NONE;
00755 }
00756
00757 int ff_read_riff_info(AVFormatContext *s, int64_t size)
00758 {
00759 int64_t start, end, cur;
00760 AVIOContext *pb = s->pb;
00761
00762 start = avio_tell(pb);
00763 end = start + size;
00764
00765 while ((cur = avio_tell(pb)) >= 0 && cur <= end - 8 ) {
00766 uint32_t chunk_code;
00767 int64_t chunk_size;
00768 char key[5] = {0};
00769 char *value;
00770
00771 chunk_code = avio_rl32(pb);
00772 chunk_size = avio_rl32(pb);
00773 if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) {
00774 av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n");
00775 return AVERROR_INVALIDDATA;
00776 }
00777
00778 chunk_size += (chunk_size & 1);
00779
00780 value = av_malloc(chunk_size + 1);
00781 if (!value) {
00782 av_log(s, AV_LOG_ERROR, "out of memory, unable to read INFO tag\n");
00783 return AVERROR(ENOMEM);
00784 }
00785
00786 AV_WL32(key, chunk_code);
00787
00788 if (avio_read(pb, value, chunk_size) != chunk_size) {
00789 av_freep(&value);
00790 av_log(s, AV_LOG_ERROR, "premature end of file while reading INFO tag\n");
00791 return AVERROR_INVALIDDATA;
00792 }
00793
00794 value[chunk_size] = 0;
00795
00796 av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
00797 }
00798
00799 return 0;
00800 }