Bump to WebRTC M131 release
Ongoing fixes and improvements, transient suppressor is gone. Also, dropping isac because it doesn't seem to be useful, and is just build system deadweight now. Upstream references: Version: 131.0.6778.200 WebRTC: 79aff54b0fa9238ce3518dd9eaf9610cd6f22e82 Chromium: 2a19506ad24af755f2a215a4c61f775393e0db42
This commit is contained in:
@ -156,10 +156,7 @@ rtc_library("aec3") {
|
||||
"../../../system_wrappers:field_trial",
|
||||
"../../../system_wrappers:metrics",
|
||||
"../utility:cascaded_biquad_filter",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
|
||||
if (current_cpu == "x86" || current_cpu == "x64") {
|
||||
@ -210,8 +207,8 @@ rtc_source_set("adaptive_fir_filter") {
|
||||
"..:apm_logging",
|
||||
"../../../api:array_view",
|
||||
"../../../rtc_base/system:arch",
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||
}
|
||||
|
||||
rtc_source_set("adaptive_fir_filter_erl") {
|
||||
@ -231,7 +228,6 @@ rtc_source_set("matched_filter") {
|
||||
"../../../rtc_base:gtest_prod",
|
||||
"../../../rtc_base/system:arch",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
}
|
||||
|
||||
rtc_source_set("vector_math") {
|
||||
@ -329,7 +325,6 @@ if (rtc_include_tests) {
|
||||
"../../../test:test_support",
|
||||
"../utility:cascaded_biquad_filter",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
|
||||
defines = []
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
@ -170,7 +170,7 @@ void AecState::HandleEchoPathChange(
|
||||
}
|
||||
|
||||
void AecState::Update(
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
rtc::ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>>
|
||||
adaptive_filter_frequency_responses,
|
||||
rtc::ArrayView<const std::vector<float>> adaptive_filter_impulse_responses,
|
||||
@ -359,7 +359,7 @@ AecState::FilterDelay::FilterDelay(const EchoCanceller3Config& config,
|
||||
|
||||
void AecState::FilterDelay::Update(
|
||||
rtc::ArrayView<const int> analyzer_filter_delay_estimates_blocks,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
size_t blocks_with_proper_filter_adaptation) {
|
||||
// Update the delay based on the external delay.
|
||||
if (external_delay &&
|
||||
@ -405,7 +405,7 @@ void AecState::FilteringQualityAnalyzer::Update(
|
||||
bool active_render,
|
||||
bool transparent_mode,
|
||||
bool saturated_capture,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
bool any_filter_converged) {
|
||||
// Update blocks counter.
|
||||
const bool filter_update = active_render && !saturated_capture;
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
@ -138,7 +138,7 @@ class AecState {
|
||||
// Updates the aec state.
|
||||
// TODO(bugs.webrtc.org/10913): Compute multi-channel ERL.
|
||||
void Update(
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
rtc::ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>>
|
||||
adaptive_filter_frequency_responses,
|
||||
rtc::ArrayView<const std::vector<float>>
|
||||
@ -213,7 +213,7 @@ class AecState {
|
||||
// Updates the delay estimates based on new data.
|
||||
void Update(
|
||||
rtc::ArrayView<const int> analyzer_filter_delay_estimates_blocks,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
size_t blocks_with_proper_filter_adaptation);
|
||||
|
||||
private:
|
||||
@ -221,7 +221,7 @@ class AecState {
|
||||
bool external_delay_reported_ = false;
|
||||
std::vector<int> filter_delays_blocks_;
|
||||
int min_filter_delay_;
|
||||
absl::optional<DelayEstimate> external_delay_;
|
||||
std::optional<DelayEstimate> external_delay_;
|
||||
} delay_state_;
|
||||
|
||||
// Classifier for toggling transparent mode when there is no echo.
|
||||
@ -253,7 +253,7 @@ class AecState {
|
||||
void Update(bool active_render,
|
||||
bool transparent_mode,
|
||||
bool saturated_capture,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
bool any_filter_converged);
|
||||
|
||||
private:
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "api/audio/echo_control.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
@ -76,7 +76,7 @@ class BlockProcessorImpl final : public BlockProcessor {
|
||||
BlockProcessorMetrics metrics_;
|
||||
RenderDelayBuffer::BufferingEvent render_event_;
|
||||
size_t capture_call_counter_ = 0;
|
||||
absl::optional<DelayEstimate> estimated_delay_;
|
||||
std::optional<DelayEstimate> estimated_delay_;
|
||||
};
|
||||
|
||||
std::atomic<int> BlockProcessorImpl::instance_count_(0);
|
||||
@ -223,7 +223,7 @@ void BlockProcessorImpl::UpdateEchoLeakageStatus(bool leakage_detected) {
|
||||
void BlockProcessorImpl::GetMetrics(EchoControl::Metrics* metrics) const {
|
||||
echo_remover_->GetMetrics(metrics);
|
||||
constexpr int block_size_ms = 4;
|
||||
absl::optional<size_t> delay = render_buffer_->Delay();
|
||||
std::optional<size_t> delay = render_buffer_->Delay();
|
||||
metrics->delay_ms = delay ? static_cast<int>(*delay) * block_size_ms : 0;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ bool CompatibleConfigs(const EchoCanceller3Config& mono_config,
|
||||
|
||||
ConfigSelector::ConfigSelector(
|
||||
const EchoCanceller3Config& config,
|
||||
const absl::optional<EchoCanceller3Config>& multichannel_config,
|
||||
const std::optional<EchoCanceller3Config>& multichannel_config,
|
||||
int num_render_input_channels)
|
||||
: config_(config), multichannel_config_(multichannel_config) {
|
||||
if (multichannel_config_.has_value()) {
|
||||
|
@ -11,7 +11,8 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AEC3_CONFIG_SELECTOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_CONFIG_SELECTOR_H_
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include <optional>
|
||||
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -19,10 +20,9 @@ namespace webrtc {
|
||||
// Selects the config to use.
|
||||
class ConfigSelector {
|
||||
public:
|
||||
ConfigSelector(
|
||||
const EchoCanceller3Config& config,
|
||||
const absl::optional<EchoCanceller3Config>& multichannel_config,
|
||||
int num_render_input_channels);
|
||||
ConfigSelector(const EchoCanceller3Config& config,
|
||||
const std::optional<EchoCanceller3Config>& multichannel_config,
|
||||
int num_render_input_channels);
|
||||
|
||||
// Updates the config selection based on the detection of multichannel
|
||||
// content.
|
||||
@ -32,7 +32,7 @@ class ConfigSelector {
|
||||
|
||||
private:
|
||||
const EchoCanceller3Config config_;
|
||||
const absl::optional<EchoCanceller3Config> multichannel_config_;
|
||||
const std::optional<EchoCanceller3Config> multichannel_config_;
|
||||
const EchoCanceller3Config* active_config_ = nullptr;
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ void EchoAudibility::Update(const RenderBuffer& render_buffer,
|
||||
void EchoAudibility::Reset() {
|
||||
render_stationarity_.Reset();
|
||||
non_zero_render_seen_ = false;
|
||||
render_spectrum_write_prev_ = absl::nullopt;
|
||||
render_spectrum_write_prev_ = std::nullopt;
|
||||
}
|
||||
|
||||
void EchoAudibility::UpdateRenderStationarityFlags(
|
||||
|
@ -13,7 +13,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include <optional>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/block_buffer.h"
|
||||
#include "modules/audio_processing/aec3/render_buffer.h"
|
||||
@ -73,7 +74,7 @@ class EchoAudibility {
|
||||
// values.
|
||||
bool IsRenderTooLow(const BlockBuffer& block_buffer);
|
||||
|
||||
absl::optional<int> render_spectrum_write_prev_;
|
||||
std::optional<int> render_spectrum_write_prev_;
|
||||
int render_block_write_prev_;
|
||||
bool non_zero_render_seen_;
|
||||
const bool use_render_stationarity_at_init_;
|
||||
|
@ -378,14 +378,6 @@ EchoCanceller3Config AdjustConfig(const EchoCanceller3Config& config) {
|
||||
false;
|
||||
}
|
||||
|
||||
if (field_trial::IsEnabled("WebRTC-Aec3DelayEstimatorDetectPreEcho")) {
|
||||
adjusted_cfg.delay.detect_pre_echo = true;
|
||||
}
|
||||
|
||||
if (field_trial::IsDisabled("WebRTC-Aec3DelayEstimatorDetectPreEcho")) {
|
||||
adjusted_cfg.delay.detect_pre_echo = false;
|
||||
}
|
||||
|
||||
if (field_trial::IsEnabled("WebRTC-Aec3SensitiveDominantNearendActivation")) {
|
||||
adjusted_cfg.suppressor.dominant_nearend_detection.enr_threshold = 0.5f;
|
||||
} else if (field_trial::IsEnabled(
|
||||
@ -641,6 +633,13 @@ EchoCanceller3Config AdjustConfig(const EchoCanceller3Config& config) {
|
||||
"WebRTC-Aec3DelayEstimateSmoothingDelayFoundOverride", 0.f, 1.f,
|
||||
&adjusted_cfg.delay.delay_estimate_smoothing_delay_found);
|
||||
|
||||
int max_allowed_excess_render_blocks_override =
|
||||
adjusted_cfg.buffering.max_allowed_excess_render_blocks;
|
||||
RetrieveFieldTrialValue(
|
||||
"WebRTC-Aec3BufferingMaxAllowedExcessRenderBlocksOverride", 0, 20,
|
||||
&max_allowed_excess_render_blocks_override);
|
||||
adjusted_cfg.buffering.max_allowed_excess_render_blocks =
|
||||
max_allowed_excess_render_blocks_override;
|
||||
return adjusted_cfg;
|
||||
}
|
||||
|
||||
@ -719,7 +718,7 @@ std::atomic<int> EchoCanceller3::instance_count_(0);
|
||||
|
||||
EchoCanceller3::EchoCanceller3(
|
||||
const EchoCanceller3Config& config,
|
||||
const absl::optional<EchoCanceller3Config>& multichannel_config,
|
||||
const std::optional<EchoCanceller3Config>& multichannel_config,
|
||||
int sample_rate_hz,
|
||||
size_t num_render_channels,
|
||||
size_t num_capture_channels)
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "api/audio/echo_control.h"
|
||||
@ -88,12 +88,11 @@ class Aec3RenderQueueItemVerifier {
|
||||
// AnalyzeRender call which can be called concurrently with the other methods.
|
||||
class EchoCanceller3 : public EchoControl {
|
||||
public:
|
||||
EchoCanceller3(
|
||||
const EchoCanceller3Config& config,
|
||||
const absl::optional<EchoCanceller3Config>& multichannel_config,
|
||||
int sample_rate_hz,
|
||||
size_t num_render_channels,
|
||||
size_t num_capture_channels);
|
||||
EchoCanceller3(const EchoCanceller3Config& config,
|
||||
const std::optional<EchoCanceller3Config>& multichannel_config,
|
||||
int sample_rate_hz,
|
||||
size_t num_render_channels,
|
||||
size_t num_capture_channels);
|
||||
|
||||
~EchoCanceller3() override;
|
||||
|
||||
|
@ -58,7 +58,7 @@ void EchoPathDelayEstimator::Reset(bool reset_delay_confidence) {
|
||||
Reset(true, reset_delay_confidence);
|
||||
}
|
||||
|
||||
absl::optional<DelayEstimate> EchoPathDelayEstimator::EstimateDelay(
|
||||
std::optional<DelayEstimate> EchoPathDelayEstimator::EstimateDelay(
|
||||
const DownsampledRenderBuffer& render_buffer,
|
||||
const Block& capture) {
|
||||
std::array<float, kBlockSize> downsampled_capture_data;
|
||||
@ -74,7 +74,7 @@ absl::optional<DelayEstimate> EchoPathDelayEstimator::EstimateDelay(
|
||||
matched_filter_.Update(render_buffer, downsampled_capture,
|
||||
matched_filter_lag_aggregator_.ReliableDelayFound());
|
||||
|
||||
absl::optional<DelayEstimate> aggregated_matched_filter_lag =
|
||||
std::optional<DelayEstimate> aggregated_matched_filter_lag =
|
||||
matched_filter_lag_aggregator_.Aggregate(
|
||||
matched_filter_.GetBestLagEstimate());
|
||||
|
||||
@ -121,7 +121,7 @@ void EchoPathDelayEstimator::Reset(bool reset_lag_aggregator,
|
||||
matched_filter_lag_aggregator_.Reset(reset_delay_confidence);
|
||||
}
|
||||
matched_filter_.Reset(/*full_reset=*/reset_lag_aggregator);
|
||||
old_aggregated_lag_ = absl::nullopt;
|
||||
old_aggregated_lag_ = std::nullopt;
|
||||
consistent_estimate_counter_ = 0;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
@ -13,7 +13,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include <optional>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/alignment_mixer.h"
|
||||
#include "modules/audio_processing/aec3/block.h"
|
||||
@ -45,7 +46,7 @@ class EchoPathDelayEstimator {
|
||||
void Reset(bool reset_delay_confidence);
|
||||
|
||||
// Produce a delay estimate if such is avaliable.
|
||||
absl::optional<DelayEstimate> EstimateDelay(
|
||||
std::optional<DelayEstimate> EstimateDelay(
|
||||
const DownsampledRenderBuffer& render_buffer,
|
||||
const Block& capture);
|
||||
|
||||
@ -68,7 +69,7 @@ class EchoPathDelayEstimator {
|
||||
Decimator capture_decimator_;
|
||||
MatchedFilter matched_filter_;
|
||||
MatchedFilterLagAggregator matched_filter_lag_aggregator_;
|
||||
absl::optional<DelayEstimate> old_aggregated_lag_;
|
||||
std::optional<DelayEstimate> old_aggregated_lag_;
|
||||
size_t consistent_estimate_counter_ = 0;
|
||||
ClockdriftDetector clockdrift_detector_;
|
||||
|
||||
|
@ -120,7 +120,7 @@ class EchoRemoverImpl final : public EchoRemover {
|
||||
// signal.
|
||||
void ProcessCapture(EchoPathVariability echo_path_variability,
|
||||
bool capture_signal_saturation,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
RenderBuffer* render_buffer,
|
||||
Block* linear_output,
|
||||
Block* capture) override;
|
||||
@ -239,7 +239,7 @@ void EchoRemoverImpl::GetMetrics(EchoControl::Metrics* metrics) const {
|
||||
void EchoRemoverImpl::ProcessCapture(
|
||||
EchoPathVariability echo_path_variability,
|
||||
bool capture_signal_saturation,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
RenderBuffer* render_buffer,
|
||||
Block* linear_output,
|
||||
Block* capture) {
|
||||
|
@ -11,9 +11,9 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AEC3_ECHO_REMOVER_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_ECHO_REMOVER_H_
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "api/audio/echo_control.h"
|
||||
#include "modules/audio_processing/aec3/block.h"
|
||||
@ -41,7 +41,7 @@ class EchoRemover {
|
||||
virtual void ProcessCapture(
|
||||
EchoPathVariability echo_path_variability,
|
||||
bool capture_signal_saturation,
|
||||
const absl::optional<DelayEstimate>& external_delay,
|
||||
const std::optional<DelayEstimate>& external_delay,
|
||||
RenderBuffer* render_buffer,
|
||||
Block* linear_output,
|
||||
Block* capture) = 0;
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
@ -91,7 +91,7 @@ class ErleEstimator {
|
||||
// vector with content between 0 and 1 where 1 indicates that, at this current
|
||||
// time instant, the linear filter is reaching its maximum subtraction
|
||||
// performance.
|
||||
rtc::ArrayView<const absl::optional<float>> GetInstLinearQualityEstimates()
|
||||
rtc::ArrayView<const std::optional<float>> GetInstLinearQualityEstimates()
|
||||
const {
|
||||
return fullband_erle_estimator_.GetInstLinearQualityEstimates();
|
||||
}
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
@ -142,7 +142,7 @@ void FullBandErleEstimator::ErleInstantaneous::Reset() {
|
||||
}
|
||||
|
||||
void FullBandErleEstimator::ErleInstantaneous::ResetAccumulators() {
|
||||
erle_log2_ = absl::nullopt;
|
||||
erle_log2_ = std::nullopt;
|
||||
inst_quality_estimate_ = 0.f;
|
||||
num_points_ = 0;
|
||||
E2_acum_ = 0.f;
|
||||
|
@ -12,9 +12,9 @@
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_FULLBAND_ERLE_ESTIMATOR_H_
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
@ -49,7 +49,7 @@ class FullBandErleEstimator {
|
||||
|
||||
// Returns an estimation of the current linear filter quality. It returns a
|
||||
// float number between 0 and 1 mapping 1 to the highest possible quality.
|
||||
rtc::ArrayView<const absl::optional<float>> GetInstLinearQualityEstimates()
|
||||
rtc::ArrayView<const std::optional<float>> GetInstLinearQualityEstimates()
|
||||
const {
|
||||
return linear_filters_qualities_;
|
||||
}
|
||||
@ -73,10 +73,10 @@ class FullBandErleEstimator {
|
||||
// Resets the members related with an instantaneous estimate.
|
||||
void ResetAccumulators();
|
||||
// Returns the instantaneous ERLE in log2 units.
|
||||
absl::optional<float> GetInstErleLog2() const { return erle_log2_; }
|
||||
std::optional<float> GetInstErleLog2() const { return erle_log2_; }
|
||||
// Gets an indication between 0 and 1 of the performance of the linear
|
||||
// filter for the current time instant.
|
||||
absl::optional<float> GetQualityEstimate() const {
|
||||
std::optional<float> GetQualityEstimate() const {
|
||||
if (erle_log2_) {
|
||||
float value = inst_quality_estimate_;
|
||||
if (clamp_inst_quality_to_zero_) {
|
||||
@ -85,9 +85,9 @@ class FullBandErleEstimator {
|
||||
if (clamp_inst_quality_to_one_) {
|
||||
value = std::min(1.f, value);
|
||||
}
|
||||
return absl::optional<float>(value);
|
||||
return std::optional<float>(value);
|
||||
}
|
||||
return absl::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
void Dump(const std::unique_ptr<ApmDataDumper>& data_dumper) const;
|
||||
|
||||
@ -96,7 +96,7 @@ class FullBandErleEstimator {
|
||||
void UpdateQualityEstimate();
|
||||
const bool clamp_inst_quality_to_zero_;
|
||||
const bool clamp_inst_quality_to_one_;
|
||||
absl::optional<float> erle_log2_;
|
||||
std::optional<float> erle_log2_;
|
||||
float inst_quality_estimate_;
|
||||
float max_erle_log2_;
|
||||
float min_erle_log2_;
|
||||
@ -110,7 +110,7 @@ class FullBandErleEstimator {
|
||||
std::vector<int> hold_counters_instantaneous_erle_;
|
||||
std::vector<float> erle_time_domain_log2_;
|
||||
std::vector<ErleInstantaneous> instantaneous_erle_;
|
||||
std::vector<absl::optional<float>> linear_filters_qualities_;
|
||||
std::vector<std::optional<float>> linear_filters_qualities_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/downsampled_render_buffer.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
@ -43,8 +43,8 @@ constexpr int kAccumulatedErrorSubSampleRate = 4;
|
||||
void UpdateAccumulatedError(
|
||||
const rtc::ArrayView<const float> instantaneous_accumulated_error,
|
||||
const rtc::ArrayView<float> accumulated_error,
|
||||
float one_over_error_sum_anchor,
|
||||
float smooth_constant_increases) {
|
||||
float one_over_error_sum_anchor) {
|
||||
static constexpr float kSmoothConstantIncreases = 0.015f;
|
||||
for (size_t k = 0; k < instantaneous_accumulated_error.size(); ++k) {
|
||||
float error_norm =
|
||||
instantaneous_accumulated_error[k] * one_over_error_sum_anchor;
|
||||
@ -52,97 +52,30 @@ void UpdateAccumulatedError(
|
||||
accumulated_error[k] = error_norm;
|
||||
} else {
|
||||
accumulated_error[k] +=
|
||||
smooth_constant_increases * (error_norm - accumulated_error[k]);
|
||||
kSmoothConstantIncreases * (error_norm - accumulated_error[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t ComputePreEchoLag(
|
||||
const webrtc::MatchedFilter::PreEchoConfiguration& pre_echo_configuration,
|
||||
const rtc::ArrayView<const float> accumulated_error,
|
||||
size_t lag,
|
||||
size_t alignment_shift_winner) {
|
||||
static constexpr float kPreEchoThreshold = 0.5f;
|
||||
RTC_DCHECK_GE(lag, alignment_shift_winner);
|
||||
size_t pre_echo_lag_estimate = lag - alignment_shift_winner;
|
||||
size_t maximum_pre_echo_lag =
|
||||
std::min(pre_echo_lag_estimate / kAccumulatedErrorSubSampleRate,
|
||||
accumulated_error.size());
|
||||
switch (pre_echo_configuration.mode) {
|
||||
case 0:
|
||||
// Mode 0: Pre echo lag is defined as the first coefficient with an error
|
||||
// lower than a threshold with a certain decrease slope.
|
||||
for (size_t k = 1; k < maximum_pre_echo_lag; ++k) {
|
||||
if (accumulated_error[k] <
|
||||
pre_echo_configuration.threshold * accumulated_error[k - 1] &&
|
||||
accumulated_error[k] < pre_echo_configuration.threshold) {
|
||||
pre_echo_lag_estimate = (k + 1) * kAccumulatedErrorSubSampleRate - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// Mode 1: Pre echo lag is defined as the first coefficient with an error
|
||||
// lower than a certain threshold.
|
||||
for (size_t k = 0; k < maximum_pre_echo_lag; ++k) {
|
||||
if (accumulated_error[k] < pre_echo_configuration.threshold) {
|
||||
pre_echo_lag_estimate = (k + 1) * kAccumulatedErrorSubSampleRate - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
// Mode 2,3: Pre echo lag is defined as the closest coefficient to the lag
|
||||
// with an error lower than a certain threshold.
|
||||
for (int k = static_cast<int>(maximum_pre_echo_lag) - 1; k >= 0; --k) {
|
||||
if (accumulated_error[k] > pre_echo_configuration.threshold) {
|
||||
break;
|
||||
}
|
||||
pre_echo_lag_estimate = (k + 1) * kAccumulatedErrorSubSampleRate - 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
for (int k = static_cast<int>(maximum_pre_echo_lag) - 1; k >= 0; --k) {
|
||||
if (accumulated_error[k] > kPreEchoThreshold) {
|
||||
break;
|
||||
}
|
||||
pre_echo_lag_estimate = (k + 1) * kAccumulatedErrorSubSampleRate - 1;
|
||||
}
|
||||
return pre_echo_lag_estimate + alignment_shift_winner;
|
||||
}
|
||||
|
||||
webrtc::MatchedFilter::PreEchoConfiguration FetchPreEchoConfiguration() {
|
||||
constexpr float kDefaultThreshold = 0.5f;
|
||||
constexpr int kDefaultMode = 3;
|
||||
float threshold = kDefaultThreshold;
|
||||
int mode = kDefaultMode;
|
||||
const std::string pre_echo_configuration_field_trial =
|
||||
webrtc::field_trial::FindFullName("WebRTC-Aec3PreEchoConfiguration");
|
||||
webrtc::FieldTrialParameter<double> threshold_field_trial_parameter(
|
||||
/*key=*/"threshold", /*default_value=*/kDefaultThreshold);
|
||||
webrtc::FieldTrialParameter<int> mode_field_trial_parameter(
|
||||
/*key=*/"mode", /*default_value=*/kDefaultMode);
|
||||
webrtc::ParseFieldTrial(
|
||||
{&threshold_field_trial_parameter, &mode_field_trial_parameter},
|
||||
pre_echo_configuration_field_trial);
|
||||
float threshold_read =
|
||||
static_cast<float>(threshold_field_trial_parameter.Get());
|
||||
int mode_read = mode_field_trial_parameter.Get();
|
||||
if (threshold_read < 1.0f && threshold_read > 0.0f) {
|
||||
threshold = threshold_read;
|
||||
} else {
|
||||
RTC_LOG(LS_ERROR)
|
||||
<< "AEC3: Pre echo configuration: wrong input, threshold = "
|
||||
<< threshold_read << ".";
|
||||
}
|
||||
if (mode_read >= 0 && mode_read <= 3) {
|
||||
mode = mode_read;
|
||||
} else {
|
||||
RTC_LOG(LS_ERROR) << "AEC3: Pre echo configuration: wrong input, mode = "
|
||||
<< mode_read << ".";
|
||||
}
|
||||
RTC_LOG(LS_INFO) << "AEC3: Pre echo configuration: threshold = " << threshold
|
||||
<< ", mode = " << mode << ".";
|
||||
return {.threshold = threshold, .mode = mode};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace webrtc {
|
||||
@ -685,8 +618,7 @@ MatchedFilter::MatchedFilter(ApmDataDumper* data_dumper,
|
||||
smoothing_fast_(smoothing_fast),
|
||||
smoothing_slow_(smoothing_slow),
|
||||
matching_filter_threshold_(matching_filter_threshold),
|
||||
detect_pre_echo_(detect_pre_echo),
|
||||
pre_echo_config_(FetchPreEchoConfiguration()) {
|
||||
detect_pre_echo_(detect_pre_echo) {
|
||||
RTC_DCHECK(data_dumper);
|
||||
RTC_DCHECK_LT(0, window_size_sub_blocks);
|
||||
RTC_DCHECK((kBlockSize % sub_block_size) == 0);
|
||||
@ -715,9 +647,9 @@ void MatchedFilter::Reset(bool full_reset) {
|
||||
std::fill(f.begin(), f.end(), 0.f);
|
||||
}
|
||||
|
||||
winner_lag_ = absl::nullopt;
|
||||
reported_lag_estimate_ = absl::nullopt;
|
||||
if (pre_echo_config_.mode != 3 || full_reset) {
|
||||
winner_lag_ = std::nullopt;
|
||||
reported_lag_estimate_ = std::nullopt;
|
||||
if (full_reset) {
|
||||
for (auto& e : accumulated_error_) {
|
||||
std::fill(e.begin(), e.end(), 1.0f);
|
||||
}
|
||||
@ -745,10 +677,10 @@ void MatchedFilter::Update(const DownsampledRenderBuffer& render_buffer,
|
||||
|
||||
// Apply all matched filters.
|
||||
float winner_error_sum = error_sum_anchor;
|
||||
winner_lag_ = absl::nullopt;
|
||||
reported_lag_estimate_ = absl::nullopt;
|
||||
winner_lag_ = std::nullopt;
|
||||
reported_lag_estimate_ = std::nullopt;
|
||||
size_t alignment_shift = 0;
|
||||
absl::optional<size_t> previous_lag_estimate;
|
||||
std::optional<size_t> previous_lag_estimate;
|
||||
const int num_filters = static_cast<int>(filters_.size());
|
||||
int winner_index = -1;
|
||||
for (int n = 0; n < num_filters; ++n) {
|
||||
@ -823,22 +755,16 @@ void MatchedFilter::Update(const DownsampledRenderBuffer& render_buffer,
|
||||
reported_lag_estimate_ =
|
||||
LagEstimate(winner_lag_.value(), /*pre_echo_lag=*/winner_lag_.value());
|
||||
if (detect_pre_echo_ && last_detected_best_lag_filter_ == winner_index) {
|
||||
const float energy_threshold =
|
||||
pre_echo_config_.mode == 3 ? 1.0f : 30.0f * 30.0f * y.size();
|
||||
|
||||
if (error_sum_anchor > energy_threshold) {
|
||||
const float smooth_constant_increases =
|
||||
pre_echo_config_.mode != 3 ? 0.01f : 0.015f;
|
||||
|
||||
UpdateAccumulatedError(
|
||||
instantaneous_accumulated_error_, accumulated_error_[winner_index],
|
||||
1.0f / error_sum_anchor, smooth_constant_increases);
|
||||
static constexpr float kEnergyThreshold = 1.0f;
|
||||
if (error_sum_anchor > kEnergyThreshold) {
|
||||
UpdateAccumulatedError(instantaneous_accumulated_error_,
|
||||
accumulated_error_[winner_index],
|
||||
1.0f / error_sum_anchor);
|
||||
number_pre_echo_updates_++;
|
||||
}
|
||||
if (pre_echo_config_.mode != 3 || number_pre_echo_updates_ >= 50) {
|
||||
if (number_pre_echo_updates_ >= 50) {
|
||||
reported_lag_estimate_->pre_echo_lag = ComputePreEchoLag(
|
||||
pre_echo_config_, accumulated_error_[winner_index],
|
||||
winner_lag_.value(),
|
||||
accumulated_error_[winner_index], winner_lag_.value(),
|
||||
winner_index * filter_intra_lag_shift_ /*alignment_shift_winner*/);
|
||||
} else {
|
||||
reported_lag_estimate_->pre_echo_lag = winner_lag_.value();
|
||||
@ -885,10 +811,9 @@ void MatchedFilter::Dump() {
|
||||
"aec3_correlator_error_" + std::to_string(n) + "_h";
|
||||
data_dumper_->DumpRaw(dumper_error.c_str(), accumulated_error_[n]);
|
||||
|
||||
size_t pre_echo_lag =
|
||||
ComputePreEchoLag(pre_echo_config_, accumulated_error_[n],
|
||||
lag_estimate + n * filter_intra_lag_shift_,
|
||||
n * filter_intra_lag_shift_);
|
||||
size_t pre_echo_lag = ComputePreEchoLag(
|
||||
accumulated_error_[n], lag_estimate + n * filter_intra_lag_shift_,
|
||||
n * filter_intra_lag_shift_);
|
||||
std::string dumper_pre_lag =
|
||||
"aec3_correlator_pre_echo_lag_" + std::to_string(n);
|
||||
data_dumper_->DumpRaw(dumper_pre_lag.c_str(), pre_echo_lag);
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
#include "rtc_base/gtest_prod_util.h"
|
||||
@ -106,11 +106,6 @@ class MatchedFilter {
|
||||
size_t pre_echo_lag = 0;
|
||||
};
|
||||
|
||||
struct PreEchoConfiguration {
|
||||
const float threshold;
|
||||
const int mode;
|
||||
};
|
||||
|
||||
MatchedFilter(ApmDataDumper* data_dumper,
|
||||
Aec3Optimization optimization,
|
||||
size_t sub_block_size,
|
||||
@ -138,7 +133,7 @@ class MatchedFilter {
|
||||
void Reset(bool full_reset);
|
||||
|
||||
// Returns the current lag estimates.
|
||||
absl::optional<const MatchedFilter::LagEstimate> GetBestLagEstimate() const {
|
||||
std::optional<const MatchedFilter::LagEstimate> GetBestLagEstimate() const {
|
||||
return reported_lag_estimate_;
|
||||
}
|
||||
|
||||
@ -153,15 +148,6 @@ class MatchedFilter {
|
||||
size_t downsampling_factor) const;
|
||||
|
||||
private:
|
||||
FRIEND_TEST_ALL_PREFIXES(MatchedFilterFieldTrialTest,
|
||||
PreEchoConfigurationTest);
|
||||
FRIEND_TEST_ALL_PREFIXES(MatchedFilterFieldTrialTest,
|
||||
WrongPreEchoConfigurationTest);
|
||||
|
||||
// Only for testing. Gets the pre echo detection configuration.
|
||||
const PreEchoConfiguration& GetPreEchoConfiguration() const {
|
||||
return pre_echo_config_;
|
||||
}
|
||||
void Dump();
|
||||
|
||||
ApmDataDumper* const data_dumper_;
|
||||
@ -172,8 +158,8 @@ class MatchedFilter {
|
||||
std::vector<std::vector<float>> accumulated_error_;
|
||||
std::vector<float> instantaneous_accumulated_error_;
|
||||
std::vector<float> scratch_memory_;
|
||||
absl::optional<MatchedFilter::LagEstimate> reported_lag_estimate_;
|
||||
absl::optional<size_t> winner_lag_;
|
||||
std::optional<MatchedFilter::LagEstimate> reported_lag_estimate_;
|
||||
std::optional<size_t> winner_lag_;
|
||||
int last_detected_best_lag_filter_ = -1;
|
||||
std::vector<size_t> filters_offsets_;
|
||||
int number_pre_echo_updates_ = 0;
|
||||
@ -182,7 +168,6 @@ class MatchedFilter {
|
||||
const float smoothing_slow_;
|
||||
const float matching_filter_threshold_;
|
||||
const bool detect_pre_echo_;
|
||||
const PreEchoConfiguration pre_echo_config_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -13,16 +13,6 @@
|
||||
#include "modules/audio_processing/aec3/matched_filter.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Visual Studio
|
||||
#define LOOKUP_M128(v, i) v.m128_f32[i]
|
||||
#define LOOKUP_M256(v, i) v.m256_f32[i]
|
||||
#else
|
||||
// GCC/Clang
|
||||
#define LOOKUP_M128(v, i) v[i]
|
||||
#define LOOKUP_M256(v, i) v[i]
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
namespace aec3 {
|
||||
|
||||
@ -91,14 +81,14 @@ void MatchedFilterCore_AccumulatedError_AVX2(
|
||||
s_inst_256_8 = _mm256_mul_ps(h_k_8, x_k_8);
|
||||
s_inst_hadd_256 = _mm256_hadd_ps(s_inst_256, s_inst_256_8);
|
||||
s_inst_hadd_256 = _mm256_hadd_ps(s_inst_hadd_256, s_inst_hadd_256);
|
||||
s_acum += LOOKUP_M256(s_inst_hadd_256, 0);
|
||||
LOOKUP_M128(e_128, 0) = s_acum - y[i];
|
||||
s_acum += LOOKUP_M256(s_inst_hadd_256,4);
|
||||
LOOKUP_M128(e_128, 1) = s_acum - y[i];
|
||||
s_acum += LOOKUP_M256(s_inst_hadd_256,1);
|
||||
LOOKUP_M128(e_128, 2) = s_acum - y[i];
|
||||
s_acum += LOOKUP_M256(s_inst_hadd_256,5);
|
||||
LOOKUP_M128(e_128, 3) = s_acum - y[i];
|
||||
s_acum += s_inst_hadd_256[0];
|
||||
e_128[0] = s_acum - y[i];
|
||||
s_acum += s_inst_hadd_256[4];
|
||||
e_128[1] = s_acum - y[i];
|
||||
s_acum += s_inst_hadd_256[1];
|
||||
e_128[2] = s_acum - y[i];
|
||||
s_acum += s_inst_hadd_256[5];
|
||||
e_128[3] = s_acum - y[i];
|
||||
|
||||
__m128 accumulated_error = _mm_load_ps(a_p);
|
||||
accumulated_error = _mm_fmadd_ps(e_128, e_128, accumulated_error);
|
||||
@ -219,8 +209,8 @@ void MatchedFilterCore_AVX2(size_t x_start_index,
|
||||
x2_sum_256 = _mm256_add_ps(x2_sum_256, x2_sum_256_8);
|
||||
s_256 = _mm256_add_ps(s_256, s_256_8);
|
||||
__m128 sum = hsum_ab(x2_sum_256, s_256);
|
||||
x2_sum += LOOKUP_M128(sum, 0);
|
||||
s += LOOKUP_M128(sum, 1);
|
||||
x2_sum += sum[0];
|
||||
s += sum[1];
|
||||
|
||||
// Compute the matched filter error.
|
||||
float e = y[i] - s;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/numerics/safe_minmax.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
@ -63,8 +62,8 @@ void MatchedFilterLagAggregator::Reset(bool hard_reset) {
|
||||
}
|
||||
}
|
||||
|
||||
absl::optional<DelayEstimate> MatchedFilterLagAggregator::Aggregate(
|
||||
const absl::optional<const MatchedFilter::LagEstimate>& lag_estimate) {
|
||||
std::optional<DelayEstimate> MatchedFilterLagAggregator::Aggregate(
|
||||
const std::optional<const MatchedFilter::LagEstimate>& lag_estimate) {
|
||||
if (lag_estimate && pre_echo_lag_aggregator_) {
|
||||
pre_echo_lag_aggregator_->Dump(data_dumper_);
|
||||
pre_echo_lag_aggregator_->Aggregate(
|
||||
@ -91,7 +90,7 @@ absl::optional<DelayEstimate> MatchedFilterLagAggregator::Aggregate(
|
||||
}
|
||||
}
|
||||
|
||||
return absl::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
MatchedFilterLagAggregator::HighestPeakAggregator::HighestPeakAggregator(
|
||||
@ -124,8 +123,6 @@ MatchedFilterLagAggregator::PreEchoLagAggregator::PreEchoLagAggregator(
|
||||
size_t max_filter_lag,
|
||||
size_t down_sampling_factor)
|
||||
: block_size_log2_(GetDownSamplingBlockSizeLog2(down_sampling_factor)),
|
||||
penalize_high_delays_initial_phase_(!field_trial::IsDisabled(
|
||||
"WebRTC-Aec3PenalyzeHighDelaysInitialPhase")),
|
||||
histogram_(
|
||||
((max_filter_lag + 1) * down_sampling_factor) >> kBlockSizeLog2,
|
||||
0) {
|
||||
@ -156,8 +153,7 @@ void MatchedFilterLagAggregator::PreEchoLagAggregator::Aggregate(
|
||||
++histogram_[histogram_data_[histogram_data_index_]];
|
||||
histogram_data_index_ = (histogram_data_index_ + 1) % histogram_data_.size();
|
||||
int pre_echo_candidate_block_size = 0;
|
||||
if (penalize_high_delays_initial_phase_ &&
|
||||
number_updates_ < kNumBlocksPerSecond * 2) {
|
||||
if (number_updates_ < kNumBlocksPerSecond * 2) {
|
||||
number_updates_++;
|
||||
float penalization_per_delay = 1.0f;
|
||||
float max_histogram_value = -1.0f;
|
||||
|
@ -11,9 +11,9 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/delay_estimate.h"
|
||||
#include "modules/audio_processing/aec3/matched_filter.h"
|
||||
@ -41,8 +41,8 @@ class MatchedFilterLagAggregator {
|
||||
void Reset(bool hard_reset);
|
||||
|
||||
// Aggregates the provided lag estimates.
|
||||
absl::optional<DelayEstimate> Aggregate(
|
||||
const absl::optional<const MatchedFilter::LagEstimate>& lag_estimate);
|
||||
std::optional<DelayEstimate> Aggregate(
|
||||
const std::optional<const MatchedFilter::LagEstimate>& lag_estimate);
|
||||
|
||||
// Returns whether a reliable delay estimate has been found.
|
||||
bool ReliableDelayFound() const { return significant_candidate_found_; }
|
||||
@ -64,7 +64,6 @@ class MatchedFilterLagAggregator {
|
||||
|
||||
private:
|
||||
const int block_size_log2_;
|
||||
const bool penalize_high_delays_initial_phase_;
|
||||
std::array<int, 250> histogram_data_;
|
||||
std::vector<int> histogram_;
|
||||
int histogram_data_index_ = 0;
|
||||
|
@ -94,9 +94,9 @@ MultiChannelContentDetector::MultiChannelContentDetector(
|
||||
detection_threshold_(detection_threshold),
|
||||
detection_timeout_threshold_frames_(
|
||||
stereo_detection_timeout_threshold_seconds > 0
|
||||
? absl::make_optional(stereo_detection_timeout_threshold_seconds *
|
||||
kNumFramesPerSecond)
|
||||
: absl::nullopt),
|
||||
? std::make_optional(stereo_detection_timeout_threshold_seconds *
|
||||
kNumFramesPerSecond)
|
||||
: std::nullopt),
|
||||
stereo_detection_hysteresis_frames_(static_cast<int>(
|
||||
stereo_detection_hysteresis_seconds * kNumFramesPerSecond)),
|
||||
metrics_logger_((detect_stereo_content && num_render_input_channels > 1)
|
||||
|
@ -14,10 +14,9 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Analyzes audio content to determine whether the contained audio is proper
|
||||
@ -76,7 +75,7 @@ class MultiChannelContentDetector {
|
||||
|
||||
const bool detect_stereo_content_;
|
||||
const float detection_threshold_;
|
||||
const absl::optional<int> detection_timeout_threshold_frames_;
|
||||
const std::optional<int> detection_timeout_threshold_frames_;
|
||||
const int stereo_detection_hysteresis_frames_;
|
||||
|
||||
// Collects and reports metrics on the amount of multichannel content
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
@ -80,7 +80,7 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer {
|
||||
BlockBuffer blocks_;
|
||||
SpectrumBuffer spectra_;
|
||||
FftBuffer ffts_;
|
||||
absl::optional<size_t> delay_;
|
||||
std::optional<size_t> delay_;
|
||||
RenderBuffer echo_remover_buffer_;
|
||||
DownsampledRenderBuffer low_rate_;
|
||||
AlignmentMixer render_mixer_;
|
||||
@ -95,7 +95,7 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer {
|
||||
int64_t render_call_counter_ = 0;
|
||||
bool render_activity_ = false;
|
||||
size_t render_activity_counter_ = 0;
|
||||
absl::optional<int> external_audio_buffer_delay_;
|
||||
std::optional<int> external_audio_buffer_delay_;
|
||||
bool external_audio_buffer_delay_verified_after_reset_ = false;
|
||||
size_t min_latency_blocks_ = 0;
|
||||
size_t excess_render_detection_counter_ = 0;
|
||||
@ -193,7 +193,7 @@ void RenderDelayBufferImpl::Reset() {
|
||||
ApplyTotalDelay(config_.delay.default_delay);
|
||||
|
||||
// Unset the delays which are set by AlignFromDelay.
|
||||
delay_ = absl::nullopt;
|
||||
delay_ = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
@ -44,7 +44,7 @@ class RenderDelayControllerImpl final : public RenderDelayController {
|
||||
~RenderDelayControllerImpl() override;
|
||||
void Reset(bool reset_delay_confidence) override;
|
||||
void LogRenderCall() override;
|
||||
absl::optional<DelayEstimate> GetDelay(
|
||||
std::optional<DelayEstimate> GetDelay(
|
||||
const DownsampledRenderBuffer& render_buffer,
|
||||
size_t render_delay_buffer_delay,
|
||||
const Block& capture) override;
|
||||
@ -54,17 +54,17 @@ class RenderDelayControllerImpl final : public RenderDelayController {
|
||||
static std::atomic<int> instance_count_;
|
||||
std::unique_ptr<ApmDataDumper> data_dumper_;
|
||||
const int hysteresis_limit_blocks_;
|
||||
absl::optional<DelayEstimate> delay_;
|
||||
std::optional<DelayEstimate> delay_;
|
||||
EchoPathDelayEstimator delay_estimator_;
|
||||
RenderDelayControllerMetrics metrics_;
|
||||
absl::optional<DelayEstimate> delay_samples_;
|
||||
std::optional<DelayEstimate> delay_samples_;
|
||||
size_t capture_call_counter_ = 0;
|
||||
int delay_change_counter_ = 0;
|
||||
DelayEstimate::Quality last_delay_estimate_quality_;
|
||||
};
|
||||
|
||||
DelayEstimate ComputeBufferDelay(
|
||||
const absl::optional<DelayEstimate>& current_delay,
|
||||
const std::optional<DelayEstimate>& current_delay,
|
||||
int hysteresis_limit_blocks,
|
||||
DelayEstimate estimated_delay) {
|
||||
// Compute the buffer delay increase required to achieve the desired latency.
|
||||
@ -100,8 +100,8 @@ RenderDelayControllerImpl::RenderDelayControllerImpl(
|
||||
RenderDelayControllerImpl::~RenderDelayControllerImpl() = default;
|
||||
|
||||
void RenderDelayControllerImpl::Reset(bool reset_delay_confidence) {
|
||||
delay_ = absl::nullopt;
|
||||
delay_samples_ = absl::nullopt;
|
||||
delay_ = std::nullopt;
|
||||
delay_samples_ = std::nullopt;
|
||||
delay_estimator_.Reset(reset_delay_confidence);
|
||||
delay_change_counter_ = 0;
|
||||
if (reset_delay_confidence) {
|
||||
@ -111,7 +111,7 @@ void RenderDelayControllerImpl::Reset(bool reset_delay_confidence) {
|
||||
|
||||
void RenderDelayControllerImpl::LogRenderCall() {}
|
||||
|
||||
absl::optional<DelayEstimate> RenderDelayControllerImpl::GetDelay(
|
||||
std::optional<DelayEstimate> RenderDelayControllerImpl::GetDelay(
|
||||
const DownsampledRenderBuffer& render_buffer,
|
||||
size_t render_delay_buffer_delay,
|
||||
const Block& capture) {
|
||||
@ -155,11 +155,10 @@ absl::optional<DelayEstimate> RenderDelayControllerImpl::GetDelay(
|
||||
last_delay_estimate_quality_ = delay_samples_->quality;
|
||||
}
|
||||
|
||||
metrics_.Update(
|
||||
delay_samples_ ? absl::optional<size_t>(delay_samples_->delay)
|
||||
: absl::nullopt,
|
||||
delay_ ? absl::optional<size_t>(delay_->delay) : absl::nullopt,
|
||||
delay_estimator_.Clockdrift());
|
||||
metrics_.Update(delay_samples_ ? std::optional<size_t>(delay_samples_->delay)
|
||||
: std::nullopt,
|
||||
delay_ ? std::optional<size_t>(delay_->delay) : std::nullopt,
|
||||
delay_estimator_.Clockdrift());
|
||||
|
||||
data_dumper_->DumpRaw("aec3_render_delay_controller_delay",
|
||||
delay_samples ? delay_samples->delay : 0);
|
||||
|
@ -11,7 +11,8 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include <optional>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/block.h"
|
||||
@ -38,7 +39,7 @@ class RenderDelayController {
|
||||
virtual void LogRenderCall() = 0;
|
||||
|
||||
// Aligns the render buffer content with the capture signal.
|
||||
virtual absl::optional<DelayEstimate> GetDelay(
|
||||
virtual std::optional<DelayEstimate> GetDelay(
|
||||
const DownsampledRenderBuffer& render_buffer,
|
||||
size_t render_delay_buffer_delay,
|
||||
const Block& capture) = 0;
|
||||
|
@ -42,8 +42,8 @@ enum class DelayChangesCategory {
|
||||
RenderDelayControllerMetrics::RenderDelayControllerMetrics() = default;
|
||||
|
||||
void RenderDelayControllerMetrics::Update(
|
||||
absl::optional<size_t> delay_samples,
|
||||
absl::optional<size_t> buffer_delay_blocks,
|
||||
std::optional<size_t> delay_samples,
|
||||
std::optional<size_t> buffer_delay_blocks,
|
||||
ClockdriftDetector::Level clockdrift) {
|
||||
++call_counter_;
|
||||
|
||||
|
@ -13,7 +13,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include <optional>
|
||||
|
||||
#include "modules/audio_processing/aec3/clockdrift_detector.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -28,8 +29,8 @@ class RenderDelayControllerMetrics {
|
||||
delete;
|
||||
|
||||
// Updates the metric with new data.
|
||||
void Update(absl::optional<size_t> delay_samples,
|
||||
absl::optional<size_t> buffer_delay_blocks,
|
||||
void Update(std::optional<size_t> delay_samples,
|
||||
std::optional<size_t> buffer_delay_blocks,
|
||||
ClockdriftDetector::Level clockdrift);
|
||||
|
||||
private:
|
||||
|
@ -27,7 +27,7 @@ constexpr size_t kCounterThreshold = 5;
|
||||
// Identifies local bands with narrow characteristics.
|
||||
void IdentifySmallNarrowBandRegions(
|
||||
const RenderBuffer& render_buffer,
|
||||
const absl::optional<size_t>& delay_partitions,
|
||||
const std::optional<size_t>& delay_partitions,
|
||||
std::array<size_t, kFftLengthBy2 - 1>* narrow_band_counters) {
|
||||
RTC_DCHECK(narrow_band_counters);
|
||||
|
||||
@ -56,14 +56,14 @@ void IdentifySmallNarrowBandRegions(
|
||||
// Identifies whether the signal has a single strong narrow-band component.
|
||||
void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer,
|
||||
int strong_peak_freeze_duration,
|
||||
absl::optional<int>* narrow_peak_band,
|
||||
std::optional<int>* narrow_peak_band,
|
||||
size_t* narrow_peak_counter) {
|
||||
RTC_DCHECK(narrow_peak_band);
|
||||
RTC_DCHECK(narrow_peak_counter);
|
||||
if (*narrow_peak_band &&
|
||||
++(*narrow_peak_counter) >
|
||||
static_cast<size_t>(strong_peak_freeze_duration)) {
|
||||
*narrow_peak_band = absl::nullopt;
|
||||
*narrow_peak_band = std::nullopt;
|
||||
}
|
||||
|
||||
const Block& x_latest = render_buffer.GetBlock(0);
|
||||
@ -125,7 +125,7 @@ RenderSignalAnalyzer::~RenderSignalAnalyzer() = default;
|
||||
|
||||
void RenderSignalAnalyzer::Update(
|
||||
const RenderBuffer& render_buffer,
|
||||
const absl::optional<size_t>& delay_partitions) {
|
||||
const std::optional<size_t>& delay_partitions) {
|
||||
// Identify bands of narrow nature.
|
||||
IdentifySmallNarrowBandRegions(render_buffer, delay_partitions,
|
||||
&narrow_band_counters_);
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
#include "modules/audio_processing/aec3/render_buffer.h"
|
||||
@ -34,7 +34,7 @@ class RenderSignalAnalyzer {
|
||||
|
||||
// Updates the render signal analysis with the most recent render signal.
|
||||
void Update(const RenderBuffer& render_buffer,
|
||||
const absl::optional<size_t>& delay_partitions);
|
||||
const std::optional<size_t>& delay_partitions);
|
||||
|
||||
// Returns true if the render signal is poorly exciting.
|
||||
bool PoorSignalExcitation() const {
|
||||
@ -48,12 +48,12 @@ class RenderSignalAnalyzer {
|
||||
void MaskRegionsAroundNarrowBands(
|
||||
std::array<float, kFftLengthBy2Plus1>* v) const;
|
||||
|
||||
absl::optional<int> NarrowPeakBand() const { return narrow_peak_band_; }
|
||||
std::optional<int> NarrowPeakBand() const { return narrow_peak_band_; }
|
||||
|
||||
private:
|
||||
const int strong_peak_freeze_duration_;
|
||||
std::array<size_t, kFftLengthBy2 - 1> narrow_band_counters_;
|
||||
absl::optional<int> narrow_peak_band_;
|
||||
std::optional<int> narrow_peak_band_;
|
||||
size_t narrow_peak_counter_;
|
||||
};
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
#include "modules/audio_processing/aec3/aec_state.h"
|
||||
|
@ -102,7 +102,7 @@ ReverbDecayEstimator::ReverbDecayEstimator(const EchoCanceller3Config& config)
|
||||
ReverbDecayEstimator::~ReverbDecayEstimator() = default;
|
||||
|
||||
void ReverbDecayEstimator::Update(rtc::ArrayView<const float> filter,
|
||||
const absl::optional<float>& filter_quality,
|
||||
const std::optional<float>& filter_quality,
|
||||
int filter_delay_blocks,
|
||||
bool usable_linear_filter,
|
||||
bool stationary_signal) {
|
||||
|
@ -12,9 +12,9 @@
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_REVERB_DECAY_ESTIMATOR_H_
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h" // kMaxAdaptiveFilter...
|
||||
|
||||
@ -30,7 +30,7 @@ class ReverbDecayEstimator {
|
||||
~ReverbDecayEstimator();
|
||||
// Updates the decay estimate.
|
||||
void Update(rtc::ArrayView<const float> filter,
|
||||
const absl::optional<float>& filter_quality,
|
||||
const std::optional<float>& filter_quality,
|
||||
int filter_delay_blocks,
|
||||
bool usable_linear_filter,
|
||||
bool stationary_signal);
|
||||
|
@ -62,7 +62,7 @@ void ReverbFrequencyResponse::Update(
|
||||
const std::vector<std::array<float, kFftLengthBy2Plus1>>&
|
||||
frequency_response,
|
||||
int filter_delay_blocks,
|
||||
const absl::optional<float>& linear_filter_quality,
|
||||
const std::optional<float>& linear_filter_quality,
|
||||
bool stationary_block) {
|
||||
if (stationary_block || !linear_filter_quality) {
|
||||
return;
|
||||
|
@ -12,9 +12,9 @@
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_REVERB_FREQUENCY_RESPONSE_H_
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
|
||||
@ -31,7 +31,7 @@ class ReverbFrequencyResponse {
|
||||
void Update(const std::vector<std::array<float, kFftLengthBy2Plus1>>&
|
||||
frequency_response,
|
||||
int filter_delay_blocks,
|
||||
const absl::optional<float>& linear_filter_quality,
|
||||
const std::optional<float>& linear_filter_quality,
|
||||
bool stationary_block);
|
||||
|
||||
// Returns the estimated frequency response for the reverb.
|
||||
|
@ -31,7 +31,7 @@ void ReverbModelEstimator::Update(
|
||||
rtc::ArrayView<const std::vector<float>> impulse_responses,
|
||||
rtc::ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>>
|
||||
frequency_responses,
|
||||
rtc::ArrayView<const absl::optional<float>> linear_filter_qualities,
|
||||
rtc::ArrayView<const std::optional<float>> linear_filter_qualities,
|
||||
rtc::ArrayView<const int> filter_delays_blocks,
|
||||
const std::vector<bool>& usable_linear_estimates,
|
||||
bool stationary_block) {
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h" // kFftLengthBy2Plus1
|
||||
@ -38,7 +38,7 @@ class ReverbModelEstimator {
|
||||
rtc::ArrayView<const std::vector<float>> impulse_responses,
|
||||
rtc::ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>>
|
||||
frequency_responses,
|
||||
rtc::ArrayView<const absl::optional<float>> linear_filter_qualities,
|
||||
rtc::ArrayView<const std::optional<float>> linear_filter_qualities,
|
||||
rtc::ArrayView<const int> filter_delays_blocks,
|
||||
const std::vector<bool>& usable_linear_estimates,
|
||||
bool stationary_block);
|
||||
|
@ -44,7 +44,7 @@ void SubtractorOutputAnalyzer::Update(
|
||||
bool coarse_filter_converged_strict =
|
||||
e2_coarse < 0.05f * y2 && y2 > kConvergenceThreshold;
|
||||
bool coarse_filter_converged_relaxed =
|
||||
e2_coarse < 0.2f * y2 && y2 > kConvergenceThresholdLowLevel;
|
||||
e2_coarse < 0.3f * y2 && y2 > kConvergenceThresholdLowLevel;
|
||||
float min_e2 = std::min(e2_refined, e2_coarse);
|
||||
bool filter_diverged = min_e2 > 1.5f * y2 && y2 > 30.f * 30.f * kBlockSize;
|
||||
filters_converged_[ch] =
|
||||
|
@ -107,7 +107,7 @@ float SuppressionGain::UpperBandsGain(
|
||||
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum,
|
||||
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
|
||||
comfort_noise_spectrum,
|
||||
const absl::optional<int>& narrow_peak_band,
|
||||
const std::optional<int>& narrow_peak_band,
|
||||
bool saturated_echo,
|
||||
const Block& render,
|
||||
const std::array<float, kFftLengthBy2Plus1>& low_band_gain) const {
|
||||
@ -394,7 +394,7 @@ void SuppressionGain::GetGain(
|
||||
low_band_gain);
|
||||
|
||||
// Compute the gain for the upper bands.
|
||||
const absl::optional<int> narrow_peak_band =
|
||||
const std::optional<int> narrow_peak_band =
|
||||
render_signal_analyzer.NarrowPeakBand();
|
||||
|
||||
*high_bands_gain =
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "modules/audio_processing/aec3/aec3_common.h"
|
||||
@ -70,7 +70,7 @@ class SuppressionGain {
|
||||
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum,
|
||||
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
|
||||
comfort_noise_spectrum,
|
||||
const absl::optional<int>& narrow_peak_band,
|
||||
const std::optional<int>& narrow_peak_band,
|
||||
bool saturated_echo,
|
||||
const Block& render,
|
||||
const std::array<float, kFftLengthBy2Plus1>& low_band_gain) const;
|
||||
|
@ -19,6 +19,7 @@ namespace {
|
||||
|
||||
constexpr size_t kBlocksSinceConvergencedFilterInit = 10000;
|
||||
constexpr size_t kBlocksSinceConsistentEstimateInit = 10000;
|
||||
constexpr float kInitialTransparentStateProbability = 0.2f;
|
||||
|
||||
bool DeactivateTransparentMode() {
|
||||
return field_trial::IsEnabled("WebRTC-Aec3TransparentModeKillSwitch");
|
||||
@ -41,7 +42,7 @@ class TransparentModeImpl : public TransparentMode {
|
||||
transparency_activated_ = false;
|
||||
|
||||
// The estimated probability of being transparent mode.
|
||||
prob_transparent_state_ = 0.f;
|
||||
prob_transparent_state_ = kInitialTransparentStateProbability;
|
||||
}
|
||||
|
||||
void Update(int filter_delay_blocks,
|
||||
@ -118,7 +119,7 @@ class TransparentModeImpl : public TransparentMode {
|
||||
|
||||
private:
|
||||
bool transparency_activated_ = false;
|
||||
float prob_transparent_state_ = 0.f;
|
||||
float prob_transparent_state_ = kInitialTransparentStateProbability;
|
||||
};
|
||||
|
||||
// Legacy classifier for toggling transparent mode.
|
||||
|
Reference in New Issue
Block a user