Robustification of the echo suppression behavior during headset usage.
This CL robustifies the echo removal behavior when headsets are used. In particular it: -Introduces a secondary, more refined alignment when no alignment can be found using the delay estimator. -Changes decision logic for when to use the linear filter output. -Changes the decision logic for when to be transparent. -Changes the way that the transparent mode works. -Makes the nonlinear mode less aggressive. -Removes the detector for non-audible echoes. -Makes the attenuation when there are signals with strong narrowband characteristics more mild in scenarios with low render. Furthermore the CL: -Removes the input of external echo leakage information. Bug: webrtc:9047,chromium:824111,webrtc:8314,webrtc:8671,webrtc:5201,webrtc:5919 Change-Id: Ied1fe0c0a35d3c31b47606ed2db319a73644d406 Reviewed-on: https://webrtc-review.googlesource.com/60866 Commit-Queue: Per Åhgren <peah@webrtc.org> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22548}
This commit is contained in:
@ -38,7 +38,7 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer {
|
||||
BufferingEvent Insert(const std::vector<std::vector<float>>& block) override;
|
||||
BufferingEvent PrepareCaptureProcessing() override;
|
||||
bool SetDelay(size_t delay) override;
|
||||
rtc::Optional<size_t> Delay() const override { return delay_; }
|
||||
size_t Delay() const override { return MapInternalDelayToExternalDelay(); }
|
||||
size_t MaxDelay() const override {
|
||||
return blocks_.buffer.size() - 1 - buffer_headroom_;
|
||||
}
|
||||
@ -77,7 +77,8 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer {
|
||||
size_t render_activity_counter_ = 0;
|
||||
|
||||
int LowRateBufferOffset() const { return DelayEstimatorOffset(config_) >> 1; }
|
||||
int MaxExternalDelayToInternalDelay(size_t delay) const;
|
||||
int MapExternalDelayToInternalDelay(size_t external_delay_blocks) const;
|
||||
int MapInternalDelayToExternalDelay() const;
|
||||
void ApplyDelay(int delay);
|
||||
void InsertBlock(const std::vector<std::vector<float>>& block,
|
||||
int previous_write);
|
||||
@ -167,7 +168,7 @@ RenderDelayBufferImpl::RenderDelayBufferImpl(const EchoCanceller3Config& config,
|
||||
kBlockSize),
|
||||
spectra_(blocks_.buffer.size(), kFftLengthBy2Plus1),
|
||||
ffts_(blocks_.buffer.size()),
|
||||
delay_(config_.delay.min_echo_path_delay_blocks),
|
||||
delay_(config_.delay.default_delay),
|
||||
echo_remover_buffer_(&blocks_, &spectra_, &ffts_),
|
||||
low_rate_(GetDownSampledBufferSize(config.delay.down_sampling_factor,
|
||||
config.delay.num_filters)),
|
||||
@ -310,7 +311,7 @@ bool RenderDelayBufferImpl::SetDelay(size_t delay) {
|
||||
delay_ = delay;
|
||||
|
||||
// Compute the internal delay and limit the delay to the allowed range.
|
||||
int internal_delay = MaxExternalDelayToInternalDelay(*delay_);
|
||||
int internal_delay = MapExternalDelayToInternalDelay(*delay_);
|
||||
internal_delay_ =
|
||||
std::min(MaxDelay(), static_cast<size_t>(std::max(internal_delay, 0)));
|
||||
|
||||
@ -322,7 +323,7 @@ bool RenderDelayBufferImpl::SetDelay(size_t delay) {
|
||||
// Returns whether the specified delay is causal.
|
||||
bool RenderDelayBufferImpl::CausalDelay(size_t delay) const {
|
||||
// Compute the internal delay and limit the delay to the allowed range.
|
||||
int internal_delay = MaxExternalDelayToInternalDelay(delay);
|
||||
int internal_delay = MapExternalDelayToInternalDelay(delay);
|
||||
internal_delay =
|
||||
std::min(MaxDelay(), static_cast<size_t>(std::max(internal_delay, 0)));
|
||||
|
||||
@ -331,7 +332,7 @@ bool RenderDelayBufferImpl::CausalDelay(size_t delay) const {
|
||||
}
|
||||
|
||||
// Maps the externally computed delay to the delay used internally.
|
||||
int RenderDelayBufferImpl::MaxExternalDelayToInternalDelay(
|
||||
int RenderDelayBufferImpl::MapExternalDelayToInternalDelay(
|
||||
size_t external_delay_blocks) const {
|
||||
const int latency = BufferLatency(low_rate_);
|
||||
RTC_DCHECK_LT(0, sub_block_size_);
|
||||
@ -341,6 +342,17 @@ int RenderDelayBufferImpl::MaxExternalDelayToInternalDelay(
|
||||
DelayEstimatorOffset(config_);
|
||||
}
|
||||
|
||||
// Maps the internally used delay to the delay used externally.
|
||||
int RenderDelayBufferImpl::MapInternalDelayToExternalDelay() const {
|
||||
const int latency = BufferLatency(low_rate_);
|
||||
int latency_blocks = latency / sub_block_size_;
|
||||
int internal_delay = spectra_.read >= spectra_.write
|
||||
? spectra_.read - spectra_.write
|
||||
: spectra_.size + spectra_.read - spectra_.write;
|
||||
|
||||
return internal_delay - latency_blocks + DelayEstimatorOffset(config_);
|
||||
}
|
||||
|
||||
// Set the read indices according to the delay.
|
||||
void RenderDelayBufferImpl::ApplyDelay(int delay) {
|
||||
blocks_.read = blocks_.OffsetIndex(blocks_.write, -delay);
|
||||
|
||||
Reference in New Issue
Block a user