1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "media/base/media.h"
8 #include "media/ffmpeg/ffmpeg_common.h"
9 #include "media/filters/ffmpeg_glue.h"
10 #include "testing/gtest/include/gtest/gtest.h"
14 // Verify that the AV_CODEC_ID values match what is specified in histograms.xml
15 // for Media.DetectedAudioCodec and Media.DetectedVideoCodec
16 #define STATIC_ASSERT(test) static_assert(test, #test)
17 STATIC_ASSERT(0 == AV_CODEC_ID_NONE
);
18 STATIC_ASSERT(1 == AV_CODEC_ID_MPEG1VIDEO
);
19 STATIC_ASSERT(2 == AV_CODEC_ID_MPEG2VIDEO
);
20 STATIC_ASSERT(3 == AV_CODEC_ID_MPEG2VIDEO_XVMC
);
21 STATIC_ASSERT(4 == AV_CODEC_ID_H261
);
22 STATIC_ASSERT(5 == AV_CODEC_ID_H263
);
23 STATIC_ASSERT(6 == AV_CODEC_ID_RV10
);
24 STATIC_ASSERT(7 == AV_CODEC_ID_RV20
);
25 STATIC_ASSERT(8 == AV_CODEC_ID_MJPEG
);
26 STATIC_ASSERT(9 == AV_CODEC_ID_MJPEGB
);
27 STATIC_ASSERT(10 == AV_CODEC_ID_LJPEG
);
28 STATIC_ASSERT(11 == AV_CODEC_ID_SP5X
);
29 STATIC_ASSERT(12 == AV_CODEC_ID_JPEGLS
);
30 STATIC_ASSERT(13 == AV_CODEC_ID_MPEG4
);
31 STATIC_ASSERT(14 == AV_CODEC_ID_RAWVIDEO
);
32 STATIC_ASSERT(15 == AV_CODEC_ID_MSMPEG4V1
);
33 STATIC_ASSERT(16 == AV_CODEC_ID_MSMPEG4V2
);
34 STATIC_ASSERT(17 == AV_CODEC_ID_MSMPEG4V3
);
35 STATIC_ASSERT(18 == AV_CODEC_ID_WMV1
);
36 STATIC_ASSERT(19 == AV_CODEC_ID_WMV2
);
37 STATIC_ASSERT(20 == AV_CODEC_ID_H263P
);
38 STATIC_ASSERT(21 == AV_CODEC_ID_H263I
);
39 STATIC_ASSERT(22 == AV_CODEC_ID_FLV1
);
40 STATIC_ASSERT(23 == AV_CODEC_ID_SVQ1
);
41 STATIC_ASSERT(24 == AV_CODEC_ID_SVQ3
);
42 STATIC_ASSERT(25 == AV_CODEC_ID_DVVIDEO
);
43 STATIC_ASSERT(26 == AV_CODEC_ID_HUFFYUV
);
44 STATIC_ASSERT(27 == AV_CODEC_ID_CYUV
);
45 STATIC_ASSERT(28 == AV_CODEC_ID_H264
);
46 STATIC_ASSERT(29 == AV_CODEC_ID_INDEO3
);
47 STATIC_ASSERT(30 == AV_CODEC_ID_VP3
);
48 STATIC_ASSERT(31 == AV_CODEC_ID_THEORA
);
49 STATIC_ASSERT(32 == AV_CODEC_ID_ASV1
);
50 STATIC_ASSERT(33 == AV_CODEC_ID_ASV2
);
51 STATIC_ASSERT(34 == AV_CODEC_ID_FFV1
);
52 STATIC_ASSERT(35 == AV_CODEC_ID_4XM
);
53 STATIC_ASSERT(36 == AV_CODEC_ID_VCR1
);
54 STATIC_ASSERT(37 == AV_CODEC_ID_CLJR
);
55 STATIC_ASSERT(38 == AV_CODEC_ID_MDEC
);
56 STATIC_ASSERT(39 == AV_CODEC_ID_ROQ
);
57 STATIC_ASSERT(40 == AV_CODEC_ID_INTERPLAY_VIDEO
);
58 STATIC_ASSERT(41 == AV_CODEC_ID_XAN_WC3
);
59 STATIC_ASSERT(42 == AV_CODEC_ID_XAN_WC4
);
60 STATIC_ASSERT(43 == AV_CODEC_ID_RPZA
);
61 STATIC_ASSERT(44 == AV_CODEC_ID_CINEPAK
);
62 STATIC_ASSERT(45 == AV_CODEC_ID_WS_VQA
);
63 STATIC_ASSERT(46 == AV_CODEC_ID_MSRLE
);
64 STATIC_ASSERT(47 == AV_CODEC_ID_MSVIDEO1
);
65 STATIC_ASSERT(48 == AV_CODEC_ID_IDCIN
);
66 STATIC_ASSERT(49 == AV_CODEC_ID_8BPS
);
67 STATIC_ASSERT(50 == AV_CODEC_ID_SMC
);
68 STATIC_ASSERT(51 == AV_CODEC_ID_FLIC
);
69 STATIC_ASSERT(52 == AV_CODEC_ID_TRUEMOTION1
);
70 STATIC_ASSERT(53 == AV_CODEC_ID_VMDVIDEO
);
71 STATIC_ASSERT(54 == AV_CODEC_ID_MSZH
);
72 STATIC_ASSERT(55 == AV_CODEC_ID_ZLIB
);
73 STATIC_ASSERT(56 == AV_CODEC_ID_QTRLE
);
74 STATIC_ASSERT(57 == AV_CODEC_ID_SNOW_DEPRECATED
);
75 STATIC_ASSERT(58 == AV_CODEC_ID_TSCC
);
76 STATIC_ASSERT(59 == AV_CODEC_ID_ULTI
);
77 STATIC_ASSERT(60 == AV_CODEC_ID_QDRAW
);
78 STATIC_ASSERT(61 == AV_CODEC_ID_VIXL
);
79 STATIC_ASSERT(62 == AV_CODEC_ID_QPEG
);
80 STATIC_ASSERT(63 == AV_CODEC_ID_PNG
);
81 STATIC_ASSERT(64 == AV_CODEC_ID_PPM
);
82 STATIC_ASSERT(65 == AV_CODEC_ID_PBM
);
83 STATIC_ASSERT(66 == AV_CODEC_ID_PGM
);
84 STATIC_ASSERT(67 == AV_CODEC_ID_PGMYUV
);
85 STATIC_ASSERT(68 == AV_CODEC_ID_PAM
);
86 STATIC_ASSERT(69 == AV_CODEC_ID_FFVHUFF
);
87 STATIC_ASSERT(70 == AV_CODEC_ID_RV30
);
88 STATIC_ASSERT(71 == AV_CODEC_ID_RV40
);
89 STATIC_ASSERT(72 == AV_CODEC_ID_VC1
);
90 STATIC_ASSERT(73 == AV_CODEC_ID_WMV3
);
91 STATIC_ASSERT(74 == AV_CODEC_ID_LOCO
);
92 STATIC_ASSERT(75 == AV_CODEC_ID_WNV1
);
93 STATIC_ASSERT(76 == AV_CODEC_ID_AASC
);
94 STATIC_ASSERT(77 == AV_CODEC_ID_INDEO2
);
95 STATIC_ASSERT(78 == AV_CODEC_ID_FRAPS
);
96 STATIC_ASSERT(79 == AV_CODEC_ID_TRUEMOTION2
);
97 STATIC_ASSERT(80 == AV_CODEC_ID_BMP
);
98 STATIC_ASSERT(81 == AV_CODEC_ID_CSCD
);
99 STATIC_ASSERT(82 == AV_CODEC_ID_MMVIDEO
);
100 STATIC_ASSERT(83 == AV_CODEC_ID_ZMBV
);
101 STATIC_ASSERT(84 == AV_CODEC_ID_AVS
);
102 STATIC_ASSERT(85 == AV_CODEC_ID_SMACKVIDEO
);
103 STATIC_ASSERT(86 == AV_CODEC_ID_NUV
);
104 STATIC_ASSERT(87 == AV_CODEC_ID_KMVC
);
105 STATIC_ASSERT(88 == AV_CODEC_ID_FLASHSV
);
106 STATIC_ASSERT(89 == AV_CODEC_ID_CAVS
);
107 STATIC_ASSERT(90 == AV_CODEC_ID_JPEG2000
);
108 STATIC_ASSERT(91 == AV_CODEC_ID_VMNC
);
109 STATIC_ASSERT(92 == AV_CODEC_ID_VP5
);
110 STATIC_ASSERT(93 == AV_CODEC_ID_VP6
);
111 STATIC_ASSERT(94 == AV_CODEC_ID_VP6F
);
112 STATIC_ASSERT(95 == AV_CODEC_ID_TARGA
);
113 STATIC_ASSERT(96 == AV_CODEC_ID_DSICINVIDEO
);
114 STATIC_ASSERT(97 == AV_CODEC_ID_TIERTEXSEQVIDEO
);
115 STATIC_ASSERT(98 == AV_CODEC_ID_TIFF
);
116 STATIC_ASSERT(99 == AV_CODEC_ID_GIF
);
117 STATIC_ASSERT(100 == AV_CODEC_ID_DXA
);
118 STATIC_ASSERT(101 == AV_CODEC_ID_DNXHD
);
119 STATIC_ASSERT(102 == AV_CODEC_ID_THP
);
120 STATIC_ASSERT(103 == AV_CODEC_ID_SGI
);
121 STATIC_ASSERT(104 == AV_CODEC_ID_C93
);
122 STATIC_ASSERT(105 == AV_CODEC_ID_BETHSOFTVID
);
123 STATIC_ASSERT(106 == AV_CODEC_ID_PTX
);
124 STATIC_ASSERT(107 == AV_CODEC_ID_TXD
);
125 STATIC_ASSERT(108 == AV_CODEC_ID_VP6A
);
126 STATIC_ASSERT(109 == AV_CODEC_ID_AMV
);
127 STATIC_ASSERT(110 == AV_CODEC_ID_VB
);
128 STATIC_ASSERT(111 == AV_CODEC_ID_PCX
);
129 STATIC_ASSERT(112 == AV_CODEC_ID_SUNRAST
);
130 STATIC_ASSERT(113 == AV_CODEC_ID_INDEO4
);
131 STATIC_ASSERT(114 == AV_CODEC_ID_INDEO5
);
132 STATIC_ASSERT(115 == AV_CODEC_ID_MIMIC
);
133 STATIC_ASSERT(116 == AV_CODEC_ID_RL2
);
134 STATIC_ASSERT(117 == AV_CODEC_ID_ESCAPE124
);
135 STATIC_ASSERT(118 == AV_CODEC_ID_DIRAC
);
136 STATIC_ASSERT(119 == AV_CODEC_ID_BFI
);
137 STATIC_ASSERT(120 == AV_CODEC_ID_CMV
);
138 STATIC_ASSERT(121 == AV_CODEC_ID_MOTIONPIXELS
);
139 STATIC_ASSERT(122 == AV_CODEC_ID_TGV
);
140 STATIC_ASSERT(123 == AV_CODEC_ID_TGQ
);
141 STATIC_ASSERT(124 == AV_CODEC_ID_TQI
);
142 STATIC_ASSERT(125 == AV_CODEC_ID_AURA
);
143 STATIC_ASSERT(126 == AV_CODEC_ID_AURA2
);
144 STATIC_ASSERT(127 == AV_CODEC_ID_V210X
);
145 STATIC_ASSERT(128 == AV_CODEC_ID_TMV
);
146 STATIC_ASSERT(129 == AV_CODEC_ID_V210
);
147 STATIC_ASSERT(130 == AV_CODEC_ID_DPX
);
148 STATIC_ASSERT(131 == AV_CODEC_ID_MAD
);
149 STATIC_ASSERT(132 == AV_CODEC_ID_FRWU
);
150 STATIC_ASSERT(133 == AV_CODEC_ID_FLASHSV2
);
151 STATIC_ASSERT(134 == AV_CODEC_ID_CDGRAPHICS
);
152 STATIC_ASSERT(135 == AV_CODEC_ID_R210
);
153 STATIC_ASSERT(136 == AV_CODEC_ID_ANM
);
154 STATIC_ASSERT(137 == AV_CODEC_ID_BINKVIDEO
);
155 STATIC_ASSERT(138 == AV_CODEC_ID_IFF_ILBM
);
156 STATIC_ASSERT(139 == AV_CODEC_ID_IFF_BYTERUN1
);
157 STATIC_ASSERT(140 == AV_CODEC_ID_KGV1
);
158 STATIC_ASSERT(141 == AV_CODEC_ID_YOP
);
159 STATIC_ASSERT(142 == AV_CODEC_ID_VP8
);
160 STATIC_ASSERT(143 == AV_CODEC_ID_PICTOR
);
161 STATIC_ASSERT(144 == AV_CODEC_ID_ANSI
);
162 STATIC_ASSERT(145 == AV_CODEC_ID_A64_MULTI
);
163 STATIC_ASSERT(146 == AV_CODEC_ID_A64_MULTI5
);
164 STATIC_ASSERT(147 == AV_CODEC_ID_R10K
);
165 STATIC_ASSERT(148 == AV_CODEC_ID_MXPEG
);
166 STATIC_ASSERT(149 == AV_CODEC_ID_LAGARITH
);
167 STATIC_ASSERT(150 == AV_CODEC_ID_PRORES
);
168 STATIC_ASSERT(151 == AV_CODEC_ID_JV
);
169 STATIC_ASSERT(152 == AV_CODEC_ID_DFA
);
170 STATIC_ASSERT(153 == AV_CODEC_ID_WMV3IMAGE
);
171 STATIC_ASSERT(154 == AV_CODEC_ID_VC1IMAGE
);
172 STATIC_ASSERT(155 == AV_CODEC_ID_UTVIDEO
);
173 STATIC_ASSERT(156 == AV_CODEC_ID_BMV_VIDEO
);
174 STATIC_ASSERT(157 == AV_CODEC_ID_VBLE
);
175 STATIC_ASSERT(158 == AV_CODEC_ID_DXTORY
);
176 STATIC_ASSERT(159 == AV_CODEC_ID_V410
);
177 STATIC_ASSERT(160 == AV_CODEC_ID_XWD
);
178 STATIC_ASSERT(161 == AV_CODEC_ID_CDXL
);
179 STATIC_ASSERT(162 == AV_CODEC_ID_XBM
);
180 STATIC_ASSERT(163 == AV_CODEC_ID_ZEROCODEC
);
181 STATIC_ASSERT(164 == AV_CODEC_ID_MSS1
);
182 STATIC_ASSERT(165 == AV_CODEC_ID_MSA1
);
183 STATIC_ASSERT(166 == AV_CODEC_ID_TSCC2
);
184 STATIC_ASSERT(167 == AV_CODEC_ID_MTS2
);
185 STATIC_ASSERT(168 == AV_CODEC_ID_CLLC
);
186 STATIC_ASSERT(169 == AV_CODEC_ID_MSS2
);
187 STATIC_ASSERT(170 == AV_CODEC_ID_VP9
);
188 STATIC_ASSERT(65536 == AV_CODEC_ID_PCM_S16LE
);
189 STATIC_ASSERT(65537 == AV_CODEC_ID_PCM_S16BE
);
190 STATIC_ASSERT(65538 == AV_CODEC_ID_PCM_U16LE
);
191 STATIC_ASSERT(65539 == AV_CODEC_ID_PCM_U16BE
);
192 STATIC_ASSERT(65540 == AV_CODEC_ID_PCM_S8
);
193 STATIC_ASSERT(65541 == AV_CODEC_ID_PCM_U8
);
194 STATIC_ASSERT(65542 == AV_CODEC_ID_PCM_MULAW
);
195 STATIC_ASSERT(65543 == AV_CODEC_ID_PCM_ALAW
);
196 STATIC_ASSERT(65544 == AV_CODEC_ID_PCM_S32LE
);
197 STATIC_ASSERT(65545 == AV_CODEC_ID_PCM_S32BE
);
198 STATIC_ASSERT(65546 == AV_CODEC_ID_PCM_U32LE
);
199 STATIC_ASSERT(65547 == AV_CODEC_ID_PCM_U32BE
);
200 STATIC_ASSERT(65548 == AV_CODEC_ID_PCM_S24LE
);
201 STATIC_ASSERT(65549 == AV_CODEC_ID_PCM_S24BE
);
202 STATIC_ASSERT(65550 == AV_CODEC_ID_PCM_U24LE
);
203 STATIC_ASSERT(65551 == AV_CODEC_ID_PCM_U24BE
);
204 STATIC_ASSERT(65552 == AV_CODEC_ID_PCM_S24DAUD
);
205 STATIC_ASSERT(65553 == AV_CODEC_ID_PCM_ZORK
);
206 STATIC_ASSERT(65554 == AV_CODEC_ID_PCM_S16LE_PLANAR
);
207 STATIC_ASSERT(65555 == AV_CODEC_ID_PCM_DVD
);
208 STATIC_ASSERT(65556 == AV_CODEC_ID_PCM_F32BE
);
209 STATIC_ASSERT(65557 == AV_CODEC_ID_PCM_F32LE
);
210 STATIC_ASSERT(65558 == AV_CODEC_ID_PCM_F64BE
);
211 STATIC_ASSERT(65559 == AV_CODEC_ID_PCM_F64LE
);
212 STATIC_ASSERT(65560 == AV_CODEC_ID_PCM_BLURAY
);
213 STATIC_ASSERT(65561 == AV_CODEC_ID_PCM_LXF
);
214 STATIC_ASSERT(65562 == AV_CODEC_ID_S302M
);
215 STATIC_ASSERT(65563 == AV_CODEC_ID_PCM_S8_PLANAR
);
216 STATIC_ASSERT(69632 == AV_CODEC_ID_ADPCM_IMA_QT
);
217 STATIC_ASSERT(69633 == AV_CODEC_ID_ADPCM_IMA_WAV
);
218 STATIC_ASSERT(69634 == AV_CODEC_ID_ADPCM_IMA_DK3
);
219 STATIC_ASSERT(69635 == AV_CODEC_ID_ADPCM_IMA_DK4
);
220 STATIC_ASSERT(69636 == AV_CODEC_ID_ADPCM_IMA_WS
);
221 STATIC_ASSERT(69637 == AV_CODEC_ID_ADPCM_IMA_SMJPEG
);
222 STATIC_ASSERT(69638 == AV_CODEC_ID_ADPCM_MS
);
223 STATIC_ASSERT(69639 == AV_CODEC_ID_ADPCM_4XM
);
224 STATIC_ASSERT(69640 == AV_CODEC_ID_ADPCM_XA
);
225 STATIC_ASSERT(69641 == AV_CODEC_ID_ADPCM_ADX
);
226 STATIC_ASSERT(69642 == AV_CODEC_ID_ADPCM_EA
);
227 STATIC_ASSERT(69643 == AV_CODEC_ID_ADPCM_G726
);
228 STATIC_ASSERT(69644 == AV_CODEC_ID_ADPCM_CT
);
229 STATIC_ASSERT(69645 == AV_CODEC_ID_ADPCM_SWF
);
230 STATIC_ASSERT(69646 == AV_CODEC_ID_ADPCM_YAMAHA
);
231 STATIC_ASSERT(69647 == AV_CODEC_ID_ADPCM_SBPRO_4
);
232 STATIC_ASSERT(69648 == AV_CODEC_ID_ADPCM_SBPRO_3
);
233 STATIC_ASSERT(69649 == AV_CODEC_ID_ADPCM_SBPRO_2
);
234 STATIC_ASSERT(69650 == AV_CODEC_ID_ADPCM_THP
);
235 STATIC_ASSERT(69651 == AV_CODEC_ID_ADPCM_IMA_AMV
);
236 STATIC_ASSERT(69652 == AV_CODEC_ID_ADPCM_EA_R1
);
237 STATIC_ASSERT(69653 == AV_CODEC_ID_ADPCM_EA_R3
);
238 STATIC_ASSERT(69654 == AV_CODEC_ID_ADPCM_EA_R2
);
239 STATIC_ASSERT(69655 == AV_CODEC_ID_ADPCM_IMA_EA_SEAD
);
240 STATIC_ASSERT(69656 == AV_CODEC_ID_ADPCM_IMA_EA_EACS
);
241 STATIC_ASSERT(69657 == AV_CODEC_ID_ADPCM_EA_XAS
);
242 STATIC_ASSERT(69658 == AV_CODEC_ID_ADPCM_EA_MAXIS_XA
);
243 STATIC_ASSERT(69659 == AV_CODEC_ID_ADPCM_IMA_ISS
);
244 STATIC_ASSERT(69660 == AV_CODEC_ID_ADPCM_G722
);
245 STATIC_ASSERT(69661 == AV_CODEC_ID_ADPCM_IMA_APC
);
246 STATIC_ASSERT(73728 == AV_CODEC_ID_AMR_NB
);
247 STATIC_ASSERT(73729 == AV_CODEC_ID_AMR_WB
);
248 STATIC_ASSERT(77824 == AV_CODEC_ID_RA_144
);
249 STATIC_ASSERT(77825 == AV_CODEC_ID_RA_288
);
250 STATIC_ASSERT(81920 == AV_CODEC_ID_ROQ_DPCM
);
251 STATIC_ASSERT(81921 == AV_CODEC_ID_INTERPLAY_DPCM
);
252 STATIC_ASSERT(81922 == AV_CODEC_ID_XAN_DPCM
);
253 STATIC_ASSERT(81923 == AV_CODEC_ID_SOL_DPCM
);
254 STATIC_ASSERT(86016 == AV_CODEC_ID_MP2
);
255 STATIC_ASSERT(86017 == AV_CODEC_ID_MP3
);
256 STATIC_ASSERT(86018 == AV_CODEC_ID_AAC
);
257 STATIC_ASSERT(86019 == AV_CODEC_ID_AC3
);
258 STATIC_ASSERT(86020 == AV_CODEC_ID_DTS
);
259 STATIC_ASSERT(86021 == AV_CODEC_ID_VORBIS
);
260 STATIC_ASSERT(86022 == AV_CODEC_ID_DVAUDIO
);
261 STATIC_ASSERT(86023 == AV_CODEC_ID_WMAV1
);
262 STATIC_ASSERT(86024 == AV_CODEC_ID_WMAV2
);
263 STATIC_ASSERT(86025 == AV_CODEC_ID_MACE3
);
264 STATIC_ASSERT(86026 == AV_CODEC_ID_MACE6
);
265 STATIC_ASSERT(86027 == AV_CODEC_ID_VMDAUDIO
);
266 STATIC_ASSERT(86028 == AV_CODEC_ID_FLAC
);
267 STATIC_ASSERT(86029 == AV_CODEC_ID_MP3ADU
);
268 STATIC_ASSERT(86030 == AV_CODEC_ID_MP3ON4
);
269 STATIC_ASSERT(86031 == AV_CODEC_ID_SHORTEN
);
270 STATIC_ASSERT(86032 == AV_CODEC_ID_ALAC
);
271 STATIC_ASSERT(86033 == AV_CODEC_ID_WESTWOOD_SND1
);
272 STATIC_ASSERT(86034 == AV_CODEC_ID_GSM
);
273 STATIC_ASSERT(86035 == AV_CODEC_ID_QDM2
);
274 STATIC_ASSERT(86036 == AV_CODEC_ID_COOK
);
275 STATIC_ASSERT(86037 == AV_CODEC_ID_TRUESPEECH
);
276 STATIC_ASSERT(86038 == AV_CODEC_ID_TTA
);
277 STATIC_ASSERT(86039 == AV_CODEC_ID_SMACKAUDIO
);
278 STATIC_ASSERT(86040 == AV_CODEC_ID_QCELP
);
279 STATIC_ASSERT(86041 == AV_CODEC_ID_WAVPACK
);
280 STATIC_ASSERT(86042 == AV_CODEC_ID_DSICINAUDIO
);
281 STATIC_ASSERT(86043 == AV_CODEC_ID_IMC
);
282 STATIC_ASSERT(86044 == AV_CODEC_ID_MUSEPACK7
);
283 STATIC_ASSERT(86045 == AV_CODEC_ID_MLP
);
284 STATIC_ASSERT(86046 == AV_CODEC_ID_GSM_MS
);
285 STATIC_ASSERT(86047 == AV_CODEC_ID_ATRAC3
);
286 STATIC_ASSERT(86048 == AV_CODEC_ID_VOXWARE
);
287 STATIC_ASSERT(86049 == AV_CODEC_ID_APE
);
288 STATIC_ASSERT(86050 == AV_CODEC_ID_NELLYMOSER
);
289 STATIC_ASSERT(86051 == AV_CODEC_ID_MUSEPACK8
);
290 STATIC_ASSERT(86052 == AV_CODEC_ID_SPEEX
);
291 STATIC_ASSERT(86053 == AV_CODEC_ID_WMAVOICE
);
292 STATIC_ASSERT(86054 == AV_CODEC_ID_WMAPRO
);
293 STATIC_ASSERT(86055 == AV_CODEC_ID_WMALOSSLESS
);
294 STATIC_ASSERT(86056 == AV_CODEC_ID_ATRAC3P
);
295 STATIC_ASSERT(86057 == AV_CODEC_ID_EAC3
);
296 STATIC_ASSERT(86058 == AV_CODEC_ID_SIPR
);
297 STATIC_ASSERT(86059 == AV_CODEC_ID_MP1
);
298 STATIC_ASSERT(86060 == AV_CODEC_ID_TWINVQ
);
299 STATIC_ASSERT(86061 == AV_CODEC_ID_TRUEHD
);
300 STATIC_ASSERT(86062 == AV_CODEC_ID_MP4ALS
);
301 STATIC_ASSERT(86063 == AV_CODEC_ID_ATRAC1
);
302 STATIC_ASSERT(86064 == AV_CODEC_ID_BINKAUDIO_RDFT
);
303 STATIC_ASSERT(86065 == AV_CODEC_ID_BINKAUDIO_DCT
);
304 STATIC_ASSERT(86066 == AV_CODEC_ID_AAC_LATM
);
305 STATIC_ASSERT(86067 == AV_CODEC_ID_QDMC
);
306 STATIC_ASSERT(86068 == AV_CODEC_ID_CELT
);
307 STATIC_ASSERT(86069 == AV_CODEC_ID_G723_1
);
308 STATIC_ASSERT(86070 == AV_CODEC_ID_G729
);
309 STATIC_ASSERT(86071 == AV_CODEC_ID_8SVX_EXP
);
310 STATIC_ASSERT(86072 == AV_CODEC_ID_8SVX_FIB
);
311 STATIC_ASSERT(86073 == AV_CODEC_ID_BMV_AUDIO
);
312 STATIC_ASSERT(86074 == AV_CODEC_ID_RALF
);
313 STATIC_ASSERT(86075 == AV_CODEC_ID_IAC
);
314 STATIC_ASSERT(86076 == AV_CODEC_ID_ILBC
);
315 STATIC_ASSERT(86077 == AV_CODEC_ID_OPUS_DEPRECATED
);
316 STATIC_ASSERT(86078 == AV_CODEC_ID_COMFORT_NOISE
);
317 STATIC_ASSERT(86079 == AV_CODEC_ID_TAK_DEPRECATED
);
318 STATIC_ASSERT(94208 == AV_CODEC_ID_DVD_SUBTITLE
);
319 STATIC_ASSERT(94209 == AV_CODEC_ID_DVB_SUBTITLE
);
320 STATIC_ASSERT(94210 == AV_CODEC_ID_TEXT
);
321 STATIC_ASSERT(94211 == AV_CODEC_ID_XSUB
);
322 STATIC_ASSERT(94212 == AV_CODEC_ID_SSA
);
323 STATIC_ASSERT(94213 == AV_CODEC_ID_MOV_TEXT
);
324 STATIC_ASSERT(94214 == AV_CODEC_ID_HDMV_PGS_SUBTITLE
);
325 STATIC_ASSERT(94215 == AV_CODEC_ID_DVB_TELETEXT
);
326 STATIC_ASSERT(94216 == AV_CODEC_ID_SRT
);
327 STATIC_ASSERT(98304 == AV_CODEC_ID_TTF
);
328 STATIC_ASSERT(102400 == AV_CODEC_ID_PROBE
);
329 STATIC_ASSERT(131072 == AV_CODEC_ID_MPEG2TS
);
330 STATIC_ASSERT(131073 == AV_CODEC_ID_MPEG4SYSTEMS
);
331 STATIC_ASSERT(135168 == AV_CODEC_ID_FFMETADATA
);
332 STATIC_ASSERT(4665933 == AV_CODEC_ID_G2M
);
333 STATIC_ASSERT(4801606 == AV_CODEC_ID_IDF
);
334 STATIC_ASSERT(5198918 == AV_CODEC_ID_OTF
);
335 STATIC_ASSERT(407917392 == AV_CODEC_ID_PCM_S24LE_PLANAR
);
336 STATIC_ASSERT(542135120 == AV_CODEC_ID_PCM_S32LE_PLANAR
);
337 STATIC_ASSERT(808530518 == AV_CODEC_ID_012V
);
338 STATIC_ASSERT(809850962 == AV_CODEC_ID_EXR
);
339 // AV_CODEC_ID_8SVX_RAW(944985688) is no longer supported by ffmpeg but remains
340 // in histograms.xml for historical purposes.
341 STATIC_ASSERT(1095123744 == AV_CODEC_ID_ADPCM_AFC
);
342 STATIC_ASSERT(1096176208 == AV_CODEC_ID_AVRP
);
343 STATIC_ASSERT(1096176238 == AV_CODEC_ID_AVRN
);
344 STATIC_ASSERT(1096176969 == AV_CODEC_ID_AVUI
);
345 STATIC_ASSERT(1096373590 == AV_CODEC_ID_AYUV
);
346 STATIC_ASSERT(1112557912 == AV_CODEC_ID_BRENDER_PIX
);
347 STATIC_ASSERT(1112823892 == AV_CODEC_ID_BINTEXT
);
348 STATIC_ASSERT(1129335105 == AV_CODEC_ID_CPIA
);
349 STATIC_ASSERT(1160852272 == AV_CODEC_ID_ESCAPE130
);
350 STATIC_ASSERT(1179014995 == AV_CODEC_ID_FFWAVESYNTH
);
351 STATIC_ASSERT(1211250229 == AV_CODEC_ID_HEVC
);
352 STATIC_ASSERT(1246975298 == AV_CODEC_ID_JACOSUB
);
353 STATIC_ASSERT(1263294017 == AV_CODEC_ID_SMPTE_KLV
);
354 STATIC_ASSERT(1297108018 == AV_CODEC_ID_MPL2
);
355 STATIC_ASSERT(1297498929 == AV_CODEC_ID_MVC1
);
356 STATIC_ASSERT(1297498930 == AV_CODEC_ID_MVC2
);
357 STATIC_ASSERT(1330333984 == AV_CODEC_ID_ADPCM_IMA_OKI
);
358 STATIC_ASSERT(1330664787 == AV_CODEC_ID_OPUS
);
359 STATIC_ASSERT(1346455105 == AV_CODEC_ID_PAF_AUDIO
);
360 STATIC_ASSERT(1346455126 == AV_CODEC_ID_PAF_VIDEO
);
361 STATIC_ASSERT(1347637264 == AV_CODEC_ID_PCM_S16BE_PLANAR
);
362 STATIC_ASSERT(1349012051 == AV_CODEC_ID_PJS
);
363 STATIC_ASSERT(1381259348 == AV_CODEC_ID_REALTEXT
);
364 STATIC_ASSERT(1396788553 == AV_CODEC_ID_SAMI
);
365 STATIC_ASSERT(1396788813 == AV_CODEC_ID_SANM
);
366 STATIC_ASSERT(1397180754 == AV_CODEC_ID_SGIRLE
);
367 STATIC_ASSERT(1397706307 == AV_CODEC_ID_SONIC
);
368 STATIC_ASSERT(1397706316 == AV_CODEC_ID_SONIC_LS
);
369 STATIC_ASSERT(1397909872 == AV_CODEC_ID_SUBRIP
);
370 STATIC_ASSERT(1398953521 == AV_CODEC_ID_SUBVIEWER1
);
371 STATIC_ASSERT(1400201814 == AV_CODEC_ID_SUBVIEWER
);
372 STATIC_ASSERT(1412575542 == AV_CODEC_ID_TARGA_Y216
);
373 STATIC_ASSERT(1446195256 == AV_CODEC_ID_V308
);
374 STATIC_ASSERT(1446260792 == AV_CODEC_ID_V408
);
375 STATIC_ASSERT(1447644481 == AV_CODEC_ID_VIMA
);
376 STATIC_ASSERT(1448111218 == AV_CODEC_ID_VPLAYER
);
377 STATIC_ASSERT(1465275476 == AV_CODEC_ID_WEBVTT
);
378 STATIC_ASSERT(1480739150 == AV_CODEC_ID_XBIN
);
379 STATIC_ASSERT(1480999235 == AV_CODEC_ID_XFACE
);
380 STATIC_ASSERT(1496592720 == AV_CODEC_ID_Y41P
);
381 STATIC_ASSERT(1498764852 == AV_CODEC_ID_YUV4
);
382 STATIC_ASSERT(1664495672 == AV_CODEC_ID_EIA_608
);
383 STATIC_ASSERT(1833195076 == AV_CODEC_ID_MICRODVD
);
384 STATIC_ASSERT(1936029283 == AV_CODEC_ID_EVRC
);
385 STATIC_ASSERT(1936944502 == AV_CODEC_ID_SMV
);
386 STATIC_ASSERT(1950507339 == AV_CODEC_ID_TAK
);
388 class FFmpegCommonTest
: public testing::Test
{
391 FFmpegGlue::InitializeFFmpeg();
393 ~FFmpegCommonTest() override
{};
396 TEST_F(FFmpegCommonTest
, OpusAudioDecoderConfig
) {
397 AVCodecContext context
= {0};
398 context
.codec_type
= AVMEDIA_TYPE_AUDIO
;
399 context
.codec_id
= AV_CODEC_ID_OPUS
;
400 context
.channel_layout
= CHANNEL_LAYOUT_STEREO
;
401 context
.channels
= 2;
402 context
.sample_fmt
= AV_SAMPLE_FMT_FLT
;
404 // During conversion this sample rate should be changed to 48kHz.
405 context
.sample_rate
= 44100;
407 AudioDecoderConfig decoder_config
;
408 AVCodecContextToAudioDecoderConfig(&context
, false, &decoder_config
, false);
409 EXPECT_EQ(48000, decoder_config
.samples_per_second());
412 TEST_F(FFmpegCommonTest
, TimeBaseConversions
) {
413 const int64 test_data
[][5] = {
414 {1, 2, 1, 500000, 1 },
415 {1, 3, 1, 333333, 1 },
416 {1, 3, 2, 666667, 2 },
419 for (size_t i
= 0; i
< arraysize(test_data
); ++i
) {
422 AVRational time_base
;
423 time_base
.num
= static_cast<int>(test_data
[i
][0]);
424 time_base
.den
= static_cast<int>(test_data
[i
][1]);
426 base::TimeDelta time_delta
=
427 ConvertFromTimeBase(time_base
, test_data
[i
][2]);
429 EXPECT_EQ(time_delta
.InMicroseconds(), test_data
[i
][3]);
430 EXPECT_EQ(ConvertToTimeBase(time_base
, time_delta
), test_data
[i
][4]);
434 TEST_F(FFmpegCommonTest
, VerifyFormatSizes
) {
435 for (AVSampleFormat format
= AV_SAMPLE_FMT_NONE
;
436 format
< AV_SAMPLE_FMT_NB
;
437 format
= static_cast<AVSampleFormat
>(format
+ 1)) {
438 SampleFormat sample_format
= AVSampleFormatToSampleFormat(format
);
439 if (sample_format
== kUnknownSampleFormat
) {
440 // This format not supported, so skip it.
444 // Have FFMpeg compute the size of a buffer of 1 channel / 1 frame
445 // with 1 byte alignment to make sure the sizes match.
446 int single_buffer_size
= av_samples_get_buffer_size(NULL
, 1, 1, format
, 1);
447 int bytes_per_channel
= SampleFormatToBytesPerChannel(sample_format
);
448 EXPECT_EQ(bytes_per_channel
, single_buffer_size
);
452 TEST_F(FFmpegCommonTest
, UTCDateToTime_Valid
) {
454 EXPECT_TRUE(FFmpegUTCDateToTime("2012-11-10 12:34:56", &result
));
456 base::Time::Exploded exploded
;
457 result
.UTCExplode(&exploded
);
458 EXPECT_TRUE(exploded
.HasValidValues());
459 EXPECT_EQ(2012, exploded
.year
);
460 EXPECT_EQ(11, exploded
.month
);
461 EXPECT_EQ(6, exploded
.day_of_week
);
462 EXPECT_EQ(10, exploded
.day_of_month
);
463 EXPECT_EQ(12, exploded
.hour
);
464 EXPECT_EQ(34, exploded
.minute
);
465 EXPECT_EQ(56, exploded
.second
);
466 EXPECT_EQ(0, exploded
.millisecond
);
469 TEST_F(FFmpegCommonTest
, UTCDateToTime_Invalid
) {
470 const char* invalid_date_strings
[] = {
482 "2012-11-10-12 12:34:56",
484 "2012-11-10 12:34:56:78",
485 "ABCD-11-10 12:34:56",
486 "2012-EF-10 12:34:56",
487 "2012-11-GH 12:34:56",
488 "2012-11-10 IJ:34:56",
489 "2012-11-10 12:JL:56",
490 "2012-11-10 12:34:MN",
491 "2012-11-10 12:34:56.123",
492 "2012-11-1012:34:56",
493 "2012-11-10 12:34:56 UTC",
496 for (size_t i
= 0; i
< arraysize(invalid_date_strings
); ++i
) {
497 const char* date_string
= invalid_date_strings
[i
];
499 EXPECT_FALSE(FFmpegUTCDateToTime(date_string
, &result
))
500 << "date_string '" << date_string
<< "'";
501 EXPECT_TRUE(result
.is_null());