Chromium Code Reviews

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

Issue 2254973003: Added functionality for specifying the initial signal level to use for the gain estimation in the l… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added range check of the supplied level Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « webrtc/modules/audio_processing/level_controller/peak_level_estimator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9abc8c4c700a62c939c07469e0f43a494ff8d36b 100644
--- a/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
+++ b/webrtc/modules/audio_processing/level_controller/peak_level_estimator.cc
@@ -13,10 +13,15 @@
#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 {
+
+const float kMinLevel = 30.f;
+const float kMaxLevel = 32768.f;
+
+} // namespace
PeakLevelEstimator::PeakLevelEstimator() {
Initialize();
@@ -25,11 +30,20 @@ PeakLevelEstimator::PeakLevelEstimator() {
PeakLevelEstimator::~PeakLevelEstimator() {}
void PeakLevelEstimator::Initialize() {
- peak_level_ = kTargetLcPeakLevel;
+ peak_level_ = initial_peak_level_;
hold_counter_ = 0;
initialization_phase_ = true;
}
+void PeakLevelEstimator::SetInitialPeakLevel(float level) {
+ RTC_DCHECK_LE(0.f, level);
+ RTC_DCHECK_GE(32768.f, level);
the sun 2016/08/22 11:58:22 Why not use the constants here?
peah-webrtc 2016/08/22 12:09:04 That is a good question: The thinking was like th
the sun 2016/08/22 14:18:39 Ok that makes sense, but when I think about it, 0
peah-webrtc 2016/08/23 05:33:44 You are right! Excellent point. I changed the AP
the sun 2016/08/23 06:23:38 Nice, I would have gone for range 0-1.0 myself, bu
peah-webrtc 2016/08/26 10:47:13 That is correct, this is not something that will h
+
+ // Limit the supplied level to the level range used internally.
+ initial_peak_level_ = std::min(std::max(level, kMinLevel), kMaxLevel);
the sun 2016/08/22 11:58:22 Do you really need to DCHECK as well as clamp?
peah-webrtc 2016/08/22 12:09:04 That is a good question. Please see above response
the sun 2016/08/22 14:18:39 Right. I think generally APIs should aggressively
peah-webrtc 2016/08/23 05:33:44 True, I removed the std::min. Done.
+ Initialize();
+}
+
float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type,
float frame_peak_level) {
if (frame_peak_level == 0) {
« no previous file with comments | « webrtc/modules/audio_processing/level_controller/peak_level_estimator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine