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

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

Issue 2337083002: Reland of added functionality for specifying the initial signal level to use for the gain estimation (Closed)
Patch Set: Changes in response to reviewer comments Created 4 years, 3 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/level_controller.cc
diff --git a/webrtc/modules/audio_processing/level_controller/level_controller.cc b/webrtc/modules/audio_processing/level_controller/level_controller.cc
index c0edeb91c50f5a472019f07eb45ce97910d9ea12..1ec20201d8640fcf2b7955af53fcff0fd9530001 100644
--- a/webrtc/modules/audio_processing/level_controller/level_controller.cc
+++ b/webrtc/modules/audio_processing/level_controller/level_controller.cc
@@ -240,8 +240,12 @@ void LevelController::Process(AudioBuffer* audio) {
float saturating_gain = saturating_gain_estimator_.GetGain();
// Compute the new gain to apply.
- last_gain_ = gain_selector_.GetNewGain(long_term_peak_level, noise_energy,
- saturating_gain, signal_type);
+ last_gain_ =
+ gain_selector_.GetNewGain(long_term_peak_level, noise_energy,
+ saturating_gain, gain_jumpstart_, signal_type);
+
+ // Unflag the jumpstart of the gain as it should only happen once.
+ gain_jumpstart_ = false;
// Apply the gain to the signal.
int num_saturations = gain_applier_.Process(last_gain_, audio);
@@ -262,17 +266,35 @@ void LevelController::Process(AudioBuffer* audio) {
audio->channels_f()[0], *sample_rate_hz_, 1);
}
+void LevelController::ApplyConfig(
+ const AudioProcessing::Config::LevelController& config) {
+ if (config.initial_level) {
+ peak_level_estimator_.SetInitialPeakLevel(*config.initial_level);
+ gain_jumpstart_ = true;
+ }
+}
+
std::string LevelController::ToString(
const AudioProcessing::Config::LevelController& config) {
std::stringstream ss;
ss << "{"
- << "enabled: " << (config.enabled ? "true" : "false") << "}";
+ << "enabled: " << (config.enabled ? "true" : "false") << ","
+ << "initial level: : ";
+ if (config.initial_level) {
+ ss << *config.initial_level;
+ } else {
+ ss << "Not specified";
+ }
+ ss << "}";
return ss.str();
}
bool LevelController::Validate(
const AudioProcessing::Config::LevelController& config) {
- return true;
+ return !config.initial_level ||
+ (*config.initial_level < std::numeric_limits<float>::epsilon() &&
the sun 2016/09/16 08:00:40 In the future, consider making a utility for this
peah-webrtc 2016/09/16 11:36:05 Acknowledged.
+ *config.initial_level >
+ -(100.f + std::numeric_limits<float>::epsilon()));
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698