Chromium Code Reviews| Index: webrtc/modules/audio_processing/aec3/erl_estimator_unittest.cc |
| diff --git a/webrtc/modules/audio_processing/aec3/erl_estimator_unittest.cc b/webrtc/modules/audio_processing/aec3/erl_estimator_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ca275206f2e70462cfc660a30012b3f42957ddb4 |
| --- /dev/null |
| +++ b/webrtc/modules/audio_processing/aec3/erl_estimator_unittest.cc |
| @@ -0,0 +1,80 @@ |
| +/* |
| + * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include "webrtc/modules/audio_processing/aec3/erl_estimator.h" |
| + |
| +#include "webrtc/test/gtest.h" |
| + |
| +namespace webrtc { |
| + |
| +// Verifies that the correct ERL estimates are achieved. |
| +TEST(ErlEstimator, Estimates) { |
| + std::array<float, kFftLengthBy2Plus1> X2; |
| + std::array<float, kFftLengthBy2Plus1> Y2; |
| + |
| + ErlEstimator estimator; |
| + |
| + // Verifies that the ERL estimate is properly reduced to lower values. |
| + X2.fill(500 * 1000.f * 1000.f); |
| + Y2.fill(10 * X2[0]); |
| + for (size_t k = 0; k < 200; ++k) { |
| + estimator.Update(X2, Y2); |
| + } |
| + { |
|
ivoc
2017/02/10 13:52:34
These lines reoccur a few times, you can consider
peah-webrtc
2017/02/20 07:37:16
Good suggestion!
Done.
|
| + const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); |
| + std::for_each(erl.begin(), erl.end(), |
| + [](float a) { EXPECT_NEAR(10.f, a, 0.001); }); |
| + } |
| + |
| + // Verifies that the ERL is not immediately increased when the ERL in the data |
| + // increases. |
| + Y2.fill(10000 * X2[0]); |
| + for (size_t k = 0; k < 998; ++k) { |
| + estimator.Update(X2, Y2); |
| + } |
| + { |
| + const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); |
| + std::for_each(erl.begin(), erl.end(), |
| + [](float a) { EXPECT_NEAR(10.f, a, 0.001); }); |
| + } |
| + |
| + // Verifies that the rate of increase is 3 dB. |
| + estimator.Update(X2, Y2); |
| + { |
| + const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); |
| + std::for_each(erl.begin(), erl.end(), |
| + [](float a) { EXPECT_NEAR(20.f, a, 0.001); }); |
| + } |
| + |
| + // Verifies that the maximum ERL is achieved when there are no low RLE |
| + // estimates. |
| + for (size_t k = 0; k < 1000; ++k) { |
| + estimator.Update(X2, Y2); |
| + } |
| + { |
| + const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); |
| + std::for_each(erl.begin(), erl.end(), |
| + [](float a) { EXPECT_NEAR(1000.f, a, 0.001); }); |
| + } |
| + |
| + // Verifies that the ERL estimate is is not updated for low-level signals |
| + X2.fill(1000.f * 1000.f); |
| + Y2.fill(10 * X2[0]); |
| + for (size_t k = 0; k < 200; ++k) { |
| + estimator.Update(X2, Y2); |
| + } |
| + { |
| + const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); |
| + std::for_each(erl.begin(), erl.end(), |
| + [](float a) { EXPECT_NEAR(1000.f, a, 0.001); }); |
| + } |
| +} |
| + |
| +} // namespace webrtc |