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

Unified 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: Skip equivalent ratios. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/sinc_resampler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/sinc_resampler_unittest.cc
diff --git a/media/base/sinc_resampler_unittest.cc b/media/base/sinc_resampler_unittest.cc
index 62156d2de5ac6e49eaf1150db810ba4c11bf99d2..8b8b4dd67bd546601fcea75657a55b405c067eb4 100644
--- a/media/base/sinc_resampler_unittest.cc
+++ b/media/base/sinc_resampler_unittest.cc
@@ -98,6 +98,22 @@ TEST(SincResamplerTest, Flush) {
ASSERT_FLOAT_EQ(resampled_destination[i], 0);
}
+// Test flush resets the internal state properly.
+TEST(SincResamplerTest, DISABLED_SetRatioBench) {
+ MockSource mock_source;
+ SincResampler resampler(
+ kSampleRateRatio,
+ base::Bind(&MockSource::ProvideInput, base::Unretained(&mock_source)));
+
+ base::TimeTicks start = base::TimeTicks::HighResNow();
+ for (int i = 1; i < 10000; ++i)
+ resampler.SetRatio(1.0 / i);
Chris Rogers 2013/04/16 22:57:02 These are pretty insanely low ratio values! But,
DaleCurtis 2013/04/16 23:03:12 Correct, it's just a timing test, so this is fine.
+ double total_time_c_ms =
+ (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("SetRatio() took %.2fms.\n", total_time_c_ms);
+}
+
+
// Define platform independent function name for Convolve* tests.
#if defined(ARCH_CPU_X86_FAMILY)
#define CONVOLVE_FUNC Convolve_SSE
@@ -299,11 +315,24 @@ TEST_P(SincResamplerTest, Resample) {
SinusoidalLinearChirpSource resampler_source(
input_rate_, input_samples, input_nyquist_freq);
+ const double io_ratio = input_rate_ / static_cast<double>(output_rate_);
SincResampler resampler(
- input_rate_ / static_cast<double>(output_rate_),
+ io_ratio,
base::Bind(&SinusoidalLinearChirpSource::ProvideInput,
base::Unretained(&resampler_source)));
+ // Force an update to the sample rate ratio to ensure dyanmic sample rate
+ // changes are working correctly.
+ scoped_ptr<float[]> kernel(new float[SincResampler::kKernelStorageSize]);
+ memcpy(kernel.get(), resampler.get_kernel_for_testing(),
+ SincResampler::kKernelStorageSize);
+ resampler.SetRatio(M_PI);
+ ASSERT_NE(0, memcmp(kernel.get(), resampler.get_kernel_for_testing(),
+ SincResampler::kKernelStorageSize));
+ resampler.SetRatio(io_ratio);
+ ASSERT_EQ(0, memcmp(kernel.get(), resampler.get_kernel_for_testing(),
+ SincResampler::kKernelStorageSize));
+
// TODO(dalecurtis): If we switch to AVX/SSE optimization, we'll need to
// allocate these on 32-byte boundaries and ensure they're sized % 32 bytes.
scoped_ptr<float[]> resampled_destination(new float[output_samples]);
« no previous file with comments | « media/base/sinc_resampler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698