Aec3:Remove unused legacy code
Bug: webrtc:8671 Change-Id: I54f14cc304dbe1639fbb356dbdf9beeb1781ede4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137801 Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28759}
This commit is contained in:
parent
d7ee76cadd
commit
cdbaeeb737
@ -63,8 +63,6 @@ AecState::AecState(const EchoCanceller3Config& config)
|
||||
delay_state_(config_),
|
||||
transparent_state_(config_),
|
||||
filter_quality_state_(config_),
|
||||
legacy_filter_quality_state_(config_),
|
||||
legacy_saturation_detector_(config_),
|
||||
erl_estimator_(2 * kNumBlocksPerSecond),
|
||||
erle_estimator_(2 * kNumBlocksPerSecond, config_),
|
||||
filter_analyzer_(config_),
|
||||
@ -83,7 +81,6 @@ void AecState::HandleEchoPathChange(
|
||||
blocks_with_active_render_ = 0;
|
||||
initial_state_.Reset();
|
||||
transparent_state_.Reset();
|
||||
legacy_saturation_detector_.Reset();
|
||||
erle_estimator_.Reset(true);
|
||||
erl_estimator_.Reset();
|
||||
filter_quality_state_.Reset();
|
||||
@ -409,78 +406,6 @@ void AecState::FilteringQualityAnalyzer::Update(
|
||||
usable_linear_estimate_ = usable_linear_estimate_ && !transparent_mode;
|
||||
}
|
||||
|
||||
AecState::LegacyFilteringQualityAnalyzer::LegacyFilteringQualityAnalyzer(
|
||||
const EchoCanceller3Config& config)
|
||||
: conservative_initial_phase_(config.filter.conservative_initial_phase),
|
||||
required_blocks_for_convergence_(
|
||||
kNumBlocksPerSecond * (conservative_initial_phase_ ? 1.5f : 0.8f)),
|
||||
linear_and_stable_echo_path_(
|
||||
config.echo_removal_control.linear_and_stable_echo_path),
|
||||
non_converged_sequence_size_(kBlocksSinceConvergencedFilterInit) {}
|
||||
|
||||
void AecState::LegacyFilteringQualityAnalyzer::Reset() {
|
||||
usable_linear_estimate_ = false;
|
||||
strong_not_saturated_render_blocks_ = 0;
|
||||
if (linear_and_stable_echo_path_) {
|
||||
recent_convergence_during_activity_ = false;
|
||||
}
|
||||
diverged_sequence_size_ = 0;
|
||||
// TODO(peah): Change to ensure proper triggering of usable filter.
|
||||
non_converged_sequence_size_ = 10000;
|
||||
recent_convergence_ = true;
|
||||
}
|
||||
|
||||
void AecState::LegacyFilteringQualityAnalyzer::Update(
|
||||
bool saturated_echo,
|
||||
bool active_render,
|
||||
bool saturated_capture,
|
||||
bool transparent_mode,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
bool converged_filter,
|
||||
bool diverged_filter) {
|
||||
diverged_sequence_size_ = diverged_filter ? diverged_sequence_size_ + 1 : 0;
|
||||
if (diverged_sequence_size_ >= 60) {
|
||||
// TODO(peah): Change these lines to ensure proper triggering of usable
|
||||
// filter.
|
||||
non_converged_sequence_size_ = 10000;
|
||||
recent_convergence_ = true;
|
||||
}
|
||||
|
||||
if (converged_filter) {
|
||||
non_converged_sequence_size_ = 0;
|
||||
recent_convergence_ = true;
|
||||
active_non_converged_sequence_size_ = 0;
|
||||
recent_convergence_during_activity_ = true;
|
||||
} else {
|
||||
if (++non_converged_sequence_size_ >= 60 * kNumBlocksPerSecond) {
|
||||
recent_convergence_ = false;
|
||||
}
|
||||
|
||||
if (active_render &&
|
||||
++active_non_converged_sequence_size_ > 60 * kNumBlocksPerSecond) {
|
||||
recent_convergence_during_activity_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
strong_not_saturated_render_blocks_ +=
|
||||
active_render && !saturated_capture ? 1 : 0;
|
||||
const bool filter_has_had_time_to_converge =
|
||||
strong_not_saturated_render_blocks_ > required_blocks_for_convergence_;
|
||||
|
||||
usable_linear_estimate_ = filter_has_had_time_to_converge && external_delay;
|
||||
|
||||
if (!conservative_initial_phase_ && recent_convergence_during_activity_) {
|
||||
usable_linear_estimate_ = true;
|
||||
}
|
||||
|
||||
if (!linear_and_stable_echo_path_ && !recent_convergence_) {
|
||||
usable_linear_estimate_ = false;
|
||||
}
|
||||
|
||||
if (saturated_echo || transparent_mode) {
|
||||
usable_linear_estimate_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AecState::SaturationDetector::Update(
|
||||
rtc::ArrayView<const float> x,
|
||||
@ -505,39 +430,4 @@ void AecState::SaturationDetector::Update(
|
||||
}
|
||||
}
|
||||
|
||||
AecState::LegacySaturationDetector::LegacySaturationDetector(
|
||||
const EchoCanceller3Config& config)
|
||||
: echo_can_saturate_(config.ep_strength.echo_can_saturate),
|
||||
not_saturated_sequence_size_(1000) {}
|
||||
|
||||
void AecState::LegacySaturationDetector::Reset() {
|
||||
not_saturated_sequence_size_ = 0;
|
||||
}
|
||||
|
||||
void AecState::LegacySaturationDetector::Update(rtc::ArrayView<const float> x,
|
||||
bool saturated_capture,
|
||||
float echo_path_gain) {
|
||||
if (!echo_can_saturate_) {
|
||||
saturated_echo_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RTC_DCHECK_LT(0, x.size());
|
||||
if (saturated_capture) {
|
||||
const float max_sample = fabs(*std::max_element(
|
||||
x.begin(), x.end(), [](float a, float b) { return a * a < b * b; }));
|
||||
|
||||
// Set flag for potential presence of saturated echo
|
||||
const float kMargin = 10.f;
|
||||
float peak_echo_amplitude = max_sample * echo_path_gain * kMargin;
|
||||
if (peak_echo_amplitude > 32000) {
|
||||
not_saturated_sequence_size_ = 0;
|
||||
saturated_echo_ = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
saturated_echo_ = ++not_saturated_sequence_size_ < 5;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -267,43 +267,6 @@ class AecState {
|
||||
bool convergence_seen_ = false;
|
||||
} filter_quality_state_;
|
||||
|
||||
// Class containing the legacy functionality for analyzing how well the linear
|
||||
// filter is, and can be expected to perform on the current signals. The
|
||||
// purpose of this is for using to select the echo suppression functionality
|
||||
// as well as the input to the echo suppressor.
|
||||
class LegacyFilteringQualityAnalyzer {
|
||||
public:
|
||||
explicit LegacyFilteringQualityAnalyzer(const EchoCanceller3Config& config);
|
||||
|
||||
// Returns whether the the linear filter is can be used for the echo
|
||||
// canceller output.
|
||||
bool LinearFilterUsable() const { return usable_linear_estimate_; }
|
||||
|
||||
// Resets the state of the analyzer.
|
||||
void Reset();
|
||||
|
||||
// Updates the analysis based on new data.
|
||||
void Update(bool saturated_echo,
|
||||
bool active_render,
|
||||
bool saturated_capture,
|
||||
bool transparent_mode,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
bool converged_filter,
|
||||
bool diverged_filter);
|
||||
|
||||
private:
|
||||
const bool conservative_initial_phase_;
|
||||
const float required_blocks_for_convergence_;
|
||||
const bool linear_and_stable_echo_path_;
|
||||
bool usable_linear_estimate_ = false;
|
||||
size_t strong_not_saturated_render_blocks_ = 0;
|
||||
size_t non_converged_sequence_size_;
|
||||
size_t diverged_sequence_size_ = 0;
|
||||
size_t active_non_converged_sequence_size_ = 0;
|
||||
bool recent_convergence_during_activity_ = false;
|
||||
bool recent_convergence_ = false;
|
||||
} legacy_filter_quality_state_;
|
||||
|
||||
// Class for detecting whether the echo is to be considered to be
|
||||
// saturated.
|
||||
class SaturationDetector {
|
||||
@ -322,30 +285,6 @@ class AecState {
|
||||
bool saturated_echo_ = false;
|
||||
} saturation_detector_;
|
||||
|
||||
// Legacy class for detecting whether the echo is to be considered to be
|
||||
// saturated. This is kept as a fallback solution to use instead of the class
|
||||
// SaturationDetector,
|
||||
class LegacySaturationDetector {
|
||||
public:
|
||||
explicit LegacySaturationDetector(const EchoCanceller3Config& config);
|
||||
|
||||
// Returns whether the echo is to be considered saturated.
|
||||
bool SaturatedEcho() const { return saturated_echo_; }
|
||||
|
||||
// Resets the state of the detector.
|
||||
void Reset();
|
||||
|
||||
// Updates the detection decision based on new data.
|
||||
void Update(rtc::ArrayView<const float> x,
|
||||
bool saturated_capture,
|
||||
float echo_path_gain);
|
||||
|
||||
private:
|
||||
const bool echo_can_saturate_;
|
||||
size_t not_saturated_sequence_size_;
|
||||
bool saturated_echo_ = false;
|
||||
} legacy_saturation_detector_;
|
||||
|
||||
ErlEstimator erl_estimator_;
|
||||
ErleEstimator erle_estimator_;
|
||||
size_t strong_not_saturated_render_blocks_ = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user