mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00
Penalization of large delays on the initial phase.
Bug: webrtc:14919 Change-Id: Iba00b2782b7e7c3dbd345a94aba541fad8c979ee Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294289 Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39364}
This commit is contained in:
parent
5561599656
commit
e7478182ac
2 changed files with 30 additions and 3 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/numerics/safe_minmax.h"
|
#include "rtc_base/numerics/safe_minmax.h"
|
||||||
|
#include "system_wrappers/include/field_trial.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -123,6 +124,8 @@ MatchedFilterLagAggregator::PreEchoLagAggregator::PreEchoLagAggregator(
|
||||||
size_t max_filter_lag,
|
size_t max_filter_lag,
|
||||||
size_t down_sampling_factor)
|
size_t down_sampling_factor)
|
||||||
: block_size_log2_(GetDownSamplingBlockSizeLog2(down_sampling_factor)),
|
: block_size_log2_(GetDownSamplingBlockSizeLog2(down_sampling_factor)),
|
||||||
|
penalize_high_delays_initial_phase_(
|
||||||
|
field_trial::IsEnabled("WebRTC-Aec3PenalyzeHighDelaysInitialPhase")),
|
||||||
histogram_(
|
histogram_(
|
||||||
((max_filter_lag + 1) * down_sampling_factor) >> kBlockSizeLog2,
|
((max_filter_lag + 1) * down_sampling_factor) >> kBlockSizeLog2,
|
||||||
0) {
|
0) {
|
||||||
|
@ -152,9 +155,31 @@ void MatchedFilterLagAggregator::PreEchoLagAggregator::Aggregate(
|
||||||
histogram_data_[histogram_data_index_] = pre_echo_block_size;
|
histogram_data_[histogram_data_index_] = pre_echo_block_size;
|
||||||
++histogram_[histogram_data_[histogram_data_index_]];
|
++histogram_[histogram_data_[histogram_data_index_]];
|
||||||
histogram_data_index_ = (histogram_data_index_ + 1) % histogram_data_.size();
|
histogram_data_index_ = (histogram_data_index_ + 1) % histogram_data_.size();
|
||||||
int pre_echo_candidate_block_size =
|
int pre_echo_candidate_block_size = 0;
|
||||||
|
if (penalize_high_delays_initial_phase_ &&
|
||||||
|
number_updates_ < kNumBlocksPerSecond * 2) {
|
||||||
|
number_updates_++;
|
||||||
|
float penalization_per_delay = 1.0f;
|
||||||
|
float max_histogram_value = -1.0f;
|
||||||
|
for (auto it = histogram_.begin();
|
||||||
|
it + kMatchedFilterWindowSizeSubBlocks <= histogram_.end();
|
||||||
|
it = it + kMatchedFilterWindowSizeSubBlocks) {
|
||||||
|
auto it_max_element =
|
||||||
|
std::max_element(it, it + kMatchedFilterWindowSizeSubBlocks);
|
||||||
|
float weighted_max_value =
|
||||||
|
static_cast<float>(*it_max_element) * penalization_per_delay;
|
||||||
|
if (weighted_max_value > max_histogram_value) {
|
||||||
|
max_histogram_value = weighted_max_value;
|
||||||
|
pre_echo_candidate_block_size =
|
||||||
|
std::distance(histogram_.begin(), it_max_element);
|
||||||
|
}
|
||||||
|
penalization_per_delay *= 0.7f;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pre_echo_candidate_block_size =
|
||||||
std::distance(histogram_.begin(),
|
std::distance(histogram_.begin(),
|
||||||
std::max_element(histogram_.begin(), histogram_.end()));
|
std::max_element(histogram_.begin(), histogram_.end()));
|
||||||
|
}
|
||||||
pre_echo_candidate_ = (pre_echo_candidate_block_size << block_size_log2_);
|
pre_echo_candidate_ = (pre_echo_candidate_block_size << block_size_log2_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,12 @@ class MatchedFilterLagAggregator {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int block_size_log2_;
|
const int block_size_log2_;
|
||||||
|
const bool penalize_high_delays_initial_phase_;
|
||||||
std::array<int, 250> histogram_data_;
|
std::array<int, 250> histogram_data_;
|
||||||
std::vector<int> histogram_;
|
std::vector<int> histogram_;
|
||||||
int histogram_data_index_ = 0;
|
int histogram_data_index_ = 0;
|
||||||
int pre_echo_candidate_ = 0;
|
int pre_echo_candidate_ = 0;
|
||||||
|
int number_updates_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HighestPeakAggregator {
|
class HighestPeakAggregator {
|
||||||
|
|
Loading…
Reference in a new issue