Remove all AudioBuffer code that is not related to storing audio data
This CL moves/removes all code from the AudioBuffer that:
-Is not directly handling audio data (e.g., keytaps, VAD descisions).
-Is caching aggregated versions of the rest of the audio data.
-Is not used (or only used in testing)
Bug: webrtc:10882
Change-Id: I737deb3f692748eff30f46ad806b2c6f6292802c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149072
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28866}
diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc
index 2ca522c..5855943 100644
--- a/modules/audio_processing/gain_control_impl.cc
+++ b/modules/audio_processing/gain_control_impl.cc
@@ -120,10 +120,28 @@
std::vector<int16_t>* packed_buffer) {
RTC_DCHECK_GE(160, audio->num_frames_per_band());
+ std::array<int16_t, 160> mixed_low_pass_data;
+ rtc::ArrayView<const int16_t> mixed_low_pass;
+ if (audio->num_proc_channels() == 1) {
+ mixed_low_pass =
+ rtc::ArrayView<const int16_t>(audio->split_bands_const(0)[kBand0To8kHz],
+ audio->num_frames_per_band());
+ } else {
+ const int num_channels = static_cast<int>(audio->num_channels());
+ for (size_t i = 0; i < audio->num_frames_per_band(); ++i) {
+ int32_t value = audio->split_channels_const(kBand0To8kHz)[0][i];
+ for (int j = 1; j < num_channels; ++j) {
+ value += audio->split_channels_const(kBand0To8kHz)[j][i];
+ }
+ mixed_low_pass_data[i] = value / num_channels;
+ }
+ mixed_low_pass = rtc::ArrayView<const int16_t>(
+ mixed_low_pass_data.data(), audio->num_frames_per_band());
+ }
+
packed_buffer->clear();
- packed_buffer->insert(
- packed_buffer->end(), audio->mixed_low_pass_data(),
- (audio->mixed_low_pass_data() + audio->num_frames_per_band()));
+ packed_buffer->insert(packed_buffer->end(), mixed_low_pass.data(),
+ (mixed_low_pass.data() + audio->num_frames_per_band()));
}
int GainControlImpl::AnalyzeCaptureAudio(AudioBuffer* audio) {