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

Unified Diff: webrtc/modules/audio_processing/aec3/subtractor.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/subtractor.cc
diff --git a/webrtc/modules/audio_processing/aec3/subtractor.cc b/webrtc/modules/audio_processing/aec3/subtractor.cc
index a7bf84d16b2357d9142c582a45cd1cd6978f2a4c..20ba5108e404ea9a00e350386f247f24f1ab88aa 100644
--- a/webrtc/modules/audio_processing/aec3/subtractor.cc
+++ b/webrtc/modules/audio_processing/aec3/subtractor.cc
@@ -25,15 +25,22 @@ void PredictionError(const Aec3Fft& fft,
const FftData& S,
rtc::ArrayView<const float> y,
std::array<float, kBlockSize>* e,
- FftData* E) {
- std::array<float, kFftLength> s;
- fft.Ifft(S, &s);
+ FftData* E,
+ std::array<float, kBlockSize>* s) {
+ std::array<float, kFftLength> s_scratch;
+ fft.Ifft(S, &s_scratch);
constexpr float kScale = 1.0f / kFftLengthBy2;
- std::transform(y.begin(), y.end(), s.begin() + kFftLengthBy2, e->begin(),
- [&](float a, float b) { return a - b * kScale; });
+ std::transform(y.begin(), y.end(), s_scratch.begin() + kFftLengthBy2,
+ e->begin(), [&](float a, float b) { return a - b * kScale; });
std::for_each(e->begin(), e->end(),
[](float& a) { a = rtc::SafeClamp(a, -32768.f, 32767.f); });
fft.ZeroPaddedFft(*e, E);
+
+ if (s) {
+ for (size_t k = 0; k < s->size(); ++k) {
+ (*s)[k] = kScale * s_scratch[k + kFftLengthBy2];
+ }
+ }
}
} // namespace
@@ -47,7 +54,7 @@ Subtractor::Subtractor(ApmDataDumper* data_dumper,
RTC_DCHECK(data_dumper_);
}
-Subtractor::~Subtractor() {}
+Subtractor::~Subtractor() = default;
void Subtractor::HandleEchoPathChange(
const EchoPathVariability& echo_path_variability) {
@@ -76,11 +83,11 @@ void Subtractor::Process(const RenderBuffer& render_buffer,
// Form the output of the main filter.
main_filter_.Filter(render_buffer, &S);
- PredictionError(fft_, S, y, &e_main, &E_main);
+ PredictionError(fft_, S, y, &e_main, &E_main, &output->s_main);
// Form the output of the shadow filter.
shadow_filter_.Filter(render_buffer, &S);
- PredictionError(fft_, S, y, &e_shadow, &E_shadow);
+ PredictionError(fft_, S, y, &e_shadow, &E_shadow, nullptr);
// Compute spectra for future use.
E_main.Spectrum(optimization_, &output->E2_main);
« no previous file with comments | « webrtc/modules/audio_processing/aec3/subtractor.h ('k') | webrtc/modules/audio_processing/aec3/subtractor_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698