OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <list> | 5 #include <list> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 216 } |
217 | 217 |
218 TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedDecoder) { | 218 TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedDecoder) { |
219 // Test avcodec_find_decoder() returning NULL. | 219 // Test avcodec_find_decoder() returning NULL. |
220 InitializeWithConfigWithResult(TestVideoConfig::Invalid(), false); | 220 InitializeWithConfigWithResult(TestVideoConfig::Invalid(), false); |
221 } | 221 } |
222 | 222 |
223 TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedPixelFormat) { | 223 TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedPixelFormat) { |
224 // Ensure decoder handles unsupported pixel formats without crashing. | 224 // Ensure decoder handles unsupported pixel formats without crashing. |
225 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, | 225 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, |
226 PIXEL_FORMAT_UNKNOWN, kCodedSize, kVisibleRect, | 226 PIXEL_FORMAT_UNKNOWN, COLOR_SPACE_UNSPECIFIED, |
227 kNaturalSize, NULL, 0, false); | 227 kCodedSize, kVisibleRect, kNaturalSize, NULL, 0, |
| 228 false); |
228 InitializeWithConfigWithResult(config, false); | 229 InitializeWithConfigWithResult(config, false); |
229 } | 230 } |
230 | 231 |
231 TEST_F(FFmpegVideoDecoderTest, Initialize_OpenDecoderFails) { | 232 TEST_F(FFmpegVideoDecoderTest, Initialize_OpenDecoderFails) { |
232 // Specify Theora w/o extra data so that avcodec_open2() fails. | 233 // Specify Theora w/o extra data so that avcodec_open2() fails. |
233 VideoDecoderConfig config(kCodecTheora, VIDEO_CODEC_PROFILE_UNKNOWN, | 234 VideoDecoderConfig config(kCodecTheora, VIDEO_CODEC_PROFILE_UNKNOWN, |
234 kVideoFormat, | 235 kVideoFormat, COLOR_SPACE_UNSPECIFIED, |
235 kCodedSize, kVisibleRect, kNaturalSize, | 236 kCodedSize, kVisibleRect, kNaturalSize, |
236 NULL, 0, false); | 237 NULL, 0, false); |
237 InitializeWithConfigWithResult(config, false); | 238 InitializeWithConfigWithResult(config, false); |
238 } | 239 } |
239 | 240 |
240 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorZero) { | 241 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorZero) { |
241 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 0, 1); | 242 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 0, 1); |
242 VideoDecoderConfig config(kCodecVP8, | 243 VideoDecoderConfig config(kCodecVP8, |
243 VP8PROFILE_ANY, | 244 VP8PROFILE_ANY, |
244 kVideoFormat, | 245 kVideoFormat, |
| 246 COLOR_SPACE_UNSPECIFIED, |
245 kCodedSize, | 247 kCodedSize, |
246 kVisibleRect, | 248 kVisibleRect, |
247 natural_size, | 249 natural_size, |
248 NULL, | 250 NULL, |
249 0, | 251 0, |
250 false); | 252 false); |
251 InitializeWithConfigWithResult(config, false); | 253 InitializeWithConfigWithResult(config, false); |
252 } | 254 } |
253 | 255 |
254 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorZero) { | 256 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorZero) { |
255 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, 0); | 257 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, 0); |
256 VideoDecoderConfig config(kCodecVP8, | 258 VideoDecoderConfig config(kCodecVP8, |
257 VP8PROFILE_ANY, | 259 VP8PROFILE_ANY, |
258 kVideoFormat, | 260 kVideoFormat, |
| 261 COLOR_SPACE_UNSPECIFIED, |
259 kCodedSize, | 262 kCodedSize, |
260 kVisibleRect, | 263 kVisibleRect, |
261 natural_size, | 264 natural_size, |
262 NULL, | 265 NULL, |
263 0, | 266 0, |
264 false); | 267 false); |
265 InitializeWithConfigWithResult(config, false); | 268 InitializeWithConfigWithResult(config, false); |
266 } | 269 } |
267 | 270 |
268 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorNegative) { | 271 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorNegative) { |
269 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), -1, 1); | 272 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), -1, 1); |
270 VideoDecoderConfig config(kCodecVP8, | 273 VideoDecoderConfig config(kCodecVP8, |
271 VP8PROFILE_ANY, | 274 VP8PROFILE_ANY, |
272 kVideoFormat, | 275 kVideoFormat, |
| 276 COLOR_SPACE_UNSPECIFIED, |
273 kCodedSize, | 277 kCodedSize, |
274 kVisibleRect, | 278 kVisibleRect, |
275 natural_size, | 279 natural_size, |
276 NULL, | 280 NULL, |
277 0, | 281 0, |
278 false); | 282 false); |
279 InitializeWithConfigWithResult(config, false); | 283 InitializeWithConfigWithResult(config, false); |
280 } | 284 } |
281 | 285 |
282 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorNegative) { | 286 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorNegative) { |
283 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, -1); | 287 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, -1); |
284 VideoDecoderConfig config(kCodecVP8, | 288 VideoDecoderConfig config(kCodecVP8, |
285 VP8PROFILE_ANY, | 289 VP8PROFILE_ANY, |
286 kVideoFormat, | 290 kVideoFormat, |
| 291 COLOR_SPACE_UNSPECIFIED, |
287 kCodedSize, | 292 kCodedSize, |
288 kVisibleRect, | 293 kVisibleRect, |
289 natural_size, | 294 natural_size, |
290 NULL, | 295 NULL, |
291 0, | 296 0, |
292 false); | 297 false); |
293 InitializeWithConfigWithResult(config, false); | 298 InitializeWithConfigWithResult(config, false); |
294 } | 299 } |
295 | 300 |
296 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorTooLarge) { | 301 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorTooLarge) { |
297 int width = kVisibleRect.size().width(); | 302 int width = kVisibleRect.size().width(); |
298 int num = ceil(static_cast<double>(limits::kMaxDimension + 1) / width); | 303 int num = ceil(static_cast<double>(limits::kMaxDimension + 1) / width); |
299 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), num, 1); | 304 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), num, 1); |
300 VideoDecoderConfig config(kCodecVP8, | 305 VideoDecoderConfig config(kCodecVP8, |
301 VP8PROFILE_ANY, | 306 VP8PROFILE_ANY, |
302 kVideoFormat, | 307 kVideoFormat, |
| 308 COLOR_SPACE_UNSPECIFIED, |
303 kCodedSize, | 309 kCodedSize, |
304 kVisibleRect, | 310 kVisibleRect, |
305 natural_size, | 311 natural_size, |
306 NULL, | 312 NULL, |
307 0, | 313 0, |
308 false); | 314 false); |
309 InitializeWithConfigWithResult(config, false); | 315 InitializeWithConfigWithResult(config, false); |
310 } | 316 } |
311 | 317 |
312 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorTooLarge) { | 318 TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorTooLarge) { |
313 int den = kVisibleRect.size().width() + 1; | 319 int den = kVisibleRect.size().width() + 1; |
314 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, den); | 320 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, den); |
315 VideoDecoderConfig config(kCodecVP8, | 321 VideoDecoderConfig config(kCodecVP8, |
316 VP8PROFILE_ANY, | 322 VP8PROFILE_ANY, |
317 kVideoFormat, | 323 kVideoFormat, |
| 324 COLOR_SPACE_UNSPECIFIED, |
318 kCodedSize, | 325 kCodedSize, |
319 kVisibleRect, | 326 kVisibleRect, |
320 natural_size, | 327 natural_size, |
321 NULL, | 328 NULL, |
322 0, | 329 0, |
323 false); | 330 false); |
324 InitializeWithConfigWithResult(config, false); | 331 InitializeWithConfigWithResult(config, false); |
325 } | 332 } |
326 | 333 |
327 TEST_F(FFmpegVideoDecoderTest, Reinitialize_Normal) { | 334 TEST_F(FFmpegVideoDecoderTest, Reinitialize_Normal) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 469 |
463 // Test destruction when decoder has hit end of stream. | 470 // Test destruction when decoder has hit end of stream. |
464 TEST_F(FFmpegVideoDecoderTest, Destroy_EndOfStream) { | 471 TEST_F(FFmpegVideoDecoderTest, Destroy_EndOfStream) { |
465 Initialize(); | 472 Initialize(); |
466 EnterDecodingState(); | 473 EnterDecodingState(); |
467 EnterEndOfStreamState(); | 474 EnterEndOfStreamState(); |
468 Destroy(); | 475 Destroy(); |
469 } | 476 } |
470 | 477 |
471 } // namespace media | 478 } // namespace media |
OLD | NEW |