Chromium Code Reviews| 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 7c29558c7e2c988079af5ad4554fe3b87369867d..d419174b947ab10d73124f71fb97c06d9c9c78cf 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, |
|
ivoc
2017/07/10 13:53:55
Is it possible to do the operations directly in h_
peah-webrtc
2017/07/10 23:18:09
That would be good, but unfortunately it is not po
|
| + 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 |