peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_AEC_STATE_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AEC3_AEC_STATE_H_ |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <array> |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 16 | #include <memory> |
| 17 | #include <vector> |
| 18 | |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 19 | #include "absl/types/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "api/array_view.h" |
Gustaf Ullberg | 3646f97 | 2018-02-14 15:19:04 +0100 | [diff] [blame] | 21 | #include "api/audio/echo_canceller3_config.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "modules/audio_processing/aec3/aec3_common.h" |
Per Åhgren | 3ab308f | 2018-02-21 08:46:03 +0100 | [diff] [blame] | 23 | #include "modules/audio_processing/aec3/delay_estimate.h" |
Jesús de Vicente Peña | d5cb477 | 2018-04-25 13:58:45 +0200 | [diff] [blame] | 24 | #include "modules/audio_processing/aec3/echo_audibility.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "modules/audio_processing/aec3/echo_path_variability.h" |
| 26 | #include "modules/audio_processing/aec3/erl_estimator.h" |
| 27 | #include "modules/audio_processing/aec3/erle_estimator.h" |
Per Åhgren | 5c532d3 | 2018-03-22 00:29:25 +0100 | [diff] [blame] | 28 | #include "modules/audio_processing/aec3/filter_analyzer.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 29 | #include "modules/audio_processing/aec3/render_buffer.h" |
Jesús de Vicente Peña | c98849c | 2018-10-22 11:41:05 +0200 | [diff] [blame] | 30 | #include "modules/audio_processing/aec3/render_reverb_model.h" |
Jesús de Vicente Peña | 496cedf | 2018-07-04 11:02:09 +0200 | [diff] [blame] | 31 | #include "modules/audio_processing/aec3/reverb_model_estimator.h" |
Per Åhgren | b20b937 | 2018-07-13 00:22:54 +0200 | [diff] [blame] | 32 | #include "modules/audio_processing/aec3/subtractor_output.h" |
| 33 | #include "modules/audio_processing/aec3/subtractor_output_analyzer.h" |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 34 | |
| 35 | namespace webrtc { |
| 36 | |
| 37 | class ApmDataDumper; |
| 38 | |
| 39 | // Handles the state and the conditions for the echo removal functionality. |
| 40 | class AecState { |
| 41 | public: |
Gustaf Ullberg | bd83b91 | 2017-10-18 12:32:42 +0200 | [diff] [blame] | 42 | explicit AecState(const EchoCanceller3Config& config); |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 43 | ~AecState(); |
| 44 | |
Per Åhgren | 4b3bc0f | 2017-12-20 15:26:13 +0100 | [diff] [blame] | 45 | // Returns whether the echo subtractor can be used to determine the residual |
| 46 | // echo. |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 47 | bool UsableLinearEstimate() const { |
| 48 | return filter_quality_state_.LinearFilterUsable(); |
| 49 | } |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 50 | |
Per Åhgren | 5c532d3 | 2018-03-22 00:29:25 +0100 | [diff] [blame] | 51 | // Returns whether the echo subtractor output should be used as output. |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 52 | bool UseLinearFilterOutput() const { |
| 53 | return filter_quality_state_.LinearFilterUsable(); |
| 54 | } |
Per Åhgren | 5c532d3 | 2018-03-22 00:29:25 +0100 | [diff] [blame] | 55 | |
| 56 | // Returns the estimated echo path gain. |
Per Åhgren | ced31ba | 2018-05-09 11:48:49 +0200 | [diff] [blame] | 57 | float EchoPathGain() const { return filter_analyzer_.Gain(); } |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 58 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 59 | // Returns whether the render signal is currently active. |
Per Åhgren | 4b3bc0f | 2017-12-20 15:26:13 +0100 | [diff] [blame] | 60 | bool ActiveRender() const { return blocks_with_active_render_ > 200; } |
peah | ebe7778 | 2017-02-27 07:29:21 -0800 | [diff] [blame] | 61 | |
Jesús de Vicente Peña | d5cb477 | 2018-04-25 13:58:45 +0200 | [diff] [blame] | 62 | // Returns the appropriate scaling of the residual echo to match the |
| 63 | // audibility. |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 64 | void GetResidualEchoScaling(rtc::ArrayView<float> residual_scaling) const; |
Jesús de Vicente Peña | d5cb477 | 2018-04-25 13:58:45 +0200 | [diff] [blame] | 65 | |
| 66 | // Returns whether the stationary properties of the signals are used in the |
| 67 | // aec. |
Per Åhgren | f4801a1 | 2018-09-27 13:14:02 +0200 | [diff] [blame] | 68 | bool UseStationaryProperties() const { |
| 69 | return config_.echo_audibility.use_stationary_properties; |
| 70 | } |
Jesús de Vicente Peña | d5cb477 | 2018-04-25 13:58:45 +0200 | [diff] [blame] | 71 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 72 | // Returns the ERLE. |
| 73 | const std::array<float, kFftLengthBy2Plus1>& Erle() const { |
| 74 | return erle_estimator_.Erle(); |
| 75 | } |
| 76 | |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 77 | // Returns an offset to apply to the estimation of the residual echo |
| 78 | // computation. Returning nullopt means that no offset should be used, while |
| 79 | // any other value will be applied as a multiplier to the estimated residual |
| 80 | // echo. |
| 81 | absl::optional<float> ErleUncertainty() const; |
Gustaf Ullberg | 6c618c7 | 2018-06-28 14:21:16 +0200 | [diff] [blame] | 82 | |
Jesús de Vicente Peña | e9a7e90 | 2018-09-27 11:49:39 +0200 | [diff] [blame] | 83 | // Returns the fullband ERLE estimate in log2 units. |
| 84 | float FullBandErleLog2() const { return erle_estimator_.FullbandErleLog2(); } |
Gustaf Ullberg | 332150d | 2017-11-22 14:17:39 +0100 | [diff] [blame] | 85 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 86 | // Returns the ERL. |
| 87 | const std::array<float, kFftLengthBy2Plus1>& Erl() const { |
| 88 | return erl_estimator_.Erl(); |
| 89 | } |
| 90 | |
Gustaf Ullberg | 332150d | 2017-11-22 14:17:39 +0100 | [diff] [blame] | 91 | // Returns the time-domain ERL. |
| 92 | float ErlTimeDomain() const { return erl_estimator_.ErlTimeDomain(); } |
| 93 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 94 | // Returns the delay estimate based on the linear filter. |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 95 | int FilterDelayBlocks() const { return delay_state_.DirectPathFilterDelay(); } |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 96 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 97 | // Returns whether the capture signal is saturated. |
| 98 | bool SaturatedCapture() const { return capture_signal_saturation_; } |
| 99 | |
peah | 86afe9d | 2017-04-06 15:45:32 -0700 | [diff] [blame] | 100 | // Returns whether the echo signal is saturated. |
Gustaf Ullberg | 68d6d44 | 2019-01-29 10:08:15 +0100 | [diff] [blame] | 101 | bool SaturatedEcho() const { return saturation_detector_.SaturatedEcho(); } |
peah | 86afe9d | 2017-04-06 15:45:32 -0700 | [diff] [blame] | 102 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 103 | // Updates the capture signal saturation. |
| 104 | void UpdateCaptureSaturation(bool capture_signal_saturation) { |
| 105 | capture_signal_saturation_ = capture_signal_saturation; |
| 106 | } |
| 107 | |
Per Åhgren | 1b4059e | 2017-10-15 20:19:21 +0200 | [diff] [blame] | 108 | // Returns whether the transparent mode is active |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 109 | bool TransparentMode() const { return transparent_state_.Active(); } |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 110 | |
peah | 86afe9d | 2017-04-06 15:45:32 -0700 | [diff] [blame] | 111 | // Takes appropriate action at an echo path change. |
| 112 | void HandleEchoPathChange(const EchoPathVariability& echo_path_variability); |
| 113 | |
peah | 8942045 | 2017-04-07 06:13:39 -0700 | [diff] [blame] | 114 | // Returns the decay factor for the echo reverberation. |
Jesús de Vicente Peña | 496cedf | 2018-07-04 11:02:09 +0200 | [diff] [blame] | 115 | float ReverbDecay() const { return reverb_model_estimator_.ReverbDecay(); } |
peah | 8942045 | 2017-04-07 06:13:39 -0700 | [diff] [blame] | 116 | |
Per Åhgren | ef5d5af | 2018-07-31 00:03:46 +0200 | [diff] [blame] | 117 | // Return the frequency response of the reverberant echo. |
| 118 | rtc::ArrayView<const float> GetReverbFrequencyResponse() const { |
| 119 | return reverb_model_estimator_.GetReverbFrequencyResponse(); |
| 120 | } |
| 121 | |
Jesús de Vicente Peña | 02e9e44 | 2018-08-29 13:34:07 +0200 | [diff] [blame] | 122 | // Returns whether the transition for going out of the initial stated has |
| 123 | // been triggered. |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 124 | bool TransitionTriggered() const { |
| 125 | return initial_state_.TransitionTriggered(); |
| 126 | } |
Per Åhgren | a98c807 | 2018-01-15 19:17:16 +0100 | [diff] [blame] | 127 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 128 | // Updates the aec state. |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 129 | void Update(const absl::optional<DelayEstimate>& external_delay, |
Per Åhgren | 3ab308f | 2018-02-21 08:46:03 +0100 | [diff] [blame] | 130 | const std::vector<std::array<float, kFftLengthBy2Plus1>>& |
peah | 86afe9d | 2017-04-06 15:45:32 -0700 | [diff] [blame] | 131 | adaptive_filter_frequency_response, |
Per Åhgren | 09a718a | 2017-12-11 22:28:45 +0100 | [diff] [blame] | 132 | const std::vector<float>& adaptive_filter_impulse_response, |
peah | 86afe9d | 2017-04-06 15:45:32 -0700 | [diff] [blame] | 133 | const RenderBuffer& render_buffer, |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 134 | const std::array<float, kFftLengthBy2Plus1>& E2_main, |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 135 | const std::array<float, kFftLengthBy2Plus1>& Y2, |
Per Åhgren | b20b937 | 2018-07-13 00:22:54 +0200 | [diff] [blame] | 136 | const SubtractorOutput& subtractor_output, |
| 137 | rtc::ArrayView<const float> y); |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 138 | |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 139 | // Returns filter length in blocks. |
| 140 | int FilterLengthBlocks() const { |
| 141 | return filter_analyzer_.FilterLengthBlocks(); |
| 142 | } |
| 143 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 144 | private: |
| 145 | static int instance_count_; |
| 146 | std::unique_ptr<ApmDataDumper> data_dumper_; |
Per Åhgren | 90e3fbd | 2018-05-16 15:25:04 +0200 | [diff] [blame] | 147 | const EchoCanceller3Config config_; |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 148 | |
| 149 | // Class for controlling the transition from the intial state, which in turn |
| 150 | // controls when the filter parameters for the initial state should be used. |
| 151 | class InitialState { |
| 152 | public: |
| 153 | explicit InitialState(const EchoCanceller3Config& config); |
| 154 | // Resets the state to again begin in the initial state. |
| 155 | void Reset(); |
| 156 | |
| 157 | // Updates the state based on new data. |
| 158 | void Update(bool active_render, bool saturated_capture); |
| 159 | |
| 160 | // Returns whether the initial state is active or not. |
| 161 | bool InitialStateActive() const { return initial_state_; } |
| 162 | |
| 163 | // Returns that the transition from the initial state has was started. |
| 164 | bool TransitionTriggered() const { return transition_triggered_; } |
| 165 | |
| 166 | private: |
| 167 | const bool conservative_initial_phase_; |
| 168 | const float initial_state_seconds_; |
| 169 | bool transition_triggered_ = false; |
| 170 | bool initial_state_ = true; |
| 171 | size_t strong_not_saturated_render_blocks_ = 0; |
| 172 | } initial_state_; |
| 173 | |
| 174 | // Class for choosing the direct-path delay relative to the beginning of the |
| 175 | // filter, as well as any other data related to the delay used within |
| 176 | // AecState. |
| 177 | class FilterDelay { |
| 178 | public: |
| 179 | explicit FilterDelay(const EchoCanceller3Config& config); |
| 180 | |
| 181 | // Returns whether an external delay has been reported to the AecState (from |
| 182 | // the delay estimator). |
| 183 | bool ExternalDelayReported() const { return external_delay_reported_; } |
| 184 | |
| 185 | // Returns the delay in blocks relative to the beginning of the filter that |
| 186 | // corresponds to the direct path of the echo. |
| 187 | int DirectPathFilterDelay() const { return filter_delay_blocks_; } |
| 188 | |
| 189 | // Updates the delay estimates based on new data. |
| 190 | void Update(const FilterAnalyzer& filter_analyzer, |
| 191 | const absl::optional<DelayEstimate>& external_delay, |
| 192 | size_t blocks_with_proper_filter_adaptation); |
| 193 | |
| 194 | private: |
Gustaf Ullberg | 9249fbf | 2019-03-14 11:24:54 +0100 | [diff] [blame^] | 195 | const int delay_headroom_samples_; |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 196 | bool external_delay_reported_ = false; |
| 197 | int filter_delay_blocks_ = 0; |
| 198 | absl::optional<DelayEstimate> external_delay_; |
| 199 | } delay_state_; |
| 200 | |
| 201 | // Class for detecting and toggling the transparent mode which causes the |
| 202 | // suppressor to apply no suppression. |
| 203 | class TransparentMode { |
| 204 | public: |
| 205 | explicit TransparentMode(const EchoCanceller3Config& config); |
| 206 | |
| 207 | // Returns whether the transparent mode should be active. |
| 208 | bool Active() const { return transparency_activated_; } |
| 209 | |
| 210 | // Resets the state of the detector. |
| 211 | void Reset(); |
| 212 | |
| 213 | // Updates the detection deciscion based on new data. |
| 214 | void Update(int filter_delay_blocks, |
| 215 | bool consistent_filter, |
| 216 | bool converged_filter, |
| 217 | bool diverged_filter, |
| 218 | bool active_render, |
| 219 | bool saturated_capture); |
| 220 | |
| 221 | private: |
| 222 | const bool bounded_erl_; |
| 223 | const bool linear_and_stable_echo_path_; |
| 224 | size_t capture_block_counter_ = 0; |
| 225 | bool transparency_activated_ = false; |
| 226 | size_t active_blocks_since_sane_filter_; |
| 227 | bool sane_filter_observed_ = false; |
| 228 | bool finite_erl_recently_detected_ = false; |
| 229 | size_t non_converged_sequence_size_; |
| 230 | size_t diverged_sequence_size_ = 0; |
| 231 | size_t active_non_converged_sequence_size_ = 0; |
| 232 | size_t num_converged_blocks_ = 0; |
| 233 | bool recent_convergence_during_activity_ = false; |
| 234 | size_t strong_not_saturated_render_blocks_ = 0; |
| 235 | } transparent_state_; |
| 236 | |
| 237 | // Class for analyzing how well the linear filter is, and can be expected to, |
| 238 | // perform on the current signals. The purpose of this is for using to |
| 239 | // select the echo suppression functionality as well as the input to the echo |
| 240 | // suppressor. |
| 241 | class FilteringQualityAnalyzer { |
| 242 | public: |
Per Åhgren | 3e7b7b1 | 2018-10-16 14:38:10 +0200 | [diff] [blame] | 243 | FilteringQualityAnalyzer(const EchoCanceller3Config& config); |
| 244 | |
| 245 | // Returns whether the the linear filter can be used for the echo |
| 246 | // canceller output. |
| 247 | bool LinearFilterUsable() const { return usable_linear_estimate_; } |
| 248 | |
| 249 | // Resets the state of the analyzer. |
| 250 | void Reset(); |
| 251 | |
| 252 | // Updates the analysis based on new data. |
| 253 | void Update(bool active_render, |
| 254 | bool transparent_mode, |
| 255 | bool saturated_capture, |
| 256 | bool consistent_estimate_, |
| 257 | const absl::optional<DelayEstimate>& external_delay, |
| 258 | bool converged_filter); |
| 259 | |
| 260 | private: |
| 261 | bool usable_linear_estimate_ = false; |
| 262 | size_t filter_update_blocks_since_reset_ = 0; |
| 263 | size_t filter_update_blocks_since_start_ = 0; |
| 264 | bool convergence_seen_ = false; |
| 265 | } filter_quality_state_; |
| 266 | |
| 267 | // Class containing the legacy functionality for analyzing how well the linear |
| 268 | // filter is, and can be expected to perform on the current signals. The |
| 269 | // purpose of this is for using to select the echo suppression functionality |
| 270 | // as well as the input to the echo suppressor. |
| 271 | class LegacyFilteringQualityAnalyzer { |
| 272 | public: |
| 273 | explicit LegacyFilteringQualityAnalyzer(const EchoCanceller3Config& config); |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 274 | |
| 275 | // Returns whether the the linear filter is can be used for the echo |
| 276 | // canceller output. |
| 277 | bool LinearFilterUsable() const { return usable_linear_estimate_; } |
| 278 | |
| 279 | // Resets the state of the analyzer. |
| 280 | void Reset(); |
| 281 | |
| 282 | // Updates the analysis based on new data. |
| 283 | void Update(bool saturated_echo, |
| 284 | bool active_render, |
| 285 | bool saturated_capture, |
| 286 | bool transparent_mode, |
| 287 | const absl::optional<DelayEstimate>& external_delay, |
| 288 | bool converged_filter, |
| 289 | bool diverged_filter); |
| 290 | |
| 291 | private: |
| 292 | const bool conservative_initial_phase_; |
| 293 | const float required_blocks_for_convergence_; |
| 294 | const bool linear_and_stable_echo_path_; |
| 295 | bool usable_linear_estimate_ = false; |
| 296 | size_t strong_not_saturated_render_blocks_ = 0; |
| 297 | size_t non_converged_sequence_size_; |
| 298 | size_t diverged_sequence_size_ = 0; |
| 299 | size_t active_non_converged_sequence_size_ = 0; |
| 300 | bool recent_convergence_during_activity_ = false; |
| 301 | bool recent_convergence_ = false; |
Per Åhgren | 3e7b7b1 | 2018-10-16 14:38:10 +0200 | [diff] [blame] | 302 | } legacy_filter_quality_state_; |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 303 | |
Per Åhgren | 3e7b7b1 | 2018-10-16 14:38:10 +0200 | [diff] [blame] | 304 | // Class for detecting whether the echo is to be considered to be |
| 305 | // saturated. |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 306 | class SaturationDetector { |
| 307 | public: |
Per Åhgren | 3e7b7b1 | 2018-10-16 14:38:10 +0200 | [diff] [blame] | 308 | // Returns whether the echo is to be considered saturated. |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame] | 309 | bool SaturatedEcho() const { return saturated_echo_; } |
Per Åhgren | 3e7b7b1 | 2018-10-16 14:38:10 +0200 | [diff] [blame] | 310 | |
| 311 | // Updates the detection decision based on new data. |
| 312 | void Update(rtc::ArrayView<const float> x, |
| 313 | bool saturated_capture, |
| 314 | bool usable_linear_estimate, |
| 315 | const SubtractorOutput& subtractor_output, |
| 316 | float echo_path_gain); |
| 317 | |
| 318 | private: |
| 319 | bool saturated_echo_ = false; |
| 320 | } saturation_detector_; |
| 321 | |
| 322 | // Legacy class for detecting whether the echo is to be considered to be |
| 323 | // saturated. This is kept as a fallback solution to use instead of the class |
| 324 | // SaturationDetector, |
| 325 | class LegacySaturationDetector { |
| 326 | public: |
| 327 | explicit LegacySaturationDetector(const EchoCanceller3Config& config); |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 328 | |
| 329 | // Returns whether the echo is to be considered saturated. |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame] | 330 | bool SaturatedEcho() const { return saturated_echo_; } |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 331 | |
| 332 | // Resets the state of the detector. |
| 333 | void Reset(); |
| 334 | |
| 335 | // Updates the detection decision based on new data. |
| 336 | void Update(rtc::ArrayView<const float> x, |
| 337 | bool saturated_capture, |
| 338 | float echo_path_gain); |
| 339 | |
| 340 | private: |
| 341 | const bool echo_can_saturate_; |
| 342 | size_t not_saturated_sequence_size_; |
| 343 | bool saturated_echo_ = false; |
Per Åhgren | 3e7b7b1 | 2018-10-16 14:38:10 +0200 | [diff] [blame] | 344 | } legacy_saturation_detector_; |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 345 | |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 346 | ErlEstimator erl_estimator_; |
| 347 | ErleEstimator erle_estimator_; |
Per Åhgren | c5a38ad | 2018-10-04 15:37:54 +0200 | [diff] [blame] | 348 | size_t strong_not_saturated_render_blocks_ = 0; |
Per Åhgren | 4b3bc0f | 2017-12-20 15:26:13 +0100 | [diff] [blame] | 349 | size_t blocks_with_active_render_ = 0; |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 350 | bool capture_signal_saturation_ = false; |
Per Åhgren | 5c532d3 | 2018-03-22 00:29:25 +0100 | [diff] [blame] | 351 | FilterAnalyzer filter_analyzer_; |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 352 | absl::optional<DelayEstimate> external_delay_; |
Jesús de Vicente Peña | d5cb477 | 2018-04-25 13:58:45 +0200 | [diff] [blame] | 353 | EchoAudibility echo_audibility_; |
Jesús de Vicente Peña | 496cedf | 2018-07-04 11:02:09 +0200 | [diff] [blame] | 354 | ReverbModelEstimator reverb_model_estimator_; |
Jesús de Vicente Peña | c98849c | 2018-10-22 11:41:05 +0200 | [diff] [blame] | 355 | RenderReverbModel render_reverb_; |
Per Åhgren | b20b937 | 2018-07-13 00:22:54 +0200 | [diff] [blame] | 356 | SubtractorOutputAnalyzer subtractor_output_analyzer_; |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 357 | }; |
| 358 | |
| 359 | } // namespace webrtc |
| 360 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 361 | #endif // MODULES_AUDIO_PROCESSING_AEC3_AEC_STATE_H_ |