From e82d2a177387a69b0c6262255f360d4cf1a74460 Mon Sep 17 00:00:00 2001 From: Hanna Silen Date: Wed, 9 Nov 2022 12:08:34 +0100 Subject: [PATCH] InputVolumeController: Use clipped_level_min in clipping prediction Replace the use of MonoInputController::min_mic_level() with MonoInputVolumeController::clipped_level_min() when estimating input volume adjustment from clipping prediction. The adjustment is later capped in MonoInputVolumeController::HandleClipping() using clipped_level_min_ so no audio changes are expected from this change. Bug: webrtc:7494 Change-Id: Ie26d0aa5cce3eeef06f70a281504889519bb5aca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282840 Reviewed-by: Alessio Bazzica Commit-Queue: Hanna Silen Cr-Commit-Position: refs/heads/main@{#38593} --- modules/audio_processing/agc2/input_volume_controller.cc | 2 +- modules/audio_processing/agc2/input_volume_controller.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/audio_processing/agc2/input_volume_controller.cc b/modules/audio_processing/agc2/input_volume_controller.cc index 8617d6c974..76d81d8c59 100644 --- a/modules/audio_processing/agc2/input_volume_controller.cc +++ b/modules/audio_processing/agc2/input_volume_controller.cc @@ -440,7 +440,7 @@ void InputVolumeController::AnalyzePreProcess(const AudioBuffer& audio_buffer) { for (int channel = 0; channel < num_capture_channels_; ++channel) { const auto step = clipping_predictor_->EstimateClippedLevelStep( channel, recommended_input_volume_, clipped_level_step_, - channel_controllers_[channel]->min_mic_level(), kMaxMicLevel); + channel_controllers_[channel]->clipped_level_min(), kMaxMicLevel); if (step.has_value()) { predicted_step = std::max(predicted_step, step.value()); clipping_predicted = true; diff --git a/modules/audio_processing/agc2/input_volume_controller.h b/modules/audio_processing/agc2/input_volume_controller.h index b832176fd4..941dd59b70 100644 --- a/modules/audio_processing/agc2/input_volume_controller.h +++ b/modules/audio_processing/agc2/input_volume_controller.h @@ -208,6 +208,8 @@ class MonoInputVolumeController { void ActivateLogging() { log_to_histograms_ = true; } + int clipped_level_min() const { return clipped_level_min_; } + // Only used for testing. int min_mic_level() const { return min_mic_level_; }