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

Unified Diff: webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc

Issue 2974583004: Transparency improvements in the echo canceller 3 (Closed)
Patch Set: Corrected wrong echo estimate vector in unittest Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc
diff --git a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc
index b372df531d296777d5fd3c45407124da50230c50..43cc901f006aa3aa1999a3c894898b06b34da736 100644
--- a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc
+++ b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc
@@ -25,22 +25,6 @@
namespace webrtc {
-namespace {
-
-// Constrains the a partiton of the frequency domain filter to be limited in
-// time via setting the relevant time-domain coefficients to zero.
-void Constrain(const Aec3Fft& fft, FftData* H) {
- std::array<float, kFftLength> h;
- fft.Ifft(*H, &h);
- constexpr float kScale = 1.0f / kFftLengthBy2;
- std::for_each(h.begin(), h.begin() + kFftLengthBy2,
- [kScale](float& a) { a *= kScale; });
- std::fill(h.begin() + kFftLengthBy2, h.end(), 0.f);
- fft.Fft(&h, H);
-}
-
-} // namespace
-
namespace aec3 {
// Computes and stores the frequency response of the filter.
@@ -434,6 +418,7 @@ AdaptiveFirFilter::AdaptiveFirFilter(size_t size_partitions,
H2_(size_partitions, std::array<float, kFftLengthBy2Plus1>()) {
RTC_DCHECK(data_dumper_);
+ h_.fill(0.f);
for (auto& H_j : H_) {
H_j.Clear();
}
@@ -446,6 +431,7 @@ AdaptiveFirFilter::AdaptiveFirFilter(size_t size_partitions,
AdaptiveFirFilter::~AdaptiveFirFilter() = default;
void AdaptiveFirFilter::HandleEchoPathChange() {
+ h_.fill(0.f);
for (auto& H_j : H_) {
H_j.Clear();
}
@@ -493,10 +479,7 @@ void AdaptiveFirFilter::Adapt(const RenderBuffer& render_buffer,
}
// Constrain the filter partitions in a cyclic manner.
- Constrain(fft_, &H_[partition_to_constrain_]);
- partition_to_constrain_ = partition_to_constrain_ < (H_.size() - 1)
- ? partition_to_constrain_ + 1
- : 0;
+ Constrain();
// Update the frequency response and echo return loss for the filter.
switch (optimization_) {
@@ -518,4 +501,25 @@ void AdaptiveFirFilter::Adapt(const RenderBuffer& render_buffer,
}
}
+// Constrains the a partiton of the frequency domain filter to be limited in
+// time via setting the relevant time-domain coefficients to zero.
+void AdaptiveFirFilter::Constrain() {
+ std::array<float, kFftLength> h;
+ fft_.Ifft(H_[partition_to_constrain_], &h);
+
+ constexpr float kScale = 1.0f / kFftLengthBy2;
+ std::for_each(h.begin(), h.begin() + kFftLengthBy2,
+ [kScale](float& a) { a *= kScale; });
+ std::fill(h.begin() + kFftLengthBy2, h.end(), 0.f);
+
+ std::copy(h.begin(), h.begin() + kFftLengthBy2,
+ h_.begin() + partition_to_constrain_ * kFftLengthBy2);
+
+ fft_.Fft(&h, &H_[partition_to_constrain_]);
+
+ partition_to_constrain_ = partition_to_constrain_ < (H_.size() - 1)
+ ? partition_to_constrain_ + 1
+ : 0;
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698