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

Side by Side Diff: webrtc/common_audio/resampler/push_sinc_resampler_unittest.cc

Issue 1712513002: Replace scoped_ptr with unique_ptr in webrtc/common_audio/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 10 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 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <cmath> 11 #include <cmath>
12 #include <cstring> 12 #include <cstring>
13 #include <memory>
13 14
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/common_audio/include/audio_util.h" 17 #include "webrtc/common_audio/include/audio_util.h"
18 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" 18 #include "webrtc/common_audio/resampler/push_sinc_resampler.h"
19 #include "webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h" 19 #include "webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h"
20 #include "webrtc/system_wrappers/include/tick_util.h" 20 #include "webrtc/system_wrappers/include/tick_util.h"
21 #include "webrtc/typedefs.h" 21 #include "webrtc/typedefs.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24 namespace { 24 namespace {
25 25
26 // Almost all conversions have an RMS error of around -14 dbFS. 26 // Almost all conversions have an RMS error of around -14 dbFS.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }; 64 };
65 65
66 void PushSincResamplerTest::ResampleBenchmarkTest(bool int_format) { 66 void PushSincResamplerTest::ResampleBenchmarkTest(bool int_format) {
67 const size_t input_samples = static_cast<size_t>(input_rate_ / 100); 67 const size_t input_samples = static_cast<size_t>(input_rate_ / 100);
68 const size_t output_samples = static_cast<size_t>(output_rate_ / 100); 68 const size_t output_samples = static_cast<size_t>(output_rate_ / 100);
69 const int kResampleIterations = 500000; 69 const int kResampleIterations = 500000;
70 70
71 // Source for data to be resampled. 71 // Source for data to be resampled.
72 ZeroSource resampler_source; 72 ZeroSource resampler_source;
73 73
74 rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]); 74 std::unique_ptr<float[]> resampled_destination(new float[output_samples]);
75 rtc::scoped_ptr<float[]> source(new float[input_samples]); 75 std::unique_ptr<float[]> source(new float[input_samples]);
76 rtc::scoped_ptr<int16_t[]> source_int(new int16_t[input_samples]); 76 std::unique_ptr<int16_t[]> source_int(new int16_t[input_samples]);
77 rtc::scoped_ptr<int16_t[]> destination_int(new int16_t[output_samples]); 77 std::unique_ptr<int16_t[]> destination_int(new int16_t[output_samples]);
78 78
79 resampler_source.Run(input_samples, source.get()); 79 resampler_source.Run(input_samples, source.get());
80 for (size_t i = 0; i < input_samples; ++i) { 80 for (size_t i = 0; i < input_samples; ++i) {
81 source_int[i] = static_cast<int16_t>(floor(32767 * source[i] + 0.5)); 81 source_int[i] = static_cast<int16_t>(floor(32767 * source[i] + 0.5));
82 } 82 }
83 83
84 printf("Benchmarking %d iterations of %d Hz -> %d Hz:\n", 84 printf("Benchmarking %d iterations of %d Hz -> %d Hz:\n",
85 kResampleIterations, input_rate_, output_rate_); 85 kResampleIterations, input_rate_, output_rate_);
86 const double io_ratio = input_rate_ / static_cast<double>(output_rate_); 86 const double io_ratio = input_rate_ / static_cast<double>(output_rate_);
87 SincResampler sinc_resampler(io_ratio, SincResampler::kDefaultRequestSize, 87 SincResampler sinc_resampler(io_ratio, SincResampler::kDefaultRequestSize,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const double input_nyquist_freq = 0.5 * input_rate_; 146 const double input_nyquist_freq = 0.5 * input_rate_;
147 147
148 // Source for data to be resampled. 148 // Source for data to be resampled.
149 SinusoidalLinearChirpSource resampler_source( 149 SinusoidalLinearChirpSource resampler_source(
150 input_rate_, input_samples, input_nyquist_freq, 0); 150 input_rate_, input_samples, input_nyquist_freq, 0);
151 151
152 PushSincResampler resampler(input_block_size, output_block_size); 152 PushSincResampler resampler(input_block_size, output_block_size);
153 153
154 // TODO(dalecurtis): If we switch to AVX/SSE optimization, we'll need to 154 // TODO(dalecurtis): If we switch to AVX/SSE optimization, we'll need to
155 // allocate these on 32-byte boundaries and ensure they're sized % 32 bytes. 155 // allocate these on 32-byte boundaries and ensure they're sized % 32 bytes.
156 rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]); 156 std::unique_ptr<float[]> resampled_destination(new float[output_samples]);
157 rtc::scoped_ptr<float[]> pure_destination(new float[output_samples]); 157 std::unique_ptr<float[]> pure_destination(new float[output_samples]);
158 rtc::scoped_ptr<float[]> source(new float[input_samples]); 158 std::unique_ptr<float[]> source(new float[input_samples]);
159 rtc::scoped_ptr<int16_t[]> source_int(new int16_t[input_block_size]); 159 std::unique_ptr<int16_t[]> source_int(new int16_t[input_block_size]);
160 rtc::scoped_ptr<int16_t[]> destination_int(new int16_t[output_block_size]); 160 std::unique_ptr<int16_t[]> destination_int(new int16_t[output_block_size]);
161 161
162 // The sinc resampler has an implicit delay of approximately half the kernel 162 // The sinc resampler has an implicit delay of approximately half the kernel
163 // size at the input sample rate. By moving to a push model, this delay 163 // size at the input sample rate. By moving to a push model, this delay
164 // becomes explicit and is managed by zero-stuffing in PushSincResampler. We 164 // becomes explicit and is managed by zero-stuffing in PushSincResampler. We
165 // deal with it in the test by delaying the "pure" source to match. It must be 165 // deal with it in the test by delaying the "pure" source to match. It must be
166 // checked before the first call to Resample(), because ChunkSize() will 166 // checked before the first call to Resample(), because ChunkSize() will
167 // change afterwards. 167 // change afterwards.
168 const size_t output_delay_samples = output_block_size - 168 const size_t output_delay_samples = output_block_size -
169 resampler.get_resampler_for_testing()->ChunkSize(); 169 resampler.get_resampler_for_testing()->ChunkSize();
170 170
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // To 32 kHz 326 // To 32 kHz
327 ::testing::make_tuple(8000, 32000, kResamplingRMSError, -70.30), 327 ::testing::make_tuple(8000, 32000, kResamplingRMSError, -70.30),
328 ::testing::make_tuple(16000, 32000, kResamplingRMSError, -75.51), 328 ::testing::make_tuple(16000, 32000, kResamplingRMSError, -75.51),
329 ::testing::make_tuple(32000, 32000, kResamplingRMSError, -75.51), 329 ::testing::make_tuple(32000, 32000, kResamplingRMSError, -75.51),
330 ::testing::make_tuple(44100, 32000, -16.44, -51.10), 330 ::testing::make_tuple(44100, 32000, -16.44, -51.10),
331 ::testing::make_tuple(48000, 32000, -16.90, -44.03), 331 ::testing::make_tuple(48000, 32000, -16.90, -44.03),
332 ::testing::make_tuple(96000, 32000, -19.61, -18.04), 332 ::testing::make_tuple(96000, 32000, -19.61, -18.04),
333 ::testing::make_tuple(192000, 32000, -21.02, -10.94))); 333 ::testing::make_tuple(192000, 32000, -21.02, -10.94)));
334 334
335 } // namespace webrtc 335 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_audio/resampler/push_sinc_resampler.h ('k') | webrtc/common_audio/resampler/sinc_resampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698