Bump to WebRTC M120 release
Some API deprecation -- ExperimentalAgc and ExperimentalNs are gone. We're continuing to carry iSAC even though it's gone upstream, but maybe we'll want to drop that soon.
This commit is contained in:
@ -23,15 +23,10 @@
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
constexpr float kDefaultTransparentModeGain = 0.f;
|
||||
constexpr float kDefaultTransparentModeGain = 0.01f;
|
||||
|
||||
float GetTransparentModeGain() {
|
||||
if (field_trial::IsEnabled(
|
||||
"WebRTC-Aec3NoSuppressionInTransparentModeKillSwitch")) {
|
||||
return 0.01f;
|
||||
} else {
|
||||
return kDefaultTransparentModeGain;
|
||||
}
|
||||
return kDefaultTransparentModeGain;
|
||||
}
|
||||
|
||||
float GetEarlyReflectionsDefaultModeGain(
|
||||
@ -50,6 +45,13 @@ float GetLateReflectionsDefaultModeGain(
|
||||
return config.default_gain;
|
||||
}
|
||||
|
||||
bool UseErleOnsetCompensationInDominantNearend(
|
||||
const EchoCanceller3Config::EpStrength& config) {
|
||||
return config.erle_onset_compensation_in_dominant_nearend ||
|
||||
field_trial::IsEnabled(
|
||||
"WebRTC-Aec3UseErleOnsetCompensationInDominantNearend");
|
||||
}
|
||||
|
||||
// Computes the indexes that will be used for computing spectral power over
|
||||
// the blocks surrounding the delay.
|
||||
void GetRenderIndexesToAnalyze(
|
||||
@ -89,22 +91,6 @@ void LinearEstimate(
|
||||
}
|
||||
}
|
||||
|
||||
// Estimates the residual echo power based on an uncertainty estimate of the
|
||||
// echo return loss enhancement (ERLE) and the linear power estimate.
|
||||
void LinearEstimate(
|
||||
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> S2_linear,
|
||||
float erle_uncertainty,
|
||||
rtc::ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) {
|
||||
RTC_DCHECK_EQ(S2_linear.size(), R2.size());
|
||||
|
||||
const size_t num_capture_channels = R2.size();
|
||||
for (size_t ch = 0; ch < num_capture_channels; ++ch) {
|
||||
for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) {
|
||||
R2[ch][k] = S2_linear[ch][k] * erle_uncertainty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Estimates the residual echo power based on the estimate of the echo path
|
||||
// gain.
|
||||
void NonLinearEstimate(
|
||||
@ -177,7 +163,9 @@ ResidualEchoEstimator::ResidualEchoEstimator(const EchoCanceller3Config& config,
|
||||
early_reflections_general_gain_(
|
||||
GetEarlyReflectionsDefaultModeGain(config_.ep_strength)),
|
||||
late_reflections_general_gain_(
|
||||
GetLateReflectionsDefaultModeGain(config_.ep_strength)) {
|
||||
GetLateReflectionsDefaultModeGain(config_.ep_strength)),
|
||||
erle_onset_compensation_in_dominant_nearend_(
|
||||
UseErleOnsetCompensationInDominantNearend(config_.ep_strength)) {
|
||||
Reset();
|
||||
}
|
||||
|
||||
@ -188,7 +176,9 @@ void ResidualEchoEstimator::Estimate(
|
||||
const RenderBuffer& render_buffer,
|
||||
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> S2_linear,
|
||||
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2,
|
||||
rtc::ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) {
|
||||
bool dominant_nearend,
|
||||
rtc::ArrayView<std::array<float, kFftLengthBy2Plus1>> R2,
|
||||
rtc::ArrayView<std::array<float, kFftLengthBy2Plus1>> R2_unbounded) {
|
||||
RTC_DCHECK_EQ(R2.size(), Y2.size());
|
||||
RTC_DCHECK_EQ(R2.size(), S2_linear.size());
|
||||
|
||||
@ -204,17 +194,19 @@ void ResidualEchoEstimator::Estimate(
|
||||
if (aec_state.SaturatedEcho()) {
|
||||
for (size_t ch = 0; ch < num_capture_channels; ++ch) {
|
||||
std::copy(Y2[ch].begin(), Y2[ch].end(), R2[ch].begin());
|
||||
std::copy(Y2[ch].begin(), Y2[ch].end(), R2_unbounded[ch].begin());
|
||||
}
|
||||
} else {
|
||||
absl::optional<float> erle_uncertainty = aec_state.ErleUncertainty();
|
||||
if (erle_uncertainty) {
|
||||
LinearEstimate(S2_linear, *erle_uncertainty, R2);
|
||||
} else {
|
||||
LinearEstimate(S2_linear, aec_state.Erle(), R2);
|
||||
}
|
||||
const bool onset_compensated =
|
||||
erle_onset_compensation_in_dominant_nearend_ || !dominant_nearend;
|
||||
LinearEstimate(S2_linear, aec_state.Erle(onset_compensated), R2);
|
||||
LinearEstimate(S2_linear, aec_state.ErleUnbounded(), R2_unbounded);
|
||||
}
|
||||
|
||||
AddReverb(ReverbType::kLinear, aec_state, render_buffer, R2);
|
||||
UpdateReverb(ReverbType::kLinear, aec_state, render_buffer,
|
||||
dominant_nearend);
|
||||
AddReverb(R2);
|
||||
AddReverb(R2_unbounded);
|
||||
} else {
|
||||
const float echo_path_gain =
|
||||
GetEchoPathGain(aec_state, /*gain_for_early_reflections=*/true);
|
||||
@ -224,6 +216,7 @@ void ResidualEchoEstimator::Estimate(
|
||||
if (aec_state.SaturatedEcho()) {
|
||||
for (size_t ch = 0; ch < num_capture_channels; ++ch) {
|
||||
std::copy(Y2[ch].begin(), Y2[ch].end(), R2[ch].begin());
|
||||
std::copy(Y2[ch].begin(), Y2[ch].end(), R2_unbounded[ch].begin());
|
||||
}
|
||||
} else {
|
||||
// Estimate the echo generating signal power.
|
||||
@ -243,11 +236,15 @@ void ResidualEchoEstimator::Estimate(
|
||||
}
|
||||
|
||||
NonLinearEstimate(echo_path_gain, X2, R2);
|
||||
NonLinearEstimate(echo_path_gain, X2, R2_unbounded);
|
||||
}
|
||||
|
||||
if (config_.echo_model.model_reverb_in_nonlinear_mode &&
|
||||
!aec_state.TransparentModeActive()) {
|
||||
AddReverb(ReverbType::kNonLinear, aec_state, render_buffer, R2);
|
||||
UpdateReverb(ReverbType::kNonLinear, aec_state, render_buffer,
|
||||
dominant_nearend);
|
||||
AddReverb(R2);
|
||||
AddReverb(R2_unbounded);
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,6 +255,7 @@ void ResidualEchoEstimator::Estimate(
|
||||
for (size_t ch = 0; ch < num_capture_channels; ++ch) {
|
||||
for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) {
|
||||
R2[ch][k] *= residual_scaling[k];
|
||||
R2_unbounded[ch][k] *= residual_scaling[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,14 +304,11 @@ void ResidualEchoEstimator::UpdateRenderNoisePower(
|
||||
}
|
||||
}
|
||||
|
||||
// Adds the estimated power of the reverb to the residual echo power.
|
||||
void ResidualEchoEstimator::AddReverb(
|
||||
ReverbType reverb_type,
|
||||
const AecState& aec_state,
|
||||
const RenderBuffer& render_buffer,
|
||||
rtc::ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) {
|
||||
const size_t num_capture_channels = R2.size();
|
||||
|
||||
// Updates the reverb estimation.
|
||||
void ResidualEchoEstimator::UpdateReverb(ReverbType reverb_type,
|
||||
const AecState& aec_state,
|
||||
const RenderBuffer& render_buffer,
|
||||
bool dominant_nearend) {
|
||||
// Choose reverb partition based on what type of echo power model is used.
|
||||
const size_t first_reverb_partition =
|
||||
reverb_type == ReverbType::kLinear
|
||||
@ -338,16 +333,21 @@ void ResidualEchoEstimator::AddReverb(
|
||||
}
|
||||
|
||||
// Update the reverb estimate.
|
||||
float reverb_decay = aec_state.ReverbDecay(/*mild=*/dominant_nearend);
|
||||
if (reverb_type == ReverbType::kLinear) {
|
||||
echo_reverb_.UpdateReverb(render_power,
|
||||
aec_state.GetReverbFrequencyResponse(),
|
||||
aec_state.ReverbDecay());
|
||||
echo_reverb_.UpdateReverb(
|
||||
render_power, aec_state.GetReverbFrequencyResponse(), reverb_decay);
|
||||
} else {
|
||||
const float echo_path_gain =
|
||||
GetEchoPathGain(aec_state, /*gain_for_early_reflections=*/false);
|
||||
echo_reverb_.UpdateReverbNoFreqShaping(render_power, echo_path_gain,
|
||||
aec_state.ReverbDecay());
|
||||
reverb_decay);
|
||||
}
|
||||
}
|
||||
// Adds the estimated power of the reverb to the residual echo power.
|
||||
void ResidualEchoEstimator::AddReverb(
|
||||
rtc::ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) const {
|
||||
const size_t num_capture_channels = R2.size();
|
||||
|
||||
// Add the reverb power.
|
||||
rtc::ArrayView<const float, kFftLengthBy2Plus1> reverb_power =
|
||||
|
Reference in New Issue
Block a user