aboutsummaryrefslogtreecommitdiff
path: root/common_audio
diff options
context:
space:
mode:
Diffstat (limited to 'common_audio')
-rw-r--r--common_audio/BUILD.gn1
-rw-r--r--common_audio/resampler/include/push_resampler.h5
-rw-r--r--common_audio/resampler/push_resampler.cc17
3 files changed, 13 insertions, 10 deletions
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index 7170000740..8b18fcbf92 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -58,7 +58,6 @@ rtc_library("common_audio") {
"../system_wrappers",
"../system_wrappers:cpu_features_api",
"third_party/fft4g",
- "//third_party/abseil-cpp/absl/container:inlined_vector",
"//third_party/abseil-cpp/absl/types:optional",
]
diff --git a/common_audio/resampler/include/push_resampler.h b/common_audio/resampler/include/push_resampler.h
index 232ad2a79f..3da67120f0 100644
--- a/common_audio/resampler/include/push_resampler.h
+++ b/common_audio/resampler/include/push_resampler.h
@@ -40,6 +40,11 @@ class PushResampler {
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_;
struct ChannelResampler {
std::unique_ptr<PushSincResampler> resampler;
diff --git a/common_audio/resampler/push_resampler.cc b/common_audio/resampler/push_resampler.cc
index 17b876b6b2..d7aa8d7613 100644
--- a/common_audio/resampler/push_resampler.cc
+++ b/common_audio/resampler/push_resampler.cc
@@ -15,7 +15,6 @@
#include <memory>
-#include "absl/container/inlined_vector.h"
#include "common_audio/include/audio_util.h"
#include "common_audio/resampler/push_sinc_resampler.h"
#include "rtc_base/checks.h"
@@ -100,6 +99,8 @@ int PushResampler<T>::InitializeIfNeeded(int src_sample_rate_hz,
channel_resampler->destination.resize(dst_size_10ms_mono);
}
+ channel_data_array_.resize(num_channels_);
+
return 0;
}
@@ -121,12 +122,11 @@ int PushResampler<T>::Resample(const T* src,
const size_t src_length_mono = src_length / num_channels_;
const size_t dst_capacity_mono = dst_capacity / num_channels_;
- absl::InlinedVector<T*, 8> source_pointers;
- for (auto& resampler : channel_resamplers_) {
- source_pointers.push_back(resampler.source.data());
+ for (size_t ch = 0; ch < num_channels_; ++ch) {
+ channel_data_array_[ch] = channel_resamplers_[ch].source.data();
}
- Deinterleave(src, src_length_mono, num_channels_, source_pointers.data());
+ Deinterleave(src, src_length_mono, num_channels_, channel_data_array_.data());
size_t dst_length_mono = 0;
@@ -136,12 +136,11 @@ int PushResampler<T>::Resample(const T* src,
dst_capacity_mono);
}
- absl::InlinedVector<T*, 8> destination_pointers;
- for (auto& resampler : channel_resamplers_) {
- destination_pointers.push_back(resampler.destination.data());
+ for (size_t ch = 0; ch < num_channels_; ++ch) {
+ channel_data_array_[ch] = channel_resamplers_[ch].destination.data();
}
- Interleave(destination_pointers.data(), dst_length_mono, num_channels_, dst);
+ Interleave(channel_data_array_.data(), dst_length_mono, num_channels_, dst);
return static_cast<int>(dst_length_mono * num_channels_);
}