NetEQ: GenerateBackgroundNoise moved to BackgrounNoise

Bug: webrtc:10548
Change-Id: Ie9da0755793078b81c60c3751abcbff13da40ede
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132788
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27619}
This commit is contained in:
Alessio Bazzica
2019-04-15 12:32:23 +02:00
committed by Commit Bot
parent 9a2ca0a9d8
commit 7e53be0555
4 changed files with 74 additions and 67 deletions

View File

@ -14,6 +14,7 @@
#include <string.h> // size_t
#include <memory>
#include "api/array_view.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -27,7 +28,7 @@ class BackgroundNoise {
public:
// TODO(hlundin): For 48 kHz support, increase kMaxLpcOrder to 10.
// Will work anyway, but probably sound a little worse.
static const size_t kMaxLpcOrder = 8; // 32000 / 8000 + 4.
static constexpr size_t kMaxLpcOrder = 8; // 32000 / 8000 + 4.
explicit BackgroundNoise(size_t num_channels);
virtual ~BackgroundNoise();
@ -38,6 +39,15 @@ class BackgroundNoise {
// |sync_buffer|, and on the latest decision in |vad| if it is running.
void Update(const AudioMultiVector& sync_buffer, const PostDecodeVad& vad);
// Generates background noise given a random vector and writes the output to
// |buffer|.
void GenerateBackgroundNoise(rtc::ArrayView<const int16_t> random_vector,
size_t channel,
int mute_slope,
bool too_many_expands,
size_t num_noise_samples,
int16_t* buffer);
// Returns |energy_| for |channel|.
int32_t Energy(size_t channel) const;
@ -53,9 +63,9 @@ class BackgroundNoise {
// Returns a pointer to |filter_state_| for |channel|.
const int16_t* FilterState(size_t channel) const;
// Copies |length| elements from |input| to the filter state. Will not copy
// more than |kMaxLpcOrder| elements.
void SetFilterState(size_t channel, const int16_t* input, size_t length);
// Copies |input| to the filter state. Will not copy more than |kMaxLpcOrder|
// elements.
void SetFilterState(size_t channel, rtc::ArrayView<const int16_t> input);
// Returns |scale_| for |channel|.
int16_t Scale(size_t channel) const;