diff --git a/modules/audio_processing/aec3/aec3_common.h b/modules/audio_processing/aec3/aec3_common.h index fd0059674b..3e80442981 100644 --- a/modules/audio_processing/aec3/aec3_common.h +++ b/modules/audio_processing/aec3/aec3_common.h @@ -29,7 +29,7 @@ enum class Aec3Optimization { kNone, kSse2, kNeon }; constexpr int kNumBlocksPerSecond = 250; constexpr int kMetricsReportingIntervalBlocks = 10 * kNumBlocksPerSecond; -constexpr int kMetricsComputationBlocks = 9; +constexpr int kMetricsComputationBlocks = 11; constexpr int kMetricsCollectionBlocks = kMetricsReportingIntervalBlocks - kMetricsComputationBlocks; diff --git a/modules/audio_processing/aec3/echo_remover_metrics.cc b/modules/audio_processing/aec3/echo_remover_metrics.cc index 3a71299b1e..0544a5c28b 100644 --- a/modules/audio_processing/aec3/echo_remover_metrics.cc +++ b/modules/audio_processing/aec3/echo_remover_metrics.cc @@ -37,13 +37,21 @@ void EchoRemoverMetrics::DbMetric::Update(float value) { ceil_value = std::max(ceil_value, value); } +void EchoRemoverMetrics::DbMetric::UpdateInstant(float value) { + sum_value = value; + floor_value = std::min(floor_value, value); + ceil_value = std::max(ceil_value, value); +} + EchoRemoverMetrics::EchoRemoverMetrics() { ResetMetrics(); } void EchoRemoverMetrics::ResetMetrics() { erl_.fill(DbMetric(0.f, 10000.f, 0.000f)); + erl_time_domain_ = DbMetric(0.f, 10000.f, 0.000f); erle_.fill(DbMetric(0.f, 0.f, 1000.f)); + erle_time_domain_ = DbMetric(0.f, 0.f, 1000.f); comfort_noise_.fill(DbMetric(0.f, 100000000.f, 0.f)); suppressor_gain_.fill(DbMetric(0.f, 1.f, 0.f)); active_render_count_ = 0; @@ -57,7 +65,9 @@ void EchoRemoverMetrics::Update( metrics_reported_ = false; if (++block_counter_ <= kMetricsCollectionBlocks) { aec3::UpdateDbMetric(aec_state.Erl(), &erl_); + erl_time_domain_.UpdateInstant(aec_state.ErlTimeDomain()); aec3::UpdateDbMetric(aec_state.Erle(), &erle_); + erle_time_domain_.UpdateInstant(aec_state.ErleTimeDomain()); aec3::UpdateDbMetric(comfort_noise_spectrum, &comfort_noise_); aec3::UpdateDbMetric(suppressor_gain, &suppressor_gain_); active_render_count_ += (aec_state.ActiveRender() ? 1 : 0); @@ -232,6 +242,40 @@ void EchoRemoverMetrics::Update( 31); RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.EchoCanceller.CaptureSaturation", static_cast(saturated_capture_ ? 1 : 0)); + break; + case kMetricsCollectionBlocks + 10: + RTC_HISTOGRAM_COUNTS_LINEAR( + "WebRTC.Audio.EchoCanceller.Erl.Value", + aec3::TransformDbMetricForReporting(true, 0.f, 59.f, 30.f, 1.f, + erl_time_domain_.sum_value), + 0, 59, 30); + RTC_HISTOGRAM_COUNTS_LINEAR( + "WebRTC.Audio.EchoCanceller.Erl.Max", + aec3::TransformDbMetricForReporting(true, 0.f, 59.f, 30.f, 1.f, + erl_time_domain_.ceil_value), + 0, 59, 30); + RTC_HISTOGRAM_COUNTS_LINEAR( + "WebRTC.Audio.EchoCanceller.Erl.Min", + aec3::TransformDbMetricForReporting(true, 0.f, 59.f, 30.f, 1.f, + erl_time_domain_.floor_value), + 0, 59, 30); + break; + case kMetricsCollectionBlocks + 11: + RTC_HISTOGRAM_COUNTS_LINEAR( + "WebRTC.Audio.EchoCanceller.Erle.Value", + aec3::TransformDbMetricForReporting(false, 0.f, 19.f, 0.f, 1.f, + erle_time_domain_.sum_value), + 0, 19, 20); + RTC_HISTOGRAM_COUNTS_LINEAR( + "WebRTC.Audio.EchoCanceller.Erle.Max", + aec3::TransformDbMetricForReporting(false, 0.f, 19.f, 0.f, 1.f, + erle_time_domain_.ceil_value), + 0, 19, 20); + RTC_HISTOGRAM_COUNTS_LINEAR( + "WebRTC.Audio.EchoCanceller.Erle.Min", + aec3::TransformDbMetricForReporting(false, 0.f, 19.f, 0.f, 1.f, + erle_time_domain_.floor_value), + 0, 19, 20); metrics_reported_ = true; RTC_DCHECK_EQ(kMetricsReportingIntervalBlocks, block_counter_); block_counter_ = 0; diff --git a/modules/audio_processing/aec3/echo_remover_metrics.h b/modules/audio_processing/aec3/echo_remover_metrics.h index 6548ae8aa2..17b803a1cf 100644 --- a/modules/audio_processing/aec3/echo_remover_metrics.h +++ b/modules/audio_processing/aec3/echo_remover_metrics.h @@ -23,6 +23,7 @@ class EchoRemoverMetrics { DbMetric(); DbMetric(float sum_value, float floor_value, float ceil_value); void Update(float value); + void UpdateInstant(float value); float sum_value; float floor_value; float ceil_value; @@ -45,7 +46,9 @@ class EchoRemoverMetrics { int block_counter_ = 0; std::array erl_; + DbMetric erl_time_domain_; std::array erle_; + DbMetric erle_time_domain_; std::array comfort_noise_; std::array suppressor_gain_; int active_render_count_ = 0; diff --git a/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc b/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc index b8b20d7722..e20971048b 100644 --- a/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc +++ b/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc @@ -110,6 +110,20 @@ TEST(DbMetric, Update) { EXPECT_FLOAT_EQ(kValue, metric.floor_value); } +// Verify the Update functionality of DbMetric. +TEST(DbMetric, UpdateInstant) { + EchoRemoverMetrics::DbMetric metric(0.f, 20.f, -20.f); + constexpr float kMinValue = -77.f; + constexpr float kMaxValue = 33.f; + constexpr float kLastValue = (kMinValue + kMaxValue) / 2.0f; + for (float value = kMinValue; value <= kMaxValue; value++) + metric.UpdateInstant(value); + metric.UpdateInstant(kLastValue); + EXPECT_FLOAT_EQ(kLastValue, metric.sum_value); + EXPECT_FLOAT_EQ(kMaxValue, metric.ceil_value); + EXPECT_FLOAT_EQ(kMinValue, metric.floor_value); +} + // Verify the constructor functionality of DbMetric. TEST(DbMetric, Constructor) { EchoRemoverMetrics::DbMetric metric;