| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "media/base/limits.h" | 5 #include "media/base/limits.h" |
| 6 #include "media/base/media_util.h" | 6 #include "media/base/media_util.h" |
| 7 #include "media/base/video_decoder_config.h" | 7 #include "media/base/video_decoder_config.h" |
| 8 #include "media/base/video_util.h" | 8 #include "media/base/video_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 | 12 |
| 13 static const VideoPixelFormat kVideoFormat = PIXEL_FORMAT_YV12; | 13 static const VideoPixelFormat kVideoFormat = PIXEL_FORMAT_YV12; |
| 14 static const gfx::Size kCodedSize(320, 240); | 14 static const gfx::Size kCodedSize(320, 240); |
| 15 static const gfx::Rect kVisibleRect(320, 240); | 15 static const gfx::Rect kVisibleRect(320, 240); |
| 16 static const gfx::Size kNaturalSize(320, 240); | 16 static const gfx::Size kNaturalSize(320, 240); |
| 17 | 17 |
| 18 TEST(VideoDecoderConfigTest, Invalid_UnsupportedPixelFormat) { | 18 TEST(VideoDecoderConfigTest, Invalid_UnsupportedPixelFormat) { |
| 19 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, | 19 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, |
| 20 PIXEL_FORMAT_UNKNOWN, COLOR_SPACE_UNSPECIFIED, | 20 PIXEL_FORMAT_UNKNOWN, COLOR_SPACE_UNSPECIFIED, |
| 21 kCodedSize, kVisibleRect, kNaturalSize, | 21 kCodedSize, kVisibleRect, kNaturalSize, |
| 22 EmptyExtraData(), Unencrypted()); | 22 EmptyExtraData(), false); |
| 23 EXPECT_FALSE(config.IsValidConfig()); | 23 EXPECT_FALSE(config.IsValidConfig()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 TEST(VideoDecoderConfigTest, Invalid_AspectRatioNumeratorZero) { | 26 TEST(VideoDecoderConfigTest, Invalid_AspectRatioNumeratorZero) { |
| 27 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 0, 1); | 27 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 0, 1); |
| 28 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, | 28 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, |
| 29 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, | 29 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, |
| 30 natural_size, EmptyExtraData(), Unencrypted()); | 30 natural_size, EmptyExtraData(), false); |
| 31 EXPECT_FALSE(config.IsValidConfig()); | 31 EXPECT_FALSE(config.IsValidConfig()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 TEST(VideoDecoderConfigTest, Invalid_AspectRatioDenominatorZero) { | 34 TEST(VideoDecoderConfigTest, Invalid_AspectRatioDenominatorZero) { |
| 35 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, 0); | 35 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, 0); |
| 36 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, | 36 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, |
| 37 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, | 37 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, |
| 38 natural_size, EmptyExtraData(), Unencrypted()); | 38 natural_size, EmptyExtraData(), false); |
| 39 EXPECT_FALSE(config.IsValidConfig()); | 39 EXPECT_FALSE(config.IsValidConfig()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 TEST(VideoDecoderConfigTest, Invalid_AspectRatioNumeratorNegative) { | 42 TEST(VideoDecoderConfigTest, Invalid_AspectRatioNumeratorNegative) { |
| 43 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), -1, 1); | 43 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), -1, 1); |
| 44 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, | 44 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, |
| 45 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, | 45 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, |
| 46 natural_size, EmptyExtraData(), Unencrypted()); | 46 natural_size, EmptyExtraData(), false); |
| 47 EXPECT_FALSE(config.IsValidConfig()); | 47 EXPECT_FALSE(config.IsValidConfig()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 TEST(VideoDecoderConfigTest, Invalid_AspectRatioDenominatorNegative) { | 50 TEST(VideoDecoderConfigTest, Invalid_AspectRatioDenominatorNegative) { |
| 51 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, -1); | 51 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, -1); |
| 52 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, | 52 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, |
| 53 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, | 53 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, |
| 54 natural_size, EmptyExtraData(), Unencrypted()); | 54 natural_size, EmptyExtraData(), false); |
| 55 EXPECT_FALSE(config.IsValidConfig()); | 55 EXPECT_FALSE(config.IsValidConfig()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 TEST(VideoDecoderConfigTest, Invalid_AspectRatioNumeratorTooLarge) { | 58 TEST(VideoDecoderConfigTest, Invalid_AspectRatioNumeratorTooLarge) { |
| 59 int width = kVisibleRect.size().width(); | 59 int width = kVisibleRect.size().width(); |
| 60 int num = ceil(static_cast<double>(limits::kMaxDimension + 1) / width); | 60 int num = ceil(static_cast<double>(limits::kMaxDimension + 1) / width); |
| 61 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), num, 1); | 61 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), num, 1); |
| 62 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, | 62 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, |
| 63 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, | 63 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, |
| 64 natural_size, EmptyExtraData(), Unencrypted()); | 64 natural_size, EmptyExtraData(), false); |
| 65 EXPECT_FALSE(config.IsValidConfig()); | 65 EXPECT_FALSE(config.IsValidConfig()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST(VideoDecoderConfigTest, Invalid_AspectRatioDenominatorTooLarge) { | 68 TEST(VideoDecoderConfigTest, Invalid_AspectRatioDenominatorTooLarge) { |
| 69 // Denominator is large enough that the natural size height will be zero. | 69 // Denominator is large enough that the natural size height will be zero. |
| 70 int den = 2 * kVisibleRect.size().width() + 1; | 70 int den = 2 * kVisibleRect.size().width() + 1; |
| 71 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, den); | 71 gfx::Size natural_size = GetNaturalSize(kVisibleRect.size(), 1, den); |
| 72 EXPECT_EQ(0, natural_size.width()); | 72 EXPECT_EQ(0, natural_size.width()); |
| 73 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, | 73 VideoDecoderConfig config(kCodecVP8, VP8PROFILE_ANY, kVideoFormat, |
| 74 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, | 74 COLOR_SPACE_UNSPECIFIED, kCodedSize, kVisibleRect, |
| 75 natural_size, EmptyExtraData(), Unencrypted()); | 75 natural_size, EmptyExtraData(), false); |
| 76 EXPECT_FALSE(config.IsValidConfig()); | 76 EXPECT_FALSE(config.IsValidConfig()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace media | 79 } // namespace media |
| OLD | NEW |