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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "media/filters/video_cadence_estimator.h" | 9 #include "media/filters/video_cadence_estimator.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 // See VideoCadenceEstimator header for more details. | 14 // See VideoCadenceEstimator header for more details. |
15 const int kMinimumAcceptableTimeBetweenGlitchesSecs = 8; | 15 const int kMinimumAcceptableTimeBetweenGlitchesSecs = 8; |
16 | 16 |
17 // Slows down the given |fps| according to NTSC field reduction standards; see | 17 // Slows down the given |fps| according to NTSC field reduction standards; see |
18 // http://en.wikipedia.org/wiki/Frame_rate#Digital_video_and_television | 18 // http://en.wikipedia.org/wiki/Frame_rate#Digital_video_and_television |
19 static double NTSC(double fps) { | 19 static double NTSC(double fps) { |
20 return fps / 1.001; | 20 return fps / 1.001; |
21 } | 21 } |
22 | 22 |
23 static base::TimeDelta Interval(double hertz) { | 23 static base::TimeDelta Interval(double hertz) { |
24 return base::TimeDelta::FromSecondsD(1.0 / hertz); | 24 return base::TimeDelta::FromSecondsD(1.0 / hertz); |
25 } | 25 } |
26 | 26 |
27 std::vector<int> CreateCadenceFromString(const std::string& cadence) { | 27 std::vector<int> CreateCadenceFromString(const std::string& cadence) { |
28 std::vector<std::string> tokens; | |
29 CHECK_EQ('[', cadence[0]); | 28 CHECK_EQ('[', cadence[0]); |
30 CHECK_EQ(']', cadence[cadence.length() - 1]); | 29 CHECK_EQ(']', cadence[cadence.length() - 1]); |
31 base::SplitString(cadence.substr(1, cadence.length() - 2), ':', &tokens); | |
32 | 30 |
33 std::vector<int> result; | 31 std::vector<int> result; |
34 for (const auto& token : tokens) { | 32 for (const std::string& token : |
| 33 base::SplitString(cadence.substr(1, cadence.length() - 2), |
| 34 ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
35 int cadence_value = 0; | 35 int cadence_value = 0; |
36 CHECK(base::StringToInt(token, &cadence_value)) << token; | 36 CHECK(base::StringToInt(token, &cadence_value)) << token; |
37 result.push_back(cadence_value); | 37 result.push_back(cadence_value); |
38 } | 38 } |
39 | 39 |
40 return result; | 40 return result; |
41 } | 41 } |
42 | 42 |
43 static void VerifyCadenceVector(VideoCadenceEstimator* estimator, | 43 static void VerifyCadenceVector(VideoCadenceEstimator* estimator, |
44 double frame_hertz, | 44 double frame_hertz, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 const base::TimeDelta render_interval = | 195 const base::TimeDelta render_interval = |
196 base::TimeDelta::FromMicroseconds(16715); | 196 base::TimeDelta::FromMicroseconds(16715); |
197 const base::TimeDelta frame_duration = | 197 const base::TimeDelta frame_duration = |
198 base::TimeDelta::FromMicroseconds(33360); | 198 base::TimeDelta::FromMicroseconds(33360); |
199 | 199 |
200 EXPECT_TRUE(estimator.UpdateCadenceEstimate(render_interval, frame_duration, | 200 EXPECT_TRUE(estimator.UpdateCadenceEstimate(render_interval, frame_duration, |
201 frame_duration / 2)); | 201 frame_duration / 2)); |
202 } | 202 } |
203 | 203 |
204 } // namespace media | 204 } // namespace media |
OLD | NEW |