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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_AEC3_SUPPRESSION_GAIN_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_AEC3_SUPPRESSION_GAIN_H_
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
#include <array>
|
2017-04-06 15:45:32 -07:00
|
|
|
#include <vector>
|
2017-02-23 05:16:26 -08:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/aec3/aec3_common.h"
|
2017-10-25 02:59:45 +02:00
|
|
|
#include "modules/audio_processing/aec3/aec_state.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/aec3/render_signal_analyzer.h"
|
|
|
|
|
#include "modules/audio_processing/include/audio_processing.h"
|
|
|
|
|
#include "rtc_base/constructormagic.h"
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class SuppressionGain {
|
|
|
|
|
public:
|
2017-10-18 12:32:42 +02:00
|
|
|
SuppressionGain(const EchoCanceller3Config& config,
|
2017-08-24 22:36:53 -07:00
|
|
|
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-10-25 02:59:45 +02:00
|
|
|
const AecState& aec_state,
|
2017-04-06 15:45:32 -07:00
|
|
|
const std::vector<std::vector<float>>& render,
|
|
|
|
|
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,
|
2017-10-25 02:59:45 +02:00
|
|
|
bool saturating_echo_path,
|
2018-01-15 22:11:29 +01:00
|
|
|
bool initial_state,
|
2017-10-09 13:01:39 +02:00
|
|
|
bool linear_echo_estimate,
|
2017-05-23 04:07:10 -07:00
|
|
|
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-10-18 12:32:42 +02:00
|
|
|
const EchoCanceller3Config config_;
|
2017-08-24 22:36:53 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(SuppressionGain);
|
2017-02-23 05:16:26 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_PROCESSING_AEC3_SUPPRESSION_GAIN_H_
|