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

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: Formatting 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;
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(
213 new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
212 } 214 }
213 215
214 bool CheckUpdate() { 216 bool CheckUpdate() {
215 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels)); 217 enh_.reset(
218 new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
216 float* clear_cursor = clear_data_.data(); 219 float* clear_cursor = clear_data_.data();
217 float* noise_cursor = noise_data_.data(); 220 float* noise_cursor = noise_data_.data();
218 for (int i = 0; i < kSamples; i += kFragmentSize) { 221 for (int i = 0; i < kSamples; i += kFragmentSize) {
219 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); 222 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
220 clear_cursor += kFragmentSize; 223 clear_cursor += kFragmentSize;
221 noise_cursor += kFragmentSize; 224 noise_cursor += kFragmentSize;
222 } 225 }
223 for (int i = 0; i < kSamples; i++) { 226 for (int i = 0; i < kSamples; i++) {
224 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { 227 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) {
225 return true; 228 return true;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 289 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
287 } 290 }
288 lambda = -1.f; 291 lambda = -1.f;
289 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data()); 292 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data());
290 for (size_t i = 0; i < enh_->bank_size_; i++) { 293 for (size_t i = 0; i < enh_->bank_size_; i++) {
291 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 294 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
292 } 295 }
293 } 296 }
294 297
295 } // namespace webrtc 298 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698