LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/audio_processing/level_controller - saturating_gain_estimator.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 19 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
       3             :  *
       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
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #include "webrtc/modules/audio_processing/level_controller/saturating_gain_estimator.h"
      12             : 
      13             : #include <math.h>
      14             : #include <algorithm>
      15             : 
      16             : #include "webrtc/modules/audio_processing/level_controller/level_controller_constants.h"
      17             : #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
      18             : 
      19             : namespace webrtc {
      20             : 
      21           0 : SaturatingGainEstimator::SaturatingGainEstimator() {
      22           0 :   Initialize();
      23           0 : }
      24             : 
      25           0 : SaturatingGainEstimator::~SaturatingGainEstimator() {}
      26             : 
      27           0 : void SaturatingGainEstimator::Initialize() {
      28           0 :   saturating_gain_ = kMaxLcGain;
      29           0 :   saturating_gain_hold_counter_ = 0;
      30           0 : }
      31             : 
      32           0 : void SaturatingGainEstimator::Update(float gain, int num_saturations) {
      33           0 :   bool too_many_saturations = (num_saturations > 2);
      34             : 
      35           0 :   if (too_many_saturations) {
      36           0 :     saturating_gain_ = 0.95f * gain;
      37           0 :     saturating_gain_hold_counter_ = 1000;
      38             :   } else {
      39           0 :     saturating_gain_hold_counter_ =
      40           0 :         std::max(0, saturating_gain_hold_counter_ - 1);
      41           0 :     if (saturating_gain_hold_counter_ == 0) {
      42           0 :       saturating_gain_ *= 1.001f;
      43           0 :       saturating_gain_ = std::min(kMaxLcGain, saturating_gain_);
      44             :     }
      45             :   }
      46           0 : }
      47             : 
      48             : }  // namespace webrtc

Generated by: LCOV version 1.13