Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: media/filters/video_cadence_estimator_unittest.cc

Issue 1904213003: Convert //media/filters from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove include Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/filters/video_cadence_estimator.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
7 #include "base/memory/scoped_ptr.h" 9 #include <memory>
10
8 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
10 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
11 #include "media/filters/video_cadence_estimator.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 namespace media { 16 namespace media {
15 17
16 // See VideoCadenceEstimator header for more details. 18 // See VideoCadenceEstimator header for more details.
17 const int kMinimumAcceptableTimeBetweenGlitchesSecs = 8; 19 const int kMinimumAcceptableTimeBetweenGlitchesSecs = 8;
18 20
19 // Slows down the given |fps| according to NTSC field reduction standards; see 21 // Slows down the given |fps| according to NTSC field reduction standards; see
20 // http://en.wikipedia.org/wiki/Frame_rate#Digital_video_and_television 22 // http://en.wikipedia.org/wiki/Frame_rate#Digital_video_and_television
21 static double NTSC(double fps) { 23 static double NTSC(double fps) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // Increasing the acceptable drift should be result in more permissive 223 // Increasing the acceptable drift should be result in more permissive
222 // detection of cadence. 224 // detection of cadence.
223 acceptable_drift = render_interval; 225 acceptable_drift = render_interval;
224 EXPECT_TRUE(estimator.UpdateCadenceEstimate( 226 EXPECT_TRUE(estimator.UpdateCadenceEstimate(
225 render_interval, frame_interval, base::TimeDelta(), acceptable_drift)); 227 render_interval, frame_interval, base::TimeDelta(), acceptable_drift));
226 EXPECT_TRUE(estimator.has_cadence()); 228 EXPECT_TRUE(estimator.has_cadence());
227 EXPECT_EQ("[1:0]", estimator.GetCadenceForTesting()); 229 EXPECT_EQ("[1:0]", estimator.GetCadenceForTesting());
228 } 230 }
229 231
230 TEST(VideoCadenceEstimatorTest, CadenceVariesWithAcceptableGlitchTime) { 232 TEST(VideoCadenceEstimatorTest, CadenceVariesWithAcceptableGlitchTime) {
231 scoped_ptr<VideoCadenceEstimator> estimator(new VideoCadenceEstimator( 233 std::unique_ptr<VideoCadenceEstimator> estimator(new VideoCadenceEstimator(
232 base::TimeDelta::FromSeconds(kMinimumAcceptableTimeBetweenGlitchesSecs))); 234 base::TimeDelta::FromSeconds(kMinimumAcceptableTimeBetweenGlitchesSecs)));
233 estimator->set_cadence_hysteresis_threshold_for_testing(base::TimeDelta()); 235 estimator->set_cadence_hysteresis_threshold_for_testing(base::TimeDelta());
234 236
235 const base::TimeDelta render_interval = Interval(NTSC(60)); 237 const base::TimeDelta render_interval = Interval(NTSC(60));
236 const base::TimeDelta frame_interval = Interval(120); 238 const base::TimeDelta frame_interval = Interval(120);
237 const base::TimeDelta acceptable_drift = frame_interval / 2; 239 const base::TimeDelta acceptable_drift = frame_interval / 2;
238 240
239 EXPECT_FALSE(estimator->UpdateCadenceEstimate( 241 EXPECT_FALSE(estimator->UpdateCadenceEstimate(
240 render_interval, frame_interval, base::TimeDelta(), acceptable_drift)); 242 render_interval, frame_interval, base::TimeDelta(), acceptable_drift));
241 EXPECT_FALSE(estimator->has_cadence()); 243 EXPECT_FALSE(estimator->has_cadence());
242 244
243 // Decreasing the acceptable glitch time should be result in more permissive 245 // Decreasing the acceptable glitch time should be result in more permissive
244 // detection of cadence. 246 // detection of cadence.
245 estimator.reset(new VideoCadenceEstimator(base::TimeDelta::FromSeconds( 247 estimator.reset(new VideoCadenceEstimator(base::TimeDelta::FromSeconds(
246 kMinimumAcceptableTimeBetweenGlitchesSecs / 2))); 248 kMinimumAcceptableTimeBetweenGlitchesSecs / 2)));
247 estimator->set_cadence_hysteresis_threshold_for_testing(base::TimeDelta()); 249 estimator->set_cadence_hysteresis_threshold_for_testing(base::TimeDelta());
248 EXPECT_TRUE(estimator->UpdateCadenceEstimate( 250 EXPECT_TRUE(estimator->UpdateCadenceEstimate(
249 render_interval, frame_interval, base::TimeDelta(), acceptable_drift)); 251 render_interval, frame_interval, base::TimeDelta(), acceptable_drift));
250 EXPECT_TRUE(estimator->has_cadence()); 252 EXPECT_TRUE(estimator->has_cadence());
251 EXPECT_EQ("[1:0]", estimator->GetCadenceForTesting()); 253 EXPECT_EQ("[1:0]", estimator->GetCadenceForTesting());
252 } 254 }
253 255
254 TEST(VideoCadenceEstimatorTest, CadenceHystersisPreventsOscillation) { 256 TEST(VideoCadenceEstimatorTest, CadenceHystersisPreventsOscillation) {
255 scoped_ptr<VideoCadenceEstimator> estimator(new VideoCadenceEstimator( 257 std::unique_ptr<VideoCadenceEstimator> estimator(new VideoCadenceEstimator(
256 base::TimeDelta::FromSeconds(kMinimumAcceptableTimeBetweenGlitchesSecs))); 258 base::TimeDelta::FromSeconds(kMinimumAcceptableTimeBetweenGlitchesSecs)));
257 259
258 const base::TimeDelta render_interval = Interval(30); 260 const base::TimeDelta render_interval = Interval(30);
259 const base::TimeDelta frame_interval = Interval(60); 261 const base::TimeDelta frame_interval = Interval(60);
260 const base::TimeDelta acceptable_drift = frame_interval / 2; 262 const base::TimeDelta acceptable_drift = frame_interval / 2;
261 estimator->set_cadence_hysteresis_threshold_for_testing(render_interval * 2); 263 estimator->set_cadence_hysteresis_threshold_for_testing(render_interval * 2);
262 264
263 // Cadence hysteresis should prevent the cadence from taking effect yet. 265 // Cadence hysteresis should prevent the cadence from taking effect yet.
264 EXPECT_FALSE(estimator->UpdateCadenceEstimate( 266 EXPECT_FALSE(estimator->UpdateCadenceEstimate(
265 render_interval, frame_interval, base::TimeDelta(), acceptable_drift)); 267 render_interval, frame_interval, base::TimeDelta(), acceptable_drift));
(...skipping 22 matching lines...) Expand all
288 EXPECT_TRUE(estimator->has_cadence()); 290 EXPECT_TRUE(estimator->has_cadence());
289 291
290 // Two bad intervals should. 292 // Two bad intervals should.
291 EXPECT_TRUE( 293 EXPECT_TRUE(
292 estimator->UpdateCadenceEstimate(render_interval, frame_interval * 0.75, 294 estimator->UpdateCadenceEstimate(render_interval, frame_interval * 0.75,
293 base::TimeDelta(), acceptable_drift)); 295 base::TimeDelta(), acceptable_drift));
294 EXPECT_FALSE(estimator->has_cadence()); 296 EXPECT_FALSE(estimator->has_cadence());
295 } 297 }
296 298
297 } // namespace media 299 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/stream_parser_factory.cc ('k') | media/filters/video_decoder_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698