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

Side by Side 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: Merge from upstream CL Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_processing/level_controller/peak_level_estimator. h" 11 #include "webrtc/modules/audio_processing/level_controller/peak_level_estimator. h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "webrtc/modules/audio_processing/audio_buffer.h" 15 #include "webrtc/modules/audio_processing/audio_buffer.h"
16 #include "webrtc/modules/audio_processing/level_controller/lc_constants.h"
17 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" 16 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
18 17
19 namespace webrtc { 18 namespace webrtc {
20 19
21 PeakLevelEstimator::PeakLevelEstimator() { 20 PeakLevelEstimator::PeakLevelEstimator() {
22 Initialize(); 21 Initialize();
23 } 22 }
24 23
25 PeakLevelEstimator::~PeakLevelEstimator() {} 24 PeakLevelEstimator::~PeakLevelEstimator() {}
26 25
27 void PeakLevelEstimator::Initialize() { 26 void PeakLevelEstimator::Initialize() {
28 peak_level_ = kTargetLcPeakLevel; 27 peak_level_ = initial_peak_level_;
29 hold_counter_ = 0; 28 hold_counter_ = 0;
30 initialization_phase_ = true; 29 initialization_phase_ = true;
31 } 30 }
32 31
32 void PeakLevelEstimator::SetInitialLevel(float level) {
hlundin-webrtc 2016/08/18 12:58:13 The method should be called SetInitialPeakLevel, r
peah-webrtc 2016/08/18 17:02:58 Good find! Done.
33 initial_peak_level_ = level;
34 Initialize();
35 }
36
33 float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type, 37 float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type,
34 float frame_peak_level) { 38 float frame_peak_level) {
35 if (frame_peak_level == 0) { 39 if (frame_peak_level == 0) {
36 RTC_DCHECK_LE(30.f, peak_level_); 40 RTC_DCHECK_LE(30.f, peak_level_);
37 return peak_level_; 41 return peak_level_;
38 } 42 }
39 43
40 if (peak_level_ < frame_peak_level) { 44 if (peak_level_ < frame_peak_level) {
41 // Smoothly update the estimate upwards when the frame peak level is 45 // Smoothly update the estimate upwards when the frame peak level is
42 // higher than the estimate. 46 // higher than the estimate.
(...skipping 13 matching lines...) Expand all
56 peak_level_ * 0.995f); 60 peak_level_ * 0.995f);
57 } 61 }
58 } 62 }
59 63
60 peak_level_ = std::max(peak_level_, 30.f); 64 peak_level_ = std::max(peak_level_, 30.f);
61 65
62 return peak_level_; 66 return peak_level_;
63 } 67 }
64 68
65 } // namespace webrtc 69 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698