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

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

Issue 2337083002: Reland of added functionality for specifying the initial signal level to use for the gain estimation (Closed)
Patch Set: Fixed type conversion error Created 4 years, 2 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 2ba806c8ee0d15b58c366421aaa1e2b5c20d635b..37046fdceb21452d0429c4b99306abb97d3ce215 100644
--- a/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
+++ b/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
@@ -13,19 +13,28 @@
#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 {
+namespace {
-PeakLevelEstimator::PeakLevelEstimator() {
- Initialize();
+constexpr float kMinLevel = 30.f;
+
+} // namespace
+
+PeakLevelEstimator::PeakLevelEstimator(float initial_peak_level_dbfs) {
+ Initialize(initial_peak_level_dbfs);
}
PeakLevelEstimator::~PeakLevelEstimator() {}
-void PeakLevelEstimator::Initialize() {
- peak_level_ = kTargetLcPeakLevel;
+void PeakLevelEstimator::Initialize(float initial_peak_level_dbfs) {
+ RTC_DCHECK_LE(-100.f, initial_peak_level_dbfs);
+ RTC_DCHECK_GE(0.f, initial_peak_level_dbfs);
+
+ peak_level_ = std::pow(10.f, initial_peak_level_dbfs / 20.f) * 32768.f;
+ peak_level_ = std::max(peak_level_, kMinLevel);
+
hold_counter_ = 0;
initialization_phase_ = true;
}
@@ -33,7 +42,7 @@ void PeakLevelEstimator::Initialize() {
float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type,
float frame_peak_level) {
if (frame_peak_level == 0) {
- RTC_DCHECK_LE(30.f, peak_level_);
+ RTC_DCHECK_LE(kMinLevel, peak_level_);
return peak_level_;
}
@@ -57,7 +66,7 @@ float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type,
}
}
- peak_level_ = std::max(peak_level_, 30.f);
+ peak_level_ = std::max(peak_level_, kMinLevel);
return peak_level_;
}

Powered by Google App Engine
This is Rietveld 408576698