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

Side by Side Diff: webrtc/modules/audio_processing/aec3/erle_estimator.cc

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Created 3 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
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_processing/aec3/erle_estimator.h"
12
13 #include <algorithm>
14
15 namespace webrtc {
16
17 namespace {
18 constexpr float kMinErle = 1.f;
19 constexpr float kMaxErle = 8.f;
20
21 } // namespace
22
23 void ErleEstimator::Update(
24 const std::array<float, kFftLengthBy2Plus1>& render_spectrum,
25 const std::array<float, kFftLengthBy2Plus1>& capture_spectrum,
26 const std::array<float, kFftLengthBy2Plus1>& linear_aec_output_spectrum) {
27 const std::array<float, kFftLengthBy2Plus1>& X2 = render_spectrum;
ivoc 2017/02/10 13:52:35 I would prefer const auto&.
peah-webrtc 2017/02/20 07:37:16 Done.
28 const std::array<float, kFftLengthBy2Plus1>& Y2 = capture_spectrum;
29 const std::array<float, kFftLengthBy2Plus1>& E2 = linear_aec_output_spectrum;
30
31 const float kX2Min = 44015068.0f;
ivoc 2017/02/10 13:52:34 Where does this value come from? A comment would b
peah-webrtc 2017/02/20 07:37:17 Done.
32
33 // Update the estimates in a clamped minimum statistics manner.
34 for (size_t k = 1; k < kFftLengthBy2; ++k) {
35 if (X2[k] > kX2Min && E2[k] > 0.f) {
36 const float new_erle = Y2[k] / E2[k];
37 if (new_erle > erle_[k]) {
38 hold_counters_[k - 1] = 150;
39 erle_[k] += 0.1f * (new_erle - erle_[k]);
40 erle_[k] = std::max(kMinErle, std::min(erle_[k], kMaxErle));
41 }
42 }
43 }
44
45 std::for_each(hold_counters_.begin(), hold_counters_.end(),
46 [](int& a) { --a; });
47 std::transform(hold_counters_.begin(), hold_counters_.end(),
48 erle_.begin() + 1, erle_.begin() + 1, [](int a, float b) {
49 return a > 0 ? b : std::max(kMinErle, 0.99f * b);
50 });
51
52 erle_[0] = erle_[1];
53 erle_[kFftLengthBy2] = erle_[kFftLengthBy2 - 1];
54 }
55
56 ErleEstimator::ErleEstimator() {
ivoc 2017/02/10 13:52:34 Move the constructor and destructor to the top of
peah-webrtc 2017/02/20 07:37:16 Done.
57 erle_.fill(kMinErle);
58 hold_counters_.fill(0);
59 }
60
61 ErleEstimator::~ErleEstimator() = default;
62
63 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698