Removing unused fallback variant for the reverb computation
This CL removes a long unused fallback behavior for the reverb computation. Bug: webrtc:8671 Change-Id: I4b57795a9bb33769237858f40392881ee235653e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148520 Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28802}
This commit is contained in:
@ -90,7 +90,6 @@ struct RTC_EXPORT EchoCanceller3Config {
|
||||
struct EpStrength {
|
||||
float default_gain = 1.f;
|
||||
float default_len = 0.83f;
|
||||
bool reverb_based_on_render = true;
|
||||
bool echo_can_saturate = true;
|
||||
bool bounded_erl = false;
|
||||
} ep_strength;
|
||||
|
@ -200,8 +200,6 @@ void Aec3ConfigFromJsonString(absl::string_view json_string,
|
||||
if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", §ion)) {
|
||||
ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
|
||||
ReadParam(section, "default_len", &cfg.ep_strength.default_len);
|
||||
ReadParam(section, "reverb_based_on_render",
|
||||
&cfg.ep_strength.reverb_based_on_render);
|
||||
ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
|
||||
ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
|
||||
}
|
||||
@ -410,8 +408,6 @@ std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
|
||||
ost << "\"ep_strength\": {";
|
||||
ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
|
||||
ost << "\"default_len\": " << config.ep_strength.default_len << ",";
|
||||
ost << "\"reverb_based_on_render\": "
|
||||
<< (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
|
||||
ost << "\"echo_can_saturate\": "
|
||||
<< (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
|
||||
ost << "\"bounded_erl\": "
|
||||
|
@ -98,8 +98,6 @@ rtc_static_library("aec3") {
|
||||
"reverb_model.h",
|
||||
"reverb_model_estimator.cc",
|
||||
"reverb_model_estimator.h",
|
||||
"reverb_model_fallback.cc",
|
||||
"reverb_model_fallback.h",
|
||||
"shadow_filter_update_gain.cc",
|
||||
"shadow_filter_update_gain.h",
|
||||
"signal_dependent_erle_estimator.cc",
|
||||
|
@ -136,10 +136,9 @@ void AecState::Update(
|
||||
active_render && !SaturatedCapture() ? 1 : 0;
|
||||
|
||||
std::array<float, kFftLengthBy2Plus1> X2_reverb;
|
||||
render_reverb_.Apply(
|
||||
render_buffer.GetSpectrumBuffer(), delay_state_.DirectPathFilterDelay(),
|
||||
config_.ep_strength.reverb_based_on_render ? ReverbDecay() : 0.f,
|
||||
X2_reverb);
|
||||
render_reverb_.Apply(render_buffer.GetSpectrumBuffer(),
|
||||
delay_state_.DirectPathFilterDelay(), ReverbDecay(),
|
||||
X2_reverb);
|
||||
|
||||
if (config_.echo_audibility.use_stationarity_properties) {
|
||||
// Update the echo audibility evaluator.
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/reverb_model.h"
|
||||
#include "modules/audio_processing/aec3/reverb_model_fallback.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -48,12 +47,6 @@ void GetRenderIndexesToAnalyze(
|
||||
|
||||
ResidualEchoEstimator::ResidualEchoEstimator(const EchoCanceller3Config& config)
|
||||
: config_(config) {
|
||||
if (config_.ep_strength.reverb_based_on_render) {
|
||||
echo_reverb_.reset(new ReverbModel());
|
||||
} else {
|
||||
echo_reverb_fallback.reset(
|
||||
new ReverbModelFallback(config_.filter.main.length_blocks));
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
@ -83,18 +76,9 @@ void ResidualEchoEstimator::Estimate(
|
||||
|
||||
// Adds the estimated unmodelled echo power to the residual echo power
|
||||
// estimate.
|
||||
if (echo_reverb_) {
|
||||
echo_reverb_->AddReverb(
|
||||
render_buffer.Spectrum(aec_state.FilterLengthBlocks() + 1),
|
||||
aec_state.GetReverbFrequencyResponse(), aec_state.ReverbDecay(), *R2);
|
||||
|
||||
} else {
|
||||
RTC_DCHECK(echo_reverb_fallback);
|
||||
echo_reverb_fallback->AddEchoReverb(S2_linear,
|
||||
aec_state.FilterDelayBlocks(),
|
||||
aec_state.ReverbDecay(), R2);
|
||||
}
|
||||
|
||||
echo_reverb_.AddReverb(
|
||||
render_buffer.Spectrum(aec_state.FilterLengthBlocks() + 1),
|
||||
aec_state.GetReverbFrequencyResponse(), aec_state.ReverbDecay(), *R2);
|
||||
} else {
|
||||
// Estimate the echo generating signal power.
|
||||
std::array<float, kFftLengthBy2Plus1> X2;
|
||||
@ -123,16 +107,9 @@ void ResidualEchoEstimator::Estimate(
|
||||
}
|
||||
|
||||
if (!(aec_state.TransparentMode())) {
|
||||
if (echo_reverb_) {
|
||||
echo_reverb_->AddReverbNoFreqShaping(
|
||||
render_buffer.Spectrum(aec_state.FilterDelayBlocks() + 1),
|
||||
echo_path_gain * echo_path_gain, aec_state.ReverbDecay(), *R2);
|
||||
} else {
|
||||
RTC_DCHECK(echo_reverb_fallback);
|
||||
echo_reverb_fallback->AddEchoReverb(*R2,
|
||||
config_.filter.main.length_blocks,
|
||||
aec_state.ReverbDecay(), R2);
|
||||
}
|
||||
echo_reverb_.AddReverbNoFreqShaping(
|
||||
render_buffer.Spectrum(aec_state.FilterDelayBlocks() + 1),
|
||||
echo_path_gain * echo_path_gain, aec_state.ReverbDecay(), *R2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,12 +124,7 @@ void ResidualEchoEstimator::Estimate(
|
||||
}
|
||||
|
||||
void ResidualEchoEstimator::Reset() {
|
||||
if (echo_reverb_) {
|
||||
echo_reverb_->Reset();
|
||||
} else {
|
||||
RTC_DCHECK(echo_reverb_fallback);
|
||||
echo_reverb_fallback->Reset();
|
||||
}
|
||||
echo_reverb_.Reset();
|
||||
X2_noise_floor_counter_.fill(config_.echo_model.noise_floor_hold);
|
||||
X2_noise_floor_.fill(config_.echo_model.min_noise_floor_power);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "modules/audio_processing/aec3/aec_state.h"
|
||||
#include "modules/audio_processing/aec3/render_buffer.h"
|
||||
#include "modules/audio_processing/aec3/reverb_model.h"
|
||||
#include "modules/audio_processing/aec3/reverb_model_fallback.h"
|
||||
#include "modules/audio_processing/aec3/vector_buffer.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/constructor_magic.h"
|
||||
@ -40,12 +39,7 @@ class ResidualEchoEstimator {
|
||||
|
||||
// Returns the reverberant power spectrum contributions to the echo residual.
|
||||
rtc::ArrayView<const float> GetReverbPowerSpectrum() const {
|
||||
if (echo_reverb_) {
|
||||
return echo_reverb_->GetPowerSpectrum();
|
||||
} else {
|
||||
RTC_DCHECK(echo_reverb_fallback);
|
||||
return echo_reverb_fallback->GetPowerSpectrum();
|
||||
}
|
||||
return echo_reverb_.GetPowerSpectrum();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -83,8 +77,7 @@ class ResidualEchoEstimator {
|
||||
const EchoCanceller3Config config_;
|
||||
std::array<float, kFftLengthBy2Plus1> X2_noise_floor_;
|
||||
std::array<int, kFftLengthBy2Plus1> X2_noise_floor_counter_;
|
||||
std::unique_ptr<ReverbModel> echo_reverb_;
|
||||
std::unique_ptr<ReverbModelFallback> echo_reverb_fallback;
|
||||
ReverbModel echo_reverb_;
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ResidualEchoEstimator);
|
||||
};
|
||||
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "modules/audio_processing/aec3/reverb_model_fallback.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ReverbModelFallback::ReverbModelFallback(size_t length_blocks)
|
||||
: S2_old_(length_blocks) {
|
||||
Reset();
|
||||
}
|
||||
|
||||
ReverbModelFallback::~ReverbModelFallback() = default;
|
||||
|
||||
void ReverbModelFallback::Reset() {
|
||||
R2_reverb_.fill(0.f);
|
||||
for (auto& S2_k : S2_old_) {
|
||||
S2_k.fill(0.f);
|
||||
}
|
||||
}
|
||||
|
||||
void ReverbModelFallback::AddEchoReverb(
|
||||
const std::array<float, kFftLengthBy2Plus1>& S2,
|
||||
size_t delay,
|
||||
float reverb_decay_factor,
|
||||
std::array<float, kFftLengthBy2Plus1>* R2) {
|
||||
// Compute the decay factor for how much the echo has decayed before leaving
|
||||
// the region covered by the linear model.
|
||||
auto integer_power = [](float base, int exp) {
|
||||
float result = 1.f;
|
||||
for (int k = 0; k < exp; ++k) {
|
||||
result *= base;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
RTC_DCHECK_LE(delay, S2_old_.size());
|
||||
const float reverb_decay_for_delay =
|
||||
integer_power(reverb_decay_factor, S2_old_.size() - delay);
|
||||
|
||||
// Update the estimate of the reverberant residual echo power.
|
||||
S2_old_index_ = S2_old_index_ > 0 ? S2_old_index_ - 1 : S2_old_.size() - 1;
|
||||
const auto& S2_end = S2_old_[S2_old_index_];
|
||||
std::transform(
|
||||
S2_end.begin(), S2_end.end(), R2_reverb_.begin(), R2_reverb_.begin(),
|
||||
[reverb_decay_for_delay, reverb_decay_factor](float a, float b) {
|
||||
return (b + a * reverb_decay_for_delay) * reverb_decay_factor;
|
||||
});
|
||||
|
||||
// Update the buffer of old echo powers.
|
||||
std::copy(S2.begin(), S2.end(), S2_old_[S2_old_index_].begin());
|
||||
|
||||
// Add the power of the echo reverb to the residual echo power.
|
||||
std::transform(R2->begin(), R2->end(), R2_reverb_.begin(), R2->begin(),
|
||||
std::plus<float>());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_FALLBACK_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_FALLBACK_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// The ReverbModelFallback class describes an exponential reverberant model.
|
||||
// This model is expected to be applied over the echo power spectrum that
|
||||
// is estimated by the linear filter.
|
||||
|
||||
class ReverbModelFallback {
|
||||
public:
|
||||
explicit ReverbModelFallback(size_t length_blocks);
|
||||
~ReverbModelFallback();
|
||||
|
||||
// Resets the state
|
||||
void Reset();
|
||||
|
||||
// Adds the estimated unmodelled echo power to the residual echo power
|
||||
// estimate.
|
||||
void AddEchoReverb(const std::array<float, kFftLengthBy2Plus1>& S2,
|
||||
size_t delay,
|
||||
float reverb_decay_factor,
|
||||
std::array<float, kFftLengthBy2Plus1>* R2);
|
||||
|
||||
// Returns the current power spectrum reverberation contributions.
|
||||
const std::array<float, kFftLengthBy2Plus1>& GetPowerSpectrum() const {
|
||||
return R2_reverb_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<float, kFftLengthBy2Plus1> R2_reverb_;
|
||||
int S2_old_index_ = 0;
|
||||
std::vector<std::array<float, kFftLengthBy2Plus1>> S2_old_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_FALLBACK_H_
|
Reference in New Issue
Block a user