blob: f887268b0ecd8bf3badb5f8a92b7eb6b456dc779 [file] [log] [blame]
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
#include <stddef.h>
#include "modules/audio_processing/agc2/agc2_common.h" // kFullBufferSizeMs...
#include "modules/audio_processing/agc2/saturation_protector.h"
#include "modules/audio_processing/agc2/vad_with_level.h"
namespace webrtc {
class ApmDataDumper;
class AdaptiveModeLevelEstimator {
explicit AdaptiveModeLevelEstimator(ApmDataDumper* apm_data_dumper);
AdaptiveModeLevelEstimator(ApmDataDumper* apm_data_dumper,
float extra_saturation_margin_db);
void UpdateEstimation(const VadWithLevel::LevelAndProbability& vad_data);
float LatestLevelEstimate() const;
void Reset();
bool LevelEstimationIsConfident() const {
return buffer_size_ms_ >= kFullBufferSizeMs;
void DebugDumpEstimate();
size_t buffer_size_ms_ = 0;
float last_estimate_with_offset_dbfs_ = kInitialSpeechLevelEstimateDbfs;
float estimate_numerator_ = 0.f;
float estimate_denominator_ = 0.f;
SaturationProtector saturation_protector_;
ApmDataDumper* const apm_data_dumper_;
} // namespace webrtc