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

Side by Side Diff: media/base/sinc_resampler_unittest.cc

Issue 13741004: Varispeed support for SincResampler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« media/base/sinc_resampler.cc ('K') | « media/base/sinc_resampler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Flush and request more data, which should all be zeros now. 91 // Flush and request more data, which should all be zeros now.
92 resampler.Flush(); 92 resampler.Flush();
93 testing::Mock::VerifyAndClear(&mock_source); 93 testing::Mock::VerifyAndClear(&mock_source);
94 EXPECT_CALL(mock_source, ProvideInput(_, _)) 94 EXPECT_CALL(mock_source, ProvideInput(_, _))
95 .Times(1).WillOnce(ClearBuffer()); 95 .Times(1).WillOnce(ClearBuffer());
96 resampler.Resample(resampled_destination.get(), resampler.ChunkSize() / 2); 96 resampler.Resample(resampled_destination.get(), resampler.ChunkSize() / 2);
97 for (int i = 0; i < resampler.ChunkSize() / 2; ++i) 97 for (int i = 0; i < resampler.ChunkSize() / 2; ++i)
98 ASSERT_FLOAT_EQ(resampled_destination[i], 0); 98 ASSERT_FLOAT_EQ(resampled_destination[i], 0);
99 } 99 }
100 100
101 // Test flush resets the internal state properly.
102 TEST(SincResamplerTest, KernelBench) {
103 MockSource mock_source;
104 SincResampler resampler(
105 kSampleRateRatio,
106 base::Bind(&MockSource::ProvideInput, base::Unretained(&mock_source)));
107 scoped_array<float> resampled_destination(new float[resampler.ChunkSize()]);
108
109 base::TimeTicks start = base::TimeTicks::HighResNow();
110 for (int i = 1; i < 10000; ++i) {
111 resampler.UpdateSampleRateRatio((i % 100) / 100.0);
112 }
113 double total_time_c_ms =
114 (base::TimeTicks::HighResNow() - start).InMillisecondsF();
115 printf("UpdateSampleRateRatio took %.2fms.\n", total_time_c_ms);
116 }
117
118
101 // Define platform independent function name for Convolve* tests. 119 // Define platform independent function name for Convolve* tests.
102 #if defined(ARCH_CPU_X86_FAMILY) 120 #if defined(ARCH_CPU_X86_FAMILY)
103 #define CONVOLVE_FUNC Convolve_SSE 121 #define CONVOLVE_FUNC Convolve_SSE
104 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) 122 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
105 #define CONVOLVE_FUNC Convolve_NEON 123 #define CONVOLVE_FUNC Convolve_NEON
106 #endif 124 #endif
107 125
108 // Ensure various optimized Convolve() methods return the same value. Only run 126 // Ensure various optimized Convolve() methods return the same value. Only run
109 // this test if other optimized methods exist, otherwise the default Convolve() 127 // this test if other optimized methods exist, otherwise the default Convolve()
110 // will be tested by the parameterized SincResampler tests below. 128 // will be tested by the parameterized SincResampler tests below.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 std::tr1::make_tuple(11025, 192000, kResamplingRMSError, -62.61), 423 std::tr1::make_tuple(11025, 192000, kResamplingRMSError, -62.61),
406 std::tr1::make_tuple(16000, 192000, kResamplingRMSError, -63.14), 424 std::tr1::make_tuple(16000, 192000, kResamplingRMSError, -63.14),
407 std::tr1::make_tuple(22050, 192000, kResamplingRMSError, -62.42), 425 std::tr1::make_tuple(22050, 192000, kResamplingRMSError, -62.42),
408 std::tr1::make_tuple(32000, 192000, kResamplingRMSError, -63.38), 426 std::tr1::make_tuple(32000, 192000, kResamplingRMSError, -63.38),
409 std::tr1::make_tuple(44100, 192000, kResamplingRMSError, -62.63), 427 std::tr1::make_tuple(44100, 192000, kResamplingRMSError, -62.63),
410 std::tr1::make_tuple(48000, 192000, kResamplingRMSError, -73.44), 428 std::tr1::make_tuple(48000, 192000, kResamplingRMSError, -73.44),
411 std::tr1::make_tuple(96000, 192000, kResamplingRMSError, -73.52), 429 std::tr1::make_tuple(96000, 192000, kResamplingRMSError, -73.52),
412 std::tr1::make_tuple(192000, 192000, kResamplingRMSError, -73.52))); 430 std::tr1::make_tuple(192000, 192000, kResamplingRMSError, -73.52)));
413 431
414 } // namespace media 432 } // namespace media
OLDNEW
« media/base/sinc_resampler.cc ('K') | « media/base/sinc_resampler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698