Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc

Issue 2111553002: Improved tuning of the adaptive level controller. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@ALC_RC9_CL
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
diff --git a/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc b/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
index 9175717ab7c77271732b8398c60bef13694f1825..e65ae5bc80d609fc701b415ca3377b6ad2a7306c 100644
--- a/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
+++ b/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
@@ -13,6 +13,7 @@
#include <algorithm>
#include "webrtc/modules/audio_processing/audio_buffer.h"
+#include "webrtc/modules/audio_processing/level_controller/lc_constants.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
namespace webrtc {
@@ -24,29 +25,34 @@ PeakLevelEstimator::PeakLevelEstimator() {
PeakLevelEstimator::~PeakLevelEstimator() {}
void PeakLevelEstimator::Initialize() {
- peak_level_ = 1000.f;
+ peak_level_ = kTargetLcPeakLevel;
hold_counter_ = 0;
+ initialization_phase_ = true;
}
float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type,
float frame_peak_level) {
- if (frame_peak_level > 0) {
- if (peak_level_ < frame_peak_level) {
- // Smoothly update the estimate upwards when the frame peak level is
- // higher than the estimate.
- peak_level_ += 0.1f * (frame_peak_level - peak_level_);
- hold_counter_ = 100;
- } else {
- hold_counter_ = std::max(0, hold_counter_ - 1);
-
- // When the signal is highly non-stationary, update the estimate slowly
- // downwards if the estimate is lower than the frame peak level.
- if (signal_type == SignalClassifier::SignalType::kHighlyNonStationary &&
- hold_counter_ == 0) {
- peak_level_ =
- std::max(peak_level_ + 0.01f * (frame_peak_level - peak_level_),
- peak_level_ * 0.995f);
- }
+ if (frame_peak_level == 0) {
+ return peak_level_;
hlundin-webrtc 2016/06/30 07:36:23 I'm all in favor of early returns, but you are no
peah-webrtc 2016/06/30 14:38:18 Good point! Added a DCHECK. Done.
+ }
+
+ if (peak_level_ < frame_peak_level) {
+ // Smoothly update the estimate upwards when the frame peak level is
+ // higher than the estimate.
+ peak_level_ += 0.1f * (frame_peak_level - peak_level_);
+ hold_counter_ = 100;
+ initialization_phase_ = false;
+ } else {
+ hold_counter_ = std::max(0, hold_counter_ - 1);
+
+ // When the signal is highly non-stationary, update the estimate slowly
+ // downwards if the estimate is lower than the frame peak level.
+ if ((signal_type == SignalClassifier::SignalType::kHighlyNonStationary &&
+ hold_counter_ == 0) ||
+ initialization_phase_) {
+ peak_level_ =
+ std::max(peak_level_ + 0.01f * (frame_peak_level - peak_level_),
+ peak_level_ * 0.995f);
}
}

Powered by Google App Engine
This is Rietveld 408576698