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

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc

Issue 1766383002: Convert IntelligibilityEnhancer to multi-threaded mode (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 static_assert(arraysize(kTestCenterFreqs) == 194 static_assert(arraysize(kTestCenterFreqs) ==
195 arraysize(kTestNonZeroVarLambdaTop), 195 arraysize(kTestNonZeroVarLambdaTop),
196 "Power test data badly initialized."); 196 "Power test data badly initialized.");
197 const float kMaxTestError = 0.005f; 197 const float kMaxTestError = 0.005f;
198 198
199 // Enhancer initialization parameters. 199 // Enhancer initialization parameters.
200 const int kSamples = 1000; 200 const int kSamples = 1000;
201 const int kSampleRate = 4000; 201 const int kSampleRate = 4000;
202 const int kNumChannels = 1; 202 const int kNumChannels = 1;
203 const int kFragmentSize = kSampleRate / 100; 203 const int kFragmentSize = kSampleRate / 100;
204 const size_t kNumNoiseBins = 129;
peah-webrtc 2016/03/08 07:02:39 This is a bit of a strange number of bins, I would
aluebs-webrtc 2016/03/08 10:53:00 This is only a unittest and shouldn't affect at al
204 205
205 } // namespace 206 } // namespace
206 207
207 class IntelligibilityEnhancerTest : public ::testing::Test { 208 class IntelligibilityEnhancerTest : public ::testing::Test {
208 protected: 209 protected:
209 IntelligibilityEnhancerTest() 210 IntelligibilityEnhancerTest()
210 : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) { 211 : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) {
211 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels)); 212 enh_.reset(new IntelligibilityEnhancer(kSampleRate,
213 kNumChannels,
214 kNumNoiseBins));
212 } 215 }
213 216
214 bool CheckUpdate() { 217 bool CheckUpdate() {
215 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels)); 218 enh_.reset(new IntelligibilityEnhancer(kSampleRate,
219 kNumChannels,
220 kNumNoiseBins));
216 float* clear_cursor = clear_data_.data(); 221 float* clear_cursor = clear_data_.data();
217 float* noise_cursor = noise_data_.data(); 222 float* noise_cursor = noise_data_.data();
218 for (int i = 0; i < kSamples; i += kFragmentSize) { 223 for (int i = 0; i < kSamples; i += kFragmentSize) {
219 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); 224 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
220 clear_cursor += kFragmentSize; 225 clear_cursor += kFragmentSize;
221 noise_cursor += kFragmentSize; 226 noise_cursor += kFragmentSize;
222 } 227 }
223 for (int i = 0; i < kSamples; i++) { 228 for (int i = 0; i < kSamples; i++) {
224 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { 229 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) {
225 return true; 230 return true;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 291 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
287 } 292 }
288 lambda = -1.f; 293 lambda = -1.f;
289 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data()); 294 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data());
290 for (size_t i = 0; i < enh_->bank_size_; i++) { 295 for (size_t i = 0; i < enh_->bank_size_; i++) {
291 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 296 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
292 } 297 }
293 } 298 }
294 299
295 } // namespace webrtc 300 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698