webrtc/modules/audio_processing/aec3/signal_dependent_erle_estimator.h
Jesús de Vicente Peña 44974e143c AEC3: Adding a correction factor for the Erle estimation that depends on the portion of the filter that is currently in use.
In this CL a more precise estimation of the Erle is introduced. This is done by creating different estimators that are specialized in different regions of the linear filter. An estimation of which regions were used for generating the current echo estimate is performed and used for selecting the right Erle estimator.

Bug: webrtc:9961
Change-Id: Iba6eb24596c067c3c66d40df590be379d3e1bb7b
Reviewed-on: https://webrtc-review.googlesource.com/c/109400
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25707}
2018-11-20 12:28:05 +00:00

93 lines
3.6 KiB
C++

/*
* 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.
*/
#ifndef MODULES_AUDIO_PROCESSING_AEC3_SIGNAL_DEPENDENT_ERLE_ESTIMATOR_H_
#define MODULES_AUDIO_PROCESSING_AEC3_SIGNAL_DEPENDENT_ERLE_ESTIMATOR_H_
#include <memory>
#include <vector>
#include "api/array_view.h"
#include "api/audio/echo_canceller3_config.h"
#include "modules/audio_processing/aec3/aec3_common.h"
#include "modules/audio_processing/aec3/render_buffer.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
namespace webrtc {
// This class estimates the dependency of the Erle to the input signal. By
// looking at the input signal, an estimation on whether the current echo
// estimate is due to the direct path or to a more reverberant one is performed.
// Once that estimation is done, it is possible to refine the average Erle that
// this class receive as an input.
class SignalDependentErleEstimator {
public:
explicit SignalDependentErleEstimator(const EchoCanceller3Config& config);
~SignalDependentErleEstimator();
void Reset();
// Returns the Erle per frequency subband.
const std::array<float, kFftLengthBy2Plus1>& Erle() const { return erle_; }
// Updates the Erle estimate. The Erle that is passed as an input is required
// to be an estimation of the average Erle achieved by the linear filter.
void Update(const RenderBuffer& render_buffer,
const std::vector<std::array<float, kFftLengthBy2Plus1>>&
filter_frequency_response,
rtc::ArrayView<const float> X2,
rtc::ArrayView<const float> Y2,
rtc::ArrayView<const float> E2,
rtc::ArrayView<const float> average_erle,
bool converged_filter);
void Dump(const std::unique_ptr<ApmDataDumper>& data_dumper) const;
static constexpr size_t kSubbands = 6;
private:
void ComputeNumberOfActiveFilterSections(
const RenderBuffer& render_buffer,
const std::vector<std::array<float, kFftLengthBy2Plus1>>&
filter_frequency_response,
rtc::ArrayView<size_t> n_active_filter_sections);
void UpdateCorrectionFactors(rtc::ArrayView<const float> X2,
rtc::ArrayView<const float> Y2,
rtc::ArrayView<const float> E2,
rtc::ArrayView<const size_t> n_active_sections);
void ComputeEchoEstimatePerFilterSection(
const RenderBuffer& render_buffer,
const std::vector<std::array<float, kFftLengthBy2Plus1>>&
filter_frequency_response);
void ComputeActiveFilterSections(
rtc::ArrayView<size_t> number_active_filter_sections) const;
const float min_erle_;
const size_t num_sections_;
const size_t num_blocks_;
const size_t delay_headroom_blocks_;
const std::array<size_t, kFftLengthBy2Plus1> band_to_subband_;
const std::array<float, kSubbands> max_erle_;
const std::vector<size_t> section_boundaries_blocks_;
std::array<float, kFftLengthBy2Plus1> erle_;
std::vector<std::array<float, kFftLengthBy2Plus1>> S2_section_accum_;
std::vector<std::array<float, kSubbands>> erle_estimators_;
std::array<float, kSubbands> erle_ref_;
std::vector<std::array<float, kSubbands>> correction_factors_;
std::array<int, kSubbands> num_updates_;
};
} // namespace webrtc
#endif // MODULES_AUDIO_PROCESSING_AEC3_SIGNAL_DEPENDENT_ERLE_ESTIMATOR_H_