From 2f0f93a0c9a606753b527a836a2117c58036d5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Thu, 10 Sep 2020 09:29:42 +0200 Subject: [PATCH] Add explicit initialization for the FilterAnalyzer in AEC3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds explicit initialization of the FilterAnalyzer in AEC3. While the current code never uses any fields before they are initialized, it makes sense to be on the safe side and add initialization during construction. Bug: webrtc:11918 Change-Id: I467c4c8b8d6dd859a1b216baef28ac1e9d3f76c2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183764 Reviewed-by: Jesus de Vicente Pena Commit-Queue: Per Ã…hgren Cr-Commit-Position: refs/heads/master@{#32069} --- modules/audio_processing/aec3/filter_analyzer.cc | 8 ++++---- modules/audio_processing/aec3/filter_analyzer.h | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/audio_processing/aec3/filter_analyzer.cc b/modules/audio_processing/aec3/filter_analyzer.cc index 696a57c18d..be954d3a18 100644 --- a/modules/audio_processing/aec3/filter_analyzer.cc +++ b/modules/audio_processing/aec3/filter_analyzer.cc @@ -69,9 +69,7 @@ void FilterAnalyzer::Reset() { blocks_since_reset_ = 0; ResetRegion(); for (auto& state : filter_analysis_states_) { - state.peak_index = 0; - state.gain = default_gain_; - state.consistent_filter_detector.Reset(); + state.Reset(default_gain_); } std::fill(filter_delays_blocks_.begin(), filter_delays_blocks_.end(), 0); } @@ -204,7 +202,9 @@ FilterAnalyzer::ConsistentFilterDetector::ConsistentFilterDetector( const EchoCanceller3Config& config) : active_render_threshold_(config.render_levels.active_render_limit * config.render_levels.active_render_limit * - kFftLengthBy2) {} + kFftLengthBy2) { + Reset(); +} void FilterAnalyzer::ConsistentFilterDetector::Reset() { significant_peak_ = false; diff --git a/modules/audio_processing/aec3/filter_analyzer.h b/modules/audio_processing/aec3/filter_analyzer.h index 0be2a7bc30..b0b7070119 100644 --- a/modules/audio_processing/aec3/filter_analyzer.h +++ b/modules/audio_processing/aec3/filter_analyzer.h @@ -112,7 +112,16 @@ class FilterAnalyzer { struct FilterAnalysisState { explicit FilterAnalysisState(const EchoCanceller3Config& config) : filter_length_blocks(config.filter.refined_initial.length_blocks), - consistent_filter_detector(config) {} + consistent_filter_detector(config) { + Reset(config.ep_strength.default_gain); + } + + void Reset(float default_gain) { + peak_index = 0; + gain = default_gain; + consistent_filter_detector.Reset(); + } + float gain; size_t peak_index; int filter_length_blocks;