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

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

Issue 1729753003: Fix the stereo support in IntelligibilityEnhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@gains2
Patch Set: Rebasing 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) 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 25 matching lines...) Expand all
36 TEST(IntelligibilityUtilsTest, TestPowerEstimator) { 36 TEST(IntelligibilityUtilsTest, TestPowerEstimator) {
37 const size_t kFreqs = 10; 37 const size_t kFreqs = 10;
38 const size_t kSamples = 100; 38 const size_t kSamples = 100;
39 const float kDecay = 0.5f; 39 const float kDecay = 0.5f;
40 const std::vector<std::vector<std::complex<float>>> test_data( 40 const std::vector<std::vector<std::complex<float>>> test_data(
41 GenerateTestData(kFreqs, kSamples)); 41 GenerateTestData(kFreqs, kSamples));
42 PowerEstimator<std::complex<float>> power_estimator(kFreqs, kDecay); 42 PowerEstimator<std::complex<float>> power_estimator(kFreqs, kDecay);
43 EXPECT_EQ(0, power_estimator.power()[0]); 43 EXPECT_EQ(0, power_estimator.power()[0]);
44 44
45 // Makes sure Step is doing something. 45 // Makes sure Step is doing something.
46 power_estimator.Step(&test_data[0][0]); 46 power_estimator.Step(test_data[0].data());
47 for (size_t i = 1; i < kSamples; ++i) { 47 for (size_t i = 1; i < kSamples; ++i) {
48 power_estimator.Step(&test_data[i][0]); 48 power_estimator.Step(test_data[i].data());
49 for (size_t j = 0; j < kFreqs; ++j) { 49 for (size_t j = 0; j < kFreqs; ++j) {
50 EXPECT_GE(power_estimator.power()[j], 0.f); 50 EXPECT_GE(power_estimator.power()[j], 0.f);
51 EXPECT_LE(power_estimator.power()[j], 1.f); 51 EXPECT_LE(power_estimator.power()[j], 1.f);
52 } 52 }
53 } 53 }
54 } 54 }
55 55
56 // Tests gain applier. 56 // Tests gain applier.
57 TEST(IntelligibilityUtilsTest, TestGainApplier) { 57 TEST(IntelligibilityUtilsTest, TestGainApplier) {
58 const size_t kFreqs = 10; 58 const size_t kFreqs = 10;
59 const size_t kSamples = 100; 59 const size_t kSamples = 100;
60 const float kChangeLimit = 0.1f; 60 const float kChangeLimit = 0.1f;
61 GainApplier gain_applier(kFreqs, kChangeLimit); 61 GainApplier gain_applier(kFreqs, kChangeLimit);
62 const std::vector<std::vector<std::complex<float>>> in_data( 62 const std::vector<std::vector<std::complex<float>>> in_data(
63 GenerateTestData(kFreqs, kSamples)); 63 GenerateTestData(kFreqs, kSamples));
64 std::vector<std::vector<std::complex<float>>> out_data( 64 std::vector<std::vector<std::complex<float>>> out_data(
65 GenerateTestData(kFreqs, kSamples)); 65 GenerateTestData(kFreqs, kSamples));
66 for (size_t i = 0; i < kSamples; ++i) { 66 for (size_t i = 0; i < kSamples; ++i) {
67 gain_applier.Apply(&in_data[i][0], &out_data[i][0]); 67 gain_applier.Apply(in_data[i].data(), out_data[i].data());
68 for (size_t j = 0; j < kFreqs; ++j) { 68 for (size_t j = 0; j < kFreqs; ++j) {
69 EXPECT_GT(out_data[i][j].real(), 0.f); 69 EXPECT_GT(out_data[i][j].real(), 0.f);
70 EXPECT_LT(out_data[i][j].real(), 1.f); 70 EXPECT_LT(out_data[i][j].real(), 1.f);
71 EXPECT_GT(out_data[i][j].imag(), 0.f); 71 EXPECT_GT(out_data[i][j].imag(), 0.f);
72 EXPECT_LT(out_data[i][j].imag(), 1.f); 72 EXPECT_LT(out_data[i][j].imag(), 1.f);
73 } 73 }
74 } 74 }
75 } 75 }
76 76
77 } // namespace intelligibility 77 } // namespace intelligibility
78 78
79 } // namespace webrtc 79 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698