2017-02-23 05:16:26 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUPPRESSION_GAIN_H_
|
|
|
|
|
#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUPPRESSION_GAIN_H_
|
|
|
|
|
|
|
|
|
|
#include <array>
|
2017-04-06 15:45:32 -07:00
|
|
|
#include <vector>
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
|
2017-07-11 06:13:43 -07:00
|
|
|
#include "webrtc/modules/audio_processing/aec3/render_signal_analyzer.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/constructormagic.h"
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class SuppressionGain {
|
|
|
|
|
public:
|
|
|
|
|
explicit SuppressionGain(Aec3Optimization optimization);
|
2017-05-23 04:07:10 -07:00
|
|
|
void GetGain(const std::array<float, kFftLengthBy2Plus1>& nearend,
|
|
|
|
|
const std::array<float, kFftLengthBy2Plus1>& echo,
|
|
|
|
|
const std::array<float, kFftLengthBy2Plus1>& comfort_noise,
|
2017-07-11 06:13:43 -07:00
|
|
|
const RenderSignalAnalyzer& render_signal_analyzer,
|
2017-04-06 15:45:32 -07:00
|
|
|
bool saturated_echo,
|
|
|
|
|
const std::vector<std::vector<float>>& render,
|
2017-04-10 13:52:14 -07:00
|
|
|
bool force_zero_gain,
|
2017-04-06 15:45:32 -07:00
|
|
|
float* high_bands_gain,
|
|
|
|
|
std::array<float, kFftLengthBy2Plus1>* low_band_gain);
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
private:
|
2017-05-23 04:07:10 -07:00
|
|
|
void LowerBandGain(bool stationary_with_low_power,
|
2017-07-11 06:13:43 -07:00
|
|
|
const rtc::Optional<int>& narrow_peak_band,
|
2017-05-23 04:07:10 -07:00
|
|
|
bool saturated_echo,
|
|
|
|
|
const std::array<float, kFftLengthBy2Plus1>& nearend,
|
|
|
|
|
const std::array<float, kFftLengthBy2Plus1>& echo,
|
|
|
|
|
const std::array<float, kFftLengthBy2Plus1>& comfort_noise,
|
|
|
|
|
std::array<float, kFftLengthBy2Plus1>* gain);
|
|
|
|
|
|
|
|
|
|
class LowNoiseRenderDetector {
|
|
|
|
|
public:
|
|
|
|
|
bool Detect(const std::vector<std::vector<float>>& render);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
float average_power_ = 32768.f * 32768.f;
|
|
|
|
|
};
|
|
|
|
|
|
2017-02-23 05:16:26 -08:00
|
|
|
const Aec3Optimization optimization_;
|
2017-05-23 04:07:10 -07:00
|
|
|
std::array<float, kFftLengthBy2Plus1> last_gain_;
|
|
|
|
|
std::array<float, kFftLengthBy2Plus1> last_masker_;
|
|
|
|
|
std::array<float, kFftLengthBy2Plus1> gain_increase_;
|
|
|
|
|
std::array<float, kFftLengthBy2Plus1> last_echo_;
|
|
|
|
|
|
|
|
|
|
LowNoiseRenderDetector low_render_detector_;
|
|
|
|
|
size_t no_saturation_counter_ = 0;
|
2017-02-23 05:16:26 -08:00
|
|
|
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SuppressionGain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUPPRESSION_GAIN_H_
|