Bump to WebRTC M131 release
Ongoing fixes and improvements, transient suppressor is gone. Also, dropping isac because it doesn't seem to be useful, and is just build system deadweight now. Upstream references: Version: 131.0.6778.200 WebRTC: 79aff54b0fa9238ce3518dd9eaf9610cd6f22e82 Chromium: 2a19506ad24af755f2a215a4c61f775393e0db42
This commit is contained in:
@ -46,6 +46,7 @@ rtc_library("common_audio") {
|
||||
":common_audio_c",
|
||||
":sinc_resampler",
|
||||
"../api:array_view",
|
||||
"../api/audio:audio_frame_api",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:gtest_prod",
|
||||
"../rtc_base:logging",
|
||||
@ -58,7 +59,6 @@ rtc_library("common_audio") {
|
||||
"../system_wrappers",
|
||||
"third_party/ooura:fft_size_256",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
|
||||
defines = []
|
||||
|
||||
|
@ -23,6 +23,44 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO: b/335805780 - Remove this method. Instead, use Deinterleave() from
|
||||
// audio_util.h which requires size checked buffer views.
|
||||
template <typename T>
|
||||
void Deinterleave(const T* interleaved,
|
||||
size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
T* const* deinterleaved) {
|
||||
for (size_t i = 0; i < num_channels; ++i) {
|
||||
T* channel = deinterleaved[i];
|
||||
size_t interleaved_idx = i;
|
||||
for (size_t j = 0; j < samples_per_channel; ++j) {
|
||||
channel[j] = interleaved[interleaved_idx];
|
||||
interleaved_idx += num_channels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// `Interleave()` variant for cases where the deinterleaved channels aren't
|
||||
// represented by a `DeinterleavedView`.
|
||||
// TODO: b/335805780 - Remove this method. Instead, use Deinterleave() from
|
||||
// audio_util.h which requires size checked buffer views.
|
||||
template <typename T>
|
||||
void Interleave(const T* const* deinterleaved,
|
||||
size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
InterleavedView<T>& interleaved) {
|
||||
RTC_DCHECK_EQ(NumChannels(interleaved), num_channels);
|
||||
RTC_DCHECK_EQ(SamplesPerChannel(interleaved), samples_per_channel);
|
||||
for (size_t i = 0; i < num_channels; ++i) {
|
||||
const T* channel = deinterleaved[i];
|
||||
size_t interleaved_idx = i;
|
||||
for (size_t j = 0; j < samples_per_channel; ++j) {
|
||||
interleaved[interleaved_idx] = channel[j];
|
||||
interleaved_idx += num_channels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to encapsulate a contiguous data buffer, full or split into frequency
|
||||
// bands, with access to a pointer arrays of the deinterleaved channels and
|
||||
// bands. The buffer is zero initialized at creation.
|
||||
|
@ -18,12 +18,24 @@
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
#include "api/audio/audio_view.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
typedef std::numeric_limits<int16_t> limits_int16;
|
||||
|
||||
// TODO(tommi, peah): Move these constants to their own header, e.g.
|
||||
// `audio_constants.h`. Also consider if they should be in api/.
|
||||
|
||||
// Absolute highest acceptable sample rate supported for audio processing,
|
||||
// capture and codecs. Note that for some components some cases a lower limit
|
||||
// applies which typically is 48000 but in some cases is lower.
|
||||
constexpr int kMaxSampleRateHz = 384000;
|
||||
|
||||
// Number of samples per channel for 10ms of audio at the highest sample rate.
|
||||
constexpr size_t kMaxSamplesPerChannel10ms = kMaxSampleRateHz / 100u;
|
||||
|
||||
// The conversion functions use the following naming convention:
|
||||
// S16: int16_t [-32768, 32767]
|
||||
// Float: float [-1.0, 1.0]
|
||||
@ -94,6 +106,7 @@ inline float FloatS16ToDbfs(float v) {
|
||||
// Copy audio from `src` channels to `dest` channels unless `src` and `dest`
|
||||
// point to the same address. `src` and `dest` must have the same number of
|
||||
// channels, and there must be sufficient space allocated in `dest`.
|
||||
// TODO: b/335805780 - Accept ArrayView.
|
||||
template <typename T>
|
||||
void CopyAudioIfNeeded(const T* const* src,
|
||||
int num_frames,
|
||||
@ -111,12 +124,15 @@ void CopyAudioIfNeeded(const T* const* src,
|
||||
// `deinterleaved` buffers (`num_channel` buffers with `samples_per_channel`
|
||||
// per buffer).
|
||||
template <typename T>
|
||||
void Deinterleave(const T* interleaved,
|
||||
size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
T* const* deinterleaved) {
|
||||
void Deinterleave(const InterleavedView<const T>& interleaved,
|
||||
const DeinterleavedView<T>& deinterleaved) {
|
||||
RTC_DCHECK_EQ(NumChannels(interleaved), NumChannels(deinterleaved));
|
||||
RTC_DCHECK_EQ(SamplesPerChannel(interleaved),
|
||||
SamplesPerChannel(deinterleaved));
|
||||
const auto num_channels = NumChannels(interleaved);
|
||||
const auto samples_per_channel = SamplesPerChannel(interleaved);
|
||||
for (size_t i = 0; i < num_channels; ++i) {
|
||||
T* channel = deinterleaved[i];
|
||||
MonoView<T> channel = deinterleaved[i];
|
||||
size_t interleaved_idx = i;
|
||||
for (size_t j = 0; j < samples_per_channel; ++j) {
|
||||
channel[j] = interleaved[interleaved_idx];
|
||||
@ -129,52 +145,24 @@ void Deinterleave(const T* interleaved,
|
||||
// `interleaved`. There must be sufficient space allocated in `interleaved`
|
||||
// (`samples_per_channel` * `num_channels`).
|
||||
template <typename T>
|
||||
void Interleave(const T* const* deinterleaved,
|
||||
size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
T* interleaved) {
|
||||
for (size_t i = 0; i < num_channels; ++i) {
|
||||
const T* channel = deinterleaved[i];
|
||||
void Interleave(const DeinterleavedView<const T>& deinterleaved,
|
||||
const InterleavedView<T>& interleaved) {
|
||||
RTC_DCHECK_EQ(NumChannels(interleaved), NumChannels(deinterleaved));
|
||||
RTC_DCHECK_EQ(SamplesPerChannel(interleaved),
|
||||
SamplesPerChannel(deinterleaved));
|
||||
for (size_t i = 0; i < deinterleaved.num_channels(); ++i) {
|
||||
const auto channel = deinterleaved[i];
|
||||
size_t interleaved_idx = i;
|
||||
for (size_t j = 0; j < samples_per_channel; ++j) {
|
||||
for (size_t j = 0; j < deinterleaved.samples_per_channel(); ++j) {
|
||||
interleaved[interleaved_idx] = channel[j];
|
||||
interleaved_idx += num_channels;
|
||||
interleaved_idx += deinterleaved.num_channels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copies audio from a single channel buffer pointed to by `mono` to each
|
||||
// channel of `interleaved`. There must be sufficient space allocated in
|
||||
// `interleaved` (`samples_per_channel` * `num_channels`).
|
||||
template <typename T>
|
||||
void UpmixMonoToInterleaved(const T* mono,
|
||||
int num_frames,
|
||||
int num_channels,
|
||||
T* interleaved) {
|
||||
int interleaved_idx = 0;
|
||||
for (int i = 0; i < num_frames; ++i) {
|
||||
for (int j = 0; j < num_channels; ++j) {
|
||||
interleaved[interleaved_idx++] = mono[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename Intermediate>
|
||||
void DownmixToMono(const T* const* input_channels,
|
||||
size_t num_frames,
|
||||
int num_channels,
|
||||
T* out) {
|
||||
for (size_t i = 0; i < num_frames; ++i) {
|
||||
Intermediate value = input_channels[0][i];
|
||||
for (int j = 1; j < num_channels; ++j) {
|
||||
value += input_channels[j][i];
|
||||
}
|
||||
out[i] = value / num_channels;
|
||||
}
|
||||
}
|
||||
|
||||
// Downmixes an interleaved multichannel signal to a single channel by averaging
|
||||
// all channels.
|
||||
// TODO: b/335805780 - Accept InterleavedView and DeinterleavedView.
|
||||
template <typename T, typename Intermediate>
|
||||
void DownmixInterleavedToMonoImpl(const T* interleaved,
|
||||
size_t num_frames,
|
||||
@ -197,12 +185,14 @@ void DownmixInterleavedToMonoImpl(const T* interleaved,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: b/335805780 - Accept InterleavedView and DeinterleavedView.
|
||||
template <typename T>
|
||||
void DownmixInterleavedToMono(const T* interleaved,
|
||||
size_t num_frames,
|
||||
int num_channels,
|
||||
T* deinterleaved);
|
||||
|
||||
// TODO: b/335805780 - Accept InterleavedView and DeinterleavedView.
|
||||
template <>
|
||||
void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved,
|
||||
size_t num_frames,
|
||||
|
@ -14,45 +14,44 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "api/audio/audio_view.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class PushSincResampler;
|
||||
|
||||
// Wraps PushSincResampler to provide stereo support.
|
||||
// TODO(ajm): add support for an arbitrary number of channels.
|
||||
// Note: This implementation assumes 10ms buffer sizes throughout.
|
||||
template <typename T>
|
||||
class PushResampler {
|
||||
class PushResampler final {
|
||||
public:
|
||||
PushResampler();
|
||||
virtual ~PushResampler();
|
||||
|
||||
// Must be called whenever the parameters change. Free to be called at any
|
||||
// time as it is a no-op if parameters have not changed since the last call.
|
||||
int InitializeIfNeeded(int src_sample_rate_hz,
|
||||
int dst_sample_rate_hz,
|
||||
size_t num_channels);
|
||||
PushResampler(size_t src_samples_per_channel,
|
||||
size_t dst_samples_per_channel,
|
||||
size_t num_channels);
|
||||
~PushResampler();
|
||||
|
||||
// Returns the total number of samples provided in destination (e.g. 32 kHz,
|
||||
// 2 channel audio gives 640 samples).
|
||||
int Resample(const T* src, size_t src_length, T* dst, size_t dst_capacity);
|
||||
int Resample(InterleavedView<const T> src, InterleavedView<T> dst);
|
||||
// For when a deinterleaved/mono channel already exists and we can skip the
|
||||
// deinterleaved operation.
|
||||
int Resample(MonoView<const T> src, MonoView<T> dst);
|
||||
|
||||
private:
|
||||
int src_sample_rate_hz_;
|
||||
int dst_sample_rate_hz_;
|
||||
size_t num_channels_;
|
||||
// Vector that is needed to provide the proper inputs and outputs to the
|
||||
// interleave/de-interleave methods used in Resample. This needs to be
|
||||
// heap-allocated on the state to support an arbitrary number of channels
|
||||
// without doing run-time heap-allocations in the Resample method.
|
||||
std::vector<T*> channel_data_array_;
|
||||
// Ensures that source and destination buffers for deinterleaving are
|
||||
// correctly configured prior to resampling that requires deinterleaving.
|
||||
void EnsureInitialized(size_t src_samples_per_channel,
|
||||
size_t dst_samples_per_channel,
|
||||
size_t num_channels);
|
||||
|
||||
struct ChannelResampler {
|
||||
std::unique_ptr<PushSincResampler> resampler;
|
||||
std::vector<T> source;
|
||||
std::vector<T> destination;
|
||||
};
|
||||
// Buffers used for when a deinterleaving step is necessary.
|
||||
std::unique_ptr<T[]> source_;
|
||||
std::unique_ptr<T[]> destination_;
|
||||
DeinterleavedView<T> source_view_;
|
||||
DeinterleavedView<T> destination_view_;
|
||||
|
||||
std::vector<ChannelResampler> channel_resamplers_;
|
||||
std::vector<std::unique_ptr<PushSincResampler>> resamplers_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
|
@ -15,105 +15,109 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "common_audio/include/audio_util.h"
|
||||
#include "common_audio/resampler/push_sinc_resampler.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
template <typename T>
|
||||
PushResampler<T>::PushResampler()
|
||||
: src_sample_rate_hz_(0), dst_sample_rate_hz_(0), num_channels_(0) {}
|
||||
namespace {
|
||||
// Maximum concurrent number of channels for `PushResampler<>`.
|
||||
// Note that this may be different from what the maximum is for audio codecs.
|
||||
constexpr int kMaxNumberOfChannels = 8;
|
||||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
PushResampler<T>::~PushResampler() {}
|
||||
PushResampler<T>::PushResampler() = default;
|
||||
|
||||
template <typename T>
|
||||
int PushResampler<T>::InitializeIfNeeded(int src_sample_rate_hz,
|
||||
int dst_sample_rate_hz,
|
||||
size_t num_channels) {
|
||||
// These checks used to be factored out of this template function due to
|
||||
// Windows debug build issues with clang. http://crbug.com/615050
|
||||
RTC_DCHECK_GT(src_sample_rate_hz, 0);
|
||||
RTC_DCHECK_GT(dst_sample_rate_hz, 0);
|
||||
RTC_DCHECK_GT(num_channels, 0);
|
||||
|
||||
if (src_sample_rate_hz == src_sample_rate_hz_ &&
|
||||
dst_sample_rate_hz == dst_sample_rate_hz_ &&
|
||||
num_channels == num_channels_) {
|
||||
// No-op if settings haven't changed.
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (src_sample_rate_hz <= 0 || dst_sample_rate_hz <= 0 || num_channels <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
src_sample_rate_hz_ = src_sample_rate_hz;
|
||||
dst_sample_rate_hz_ = dst_sample_rate_hz;
|
||||
num_channels_ = num_channels;
|
||||
|
||||
const size_t src_size_10ms_mono =
|
||||
static_cast<size_t>(src_sample_rate_hz / 100);
|
||||
const size_t dst_size_10ms_mono =
|
||||
static_cast<size_t>(dst_sample_rate_hz / 100);
|
||||
channel_resamplers_.clear();
|
||||
for (size_t i = 0; i < num_channels; ++i) {
|
||||
channel_resamplers_.push_back(ChannelResampler());
|
||||
auto channel_resampler = channel_resamplers_.rbegin();
|
||||
channel_resampler->resampler = std::make_unique<PushSincResampler>(
|
||||
src_size_10ms_mono, dst_size_10ms_mono);
|
||||
channel_resampler->source.resize(src_size_10ms_mono);
|
||||
channel_resampler->destination.resize(dst_size_10ms_mono);
|
||||
}
|
||||
|
||||
channel_data_array_.resize(num_channels_);
|
||||
|
||||
return 0;
|
||||
PushResampler<T>::PushResampler(size_t src_samples_per_channel,
|
||||
size_t dst_samples_per_channel,
|
||||
size_t num_channels) {
|
||||
EnsureInitialized(src_samples_per_channel, dst_samples_per_channel,
|
||||
num_channels);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int PushResampler<T>::Resample(const T* src,
|
||||
size_t src_length,
|
||||
T* dst,
|
||||
size_t dst_capacity) {
|
||||
// These checks used to be factored out of this template function due to
|
||||
// Windows debug build issues with clang. http://crbug.com/615050
|
||||
const size_t src_size_10ms = (src_sample_rate_hz_ / 100) * num_channels_;
|
||||
const size_t dst_size_10ms = (dst_sample_rate_hz_ / 100) * num_channels_;
|
||||
RTC_DCHECK_EQ(src_length, src_size_10ms);
|
||||
RTC_DCHECK_GE(dst_capacity, dst_size_10ms);
|
||||
PushResampler<T>::~PushResampler() = default;
|
||||
|
||||
if (src_sample_rate_hz_ == dst_sample_rate_hz_) {
|
||||
template <typename T>
|
||||
void PushResampler<T>::EnsureInitialized(size_t src_samples_per_channel,
|
||||
size_t dst_samples_per_channel,
|
||||
size_t num_channels) {
|
||||
RTC_DCHECK_GT(src_samples_per_channel, 0);
|
||||
RTC_DCHECK_GT(dst_samples_per_channel, 0);
|
||||
RTC_DCHECK_GT(num_channels, 0);
|
||||
RTC_DCHECK_LE(src_samples_per_channel, kMaxSamplesPerChannel10ms);
|
||||
RTC_DCHECK_LE(dst_samples_per_channel, kMaxSamplesPerChannel10ms);
|
||||
RTC_DCHECK_LE(num_channels, kMaxNumberOfChannels);
|
||||
|
||||
if (src_samples_per_channel == SamplesPerChannel(source_view_) &&
|
||||
dst_samples_per_channel == SamplesPerChannel(destination_view_) &&
|
||||
num_channels == NumChannels(source_view_)) {
|
||||
// No-op if settings haven't changed.
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate two buffers for all source and destination channels.
|
||||
// Then organize source and destination views together with an array of
|
||||
// resamplers for each channel in the deinterlaved buffers.
|
||||
source_.reset(new T[src_samples_per_channel * num_channels]);
|
||||
destination_.reset(new T[dst_samples_per_channel * num_channels]);
|
||||
source_view_ = DeinterleavedView<T>(source_.get(), src_samples_per_channel,
|
||||
num_channels);
|
||||
destination_view_ = DeinterleavedView<T>(
|
||||
destination_.get(), dst_samples_per_channel, num_channels);
|
||||
resamplers_.resize(num_channels);
|
||||
for (size_t i = 0; i < num_channels; ++i) {
|
||||
resamplers_[i] = std::make_unique<PushSincResampler>(
|
||||
src_samples_per_channel, dst_samples_per_channel);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int PushResampler<T>::Resample(InterleavedView<const T> src,
|
||||
InterleavedView<T> dst) {
|
||||
EnsureInitialized(SamplesPerChannel(src), SamplesPerChannel(dst),
|
||||
NumChannels(src));
|
||||
|
||||
RTC_DCHECK_EQ(NumChannels(src), NumChannels(source_view_));
|
||||
RTC_DCHECK_EQ(NumChannels(dst), NumChannels(destination_view_));
|
||||
RTC_DCHECK_EQ(SamplesPerChannel(src), SamplesPerChannel(source_view_));
|
||||
RTC_DCHECK_EQ(SamplesPerChannel(dst), SamplesPerChannel(destination_view_));
|
||||
|
||||
if (SamplesPerChannel(src) == SamplesPerChannel(dst)) {
|
||||
// The old resampler provides this memcpy facility in the case of matching
|
||||
// sample rates, so reproduce it here for the sinc resampler.
|
||||
memcpy(dst, src, src_length * sizeof(T));
|
||||
return static_cast<int>(src_length);
|
||||
CopySamples(dst, src);
|
||||
return static_cast<int>(src.data().size());
|
||||
}
|
||||
|
||||
const size_t src_length_mono = src_length / num_channels_;
|
||||
const size_t dst_capacity_mono = dst_capacity / num_channels_;
|
||||
Deinterleave(src, source_view_);
|
||||
|
||||
for (size_t ch = 0; ch < num_channels_; ++ch) {
|
||||
channel_data_array_[ch] = channel_resamplers_[ch].source.data();
|
||||
for (size_t i = 0; i < resamplers_.size(); ++i) {
|
||||
size_t dst_length_mono =
|
||||
resamplers_[i]->Resample(source_view_[i], destination_view_[i]);
|
||||
RTC_DCHECK_EQ(dst_length_mono, SamplesPerChannel(dst));
|
||||
}
|
||||
|
||||
Deinterleave(src, src_length_mono, num_channels_, channel_data_array_.data());
|
||||
Interleave<T>(destination_view_, dst);
|
||||
return static_cast<int>(dst.size());
|
||||
}
|
||||
|
||||
size_t dst_length_mono = 0;
|
||||
template <typename T>
|
||||
int PushResampler<T>::Resample(MonoView<const T> src, MonoView<T> dst) {
|
||||
RTC_DCHECK_EQ(resamplers_.size(), 1);
|
||||
RTC_DCHECK_EQ(SamplesPerChannel(src), SamplesPerChannel(source_view_));
|
||||
RTC_DCHECK_EQ(SamplesPerChannel(dst), SamplesPerChannel(destination_view_));
|
||||
|
||||
for (auto& resampler : channel_resamplers_) {
|
||||
dst_length_mono = resampler.resampler->Resample(
|
||||
resampler.source.data(), src_length_mono, resampler.destination.data(),
|
||||
dst_capacity_mono);
|
||||
if (SamplesPerChannel(src) == SamplesPerChannel(dst)) {
|
||||
CopySamples(dst, src);
|
||||
return static_cast<int>(src.size());
|
||||
}
|
||||
|
||||
for (size_t ch = 0; ch < num_channels_; ++ch) {
|
||||
channel_data_array_[ch] = channel_resamplers_[ch].destination.data();
|
||||
}
|
||||
|
||||
Interleave(channel_data_array_.data(), dst_length_mono, num_channels_, dst);
|
||||
return static_cast<int>(dst_length_mono * num_channels_);
|
||||
return resamplers_[0]->Resample(src, dst);
|
||||
}
|
||||
|
||||
// Explictly generate required instantiations.
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/audio/audio_view.h"
|
||||
#include "common_audio/resampler/sinc_resampler.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -40,6 +41,12 @@ class PushSincResampler : public SincResamplerCallback {
|
||||
// at least as large as `destination_frames`. Returns the number of samples
|
||||
// provided in destination (for convenience, since this will always be equal
|
||||
// to `destination_frames`).
|
||||
template <typename S, typename D>
|
||||
size_t Resample(const MonoView<S>& source, const MonoView<D>& destination) {
|
||||
return Resample(&source[0], SamplesPerChannel(source), &destination[0],
|
||||
SamplesPerChannel(destination));
|
||||
}
|
||||
|
||||
size_t Resample(const int16_t* source,
|
||||
size_t source_frames,
|
||||
int16_t* destination,
|
||||
|
@ -26,10 +26,8 @@ size_t WebRtcSpl_FilterAR(const int16_t* a,
|
||||
int16_t* state,
|
||||
size_t state_length,
|
||||
int16_t* state_low,
|
||||
size_t state_low_length,
|
||||
int16_t* filtered,
|
||||
int16_t* filtered_low,
|
||||
size_t filtered_low_length)
|
||||
int16_t* filtered_low)
|
||||
{
|
||||
int64_t o;
|
||||
int32_t oLOW;
|
||||
|
@ -621,10 +621,8 @@ size_t WebRtcSpl_FilterAR(const int16_t* ar_coef,
|
||||
int16_t* filter_state,
|
||||
size_t filter_state_length,
|
||||
int16_t* filter_state_low,
|
||||
size_t filter_state_low_length,
|
||||
int16_t* out_vector,
|
||||
int16_t* out_vector_low,
|
||||
size_t out_vector_low_length);
|
||||
int16_t* out_vector_low);
|
||||
|
||||
// WebRtcSpl_FilterMAFastQ12(...)
|
||||
//
|
||||
@ -1464,9 +1462,6 @@ void WebRtcSpl_SynthesisQMF(const int16_t* low_band,
|
||||
// - filter_state : Current state (higher part) of the filter.
|
||||
// - filter_state_length : Length (in samples) of `filter_state`.
|
||||
// - filter_state_low : Current state (lower part) of the filter.
|
||||
// - filter_state_low_length : Length (in samples) of `filter_state_low`.
|
||||
// - out_vector_low_length : Maximum length (in samples) of
|
||||
// `out_vector_low`.
|
||||
//
|
||||
// Output:
|
||||
// - filter_state : Updated state (upper part) vector.
|
||||
|
@ -55,10 +55,10 @@ void SmoothingFilterImpl::AddSample(float sample) {
|
||||
last_sample_ = sample;
|
||||
}
|
||||
|
||||
absl::optional<float> SmoothingFilterImpl::GetAverage() {
|
||||
std::optional<float> SmoothingFilterImpl::GetAverage() {
|
||||
if (!init_end_time_ms_) {
|
||||
// `init_end_time_ms_` undefined since we have not received any sample.
|
||||
return absl::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
ExtrapolateLastSample(rtc::TimeMillis());
|
||||
return state_;
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include <optional>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -21,7 +21,7 @@ class SmoothingFilter {
|
||||
public:
|
||||
virtual ~SmoothingFilter() = default;
|
||||
virtual void AddSample(float sample) = 0;
|
||||
virtual absl::optional<float> GetAverage() = 0;
|
||||
virtual std::optional<float> GetAverage() = 0;
|
||||
virtual bool SetTimeConstantMs(int time_constant_ms) = 0;
|
||||
};
|
||||
|
||||
@ -49,7 +49,7 @@ class SmoothingFilterImpl final : public SmoothingFilter {
|
||||
~SmoothingFilterImpl() override;
|
||||
|
||||
void AddSample(float sample) override;
|
||||
absl::optional<float> GetAverage() override;
|
||||
std::optional<float> GetAverage() override;
|
||||
bool SetTimeConstantMs(int time_constant_ms) override;
|
||||
|
||||
// Methods used for unittests.
|
||||
@ -63,7 +63,7 @@ class SmoothingFilterImpl final : public SmoothingFilter {
|
||||
const float init_factor_;
|
||||
const float init_const_;
|
||||
|
||||
absl::optional<int64_t> init_end_time_ms_;
|
||||
std::optional<int64_t> init_end_time_ms_;
|
||||
float last_sample_;
|
||||
float alpha_;
|
||||
float state_;
|
||||
|
Reference in New Issue
Block a user