Update to current webrtc library
This is from the upstream library commit id 3326535126e435f1ba647885ce43a8f0f3d317eb, corresponding to Chromium 88.0.4290.1.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2020 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
|
||||
@ -8,30 +8,24 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#ifndef WEBRTC_AUDIO_PROCESSING_ONLY_BUILD
|
||||
#include "webrtc/test/testsupport/gtest_prod_util.h"
|
||||
#endif
|
||||
#include "webrtc/typedefs.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class TransientDetector;
|
||||
|
||||
// Detects transients in an audio stream and suppress them using a simple
|
||||
// restoration algorithm that attenuates unexpected spikes in the spectrum.
|
||||
class TransientSuppressor {
|
||||
public:
|
||||
TransientSuppressor();
|
||||
~TransientSuppressor();
|
||||
virtual ~TransientSuppressor() {}
|
||||
|
||||
int Initialize(int sample_rate_hz, int detector_rate_hz, int num_channels);
|
||||
virtual int Initialize(int sample_rate_hz,
|
||||
int detector_rate_hz,
|
||||
int num_channels) = 0;
|
||||
|
||||
// Processes a |data| chunk, and returns it with keystrokes suppressed from
|
||||
// it. The float format is assumed to be int16 ranged. If there are more than
|
||||
@ -50,75 +44,17 @@ class TransientSuppressor {
|
||||
// always be set to 1.
|
||||
// |key_pressed| determines if a key was pressed on this audio chunk.
|
||||
// Returns 0 on success and -1 otherwise.
|
||||
int Suppress(float* data,
|
||||
size_t data_length,
|
||||
int num_channels,
|
||||
const float* detection_data,
|
||||
size_t detection_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length,
|
||||
float voice_probability,
|
||||
bool key_pressed);
|
||||
|
||||
private:
|
||||
#ifndef WEBRTC_AUDIO_PROCESSING_ONLY_BUILD
|
||||
FRIEND_TEST_ALL_PREFIXES(TransientSuppressorTest,
|
||||
TypingDetectionLogicWorksAsExpectedForMono);
|
||||
#endif
|
||||
void Suppress(float* in_ptr, float* spectral_mean, float* out_ptr);
|
||||
|
||||
void UpdateKeypress(bool key_pressed);
|
||||
void UpdateRestoration(float voice_probability);
|
||||
|
||||
void UpdateBuffers(float* data);
|
||||
|
||||
void HardRestoration(float* spectral_mean);
|
||||
void SoftRestoration(float* spectral_mean);
|
||||
|
||||
rtc::scoped_ptr<TransientDetector> detector_;
|
||||
|
||||
size_t data_length_;
|
||||
size_t detection_length_;
|
||||
size_t analysis_length_;
|
||||
size_t buffer_delay_;
|
||||
size_t complex_analysis_length_;
|
||||
int num_channels_;
|
||||
// Input buffer where the original samples are stored.
|
||||
rtc::scoped_ptr<float[]> in_buffer_;
|
||||
rtc::scoped_ptr<float[]> detection_buffer_;
|
||||
// Output buffer where the restored samples are stored.
|
||||
rtc::scoped_ptr<float[]> out_buffer_;
|
||||
|
||||
// Arrays for fft.
|
||||
rtc::scoped_ptr<size_t[]> ip_;
|
||||
rtc::scoped_ptr<float[]> wfft_;
|
||||
|
||||
rtc::scoped_ptr<float[]> spectral_mean_;
|
||||
|
||||
// Stores the data for the fft.
|
||||
rtc::scoped_ptr<float[]> fft_buffer_;
|
||||
|
||||
rtc::scoped_ptr<float[]> magnitudes_;
|
||||
|
||||
const float* window_;
|
||||
|
||||
rtc::scoped_ptr<float[]> mean_factor_;
|
||||
|
||||
float detector_smoothed_;
|
||||
|
||||
int keypress_counter_;
|
||||
int chunks_since_keypress_;
|
||||
bool detection_enabled_;
|
||||
bool suppression_enabled_;
|
||||
|
||||
bool use_hard_restoration_;
|
||||
int chunks_since_voice_change_;
|
||||
|
||||
uint32_t seed_;
|
||||
|
||||
bool using_reference_;
|
||||
virtual int Suppress(float* data,
|
||||
size_t data_length,
|
||||
int num_channels,
|
||||
const float* detection_data,
|
||||
size_t detection_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length,
|
||||
float voice_probability,
|
||||
bool key_pressed) = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
|
Reference in New Issue
Block a user