OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "media/base/media.h" | 8 #include "media/base/media.h" |
9 #include "media/ffmpeg/ffmpeg_common.h" | 9 #include "media/ffmpeg/ffmpeg_common.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 FFmpegCommonTest::FFmpegCommonTest() { | 51 FFmpegCommonTest::FFmpegCommonTest() { |
52 CHECK(InitFFmpeg()); | 52 CHECK(InitFFmpeg()); |
53 stream_.time_base = kTimeBase; | 53 stream_.time_base = kTimeBase; |
54 stream_.index_entries = kIndexEntries; | 54 stream_.index_entries = kIndexEntries; |
55 stream_.index_entries_allocated_size = sizeof(kIndexEntries); | 55 stream_.index_entries_allocated_size = sizeof(kIndexEntries); |
56 stream_.nb_index_entries = arraysize(kIndexEntries); | 56 stream_.nb_index_entries = arraysize(kIndexEntries); |
57 } | 57 } |
58 | 58 |
59 FFmpegCommonTest::~FFmpegCommonTest() {} | 59 FFmpegCommonTest::~FFmpegCommonTest() {} |
60 | 60 |
61 TEST_F(FFmpegCommonTest, TestTimeBaseConversions) { | 61 TEST_F(FFmpegCommonTest, TimeBaseConversions) { |
62 int64 test_data[][5] = { | 62 int64 test_data[][5] = { |
63 {1, 2, 1, 500000, 1 }, | 63 {1, 2, 1, 500000, 1 }, |
64 {1, 3, 1, 333333, 1 }, | 64 {1, 3, 1, 333333, 1 }, |
65 {1, 3, 2, 666667, 2 }, | 65 {1, 3, 2, 666667, 2 }, |
66 }; | 66 }; |
67 | 67 |
68 for (size_t i = 0; i < arraysize(test_data); ++i) { | 68 for (size_t i = 0; i < arraysize(test_data); ++i) { |
69 SCOPED_TRACE(i); | 69 SCOPED_TRACE(i); |
70 | 70 |
71 AVRational time_base; | 71 AVRational time_base; |
72 time_base.num = static_cast<int>(test_data[i][0]); | 72 time_base.num = static_cast<int>(test_data[i][0]); |
73 time_base.den = static_cast<int>(test_data[i][1]); | 73 time_base.den = static_cast<int>(test_data[i][1]); |
74 | 74 |
75 TimeDelta time_delta = ConvertFromTimeBase(time_base, test_data[i][2]); | 75 TimeDelta time_delta = ConvertFromTimeBase(time_base, test_data[i][2]); |
76 | 76 |
77 EXPECT_EQ(time_delta.InMicroseconds(), test_data[i][3]); | 77 EXPECT_EQ(time_delta.InMicroseconds(), test_data[i][3]); |
78 EXPECT_EQ(ConvertToTimeBase(time_base, time_delta), test_data[i][4]); | 78 EXPECT_EQ(ConvertToTimeBase(time_base, time_delta), test_data[i][4]); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 } // namespace media | 82 } // namespace media |
OLD | NEW |