Replace ArrayView with std::span in modules/audio_processing/aec3 Search&Replace MakeArrayView and ArrayView with std::span Search&Replace include "api/array_view.h" with include <span> Remove <span> include where std::span is not mentioned in the file Remove build dependencies on array_view target No-Iwyu: suggested missing includes are questionable, and such question is out of scope of this change. Bug: webrtc:439801349 Change-Id: Iaa233c972c1420563862f43530ed354cddbcaf8c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/455800 Commit-Queue: Sam Zackrisson <saza@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Sam Zackrisson <saza@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47117}
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index 1f5a271..10b055f 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn
@@ -143,7 +143,6 @@ "..:apm_logging", "..:audio_buffer", "..:high_pass_filter", - "../../../api:array_view", "../../../api:field_trials_view", "../../../api/audio:aec3_config", "../../../api/audio:echo_control", @@ -176,10 +175,7 @@ rtc_source_set("aec3_block") { sources = [ "block.h" ] - deps = [ - ":aec3_common", - "../../../api:array_view", - ] + deps = [ ":aec3_common" ] } rtc_source_set("aec3_fft") { @@ -187,7 +183,6 @@ deps = [ ":aec3_common", ":fft_data", - "../../../api:array_view", "../../../common_audio/third_party/ooura:fft_size_128", "../../../rtc_base:checks", "../../../rtc_base/system:arch", @@ -205,7 +200,6 @@ ":aec3_block", ":aec3_common", ":fft_data", - "../../../api:array_view", "../../../rtc_base:checks", "../../../rtc_base/system:arch", ] @@ -219,7 +213,6 @@ ":fft_data", ":render_buffer", "..:apm_logging", - "../../../api:array_view", "../../../rtc_base/system:arch", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -229,7 +222,6 @@ sources = [ "adaptive_fir_filter_erl.h" ] deps = [ ":aec3_common", - "../../../api:array_view", "../../../rtc_base/system:arch", ] } @@ -238,7 +230,6 @@ sources = [ "matched_filter.h" ] deps = [ ":aec3_common", - "../../../api:array_view", "../../../rtc_base:gtest_prod", "../../../rtc_base/system:arch", ] @@ -248,7 +239,6 @@ sources = [ "vector_math.h" ] deps = [ ":aec3_common", - "../../../api:array_view", "../../../rtc_base:checks", "../../../rtc_base/system:arch", ] @@ -258,7 +248,6 @@ sources = [ "fft_data.h" ] deps = [ ":aec3_common", - "../../../api:array_view", "../../../rtc_base:checks", "../../../rtc_base/system:arch", ] @@ -292,7 +281,6 @@ ":matched_filter", ":render_buffer", ":vector_math", - "../../../api:array_view", "../../../rtc_base:checks", ] } @@ -329,7 +317,6 @@ "..:audio_buffer", "..:audio_processing", "..:high_pass_filter", - "../../../api:array_view", "../../../api:field_trials", "../../../api/audio:aec3_config", "../../../api/audio:echo_control",
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter.cc b/modules/audio_processing/aec3/adaptive_fir_filter.cc index 6a2e3ba..52718c0 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter.cc
@@ -14,9 +14,9 @@ #include <array> #include <cmath> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -134,7 +134,7 @@ const FftData& G, size_t num_partitions, std::vector<std::vector<FftData>>* H) { - ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); size_t index = render_buffer.Position(); const size_t num_render_channels = render_buffer_data[index].size(); @@ -157,7 +157,7 @@ const FftData& G, size_t num_partitions, std::vector<std::vector<FftData>>* H) { - webrtc::ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); const size_t num_render_channels = render_buffer_data[0].size(); const size_t lim1 = std::min( @@ -223,7 +223,7 @@ const FftData& G, size_t num_partitions, std::vector<std::vector<FftData>>* H) { - ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); const size_t num_render_channels = render_buffer_data[0].size(); const size_t lim1 = std::min( @@ -294,7 +294,7 @@ S->re.fill(0.f); S->im.fill(0.f); - ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); size_t index = render_buffer.Position(); const size_t num_render_channels = render_buffer_data[index].size(); @@ -319,12 +319,12 @@ const std::vector<std::vector<FftData>>& H, FftData* S) { // const RenderBuffer& render_buffer, - // webrtc::ArrayView<const FftData> H, + // std::span<const FftData> H, // FftData* S) { RTC_DCHECK_GE(H.size(), H.size() - 1); S->Clear(); - webrtc::ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); const size_t num_render_channels = render_buffer_data[0].size(); const size_t lim1 = std::min( @@ -389,13 +389,13 @@ const std::vector<std::vector<FftData>>& H, FftData* S) { // const RenderBuffer& render_buffer, - // webrtc::ArrayView<const FftData> H, + // std::span<const FftData> H, // FftData* S) { RTC_DCHECK_GE(H.size(), H.size() - 1); S->re.fill(0.f); S->im.fill(0.f); - ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); const size_t num_render_channels = render_buffer_data[0].size(); const size_t lim1 = std::min(
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter.h b/modules/audio_processing/aec3/adaptive_fir_filter.h index 34c06f4..681cd23 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter.h +++ b/modules/audio_processing/aec3/adaptive_fir_filter.h
@@ -17,7 +17,6 @@ #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec3_fft.h" #include "modules/audio_processing/aec3/fft_data.h"
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_avx2.cc b/modules/audio_processing/aec3/adaptive_fir_filter_avx2.cc index f7ba1fd..f250f84 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_avx2.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_avx2.cc
@@ -13,9 +13,9 @@ #include <algorithm> #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/adaptive_fir_filter.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" @@ -63,7 +63,7 @@ const FftData& G, size_t num_partitions, std::vector<std::vector<FftData>>* H) { - ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); const size_t num_render_channels = render_buffer_data[0].size(); const size_t lim1 = std::min( @@ -134,7 +134,7 @@ S->re.fill(0.f); S->im.fill(0.f); - ArrayView<const std::vector<FftData>> render_buffer_data = + std::span<const std::vector<FftData>> render_buffer_data = render_buffer.GetFftBuffer(); const size_t num_render_channels = render_buffer_data[0].size(); const size_t lim1 = std::min(
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_erl.cc b/modules/audio_processing/aec3/adaptive_fir_filter_erl.cc index 11f83af..77d1487 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_erl.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_erl.cc
@@ -14,9 +14,9 @@ #include <array> #include <cstddef> #include <functional> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" @@ -36,7 +36,7 @@ // Computes and stores the echo return loss estimate of the filter, which is the // sum of the partition frequency responses. void ErlComputer(const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl) { + std::span<float> erl) { std::fill(erl.begin(), erl.end(), 0.f); for (auto& H2_j : H2) { std::transform(H2_j.begin(), H2_j.end(), erl.begin(), erl.begin(), @@ -49,7 +49,7 @@ // sum of the partition frequency responses. void ErlComputer_NEON( const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - webrtc::ArrayView<float> erl) { + std::span<float> erl) { std::fill(erl.begin(), erl.end(), 0.f); for (auto& H2_j : H2) { for (size_t k = 0; k < kFftLengthBy2; k += 4) { @@ -68,7 +68,7 @@ // sum of the partition frequency responses. void ErlComputer_SSE2( const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl) { + std::span<float> erl) { std::fill(erl.begin(), erl.end(), 0.f); for (auto& H2_j : H2) { for (size_t k = 0; k < kFftLengthBy2; k += 4) { @@ -86,7 +86,7 @@ void ComputeErl(const Aec3Optimization& optimization, const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl) { + std::span<float> erl) { RTC_DCHECK_EQ(kFftLengthBy2Plus1, erl.size()); // Update the frequency response and echo return loss for the filter. switch (optimization) {
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_erl.h b/modules/audio_processing/aec3/adaptive_fir_filter_erl.h index 68da2d2..d504d27 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_erl.h +++ b/modules/audio_processing/aec3/adaptive_fir_filter_erl.h
@@ -14,9 +14,9 @@ #include <stddef.h> #include <array> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/system/arch.h" @@ -26,20 +26,20 @@ // Computes and stores the echo return loss estimate of the filter, which is the // sum of the partition frequency responses. void ErlComputer(const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl); + std::span<float> erl); #if defined(WEBRTC_HAS_NEON) void ErlComputer_NEON( const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - webrtc::ArrayView<float> erl); + std::span<float> erl); #endif #if defined(WEBRTC_ARCH_X86_FAMILY) void ErlComputer_SSE2( const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl); + std::span<float> erl); void ErlComputer_AVX2( const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl); + std::span<float> erl); #endif } // namespace aec3 @@ -47,7 +47,7 @@ // Computes the echo return loss based on a frequency response. void ComputeErl(const Aec3Optimization& optimization, const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl); + std::span<float> erl); } // namespace webrtc
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_erl_avx2.cc b/modules/audio_processing/aec3/adaptive_fir_filter_erl_avx2.cc index 6abbcae..c3606aa 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_erl_avx2.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_erl_avx2.cc
@@ -13,9 +13,9 @@ #include <algorithm> #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/adaptive_fir_filter_erl.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -27,7 +27,7 @@ // sum of the partition frequency responses. void ErlComputer_AVX2( const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, - ArrayView<float> erl) { + std::span<float> erl) { std::fill(erl.begin(), erl.end(), 0.f); for (auto& H2_j : H2) { for (size_t k = 0; k < kFftLengthBy2; k += 8) {
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc index 2e600be..60e9628 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
@@ -16,11 +16,11 @@ #include <memory> #include <numeric> #include <optional> +#include <span> #include <string> #include <tuple> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment_factory.h" #include "modules/audio_processing/aec3/adaptive_fir_filter_erl.h" @@ -546,11 +546,11 @@ num_render_channels); for (size_t ch = 0; ch < num_render_channels; ++ch) { x_hp_filter[ch] = std::make_unique<CascadedBiQuadFilter>( - ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients)); } CascadedBiQuadFilter y_hp_filter( - (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients))); SCOPED_TRACE(ProduceDebugText(num_render_channels, delay_samples));
diff --git a/modules/audio_processing/aec3/aec3_fft.cc b/modules/audio_processing/aec3/aec3_fft.cc index 7652e30..360590e 100644 --- a/modules/audio_processing/aec3/aec3_fft.cc +++ b/modules/audio_processing/aec3/aec3_fft.cc
@@ -14,8 +14,8 @@ #include <array> #include <functional> #include <iterator> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" #include "rtc_base/checks.h" @@ -88,7 +88,7 @@ Aec3Fft::Aec3Fft() : ooura_fft_(IsSse2Available()) {} // TODO(peah): Change x to be std::array once the rest of the code allows this. -void Aec3Fft::ZeroPaddedFft(ArrayView<const float> x, +void Aec3Fft::ZeroPaddedFft(std::span<const float> x, Window window, FftData* X) const { RTC_DCHECK(X); @@ -114,8 +114,8 @@ Fft(&fft, X); } -void Aec3Fft::PaddedFft(ArrayView<const float> x, - ArrayView<const float> x_old, +void Aec3Fft::PaddedFft(std::span<const float> x, + std::span<const float> x_old, Window window, FftData* X) const { RTC_DCHECK(X);
diff --git a/modules/audio_processing/aec3/aec3_fft.h b/modules/audio_processing/aec3/aec3_fft.h index 83d2a2e..2362a51 100644 --- a/modules/audio_processing/aec3/aec3_fft.h +++ b/modules/audio_processing/aec3/aec3_fft.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AEC3_AEC3_FFT_H_ #include <array> +#include <span> -#include "api/array_view.h" #include "common_audio/third_party/ooura/fft_size_128/ooura_fft.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" @@ -48,19 +48,19 @@ // Windows the input using a Hanning window, and then adds padding of // kFftLengthBy2 initial zeros before computing the Fft. - void ZeroPaddedFft(ArrayView<const float> x, Window window, FftData* X) const; + void ZeroPaddedFft(std::span<const float> x, Window window, FftData* X) const; // Concatenates the kFftLengthBy2 values long x and x_old before computing the // Fft. After that, x is copied to x_old. - void PaddedFft(ArrayView<const float> x, - ArrayView<const float> x_old, + void PaddedFft(std::span<const float> x, + std::span<const float> x_old, FftData* X) const { PaddedFft(x, x_old, Window::kRectangular, X); } // Padded Fft using a time-domain window. - void PaddedFft(ArrayView<const float> x, - ArrayView<const float> x_old, + void PaddedFft(std::span<const float> x, + std::span<const float> x_old, Window window, FftData* X) const;
diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 750c89a..d97fda3 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc
@@ -17,9 +17,9 @@ #include <cstddef> #include <numeric> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" @@ -59,7 +59,7 @@ int delay_blocks, float reverb_decay, ReverbModel* reverb_model, - ArrayView<float, kFftLengthBy2Plus1> reverb_power_spectrum) { + std::span<float, kFftLengthBy2Plus1> reverb_power_spectrum) { RTC_DCHECK(reverb_model); const size_t num_render_channels = spectrum_buffer.buffer[0].size(); int idx_at_delay = @@ -67,13 +67,13 @@ int idx_past = spectrum_buffer.IncIndex(idx_at_delay); std::array<float, kFftLengthBy2Plus1> X2_data; - ArrayView<const float> X2; + std::span<const float> X2; if (num_render_channels > 1) { auto average_channels = [](size_t num_render_channels, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> spectrum_band_0, - ArrayView<float, kFftLengthBy2Plus1> render_power) { + std::span<float, kFftLengthBy2Plus1> render_power) { std::fill(render_power.begin(), render_power.end(), 0.f); for (size_t ch = 0; ch < num_render_channels; ++ch) { for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) { @@ -101,7 +101,7 @@ X2 = spectrum_buffer.buffer[idx_at_delay][/*channel=*/0]; } - ArrayView<const float, kFftLengthBy2Plus1> reverb_power = + std::span<const float, kFftLengthBy2Plus1> reverb_power = reverb_model->reverb(); for (size_t k = 0; k < X2.size(); ++k) { reverb_power_spectrum[k] = X2[k] + reverb_power[k]; @@ -112,7 +112,7 @@ std::atomic<int> AecState::instance_count_(0); -void AecState::GetResidualEchoScaling(ArrayView<float> residual_scaling) const { +void AecState::GetResidualEchoScaling(std::span<float> residual_scaling) const { bool filter_has_had_time_to_converge; if (config_.filter.conservative_initial_phase) { filter_has_had_time_to_converge = @@ -189,13 +189,13 @@ void AecState::Update( const std::optional<DelayEstimate>& external_delay, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> adaptive_filter_frequency_responses, - ArrayView<const std::vector<float>> adaptive_filter_impulse_responses, + std::span<const std::vector<float>> adaptive_filter_impulse_responses, const RenderBuffer& render_buffer, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2_refined, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const SubtractorOutput> subtractor_output) { + std::span<const std::array<float, kFftLengthBy2Plus1>> E2_refined, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const SubtractorOutput> subtractor_output) { RTC_DCHECK_EQ(num_capture_channels_, Y2.size()); RTC_DCHECK_EQ(num_capture_channels_, subtractor_output.size()); RTC_DCHECK_EQ(num_capture_channels_, @@ -376,7 +376,7 @@ min_filter_delay_(delay_headroom_blocks_) {} void AecState::FilterDelay::Update( - ArrayView<const int> analyzer_filter_delay_estimates_blocks, + std::span<const int> analyzer_filter_delay_estimates_blocks, const std::optional<DelayEstimate>& external_delay, size_t blocks_with_proper_filter_adaptation) { // Update the delay based on the external delay. @@ -464,7 +464,7 @@ const Block& x, bool saturated_capture, bool usable_linear_estimate, - ArrayView<const SubtractorOutput> subtractor_output, + std::span<const SubtractorOutput> subtractor_output, float echo_path_gain) { saturated_echo_ = false; if (!saturated_capture) { @@ -482,7 +482,7 @@ } else { float max_sample = 0.f; for (int ch = 0; ch < x.NumChannels(); ++ch) { - ArrayView<const float, kBlockSize> x_ch = x.View(/*band=*/0, ch); + std::span<const float, kBlockSize> x_ch = x.View(/*band=*/0, ch); for (float sample : x_ch) { max_sample = std::max(max_sample, fabsf(sample)); }
diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index 9c5adc7..df5bc65 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h
@@ -17,9 +17,9 @@ #include <atomic> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -67,7 +67,7 @@ // Returns the appropriate scaling of the residual echo to match the // audibility. - void GetResidualEchoScaling(ArrayView<float> residual_scaling) const; + void GetResidualEchoScaling(std::span<float> residual_scaling) const; // Returns whether the stationary properties of the signals are used in the // aec. @@ -76,13 +76,13 @@ } // Returns the ERLE. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Erle( + std::span<const std::array<float, kFftLengthBy2Plus1>> Erle( bool onset_compensated) const { return erle_estimator_.Erle(onset_compensated); } // Returns the non-capped ERLE. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> ErleUnbounded() const { + std::span<const std::array<float, kFftLengthBy2Plus1>> ErleUnbounded() const { return erle_estimator_.ErleUnbounded(); } @@ -129,7 +129,7 @@ } // Return the frequency response of the reverberant echo. - ArrayView<const float> GetReverbFrequencyResponse() const { + std::span<const float> GetReverbFrequencyResponse() const { return reverb_model_estimator_.GetReverbFrequencyResponse(); } @@ -143,13 +143,13 @@ // TODO(bugs.webrtc.org/10913): Compute multi-channel ERL. void Update( const std::optional<DelayEstimate>& external_delay, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> adaptive_filter_frequency_responses, - ArrayView<const std::vector<float>> adaptive_filter_impulse_responses, + std::span<const std::vector<float>> adaptive_filter_impulse_responses, const RenderBuffer& render_buffer, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2_refined, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const SubtractorOutput> subtractor_output); + std::span<const std::array<float, kFftLengthBy2Plus1>> E2_refined, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const SubtractorOutput> subtractor_output); // Returns filter length in blocks. int FilterLengthBlocks() const { @@ -215,7 +215,7 @@ // Returns the delay in blocks relative to the beginning of the filter that // corresponds to the direct path of the echo. - ArrayView<const int> DirectPathFilterDelays() const { + std::span<const int> DirectPathFilterDelays() const { return filter_delays_blocks_; } @@ -224,7 +224,7 @@ int MinDirectPathFilterDelay() const { return min_filter_delay_; } // Updates the delay estimates based on new data. - void Update(ArrayView<const int> analyzer_filter_delay_estimates_blocks, + void Update(std::span<const int> analyzer_filter_delay_estimates_blocks, const std::optional<DelayEstimate>& external_delay, size_t blocks_with_proper_filter_adaptation); @@ -287,7 +287,7 @@ void Update(const Block& x, bool saturated_capture, bool usable_linear_estimate, - ArrayView<const SubtractorOutput> subtractor_output, + std::span<const SubtractorOutput> subtractor_output, float echo_path_gain); private:
diff --git a/modules/audio_processing/aec3/alignment_mixer.cc b/modules/audio_processing/aec3/alignment_mixer.cc index 0370aeb..c3e36b2 100644 --- a/modules/audio_processing/aec3/alignment_mixer.cc +++ b/modules/audio_processing/aec3/alignment_mixer.cc
@@ -12,8 +12,8 @@ #include <algorithm> #include <cstddef> #include <cstring> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" @@ -70,7 +70,7 @@ } void AlignmentMixer::ProduceOutput(const Block& x, - ArrayView<float, kBlockSize> y) { + std::span<float, kBlockSize> y) { RTC_DCHECK_EQ(x.NumChannels(), num_channels_); if (selection_variant_ == MixingVariant::kDownmix) { @@ -85,7 +85,7 @@ } void AlignmentMixer::Downmix(const Block& x, - ArrayView<float, kBlockSize> y) const { + std::span<float, kBlockSize> y) const { RTC_DCHECK_EQ(x.NumChannels(), num_channels_); RTC_DCHECK_GE(num_channels_, 2); std::memcpy(&y[0], x.View(/*band=*/0, /*channel=*/0).data(), @@ -122,7 +122,7 @@ for (int ch = 0; ch < num_ch_to_analyze; ++ch) { float x2_sum = 0.f; - ArrayView<const float, kBlockSize> x_ch = x.View(/*band=*/0, ch); + std::span<const float, kBlockSize> x_ch = x.View(/*band=*/0, ch); for (size_t i = 0; i < kBlockSize; ++i) { x2_sum += x_ch[i] * x_ch[i]; }
diff --git a/modules/audio_processing/aec3/alignment_mixer.h b/modules/audio_processing/aec3/alignment_mixer.h index 29bf14b..ecc015d 100644 --- a/modules/audio_processing/aec3/alignment_mixer.h +++ b/modules/audio_processing/aec3/alignment_mixer.h
@@ -13,9 +13,9 @@ #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" @@ -36,7 +36,7 @@ float excitation_limit, bool prefer_first_two_channels); - void ProduceOutput(const Block& x, ArrayView<float, kBlockSize> y); + void ProduceOutput(const Block& x, std::span<float, kBlockSize> y); enum class MixingVariant { kDownmix, kAdaptive, kFixed }; @@ -51,7 +51,7 @@ int selected_channel_ = 0; size_t block_counter_ = 0; - void Downmix(const Block& x, ArrayView<float, kBlockSize> y) const; + void Downmix(const Block& x, std::span<float, kBlockSize> y) const; int SelectChannel(const Block& x); }; } // namespace webrtc
diff --git a/modules/audio_processing/aec3/alignment_mixer_unittest.cc b/modules/audio_processing/aec3/alignment_mixer_unittest.cc index 72c2649..e21e211 100644 --- a/modules/audio_processing/aec3/alignment_mixer_unittest.cc +++ b/modules/audio_processing/aec3/alignment_mixer_unittest.cc
@@ -15,7 +15,6 @@ #include <cstddef> #include <string> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "rtc_base/checks.h"
diff --git a/modules/audio_processing/aec3/block.h b/modules/audio_processing/aec3/block.h index 75f032d..164ba18 100644 --- a/modules/audio_processing/aec3/block.h +++ b/modules/audio_processing/aec3/block.h
@@ -12,10 +12,10 @@ #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_H_ #include <algorithm> +#include <span> #include <utility> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" namespace webrtc { @@ -58,14 +58,14 @@ return begin(band, channel) + kBlockSize; } - // Access data via ArrayView. - ArrayView<float, kBlockSize> View(int band, int channel) { - return ArrayView<float, kBlockSize>(&data_[GetIndex(band, channel)], + // Access data via std::span. + std::span<float, kBlockSize> View(int band, int channel) { + return std::span<float, kBlockSize>(&data_[GetIndex(band, channel)], kBlockSize); } - ArrayView<const float, kBlockSize> View(int band, int channel) const { - return ArrayView<const float, kBlockSize>(&data_[GetIndex(band, channel)], + std::span<const float, kBlockSize> View(int band, int channel) const { + return std::span<const float, kBlockSize>(&data_[GetIndex(band, channel)], kBlockSize); }
diff --git a/modules/audio_processing/aec3/block_delay_buffer.cc b/modules/audio_processing/aec3/block_delay_buffer.cc index 3d67aae..84df4e50 100644 --- a/modules/audio_processing/aec3/block_delay_buffer.cc +++ b/modules/audio_processing/aec3/block_delay_buffer.cc
@@ -10,9 +10,9 @@ #include "modules/audio_processing/aec3/block_delay_buffer.h" #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" #include "rtc_base/checks.h" @@ -44,7 +44,7 @@ for (size_t ch = 0; ch < num_channels; ++ch) { RTC_DCHECK_EQ(buf_[ch].size(), frame->num_bands()); RTC_DCHECK_EQ(buf_[ch].size(), num_bands); - ArrayView<float* const> frame_ch(frame->split_bands(ch), num_bands); + std::span<float* const> frame_ch(frame->split_bands(ch), num_bands); const size_t delay = delay_; for (size_t band = 0; band < num_bands; ++band) {
diff --git a/modules/audio_processing/aec3/block_framer.cc b/modules/audio_processing/aec3/block_framer.cc index 58d1eff..f9cadb9 100644 --- a/modules/audio_processing/aec3/block_framer.cc +++ b/modules/audio_processing/aec3/block_framer.cc
@@ -12,9 +12,9 @@ #include <algorithm> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "rtc_base/checks.h" @@ -54,7 +54,7 @@ void BlockFramer::InsertBlockAndExtractSubFrame( const Block& block, - std::vector<std::vector<ArrayView<float>>>* sub_frame) { + std::vector<std::vector<std::span<float>>>* sub_frame) { RTC_DCHECK(sub_frame); RTC_DCHECK_EQ(num_bands_, block.NumBands()); RTC_DCHECK_EQ(num_channels_, block.NumChannels());
diff --git a/modules/audio_processing/aec3/block_framer.h b/modules/audio_processing/aec3/block_framer.h index c7ddc49..896bc6b 100644 --- a/modules/audio_processing/aec3/block_framer.h +++ b/modules/audio_processing/aec3/block_framer.h
@@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_ #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/block.h" namespace webrtc { @@ -37,7 +37,7 @@ // Adds a 64 sample block and extracts an 80 sample subframe. void InsertBlockAndExtractSubFrame( const Block& block, - std::vector<std::vector<ArrayView<float>>>* sub_frame); + std::vector<std::vector<std::span<float>>>* sub_frame); private: const size_t num_bands_;
diff --git a/modules/audio_processing/aec3/block_framer_unittest.cc b/modules/audio_processing/aec3/block_framer_unittest.cc index b898f32..fa9aaff 100644 --- a/modules/audio_processing/aec3/block_framer_unittest.cc +++ b/modules/audio_processing/aec3/block_framer_unittest.cc
@@ -11,10 +11,10 @@ #include "modules/audio_processing/aec3/block_framer.h" #include <cstddef> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "rtc_base/checks.h" @@ -26,12 +26,12 @@ void SetupSubFrameView( std::vector<std::vector<std::vector<float>>>* sub_frame, - std::vector<std::vector<ArrayView<float>>>* sub_frame_view) { + std::vector<std::vector<std::span<float>>>* sub_frame_view) { for (size_t band = 0; band < sub_frame_view->size(); ++band) { for (size_t channel = 0; channel < (*sub_frame_view)[band].size(); ++channel) { (*sub_frame_view)[band][channel] = - ArrayView<float>((*sub_frame)[band][channel].data(), + std::span<float>((*sub_frame)[band][channel].data(), (*sub_frame)[band][channel].size()); } } @@ -52,7 +52,7 @@ bool VerifySubFrame( size_t sub_frame_counter, int offset, - const std::vector<std::vector<ArrayView<float>>>& sub_frame_view) { + const std::vector<std::vector<std::span<float>>>& sub_frame_view) { for (size_t band = 0; band < sub_frame_view.size(); ++band) { for (size_t channel = 0; channel < sub_frame_view[band].size(); ++channel) { for (size_t sample = 0; sample < sub_frame_view[band][channel].size(); @@ -89,8 +89,8 @@ std::vector<std::vector<std::vector<float>>> output_sub_frame( num_bands, std::vector<std::vector<float>>( num_channels, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> output_sub_frame_view( - num_bands, std::vector<ArrayView<float>>(num_channels)); + std::vector<std::vector<std::span<float>>> output_sub_frame_view( + num_bands, std::vector<std::span<float>>(num_channels)); SetupSubFrameView(&output_sub_frame, &output_sub_frame_view); BlockFramer framer(num_bands, num_channels); @@ -128,9 +128,9 @@ num_sub_frame_bands, std::vector<std::vector<float>>( num_sub_frame_channels, std::vector<float>(sub_frame_length, 0.f))); - std::vector<std::vector<ArrayView<float>>> output_sub_frame_view( + std::vector<std::vector<std::span<float>>> output_sub_frame_view( output_sub_frame.size(), - std::vector<ArrayView<float>>(num_sub_frame_channels)); + std::vector<std::span<float>>(num_sub_frame_channels)); SetupSubFrameView(&output_sub_frame, &output_sub_frame_view); BlockFramer framer(correct_num_bands, correct_num_channels); EXPECT_DEATH( @@ -151,9 +151,9 @@ correct_num_bands, std::vector<std::vector<float>>( correct_num_channels, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> output_sub_frame_view( + std::vector<std::vector<std::span<float>>> output_sub_frame_view( output_sub_frame.size(), - std::vector<ArrayView<float>>(correct_num_channels)); + std::vector<std::span<float>>(correct_num_channels)); SetupSubFrameView(&output_sub_frame, &output_sub_frame_view); BlockFramer framer(correct_num_bands, correct_num_channels); framer.InsertBlockAndExtractSubFrame(correct_block, &output_sub_frame_view); @@ -178,8 +178,8 @@ correct_num_bands, std::vector<std::vector<float>>( num_channels, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> output_sub_frame_view( - output_sub_frame.size(), std::vector<ArrayView<float>>(num_channels)); + std::vector<std::vector<std::span<float>>> output_sub_frame_view( + output_sub_frame.size(), std::vector<std::span<float>>(num_channels)); SetupSubFrameView(&output_sub_frame, &output_sub_frame_view); BlockFramer framer(correct_num_bands, num_channels); for (size_t k = 0; k < num_preceeding_api_calls; ++k) {
diff --git a/modules/audio_processing/aec3/block_processor_unittest.cc b/modules/audio_processing/aec3/block_processor_unittest.cc index fe9596d..bc08584 100644 --- a/modules/audio_processing/aec3/block_processor_unittest.cc +++ b/modules/audio_processing/aec3/block_processor_unittest.cc
@@ -13,10 +13,10 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -118,7 +118,7 @@ return ss.Release(); } -void FillSampleVector(int call_counter, int delay, ArrayView<float> samples) { +void FillSampleVector(int call_counter, int delay, std::span<float> samples) { for (size_t i = 0; i < samples.size(); ++i) { samples[i] = (call_counter - delay) * 10000.0f + i; }
diff --git a/modules/audio_processing/aec3/comfort_noise_generator.cc b/modules/audio_processing/aec3/comfort_noise_generator.cc index 8df81e5..b7f30de 100644 --- a/modules/audio_processing/aec3/comfort_noise_generator.cc +++ b/modules/audio_processing/aec3/comfort_noise_generator.cc
@@ -18,9 +18,9 @@ #include <memory> #include <numbers> #include <numeric> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" @@ -60,8 +60,8 @@ void GenerateRandomSinTableIndices( uint32_t& seed, - ArrayView<int16_t, kFftLengthBy2 - 1> re_sin_table_indices, - ArrayView<int16_t, kFftLengthBy2 - 1> im_sin_table_indices) { + std::span<int16_t, kFftLengthBy2 - 1> re_sin_table_indices, + std::span<int16_t, kFftLengthBy2 - 1> im_sin_table_indices) { RTC_DCHECK_EQ(re_sin_table_indices.size(), im_sin_table_indices.size()); constexpr int32_t kSeedMask = 0x80000000 - 1; @@ -84,8 +84,8 @@ void GenerateComfortNoise( Aec3Optimization optimization, const std::array<float, kFftLengthBy2Plus1>& N2, - ArrayView<int16_t, kFftLengthBy2 - 1> re_sin_table_indices, - ArrayView<int16_t, kFftLengthBy2 - 1> im_sin_table_indices, + std::span<int16_t, kFftLengthBy2 - 1> re_sin_table_indices, + std::span<int16_t, kFftLengthBy2 - 1> im_sin_table_indices, FftData* lower_band_noise, FftData* upper_band_noise) { FftData* N_low = lower_band_noise; @@ -151,9 +151,9 @@ void ComfortNoiseGenerator::Compute( bool saturated_capture, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> capture_spectrum, - ArrayView<FftData> lower_band_noise, - ArrayView<FftData> upper_band_noise) { + std::span<const std::array<float, kFftLengthBy2Plus1>> capture_spectrum, + std::span<FftData> lower_band_noise, + std::span<FftData> upper_band_noise) { const auto& Y2 = capture_spectrum; if (!saturated_capture) {
diff --git a/modules/audio_processing/aec3/comfort_noise_generator.h b/modules/audio_processing/aec3/comfort_noise_generator.h index 3672185..c28e269 100644 --- a/modules/audio_processing/aec3/comfort_noise_generator.h +++ b/modules/audio_processing/aec3/comfort_noise_generator.h
@@ -16,9 +16,9 @@ #include <array> #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" @@ -53,12 +53,12 @@ // Computes the comfort noise. void Compute( bool saturated_capture, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> capture_spectrum, - ArrayView<FftData> lower_band_noise, - ArrayView<FftData> upper_band_noise); + std::span<const std::array<float, kFftLengthBy2Plus1>> capture_spectrum, + std::span<FftData> lower_band_noise, + std::span<FftData> upper_band_noise); // Returns the estimate of the background noise spectrum. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> NoiseSpectrum() const { + std::span<const std::array<float, kFftLengthBy2Plus1>> NoiseSpectrum() const { return N2_; }
diff --git a/modules/audio_processing/aec3/decimator.cc b/modules/audio_processing/aec3/decimator.cc index d0f0e7c..473273d 100644 --- a/modules/audio_processing/aec3/decimator.cc +++ b/modules/audio_processing/aec3/decimator.cc
@@ -11,8 +11,8 @@ #include <array> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" #include "rtc_base/checks.h" @@ -59,20 +59,20 @@ : down_sampling_factor_(down_sampling_factor), anti_aliasing_filter_( down_sampling_factor_ == 4 - ? ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + ? std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kLowPassFilterDs4) - : ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + : std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kBandPassFilterDs8)), noise_reduction_filter_( down_sampling_factor_ == 8 - ? (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + ? (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kPassThroughFilter)) - : (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + : (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilter))) { RTC_DCHECK(down_sampling_factor_ == 4 || down_sampling_factor_ == 8); } -void Decimator::Decimate(ArrayView<const float> in, ArrayView<float> out) { +void Decimator::Decimate(std::span<const float> in, std::span<float> out) { RTC_DCHECK_EQ(kBlockSize, in.size()); RTC_DCHECK_EQ(kBlockSize / down_sampling_factor_, out.size()); std::array<float, kBlockSize> x;
diff --git a/modules/audio_processing/aec3/decimator.h b/modules/audio_processing/aec3/decimator.h index 8056169..51d6489 100644 --- a/modules/audio_processing/aec3/decimator.h +++ b/modules/audio_processing/aec3/decimator.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AEC3_DECIMATOR_H_ #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" namespace webrtc { @@ -27,7 +27,7 @@ Decimator& operator=(const Decimator&) = delete; // Downsamples the signal. - void Decimate(ArrayView<const float> in, ArrayView<float> out); + void Decimate(std::span<const float> in, std::span<float> out); private: const size_t down_sampling_factor_;
diff --git a/modules/audio_processing/aec3/decimator_unittest.cc b/modules/audio_processing/aec3/decimator_unittest.cc index 8424c36..d0eb010 100644 --- a/modules/audio_processing/aec3/decimator_unittest.cc +++ b/modules/audio_processing/aec3/decimator_unittest.cc
@@ -16,10 +16,10 @@ #include <cstring> #include <numbers> #include <numeric> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" @@ -60,17 +60,17 @@ for (size_t k = 0; k < kNumBlocks; ++k) { std::vector<float> sub_block(sub_block_size); decimator.Decimate( - ArrayView<const float>(&input[k * kBlockSize], kBlockSize), sub_block); + std::span<const float>(&input[k * kBlockSize], kBlockSize), sub_block); std::copy(sub_block.begin(), sub_block.end(), output.begin() + k * sub_block_size); } ASSERT_GT(kNumBlocks, kNumStartupBlocks); - ArrayView<const float> input_to_evaluate( + std::span<const float> input_to_evaluate( &input[kNumStartupBlocks * kBlockSize], (kNumBlocks - kNumStartupBlocks) * kBlockSize); - ArrayView<const float> output_to_evaluate( + std::span<const float> output_to_evaluate( &output[kNumStartupBlocks * sub_block_size], (kNumBlocks - kNumStartupBlocks) * sub_block_size); *input_power =
diff --git a/modules/audio_processing/aec3/dominant_nearend_detector.cc b/modules/audio_processing/aec3/dominant_nearend_detector.cc index c37fa9a..35aff93 100644 --- a/modules/audio_processing/aec3/dominant_nearend_detector.cc +++ b/modules/audio_processing/aec3/dominant_nearend_detector.cc
@@ -14,8 +14,8 @@ #include <array> #include <cstddef> #include <numeric> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" @@ -35,15 +35,15 @@ hold_counters_(num_capture_channels_) {} void DominantNearendDetector::Update( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, bool initial_state) { nearend_state_ = false; - auto low_frequency_energy = [](ArrayView<const float> spectrum) { + auto low_frequency_energy = [](std::span<const float> spectrum) { RTC_DCHECK_LE(16, spectrum.size()); return std::accumulate(spectrum.begin() + 1, spectrum.begin() + 16, 0.f); };
diff --git a/modules/audio_processing/aec3/dominant_nearend_detector.h b/modules/audio_processing/aec3/dominant_nearend_detector.h index afd1516..cbab36e 100644 --- a/modules/audio_processing/aec3/dominant_nearend_detector.h +++ b/modules/audio_processing/aec3/dominant_nearend_detector.h
@@ -13,9 +13,9 @@ #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/nearend_detector.h" @@ -33,10 +33,10 @@ // Updates the state selection based on latest spectral estimates. void Update( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, bool initial_state) override;
diff --git a/modules/audio_processing/aec3/echo_audibility.cc b/modules/audio_processing/aec3/echo_audibility.cc index b7a9430..55191ef 100644 --- a/modules/audio_processing/aec3/echo_audibility.cc +++ b/modules/audio_processing/aec3/echo_audibility.cc
@@ -13,10 +13,10 @@ #include <algorithm> #include <cmath> #include <optional> +#include <span> #include <utility> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block_buffer.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -33,7 +33,7 @@ EchoAudibility::~EchoAudibility() = default; void EchoAudibility::Update(const RenderBuffer& render_buffer, - ArrayView<const float> average_reverb, + std::span<const float> average_reverb, int delay_blocks, bool external_delay_seen) { UpdateRenderNoiseEstimator(render_buffer.GetSpectrumBuffer(), @@ -53,7 +53,7 @@ void EchoAudibility::UpdateRenderStationarityFlags( const RenderBuffer& render_buffer, - ArrayView<const float> average_reverb, + std::span<const float> average_reverb, int min_channel_delay_blocks) { const SpectrumBuffer& spectrum_buffer = render_buffer.GetSpectrumBuffer(); int idx_at_delay = spectrum_buffer.OffsetIndex(spectrum_buffer.read, @@ -101,7 +101,7 @@ idx = block_buffer.IncIndex(idx)) { float max_abs_over_channels = 0.f; for (int ch = 0; ch < num_render_channels; ++ch) { - ArrayView<const float, kBlockSize> block = + std::span<const float, kBlockSize> block = block_buffer.buffer[idx].View(/*band=*/0, /*channel=*/ch); auto r = std::minmax_element(block.begin(), block.end()); float max_abs_channel =
diff --git a/modules/audio_processing/aec3/echo_audibility.h b/modules/audio_processing/aec3/echo_audibility.h index 44df926..35edb5d 100644 --- a/modules/audio_processing/aec3/echo_audibility.h +++ b/modules/audio_processing/aec3/echo_audibility.h
@@ -14,8 +14,8 @@ #include <stddef.h> #include <optional> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/block_buffer.h" #include "modules/audio_processing/aec3/render_buffer.h" #include "modules/audio_processing/aec3/spectrum_buffer.h" @@ -33,12 +33,12 @@ // Feed new render data to the echo audibility estimator. void Update(const RenderBuffer& render_buffer, - ArrayView<const float> average_reverb, + std::span<const float> average_reverb, int min_channel_delay_blocks, bool external_delay_seen); // Get the residual echo scaling. void GetResidualEchoScaling(bool filter_has_had_time_to_converge, - ArrayView<float> residual_scaling) const { + std::span<float> residual_scaling) const { for (size_t band = 0; band < residual_scaling.size(); ++band) { if (render_stationarity_.IsBandStationary(band) && (filter_has_had_time_to_converge || @@ -61,7 +61,7 @@ // Updates the render stationarity flags for the current frame. void UpdateRenderStationarityFlags(const RenderBuffer& render_buffer, - ArrayView<const float> average_reverb, + std::span<const float> average_reverb, int delay_blocks); // Updates the noise estimator with the new render data since the previous
diff --git a/modules/audio_processing/aec3/echo_canceller3.cc b/modules/audio_processing/aec3/echo_canceller3.cc index 7bf2aa3..5e99a5b 100644 --- a/modules/audio_processing/aec3/echo_canceller3.cc +++ b/modules/audio_processing/aec3/echo_canceller3.cc
@@ -14,12 +14,12 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" #include "api/audio/neural_residual_echo_estimator.h" @@ -45,7 +45,7 @@ enum class EchoCanceller3ApiCall { kCapture, kRender }; -bool DetectSaturation(ArrayView<const float> y) { +bool DetectSaturation(std::span<const float> y) { for (size_t k = 0; k < y.size(); ++k) { if (y[k] >= 32700.0f || y[k] <= -32700.0f) { return true; @@ -102,14 +102,14 @@ void FillSubFrameView( AudioBuffer* frame, size_t sub_frame_index, - std::vector<std::vector<ArrayView<float>>>* sub_frame_view) { + std::vector<std::vector<std::span<float>>>* sub_frame_view) { RTC_DCHECK_GE(1, sub_frame_index); RTC_DCHECK_LE(0, sub_frame_index); RTC_DCHECK_EQ(frame->num_bands(), sub_frame_view->size()); RTC_DCHECK_EQ(frame->num_channels(), (*sub_frame_view)[0].size()); for (size_t band = 0; band < sub_frame_view->size(); ++band) { for (size_t channel = 0; channel < (*sub_frame_view)[0].size(); ++channel) { - (*sub_frame_view)[band][channel] = ArrayView<float>( + (*sub_frame_view)[band][channel] = std::span<float>( &frame->split_bands(channel)[band][sub_frame_index * kSubFrameLength], kSubFrameLength); } @@ -120,7 +120,7 @@ bool proper_downmix_needed, std::vector<std::vector<std::vector<float>>>* frame, size_t sub_frame_index, - std::vector<std::vector<ArrayView<float>>>* sub_frame_view) { + std::vector<std::vector<std::span<float>>>* sub_frame_view) { RTC_DCHECK_GE(1, sub_frame_index); RTC_DCHECK_EQ(frame->size(), sub_frame_view->size()); const size_t frame_num_channels = (*frame)[0].size(); @@ -148,7 +148,7 @@ } } for (size_t band = 0; band < frame->size(); ++band) { - (*sub_frame_view)[band][/*channel=*/0] = ArrayView<float>( + (*sub_frame_view)[band][/*channel=*/0] = std::span<float>( &(*frame)[band][/*channel=*/0][sub_frame_index * kSubFrameLength], kSubFrameLength); } @@ -156,7 +156,7 @@ RTC_DCHECK_EQ(frame_num_channels, sub_frame_num_channels); for (size_t band = 0; band < frame->size(); ++band) { for (size_t channel = 0; channel < (*frame)[band].size(); ++channel) { - (*sub_frame_view)[band][channel] = ArrayView<float>( + (*sub_frame_view)[band][channel] = std::span<float>( &(*frame)[band][channel][sub_frame_index * kSubFrameLength], kSubFrameLength); } @@ -176,9 +176,9 @@ BlockFramer* output_framer, BlockProcessor* block_processor, Block* linear_output_block, - std::vector<std::vector<ArrayView<float>>>* linear_output_sub_frame_view, + std::vector<std::vector<std::span<float>>>* linear_output_sub_frame_view, Block* capture_block, - std::vector<std::vector<ArrayView<float>>>* capture_sub_frame_view) { + std::vector<std::vector<std::span<float>>>* capture_sub_frame_view) { FillSubFrameView(capture, sub_frame_index, capture_sub_frame_view); if (linear_output) { @@ -238,7 +238,7 @@ FrameBlocker* render_blocker, BlockProcessor* block_processor, Block* block, - std::vector<std::vector<ArrayView<float>>>* sub_frame_view) { + std::vector<std::vector<std::span<float>>>* sub_frame_view) { FillSubFrameView(proper_downmix_needed, render_frame, sub_frame_index, sub_frame_view); render_blocker->InsertSubFrameAndExtractBlock(*sub_frame_view, block); @@ -264,7 +264,7 @@ RTC_DCHECK_EQ(AudioBuffer::kSplitBandSize, (*frame)[0][0].size()); for (size_t band = 0; band < num_bands; ++band) { for (size_t channel = 0; channel < num_channels; ++channel) { - ArrayView<const float> buffer_view( + std::span<const float> buffer_view( &buffer.split_bands_const(channel)[band][0], AudioBuffer::kSplitBandSize); std::copy(buffer_view.begin(), buffer_view.end(), @@ -790,7 +790,7 @@ capture_block_(num_bands_, num_capture_channels_), capture_sub_frame_view_( num_bands_, - std::vector<ArrayView<float>>(num_capture_channels_)) { + std::vector<std::span<float>>(num_capture_channels_)) { RTC_DCHECK(ValidFullBandRate(sample_rate_hz_)); if (config_selector_.active_config().delay.fixed_capture_delay_samples > 0) { @@ -811,8 +811,8 @@ new BlockFramer(/*num_bands=*/1, num_capture_channels_)); linear_output_block_ = std::make_unique<Block>(/*num_bands=*/1, num_capture_channels_); - linear_output_sub_frame_view_ = std::vector<std::vector<ArrayView<float>>>( - 1, std::vector<ArrayView<float>>(num_capture_channels_)); + linear_output_sub_frame_view_ = std::vector<std::vector<std::span<float>>>( + 1, std::vector<std::span<float>>(num_capture_channels_)); } Initialize(); @@ -845,8 +845,8 @@ num_render_channels_to_aec_, num_capture_channels_, neural_residual_echo_estimator_); - render_sub_frame_view_ = std::vector<std::vector<ArrayView<float>>>( - num_bands_, std::vector<ArrayView<float>>(num_render_channels_to_aec_)); + render_sub_frame_view_ = std::vector<std::vector<std::span<float>>>( + num_bands_, std::vector<std::span<float>>(num_render_channels_to_aec_)); } void EchoCanceller3::AnalyzeRender(const AudioBuffer& render) { @@ -865,7 +865,7 @@ capture.channels_const()[0], sample_rate_hz_, 1); saturated_microphone_signal_ = false; for (size_t channel = 0; channel < capture.num_channels(); ++channel) { - saturated_microphone_signal_ |= DetectSaturation(ArrayView<const float>( + saturated_microphone_signal_ |= DetectSaturation(std::span<const float>( capture.channels_const()[channel], capture.num_frames())); if (saturated_microphone_signal_) { break; @@ -904,7 +904,7 @@ block_delay_buffer_->DelaySignal(capture); } - ArrayView<float> capture_lower_band = ArrayView<float>( + std::span<float> capture_lower_band = std::span<float>( &capture->split_bands(0)[0][0], AudioBuffer::kSplitBandSize); data_dumper_->DumpWav("aec3_capture_input", capture_lower_band, 16000, 1);
diff --git a/modules/audio_processing/aec3/echo_canceller3.h b/modules/audio_processing/aec3/echo_canceller3.h index 9005cc0..e12ee0a 100644 --- a/modules/audio_processing/aec3/echo_canceller3.h +++ b/modules/audio_processing/aec3/echo_canceller3.h
@@ -16,9 +16,9 @@ #include <atomic> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" #include "api/audio/neural_residual_echo_estimator.h" @@ -220,11 +220,11 @@ std::unique_ptr<Block> linear_output_block_ RTC_GUARDED_BY(capture_race_checker_); Block capture_block_ RTC_GUARDED_BY(capture_race_checker_); - std::vector<std::vector<ArrayView<float>>> render_sub_frame_view_ + std::vector<std::vector<std::span<float>>> render_sub_frame_view_ RTC_GUARDED_BY(capture_race_checker_); - std::vector<std::vector<ArrayView<float>>> linear_output_sub_frame_view_ + std::vector<std::vector<std::span<float>>> linear_output_sub_frame_view_ RTC_GUARDED_BY(capture_race_checker_); - std::vector<std::vector<ArrayView<float>>> capture_sub_frame_view_ + std::vector<std::vector<std::span<float>>> capture_sub_frame_view_ RTC_GUARDED_BY(capture_race_checker_); std::unique_ptr<BlockDelayBuffer> block_delay_buffer_ RTC_GUARDED_BY(capture_race_checker_);
diff --git a/modules/audio_processing/aec3/echo_canceller3_unittest.cc b/modules/audio_processing/aec3/echo_canceller3_unittest.cc index 01f0a6e..69d71ad 100644 --- a/modules/audio_processing/aec3/echo_canceller3_unittest.cc +++ b/modules/audio_processing/aec3/echo_canceller3_unittest.cc
@@ -16,11 +16,11 @@ #include <deque> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" #include "api/audio/neural_residual_echo_estimator.h" @@ -100,8 +100,8 @@ return true; } -bool VerifyOutputFrameBitexactness(ArrayView<const float> reference, - ArrayView<const float> frame, +bool VerifyOutputFrameBitexactness(std::span<const float> reference, + std::span<const float> frame, int offset) { for (size_t k = 0; k < frame.size(); ++k) { int reference_index = static_cast<int>(k) + offset; @@ -200,10 +200,10 @@ EchoCanceller3& aec3, float channel_0_value, float channel_1_value) { - ArrayView<float> data_channel_0(&buffer.channels()[0][0], + std::span<float> data_channel_0(&buffer.channels()[0][0], buffer.num_frames()); std::fill(data_channel_0.begin(), data_channel_0.end(), channel_0_value); - ArrayView<float> data_channel_1(&buffer.channels()[1][0], + std::span<float> data_channel_1(&buffer.channels()[1][0], buffer.num_frames()); std::fill(data_channel_1.begin(), data_channel_1.end(), channel_1_value); aec3.AnalyzeRender(&buffer); @@ -214,7 +214,7 @@ void RunAecInSMono(AudioBuffer& buffer, EchoCanceller3& aec3, float channel_0_value) { - ArrayView<float> data_channel_0(&buffer.channels()[0][0], + std::span<float> data_channel_0(&buffer.channels()[0][0], buffer.num_frames()); std::fill(data_channel_0.begin(), data_channel_0.end(), channel_0_value); aec3.AnalyzeRender(&buffer); @@ -1171,14 +1171,14 @@ NeuralResidualEchoEstimatorMock() {} void Estimate(const Block& render, - ArrayView<const std::array<float, 64>> capture, - ArrayView<const std::array<float, 64>> linear_aec_output, - ArrayView<const std::array<float, 65>> S2_linear, - ArrayView<const std::array<float, 65>> Y2, - ArrayView<const std::array<float, 65>> E2, + std::span<const std::array<float, 64>> capture, + std::span<const std::array<float, 64>> linear_aec_output, + std::span<const std::array<float, 65>> S2_linear, + std::span<const std::array<float, 65>> Y2, + std::span<const std::array<float, 65>> E2, bool dominant_nearend, - ArrayView<std::array<float, 65>> R2, - ArrayView<std::array<float, 65>> R2_unbounded) override { + std::span<std::array<float, 65>> R2, + std::span<std::array<float, 65>> R2_unbounded) override { residual_echo_estimate_requested_ = true; for (auto& R2_ch : R2) { R2_ch.fill(0.0f);
diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator.cc b/modules/audio_processing/aec3/echo_path_delay_estimator.cc index 30b6689..db238d8 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator.cc +++ b/modules/audio_processing/aec3/echo_path_delay_estimator.cc
@@ -12,8 +12,8 @@ #include <array> #include <cstddef> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" @@ -67,7 +67,7 @@ const DownsampledRenderBuffer& render_buffer, const Block& capture) { std::array<float, kBlockSize> downsampled_capture_data; - ArrayView<float> downsampled_capture(downsampled_capture_data.data(), + std::span<float> downsampled_capture(downsampled_capture_data.data(), sub_block_size_); std::array<float, kBlockSize> downmixed_capture;
diff --git a/modules/audio_processing/aec3/echo_remover.cc b/modules/audio_processing/aec3/echo_remover.cc index b6f3a7b..0d3e1d1 100644 --- a/modules/audio_processing/aec3/echo_remover.cc +++ b/modules/audio_processing/aec3/echo_remover.cc
@@ -16,9 +16,9 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" #include "api/audio/neural_residual_echo_estimator.h" @@ -74,9 +74,9 @@ } // Fades between two input signals using a fix-sized transition. -void SignalTransition(ArrayView<const float> from, - ArrayView<const float> to, - ArrayView<float> out) { +void SignalTransition(std::span<const float> from, + std::span<const float> to, + std::span<float> out) { RTC_DCHECK_EQ(from.size(), to.size()); RTC_DCHECK_EQ(from.size(), out.size()); if (from.data() == to.data()) { @@ -100,8 +100,8 @@ // Computes a windowed (square root Hanning) padded FFT and updates the related // memory. void WindowedPaddedFft(const Aec3Fft& fft, - ArrayView<const float> v, - ArrayView<float> v_old, + std::span<const float> v, + std::span<float> v_old, FftData* V) { fft.PaddedFft(v, v_old, Aec3Fft::Window::kSqrtHanning, V); std::copy(v.begin(), v.end(), v_old.begin()); @@ -134,7 +134,7 @@ void FormLinearFilterOutput(bool refined_filter_output_last_selected, bool use_refined_output, const SubtractorOutput& subtractor_output, - ArrayView<float> output) { + std::span<float> output) { RTC_DCHECK_EQ(subtractor_output.e_refined.size(), output.size()); RTC_DCHECK_EQ(subtractor_output.e_coarse.size(), output.size()); @@ -318,48 +318,48 @@ std::array<FftData, kMaxNumChannelsOnStack> high_band_comfort_noise_stack; std::array<SubtractorOutput, kMaxNumChannelsOnStack> subtractor_output_stack; - ArrayView<std::array<float, kFftLengthBy2>> e(e_stack.data(), + std::span<std::array<float, kFftLengthBy2>> e(e_stack.data(), num_capture_channels_); - ArrayView<std::array<float, kFftLengthBy2Plus1>> Y2(Y2_stack.data(), + std::span<std::array<float, kFftLengthBy2Plus1>> Y2(Y2_stack.data(), num_capture_channels_); - ArrayView<std::array<float, kFftLengthBy2Plus1>> E2(E2_stack.data(), + std::span<std::array<float, kFftLengthBy2Plus1>> E2(E2_stack.data(), num_capture_channels_); - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2(R2_stack.data(), + std::span<std::array<float, kFftLengthBy2Plus1>> R2(R2_stack.data(), num_capture_channels_); - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2_unbounded( + std::span<std::array<float, kFftLengthBy2Plus1>> R2_unbounded( R2_unbounded_stack.data(), num_capture_channels_); - ArrayView<std::array<float, kFftLengthBy2Plus1>> S2_linear( + std::span<std::array<float, kFftLengthBy2Plus1>> S2_linear( S2_linear_stack.data(), num_capture_channels_); - ArrayView<FftData> Y(Y_stack.data(), num_capture_channels_); - ArrayView<FftData> E(E_stack.data(), num_capture_channels_); - ArrayView<FftData> comfort_noise(comfort_noise_stack.data(), + std::span<FftData> Y(Y_stack.data(), num_capture_channels_); + std::span<FftData> E(E_stack.data(), num_capture_channels_); + std::span<FftData> comfort_noise(comfort_noise_stack.data(), num_capture_channels_); - ArrayView<FftData> high_band_comfort_noise( + std::span<FftData> high_band_comfort_noise( high_band_comfort_noise_stack.data(), num_capture_channels_); - ArrayView<SubtractorOutput> subtractor_output(subtractor_output_stack.data(), + std::span<SubtractorOutput> subtractor_output(subtractor_output_stack.data(), num_capture_channels_); if (NumChannelsOnHeap(num_capture_channels_) > 0) { // If the stack-allocated space is too small, use the heap for storing the // microphone data. - e = ArrayView<std::array<float, kFftLengthBy2>>(e_heap_.data(), + e = std::span<std::array<float, kFftLengthBy2>>(e_heap_.data(), num_capture_channels_); - Y2 = ArrayView<std::array<float, kFftLengthBy2Plus1>>( + Y2 = std::span<std::array<float, kFftLengthBy2Plus1>>( Y2_heap_.data(), num_capture_channels_); - E2 = ArrayView<std::array<float, kFftLengthBy2Plus1>>( + E2 = std::span<std::array<float, kFftLengthBy2Plus1>>( E2_heap_.data(), num_capture_channels_); - R2 = ArrayView<std::array<float, kFftLengthBy2Plus1>>( + R2 = std::span<std::array<float, kFftLengthBy2Plus1>>( R2_heap_.data(), num_capture_channels_); - R2_unbounded = ArrayView<std::array<float, kFftLengthBy2Plus1>>( + R2_unbounded = std::span<std::array<float, kFftLengthBy2Plus1>>( R2_unbounded_heap_.data(), num_capture_channels_); - S2_linear = ArrayView<std::array<float, kFftLengthBy2Plus1>>( + S2_linear = std::span<std::array<float, kFftLengthBy2Plus1>>( S2_linear_heap_.data(), num_capture_channels_); - Y = ArrayView<FftData>(Y_heap_.data(), num_capture_channels_); - E = ArrayView<FftData>(E_heap_.data(), num_capture_channels_); + Y = std::span<FftData>(Y_heap_.data(), num_capture_channels_); + E = std::span<FftData>(E_heap_.data(), num_capture_channels_); comfort_noise = - ArrayView<FftData>(comfort_noise_heap_.data(), num_capture_channels_); - high_band_comfort_noise = ArrayView<FftData>( + std::span<FftData>(comfort_noise_heap_.data(), num_capture_channels_); + high_band_comfort_noise = std::span<FftData>( high_band_comfort_noise_heap_.data(), num_capture_channels_); - subtractor_output = ArrayView<SubtractorOutput>( + subtractor_output = std::span<SubtractorOutput>( subtractor_output_heap_.data(), num_capture_channels_); }
diff --git a/modules/audio_processing/aec3/erl_estimator.cc b/modules/audio_processing/aec3/erl_estimator.cc index 2bf6ee9..d5894cf 100644 --- a/modules/audio_processing/aec3/erl_estimator.cc +++ b/modules/audio_processing/aec3/erl_estimator.cc
@@ -15,9 +15,9 @@ #include <cstddef> #include <iterator> #include <numeric> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" @@ -46,8 +46,8 @@ void ErlEstimator::Update( const std::vector<bool>& converged_filters, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> render_spectra, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> capture_spectra) { + std::span<const std::array<float, kFftLengthBy2Plus1>> render_spectra, + std::span<const std::array<float, kFftLengthBy2Plus1>> capture_spectra) { const size_t num_capture_channels = converged_filters.size(); RTC_DCHECK_EQ(capture_spectra.size(), num_capture_channels); @@ -90,7 +90,7 @@ const size_t num_render_channels = render_spectra.size(); std::array<float, kFftLengthBy2Plus1> max_render_spectrum_data; - ArrayView<const float, kFftLengthBy2Plus1> max_render_spectrum = + std::span<const float, kFftLengthBy2Plus1> max_render_spectrum = render_spectra[/*channel=*/0]; if (num_render_channels > 1) { std::copy(render_spectra[0].begin(), render_spectra[0].end(),
diff --git a/modules/audio_processing/aec3/erl_estimator.h b/modules/audio_processing/aec3/erl_estimator.h index b793dde..2b2ab43 100644 --- a/modules/audio_processing/aec3/erl_estimator.h +++ b/modules/audio_processing/aec3/erl_estimator.h
@@ -14,9 +14,9 @@ #include <stddef.h> #include <array> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" namespace webrtc { @@ -36,8 +36,8 @@ // Updates the ERL estimate. void Update( const std::vector<bool>& converged_filters, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> render_spectra, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> capture_spectra); + std::span<const std::array<float, kFftLengthBy2Plus1>> render_spectra, + std::span<const std::array<float, kFftLengthBy2Plus1>> capture_spectra); // Returns the most recent ERL estimate. const std::array<float, kFftLengthBy2Plus1>& Erl() const { return erl_; }
diff --git a/modules/audio_processing/aec3/erle_estimator.cc b/modules/audio_processing/aec3/erle_estimator.cc index 15de377..206103e 100644 --- a/modules/audio_processing/aec3/erle_estimator.cc +++ b/modules/audio_processing/aec3/erle_estimator.cc
@@ -13,9 +13,9 @@ #include <array> #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -56,11 +56,11 @@ void ErleEstimator::Update( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_responses, - ArrayView<const float, kFftLengthBy2Plus1> avg_render_spectrum_with_reverb, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> capture_spectra, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> subtractor_spectra, + std::span<const float, kFftLengthBy2Plus1> avg_render_spectrum_with_reverb, + std::span<const std::array<float, kFftLengthBy2Plus1>> capture_spectra, + std::span<const std::array<float, kFftLengthBy2Plus1>> subtractor_spectra, const std::vector<bool>& converged_filters) { RTC_DCHECK_EQ(subband_erle_estimator_.Erle(/*onset_compensated=*/true).size(), capture_spectra.size());
diff --git a/modules/audio_processing/aec3/erle_estimator.h b/modules/audio_processing/aec3/erle_estimator.h index fe6e71a..fb27510 100644 --- a/modules/audio_processing/aec3/erle_estimator.h +++ b/modules/audio_processing/aec3/erle_estimator.h
@@ -16,9 +16,9 @@ #include <array> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -46,16 +46,16 @@ // Updates the ERLE estimates. void Update( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_responses, - ArrayView<const float, kFftLengthBy2Plus1> + std::span<const float, kFftLengthBy2Plus1> avg_render_spectrum_with_reverb, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> capture_spectra, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> subtractor_spectra, + std::span<const std::array<float, kFftLengthBy2Plus1>> capture_spectra, + std::span<const std::array<float, kFftLengthBy2Plus1>> subtractor_spectra, const std::vector<bool>& converged_filters); // Returns the most recent subband ERLE estimates. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Erle( + std::span<const std::array<float, kFftLengthBy2Plus1>> Erle( bool onset_compensated) const { return signal_dependent_erle_estimator_ ? signal_dependent_erle_estimator_->Erle(onset_compensated) @@ -63,7 +63,7 @@ } // Returns the non-capped subband ERLE. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> ErleUnbounded() const { + std::span<const std::array<float, kFftLengthBy2Plus1>> ErleUnbounded() const { // Unbounded ERLE is only used with the subband erle estimator where the // ERLE is often capped at low values. When the signal dependent ERLE // estimator is used the capped ERLE is returned. @@ -75,7 +75,7 @@ // Returns the subband ERLE that are estimated during onsets (only used for // testing). - ArrayView<const std::array<float, kFftLengthBy2Plus1>> ErleDuringOnsets() + std::span<const std::array<float, kFftLengthBy2Plus1>> ErleDuringOnsets() const { return subband_erle_estimator_.ErleDuringOnsets(); } @@ -90,7 +90,7 @@ // vector with content between 0 and 1 where 1 indicates that, at this current // time instant, the linear filter is reaching its maximum subtraction // performance. - ArrayView<const std::optional<float>> GetInstLinearQualityEstimates() const { + std::span<const std::optional<float>> GetInstLinearQualityEstimates() const { return fullband_erle_estimator_.GetInstLinearQualityEstimates(); }
diff --git a/modules/audio_processing/aec3/erle_estimator_unittest.cc b/modules/audio_processing/aec3/erle_estimator_unittest.cc index ce75cfc..a649738 100644 --- a/modules/audio_processing/aec3/erle_estimator_unittest.cc +++ b/modules/audio_processing/aec3/erle_estimator_unittest.cc
@@ -15,10 +15,10 @@ #include <cmath> #include <cstddef> #include <memory> +#include <span> #include <tuple> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment_factory.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -38,7 +38,7 @@ constexpr float kEchoPathGain = 3.f; void VerifyErleBands( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> erle, + std::span<const std::array<float, kFftLengthBy2Plus1>> erle, float reference_lf, float reference_hf) { for (size_t ch = 0; ch < erle.size(); ++ch) { @@ -51,7 +51,7 @@ } } -void VerifyErle(ArrayView<const std::array<float, kFftLengthBy2Plus1>> erle, +void VerifyErle(std::span<const std::array<float, kFftLengthBy2Plus1>> erle, float erle_time_domain, float reference_lf, float reference_hf) { @@ -60,8 +60,8 @@ } void VerifyErleGreaterOrEqual( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> erle1, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> erle2) { + std::span<const std::array<float, kFftLengthBy2Plus1>> erle1, + std::span<const std::array<float, kFftLengthBy2Plus1>> erle2) { for (size_t ch = 0; ch < erle1.size(); ++ch) { for (size_t i = 0; i < kFftLengthBy2Plus1; ++i) { EXPECT_GE(erle1[ch][i], erle2[ch][i]); @@ -90,8 +90,8 @@ void FormFarendFrame(const RenderBuffer& render_buffer, float erle, std::array<float, kFftLengthBy2Plus1>* X2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> E2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> Y2) { + std::span<std::array<float, kFftLengthBy2Plus1>> E2, + std::span<std::array<float, kFftLengthBy2Plus1>> Y2) { const auto& spectrum_buffer = render_buffer.GetSpectrumBuffer(); const int num_render_channels = spectrum_buffer.buffer[0].size(); const int num_capture_channels = Y2.size(); @@ -114,8 +114,8 @@ void FormNearendFrame(Block* x, std::array<float, kFftLengthBy2Plus1>* X2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> E2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> Y2) { + std::span<std::array<float, kFftLengthBy2Plus1>> E2, + std::span<std::array<float, kFftLengthBy2Plus1>> Y2) { for (int band = 0; band < x->NumBands(); ++band) { for (int ch = 0; ch < x->NumChannels(); ++ch) { std::fill(x->begin(band, ch), x->end(band, ch), 0.f); @@ -130,7 +130,7 @@ } void GetFilterFreq(size_t delay_headroom_samples, - ArrayView<std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_response) { const size_t delay_headroom_blocks = delay_headroom_samples / kBlockSize; for (size_t ch = 0; ch < filter_frequency_response[0].size(); ++ch) {
diff --git a/modules/audio_processing/aec3/fft_data.h b/modules/audio_processing/aec3/fft_data.h index b227496..6bab8c9 100644 --- a/modules/audio_processing/aec3/fft_data.h +++ b/modules/audio_processing/aec3/fft_data.h
@@ -14,8 +14,8 @@ #include <algorithm> #include <array> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" @@ -43,11 +43,11 @@ } // Computes the power spectrum of the data. - void SpectrumAVX2(ArrayView<float> power_spectrum) const; + void SpectrumAVX2(std::span<float> power_spectrum) const; // Computes the power spectrum of the data. void Spectrum(Aec3Optimization optimization, - ArrayView<float> power_spectrum) const { + std::span<float> power_spectrum) const { RTC_DCHECK_EQ(kFftLengthBy2Plus1, power_spectrum.size()); switch (optimization) { #if defined(WEBRTC_ARCH_X86_FAMILY)
diff --git a/modules/audio_processing/aec3/fft_data_avx2.cc b/modules/audio_processing/aec3/fft_data_avx2.cc index eaa93c0..97c34df 100644 --- a/modules/audio_processing/aec3/fft_data_avx2.cc +++ b/modules/audio_processing/aec3/fft_data_avx2.cc
@@ -11,8 +11,8 @@ #include <immintrin.h> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" #include "rtc_base/checks.h" @@ -20,7 +20,7 @@ namespace webrtc { // Computes the power spectrum of the data. -void FftData::SpectrumAVX2(ArrayView<float> power_spectrum) const { +void FftData::SpectrumAVX2(std::span<float> power_spectrum) const { RTC_DCHECK_EQ(kFftLengthBy2Plus1, power_spectrum.size()); for (size_t k = 0; k < kFftLengthBy2; k += 8) { __m256 r = _mm256_loadu_ps(&re[k]);
diff --git a/modules/audio_processing/aec3/filter_analyzer.cc b/modules/audio_processing/aec3/filter_analyzer.cc index cf64737..e9445cf 100644 --- a/modules/audio_processing/aec3/filter_analyzer.cc +++ b/modules/audio_processing/aec3/filter_analyzer.cc
@@ -16,9 +16,9 @@ #include <cmath> #include <cstddef> #include <numeric> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" @@ -29,7 +29,7 @@ namespace webrtc { namespace { -size_t FindPeakIndex(ArrayView<const float> filter_time_domain, +size_t FindPeakIndex(std::span<const float> filter_time_domain, size_t peak_index_in, size_t start_sample, size_t end_sample) { @@ -78,7 +78,7 @@ } void FilterAnalyzer::Update( - ArrayView<const std::vector<float>> filters_time_domain, + std::span<const std::vector<float>> filters_time_domain, const RenderBuffer& render_buffer, bool* any_filter_consistent, float* max_echo_path_gain) { @@ -107,7 +107,7 @@ } void FilterAnalyzer::AnalyzeRegion( - ArrayView<const std::vector<float>> filters_time_domain, + std::span<const std::vector<float>> filters_time_domain, const RenderBuffer& render_buffer) { // Preprocess the filter to avoid issues with low-frequency components in the // filter. @@ -139,7 +139,7 @@ } } -void FilterAnalyzer::UpdateFilterGain(ArrayView<const float> filter_time_domain, +void FilterAnalyzer::UpdateFilterGain(std::span<const float> filter_time_domain, FilterAnalysisState* st) { bool sufficient_time_to_converge = blocks_since_reset_ > 5 * kNumBlocksPerSecond; @@ -159,7 +159,7 @@ } void FilterAnalyzer::PreProcessFilters( - ArrayView<const std::vector<float>> filters_time_domain) { + std::span<const std::vector<float>> filters_time_domain) { for (size_t ch = 0; ch < filters_time_domain.size(); ++ch) { RTC_DCHECK_LT(region_.start_sample_, filters_time_domain[ch].size()); RTC_DCHECK_LT(region_.end_sample_, filters_time_domain[ch].size()); @@ -224,7 +224,7 @@ } bool FilterAnalyzer::ConsistentFilterDetector::Detect( - ArrayView<const float> filter_to_analyze, + std::span<const float> filter_to_analyze, const FilterRegion& region, const Block& x_block, size_t peak_index, @@ -268,7 +268,7 @@ if (significant_peak_) { bool active_render_block = false; for (int ch = 0; ch < x_block.NumChannels(); ++ch) { - ArrayView<const float, kBlockSize> x_channel = + std::span<const float, kBlockSize> x_channel = x_block.View(/*band=*/0, ch); const float x_energy = std::inner_product( x_channel.begin(), x_channel.end(), x_channel.begin(), 0.f);
diff --git a/modules/audio_processing/aec3/filter_analyzer.h b/modules/audio_processing/aec3/filter_analyzer.h index 83c4865..28c7912 100644 --- a/modules/audio_processing/aec3/filter_analyzer.h +++ b/modules/audio_processing/aec3/filter_analyzer.h
@@ -15,9 +15,9 @@ #include <atomic> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/block.h" @@ -40,13 +40,13 @@ void Reset(); // Updates the estimates with new input data. - void Update(ArrayView<const std::vector<float>> filters_time_domain, + void Update(std::span<const std::vector<float>> filters_time_domain, const RenderBuffer& render_buffer, bool* any_filter_consistent, float* max_echo_path_gain); // Returns the delay in blocks for each filter. - ArrayView<const int> FilterDelaysBlocks() const { + std::span<const int> FilterDelaysBlocks() const { return filter_delays_blocks_; } @@ -59,7 +59,7 @@ } // Returns the preprocessed filter. - ArrayView<const std::vector<float>> GetAdjustedFilters() const { + std::span<const std::vector<float>> GetAdjustedFilters() const { return h_highpass_; } @@ -69,13 +69,13 @@ private: struct FilterAnalysisState; - void AnalyzeRegion(ArrayView<const std::vector<float>> filters_time_domain, + void AnalyzeRegion(std::span<const std::vector<float>> filters_time_domain, const RenderBuffer& render_buffer); - void UpdateFilterGain(ArrayView<const float> filters_time_domain, + void UpdateFilterGain(std::span<const float> filters_time_domain, FilterAnalysisState* st); void PreProcessFilters( - ArrayView<const std::vector<float>> filters_time_domain); + std::span<const std::vector<float>> filters_time_domain); void ResetRegion(); @@ -90,7 +90,7 @@ public: explicit ConsistentFilterDetector(const EchoCanceller3Config& config); void Reset(); - bool Detect(ArrayView<const float> filter_to_analyze, + bool Detect(std::span<const float> filter_to_analyze, const FilterRegion& region, const Block& x_block, size_t peak_index,
diff --git a/modules/audio_processing/aec3/frame_blocker.cc b/modules/audio_processing/aec3/frame_blocker.cc index 97246e1..2b93e7a 100644 --- a/modules/audio_processing/aec3/frame_blocker.cc +++ b/modules/audio_processing/aec3/frame_blocker.cc
@@ -12,9 +12,9 @@ #include <algorithm> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "rtc_base/checks.h" @@ -38,7 +38,7 @@ FrameBlocker::~FrameBlocker() = default; void FrameBlocker::InsertSubFrameAndExtractBlock( - const std::vector<std::vector<ArrayView<float>>>& sub_frame, + const std::vector<std::vector<std::span<float>>>& sub_frame, Block* block) { RTC_DCHECK(block); RTC_DCHECK_EQ(num_bands_, block->NumBands());
diff --git a/modules/audio_processing/aec3/frame_blocker.h b/modules/audio_processing/aec3/frame_blocker.h index f9dd88b..f035fed 100644 --- a/modules/audio_processing/aec3/frame_blocker.h +++ b/modules/audio_processing/aec3/frame_blocker.h
@@ -13,9 +13,9 @@ #include <stddef.h> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/block.h" namespace webrtc { @@ -32,7 +32,7 @@ // Inserts one 80 sample multiband subframe from the multiband frame and // extracts one 64 sample multiband block. void InsertSubFrameAndExtractBlock( - const std::vector<std::vector<ArrayView<float>>>& sub_frame, + const std::vector<std::vector<std::span<float>>>& sub_frame, Block* block); // Reports whether a multiband block of 64 samples is available for // extraction.
diff --git a/modules/audio_processing/aec3/frame_blocker_unittest.cc b/modules/audio_processing/aec3/frame_blocker_unittest.cc index d32cd80..eadfe71 100644 --- a/modules/audio_processing/aec3/frame_blocker_unittest.cc +++ b/modules/audio_processing/aec3/frame_blocker_unittest.cc
@@ -11,10 +11,10 @@ #include "modules/audio_processing/aec3/frame_blocker.h" #include <cstddef> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "modules/audio_processing/aec3/block_framer.h" @@ -55,12 +55,12 @@ size_t sub_frame_counter, int offset, std::vector<std::vector<std::vector<float>>>* sub_frame, - std::vector<std::vector<ArrayView<float>>>* sub_frame_view) { + std::vector<std::vector<std::span<float>>>* sub_frame_view) { FillSubFrame(sub_frame_counter, offset, sub_frame); for (size_t band = 0; band < sub_frame_view->size(); ++band) { for (size_t channel = 0; channel < (*sub_frame_view)[band].size(); ++channel) { - (*sub_frame_view)[band][channel] = ArrayView<float>( + (*sub_frame_view)[band][channel] = std::span<float>( &(*sub_frame)[band][channel][0], (*sub_frame)[band][channel].size()); } } @@ -69,7 +69,7 @@ bool VerifySubFrame( size_t sub_frame_counter, int offset, - const std::vector<std::vector<ArrayView<float>>>& sub_frame_view) { + const std::vector<std::vector<std::span<float>>>& sub_frame_view) { std::vector<std::vector<std::vector<float>>> reference_sub_frame( sub_frame_view.size(), std::vector<std::vector<float>>( @@ -115,8 +115,8 @@ std::vector<std::vector<std::vector<float>>> input_sub_frame( num_bands, std::vector<std::vector<float>>( num_channels, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> input_sub_frame_view( - num_bands, std::vector<ArrayView<float>>(num_channels)); + std::vector<std::vector<std::span<float>>> input_sub_frame_view( + num_bands, std::vector<std::span<float>>(num_channels)); FrameBlocker blocker(num_bands, num_channels); size_t block_counter = 0; @@ -153,10 +153,10 @@ std::vector<std::vector<std::vector<float>>> output_sub_frame( num_bands, std::vector<std::vector<float>>( num_channels, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> output_sub_frame_view( - num_bands, std::vector<ArrayView<float>>(num_channels)); - std::vector<std::vector<ArrayView<float>>> input_sub_frame_view( - num_bands, std::vector<ArrayView<float>>(num_channels)); + std::vector<std::vector<std::span<float>>> output_sub_frame_view( + num_bands, std::vector<std::span<float>>(num_channels)); + std::vector<std::vector<std::span<float>>> input_sub_frame_view( + num_bands, std::vector<std::span<float>>(num_channels)); FrameBlocker blocker(num_bands, num_channels); BlockFramer framer(num_bands, num_channels); @@ -203,9 +203,9 @@ num_sub_frame_bands, std::vector<std::vector<float>>( num_sub_frame_channels, std::vector<float>(sub_frame_length, 0.f))); - std::vector<std::vector<ArrayView<float>>> input_sub_frame_view( + std::vector<std::vector<std::span<float>>> input_sub_frame_view( input_sub_frame.size(), - std::vector<ArrayView<float>>(num_sub_frame_channels)); + std::vector<std::span<float>>(num_sub_frame_channels)); FillSubFrameView(0, 0, &input_sub_frame, &input_sub_frame_view); FrameBlocker blocker(correct_num_bands, correct_num_channels); EXPECT_DEATH( @@ -226,9 +226,9 @@ correct_num_bands, std::vector<std::vector<float>>( correct_num_channels, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> input_sub_frame_view( + std::vector<std::vector<std::span<float>>> input_sub_frame_view( input_sub_frame.size(), - std::vector<ArrayView<float>>(correct_num_channels)); + std::vector<std::span<float>>(correct_num_channels)); FillSubFrameView(0, 0, &input_sub_frame, &input_sub_frame_view); FrameBlocker blocker(correct_num_bands, correct_num_channels); blocker.InsertSubFrameAndExtractBlock(input_sub_frame_view, &correct_block); @@ -251,8 +251,8 @@ std::vector<std::vector<std::vector<float>>> input_sub_frame( num_bands, std::vector<std::vector<float>>( num_channels, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> input_sub_frame_view( - input_sub_frame.size(), std::vector<ArrayView<float>>(num_channels)); + std::vector<std::vector<std::span<float>>> input_sub_frame_view( + input_sub_frame.size(), std::vector<std::span<float>>(num_channels)); FillSubFrameView(0, 0, &input_sub_frame, &input_sub_frame_view); FrameBlocker blocker(num_bands, num_channels); for (size_t k = 0; k < num_preceeding_api_calls; ++k) { @@ -398,7 +398,7 @@ std::vector<std::vector<std::vector<float>>> sub_frame( 1, std::vector<std::vector<float>>( 1, std::vector<float>(kSubFrameLength, 0.f))); - std::vector<std::vector<ArrayView<float>>> sub_frame_view(sub_frame.size()); + std::vector<std::vector<std::span<float>>> sub_frame_view(sub_frame.size()); FillSubFrameView(0, 0, &sub_frame, &sub_frame_view); EXPECT_DEATH( FrameBlocker(1, 1).InsertSubFrameAndExtractBlock(sub_frame_view, nullptr),
diff --git a/modules/audio_processing/aec3/fullband_erle_estimator.cc b/modules/audio_processing/aec3/fullband_erle_estimator.cc index 07acfa9..e31ec29 100644 --- a/modules/audio_processing/aec3/fullband_erle_estimator.cc +++ b/modules/audio_processing/aec3/fullband_erle_estimator.cc
@@ -16,9 +16,9 @@ #include <memory> #include <numeric> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -60,9 +60,9 @@ } void FullBandErleEstimator::Update( - ArrayView<const float> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const float> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters) { for (size_t ch = 0; ch < Y2.size(); ++ch) { if (converged_filters[ch]) {
diff --git a/modules/audio_processing/aec3/fullband_erle_estimator.h b/modules/audio_processing/aec3/fullband_erle_estimator.h index bb710c9..17af958 100644 --- a/modules/audio_processing/aec3/fullband_erle_estimator.h +++ b/modules/audio_processing/aec3/fullband_erle_estimator.h
@@ -16,9 +16,9 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -36,9 +36,9 @@ void Reset(); // Updates the ERLE estimator. - void Update(ArrayView<const float> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + void Update(std::span<const float> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters); // Returns the fullband ERLE estimates in log2 units. @@ -52,7 +52,7 @@ // Returns an estimation of the current linear filter quality. It returns a // float number between 0 and 1 mapping 1 to the highest possible quality. - ArrayView<const std::optional<float>> GetInstLinearQualityEstimates() const { + std::span<const std::optional<float>> GetInstLinearQualityEstimates() const { return linear_filters_qualities_; }
diff --git a/modules/audio_processing/aec3/matched_filter.cc b/modules/audio_processing/aec3/matched_filter.cc index 5c86e27..961d8a8 100644 --- a/modules/audio_processing/aec3/matched_filter.cc +++ b/modules/audio_processing/aec3/matched_filter.cc
@@ -25,8 +25,8 @@ #include <cstddef> #include <initializer_list> #include <optional> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -43,8 +43,8 @@ constexpr int kAccumulatedErrorSubSampleRate = 4; void UpdateAccumulatedError( - const ArrayView<const float> instantaneous_accumulated_error, - const ArrayView<float> accumulated_error, + const std::span<const float> instantaneous_accumulated_error, + const std::span<float> accumulated_error, float one_over_error_sum_anchor) { static constexpr float kSmoothConstantIncreases = 0.015f; for (size_t k = 0; k < instantaneous_accumulated_error.size(); ++k) { @@ -59,7 +59,7 @@ } } -size_t ComputePreEchoLag(const ArrayView<const float> accumulated_error, +size_t ComputePreEchoLag(const std::span<const float> accumulated_error, size_t lag, size_t alignment_shift_winner) { static constexpr float kPreEchoThreshold = 0.5f; @@ -93,13 +93,13 @@ size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory) { + std::span<float> accumulated_error, + std::span<float> scratch_memory) { const int h_size = static_cast<int>(h.size()); const int x_size = static_cast<int>(x.size()); RTC_DCHECK_EQ(0, h_size % 4); @@ -173,14 +173,14 @@ void MatchedFilterCore_NEON(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulated_error, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory) { + std::span<float> accumulated_error, + std::span<float> scratch_memory) { const int h_size = static_cast<int>(h.size()); const int x_size = static_cast<int>(x.size()); RTC_DCHECK_EQ(0, h_size % 4); @@ -290,13 +290,13 @@ void MatchedFilterCore_AccumulatedError_SSE2(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory) { + std::span<float> accumulated_error, + std::span<float> scratch_memory) { const int h_size = static_cast<int>(h.size()); const int x_size = static_cast<int>(x.size()); RTC_DCHECK_EQ(0, h_size % 8); @@ -386,14 +386,14 @@ void MatchedFilterCore_SSE2(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulated_error, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory) { + std::span<float> accumulated_error, + std::span<float> scratch_memory) { if (compute_accumulated_error) { return MatchedFilterCore_AccumulatedError_SSE2( x_start_index, x2_sum_threshold, smoothing, x, y, h, filters_updated, @@ -498,13 +498,13 @@ void MatchedFilterCore(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulated_error, - ArrayView<float> accumulated_error) { + std::span<float> accumulated_error) { if (compute_accumulated_error) { std::fill(accumulated_error.begin(), accumulated_error.end(), 0.0f); } @@ -556,7 +556,7 @@ } } -size_t MaxSquarePeakIndex(ArrayView<const float> h) { +size_t MaxSquarePeakIndex(std::span<const float> h) { if (h.size() < 2) { return 0; } @@ -656,7 +656,7 @@ } void MatchedFilter::Update(const DownsampledRenderBuffer& render_buffer, - ArrayView<const float> capture, + std::span<const float> capture, bool use_slow_smoothing) { RTC_DCHECK_EQ(sub_block_size_, capture.size()); auto& y = capture;
diff --git a/modules/audio_processing/aec3/matched_filter.h b/modules/audio_processing/aec3/matched_filter.h index 2a910b7..993670e 100644 --- a/modules/audio_processing/aec3/matched_filter.h +++ b/modules/audio_processing/aec3/matched_filter.h
@@ -14,9 +14,9 @@ #include <stddef.h> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/system/arch.h" @@ -33,14 +33,14 @@ void MatchedFilterCore_NEON(size_t x_start_index, float x2_sum_threshold, float smoothing, - webrtc::ArrayView<const float> x, - webrtc::ArrayView<const float> y, - webrtc::ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulation_error, - webrtc::ArrayView<float> accumulated_error, - webrtc::ArrayView<float> scratch_memory); + std::span<float> accumulated_error, + std::span<float> scratch_memory); #endif @@ -50,27 +50,27 @@ void MatchedFilterCore_SSE2(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulated_error, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory); + std::span<float> accumulated_error, + std::span<float> scratch_memory); // Filter core for the matched filter that is optimized for AVX2. void MatchedFilterCore_AVX2(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulated_error, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory); + std::span<float> accumulated_error, + std::span<float> scratch_memory); #endif @@ -78,16 +78,16 @@ void MatchedFilterCore(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulation_error, - ArrayView<float> accumulated_error); + std::span<float> accumulated_error); // Find largest peak of squared values in array. -size_t MaxSquarePeakIndex(ArrayView<const float> h); +size_t MaxSquarePeakIndex(std::span<const float> h); } // namespace aec3 @@ -125,7 +125,7 @@ // Updates the correlation with the values in the capture buffer. void Update(const DownsampledRenderBuffer& render_buffer, - ArrayView<const float> capture, + std::span<const float> capture, bool use_slow_smoothing); // Resets the matched filter.
diff --git a/modules/audio_processing/aec3/matched_filter_avx2.cc b/modules/audio_processing/aec3/matched_filter_avx2.cc index 1312c83..0b9360c 100644 --- a/modules/audio_processing/aec3/matched_filter_avx2.cc +++ b/modules/audio_processing/aec3/matched_filter_avx2.cc
@@ -12,8 +12,8 @@ #include <algorithm> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/matched_filter.h" #include "rtc_base/checks.h" @@ -35,13 +35,13 @@ void MatchedFilterCore_AccumulatedError_AVX2(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory) { + std::span<float> accumulated_error, + std::span<float> scratch_memory) { const int h_size = static_cast<int>(h.size()); const int x_size = static_cast<int>(x.size()); RTC_DCHECK_EQ(0, h_size % 16); @@ -141,14 +141,14 @@ void MatchedFilterCore_AVX2(size_t x_start_index, float x2_sum_threshold, float smoothing, - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> h, + std::span<const float> x, + std::span<const float> y, + std::span<float> h, bool* filters_updated, float* error_sum, bool compute_accumulated_error, - ArrayView<float> accumulated_error, - ArrayView<float> scratch_memory) { + std::span<float> accumulated_error, + std::span<float> scratch_memory) { if (compute_accumulated_error) { return MatchedFilterCore_AccumulatedError_AVX2( x_start_index, x2_sum_threshold, smoothing, x, y, h, filters_updated,
diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc index 4909182..51e5db8 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc
@@ -14,8 +14,8 @@ #include <iterator> #include <memory> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/delay_estimate.h" @@ -81,7 +81,7 @@ if (lag_estimate) { highest_peak_aggregator_.Aggregate( std::max(0, static_cast<int>(lag_estimate->lag) - headroom_)); - ArrayView<const int> histogram = highest_peak_aggregator_.histogram(); + std::span<const int> histogram = highest_peak_aggregator_.histogram(); int candidate = highest_peak_aggregator_.candidate(); significant_candidate_found_ = significant_candidate_found_ || histogram[candidate] > thresholds_.converged;
diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h index 26cafbc..d53464f 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
@@ -15,9 +15,9 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/matched_filter.h" @@ -81,7 +81,7 @@ void Reset(); void Aggregate(int lag); int candidate() const { return candidate_; } - ArrayView<const int> histogram() const { return histogram_; } + std::span<const int> histogram() const { return histogram_; } private: std::vector<int> histogram_;
diff --git a/modules/audio_processing/aec3/matched_filter_unittest.cc b/modules/audio_processing/aec3/matched_filter_unittest.cc index dc75bcc..7369ec2 100644 --- a/modules/audio_processing/aec3/matched_filter_unittest.cc +++ b/modules/audio_processing/aec3/matched_filter_unittest.cc
@@ -16,10 +16,10 @@ #include <cstdlib> #include <iterator> #include <memory> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" @@ -305,7 +305,7 @@ render_delay_buffer->PrepareCaptureProcessing(); std::array<float, kBlockSize> downsampled_capture_data; - ArrayView<float> downsampled_capture(downsampled_capture_data.data(), + std::span<float> downsampled_capture(downsampled_capture_data.data(), sub_block_size); capture_decimator.Decimate(capture[0], downsampled_capture); filter.Update(render_delay_buffer->GetDownsampledRenderBuffer(), @@ -380,7 +380,7 @@ } render_delay_buffer->PrepareCaptureProcessing(); std::array<float, kBlockSize> downsampled_capture_data; - ArrayView<float> downsampled_capture(downsampled_capture_data.data(), + std::span<float> downsampled_capture(downsampled_capture_data.data(), sub_block_size); capture_decimator.Decimate(capture[0], downsampled_capture); filter.Update(render_delay_buffer->GetDownsampledRenderBuffer(), @@ -421,7 +421,7 @@ Block render(kNumBands, kNumChannels); std::array<float, kBlockSize> capture_data; - ArrayView<float> capture(capture_data.data(), sub_block_size); + std::span<float> capture(capture_data.data(), sub_block_size); std::fill(capture.begin(), capture.end(), 0.f); ApmDataDumper data_dumper(0); std::unique_ptr<RenderDelayBuffer> render_delay_buffer( @@ -486,7 +486,7 @@ } std::copy(render.begin(0, 0), render.end(0, 0), capture[0].begin()); std::array<float, kBlockSize> downsampled_capture_data; - ArrayView<float> downsampled_capture(downsampled_capture_data.data(), + std::span<float> downsampled_capture(downsampled_capture_data.data(), sub_block_size); capture_decimator.Decimate(capture[0], downsampled_capture); filter.Update(render_delay_buffer->GetDownsampledRenderBuffer(),
diff --git a/modules/audio_processing/aec3/moving_average.cc b/modules/audio_processing/aec3/moving_average.cc index e1e5589..503b86b 100644 --- a/modules/audio_processing/aec3/moving_average.cc +++ b/modules/audio_processing/aec3/moving_average.cc
@@ -14,8 +14,8 @@ #include <algorithm> #include <cstddef> #include <functional> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -33,8 +33,8 @@ MovingAverage::~MovingAverage() = default; -void MovingAverage::Average(ArrayView<const float> input, - ArrayView<float> output) { +void MovingAverage::Average(std::span<const float> input, + std::span<float> output) { RTC_DCHECK(input.size() == num_elem_); RTC_DCHECK(output.size() == num_elem_);
diff --git a/modules/audio_processing/aec3/moving_average.h b/modules/audio_processing/aec3/moving_average.h index 68f2fd0..77e2a59 100644 --- a/modules/audio_processing/aec3/moving_average.h +++ b/modules/audio_processing/aec3/moving_average.h
@@ -13,10 +13,9 @@ #include <stddef.h> +#include <span> #include <vector> -#include "api/array_view.h" - namespace webrtc { namespace aec3 { @@ -29,7 +28,7 @@ // Computes the average of input and mem_len-1 previous inputs and stores the // result in output. - void Average(ArrayView<const float> input, ArrayView<float> output); + void Average(std::span<const float> input, std::span<float> output); private: const size_t num_elem_;
diff --git a/modules/audio_processing/aec3/nearend_detector.h b/modules/audio_processing/aec3/nearend_detector.h index a1f30a9..c95c19e 100644 --- a/modules/audio_processing/aec3/nearend_detector.h +++ b/modules/audio_processing/aec3/nearend_detector.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AEC3_NEAREND_DETECTOR_H_ #include <array> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" namespace webrtc { @@ -27,10 +27,10 @@ // Updates the state selection based on latest spectral estimates. virtual void Update( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, bool initial_state) = 0; };
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/BUILD.gn b/modules/audio_processing/aec3/neural_residual_echo_estimator/BUILD.gn index 120d46a..029a011 100644 --- a/modules/audio_processing/aec3/neural_residual_echo_estimator/BUILD.gn +++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/BUILD.gn
@@ -34,7 +34,6 @@ "..:aec3_block", "..:aec3_common", "../..:apm_logging", - "../../../../api:array_view", "../../../../api/audio:aec3_config", "../../../../api/audio:neural_residual_echo_estimator_api", "../../../../common_audio", @@ -70,7 +69,6 @@ ":neural_residual_echo_estimator_proto", "..:aec3_block", "..:aec3_common", - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:random", "../../../../test:fileutils",
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.cc index 45c08e1..63615c9 100644 --- a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.cc +++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.cc
@@ -15,9 +15,9 @@ #include <cmath> #include <cstring> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "common_audio/window_generator.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" @@ -46,7 +46,7 @@ } std::array<float, kBlockSize> AverageAllChannels( - ArrayView<const ArrayView<const float, kBlockSize>> all_channels) { + std::span<const std::span<const float, kBlockSize>> all_channels) { std::array<float, kBlockSize> summed_block; summed_block.fill(0.0f); const float scale = kScale * 1.0f / all_channels.size(); @@ -93,7 +93,7 @@ } void TimeDomainFeatureExtractor::UpdateBuffers( - ArrayView<const ArrayView<const float, kBlockSize>> all_channels, + std::span<const std::span<const float, kBlockSize>> all_channels, ModelInputEnum input_type) { if (!RequiredInput(input_type)) { return; @@ -105,7 +105,7 @@ summed_block.end()); } -void TimeDomainFeatureExtractor::PrepareModelInput(ArrayView<float> model_input, +void TimeDomainFeatureExtractor::PrepareModelInput(std::span<float> model_input, ModelInputEnum input_type) { if (!RequiredInput(input_type)) { return; @@ -174,10 +174,10 @@ } void FrequencyDomainFeatureExtractor::ComputeAndAddPowerSpectra( - ArrayView<const float> frame, + std::span<const float> frame, std::unique_ptr<PffftState>& pffft_state, int number_channels, - ArrayView<float> power_spectra) { + std::span<float> power_spectra) { const float kAverageScale = 1.0f / number_channels; if (pffft_state == nullptr) { pffft_state = std::make_unique<PffftState>(frame_size_); @@ -202,7 +202,7 @@ } void FrequencyDomainFeatureExtractor::UpdateBuffers( - ArrayView<const ArrayView<const float, kBlockSize>> all_channels, + std::span<const std::span<const float, kBlockSize>> all_channels, ModelInputEnum input_type) { if (!RequiredInput(input_type)) { return; @@ -211,14 +211,14 @@ input_buffer_[static_cast<size_t>(input_type)]; input_buffer.resize(all_channels.size()); for (size_t ch = 0; ch < all_channels.size(); ++ch) { - const ArrayView<const float, kBlockSize>& frame_in = all_channels[ch]; + const std::span<const float, kBlockSize>& frame_in = all_channels[ch]; std::vector<float>& input_buffer_ch = input_buffer[ch]; input_buffer_ch.insert(input_buffer_ch.end(), frame_in.begin(), frame_in.end()); } } void FrequencyDomainFeatureExtractor::PrepareModelInput( - ArrayView<float> model_input, + std::span<float> model_input, ModelInputEnum input_type) { if (!RequiredInput(input_type)) { return;
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h index 5dba121..2071fb9 100644 --- a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h +++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h
@@ -13,9 +13,9 @@ #include <cstring> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "third_party/pffft/src/pffft.h" @@ -45,11 +45,11 @@ // Buffers the frames for matching the expecting inference step size. virtual void UpdateBuffers( - ArrayView<const ArrayView<const float, kBlockSize>> all_channels, + std::span<const std::span<const float, kBlockSize>> all_channels, ModelInputEnum input_type) = 0; // Uses the internal buffer data for producing the model input tensors. - virtual void PrepareModelInput(ArrayView<float> model_input, + virtual void PrepareModelInput(std::span<float> model_input, ModelInputEnum input_type) = 0; // Resets the internal state of the feature extractor. @@ -66,10 +66,10 @@ bool ReadyForInference() const override; void UpdateBuffers( - ArrayView<const ArrayView<const float, kBlockSize>> all_channels, + std::span<const std::span<const float, kBlockSize>> all_channels, ModelInputEnum input_type) override; - void PrepareModelInput(ArrayView<float> model_input, + void PrepareModelInput(std::span<float> model_input, ModelInputEnum input_type) override; private: @@ -87,10 +87,10 @@ bool ReadyForInference() const override; void UpdateBuffers( - ArrayView<const ArrayView<const float, kBlockSize>> all_channels, + std::span<const std::span<const float, kBlockSize>> all_channels, ModelInputEnum input_type) override; - void PrepareModelInput(ArrayView<float> model_input, + void PrepareModelInput(std::span<float> model_input, ModelInputEnum input_type) override; private: @@ -108,10 +108,10 @@ float* const data_; }; - void ComputeAndAddPowerSpectra(ArrayView<const float> frame, + void ComputeAndAddPowerSpectra(std::span<const float> frame, std::unique_ptr<PffftState>& pffft_state, int number_channels, - ArrayView<float> power_spectra); + std::span<float> power_spectra); const size_t step_size_; const int frame_size_;
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor_unittest.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor_unittest.cc index 66ccf6e..757af1b 100644 --- a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor_unittest.cc +++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor_unittest.cc
@@ -53,9 +53,9 @@ #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "test/gmock.h" #include "test/gtest.h" @@ -229,9 +229,9 @@ : public ::testing::TestWithParam<int> { protected: void UpdateBlock(FrequencyDomainFeatureExtractor& extractor, - ArrayView<const float, kBlockSize> block, + std::span<const float, kBlockSize> block, int num_channels) { - std::vector<ArrayView<const float, kBlockSize>> all_blocks; + std::vector<std::span<const float, kBlockSize>> all_blocks; all_blocks.reserve(num_channels); for (int i = 0; i < num_channels; ++i) { all_blocks.push_back(block); @@ -248,7 +248,7 @@ std::vector<float> output(kStepSize + 1); // First frame. for (int i = 0; i < kStepSize; i += kBlockSize) { - ArrayView<const float, kBlockSize> block(&noise1_scaled[i], kBlockSize); + std::span<const float, kBlockSize> block(&noise1_scaled[i], kBlockSize); this->UpdateBlock(extractor, block, num_channels); } EXPECT_TRUE(extractor.ReadyForInference()); @@ -258,7 +258,7 @@ EXPECT_FALSE(extractor.ReadyForInference()); for (int i = kStepSize; i < 2 * kStepSize; i += kBlockSize) { - ArrayView<const float, kBlockSize> block(&noise1_scaled[i], kBlockSize); + std::span<const float, kBlockSize> block(&noise1_scaled[i], kBlockSize); this->UpdateBlock(extractor, block, num_channels); } EXPECT_TRUE(extractor.ReadyForInference()); @@ -270,7 +270,7 @@ EXPECT_FALSE(extractor.ReadyForInference()); // Second frame. for (int i = 0; i < kStepSize; i += kBlockSize) { - ArrayView<const float, kBlockSize> block(&noise2_scaled[i], kBlockSize); + std::span<const float, kBlockSize> block(&noise2_scaled[i], kBlockSize); this->UpdateBlock(extractor, block, num_channels); } EXPECT_TRUE(extractor.ReadyForInference()); @@ -279,7 +279,7 @@ } for (int i = kStepSize; i < 2 * kStepSize; i += kBlockSize) { - ArrayView<const float, kBlockSize> block(&noise2_scaled[i], kBlockSize); + std::span<const float, kBlockSize> block(&noise2_scaled[i], kBlockSize); this->UpdateBlock(extractor, block, num_channels); } EXPECT_TRUE(extractor.ReadyForInference()); @@ -318,11 +318,11 @@ block1[i] = i; block2[i] = i + kBlockSize; } - ArrayView<const float, kBlockSize> block1_view(block1); - ArrayView<const ArrayView<const float, kBlockSize>> all_blocks1(&block1_view, + std::span<const float, kBlockSize> block1_view(block1); + std::span<const std::span<const float, kBlockSize>> all_blocks1(&block1_view, 1); - ArrayView<const float, kBlockSize> block2_view(block2); - ArrayView<const ArrayView<const float, kBlockSize>> all_blocks2(&block2_view, + std::span<const float, kBlockSize> block2_view(block2); + std::span<const std::span<const float, kBlockSize>> all_blocks2(&block2_view, 1); for (auto input_type : kExpectedInputs) { @@ -346,7 +346,7 @@ TEST(TimeDomainFeatureExtractorTest, ResetsState) { TimeDomainFeatureExtractor extractor(kStepSize); const std::array<float, kBlockSize> block{}; - const std::array<const ArrayView<const float, kBlockSize>, 1> all_blocks = { + const std::array<const std::span<const float, kBlockSize>, 1> all_blocks = { block}; EXPECT_FALSE(extractor.ReadyForInference()); for (size_t i = 0; i < kStepSize / kBlockSize; ++i) {
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.cc index 1cec3a3..0c80ef1 100644 --- a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.cc +++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.cc
@@ -17,12 +17,12 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/base/nullability.h" -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/neural_residual_echo_estimator.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -82,8 +82,8 @@ // Downsamples the model output mask to the AEC3 frequency resolution and // transforms it from a nearend prediction to an echo power mask. -void DownsampleAndTransformMask(ArrayView<const float> mask, - ArrayView<float> downsampled_mask) { +void DownsampleAndTransformMask(std::span<const float> mask, + std::span<float> downsampled_mask) { const int kDownsampleFactor = static_cast<int>((mask.size() - 1) / kFftLengthBy2); downsampled_mask[0] = mask[0]; @@ -293,7 +293,7 @@ for (const auto input_enum : {ModelInputEnum::kMic, ModelInputEnum::kLinearAecOutput, ModelInputEnum::kAecRef}) { - ArrayView<float> input_tensor = GetInput(input_enum); + std::span<float> input_tensor = GetInput(input_enum); std::fill(input_tensor.begin(), input_tensor.end(), 0.0f); } } @@ -305,34 +305,34 @@ for (const auto input_enum : {ModelInputEnum::kMic, ModelInputEnum::kLinearAecOutput, ModelInputEnum::kAecRef}) { - ArrayView<float> input_tensor = GetInput(input_enum); + std::span<float> input_tensor = GetInput(input_enum); std::fill(input_tensor.begin(), input_tensor.end(), 0.0f); } } int StepSize() const override { return step_size_; } - ArrayView<float> GetInput( + std::span<float> GetInput( FeatureExtractor::ModelInputEnum input_enum) override { size_t index = input_tensor_indexes_[static_cast<size_t>(input_enum)]; TfLiteTensor* input_tensor = tflite_interpreter_->tensor(index); float* input_typed_tensor = reinterpret_cast<float*>(input_tensor->data.data); - return ArrayView<float>(input_typed_tensor, + return std::span<float>(input_typed_tensor, tflite::NumElements(input_tensor)); } - ArrayView<const float> GetOutput( + std::span<const float> GetOutput( FeatureExtractor::ModelOutputEnum output_enum) override { if (!use_unbounded_mask_ && output_enum == ModelOutputEnum::kUnboundedEchoMask) { - return ArrayView<const float>(); + return std::span<const float>(); } size_t index = output_tensor_indexes_[static_cast<size_t>(output_enum)]; const TfLiteTensor* output_tensor = tflite_interpreter_->tensor(index); const float* output_typed_tensor = reinterpret_cast<const float*>(output_tensor->data.data); - return ArrayView<const float>(output_typed_tensor, + return std::span<const float>(output_typed_tensor, tflite::NumElements(output_tensor)); } @@ -488,14 +488,14 @@ void NeuralResidualEchoEstimatorImpl::Estimate( const Block& render, - ArrayView<const std::array<float, kBlockSize>> y, - ArrayView<const std::array<float, kBlockSize>> e, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> S2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const std::array<float, kBlockSize>> y, + std::span<const std::array<float, kBlockSize>> e, + std::span<const std::array<float, kFftLengthBy2Plus1>> S2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, bool dominant_nearend, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2_unbounded) { + std::span<std::array<float, kFftLengthBy2Plus1>> R2, + std::span<std::array<float, kFftLengthBy2Plus1>> R2_unbounded) { DumpInputs(render, y, e); render_channels_.clear(); for (int i = 0; i < render.NumChannels(); ++i) { @@ -525,11 +525,11 @@ ModelInputEnum::kAecRef); if (model_runner_->Invoke()) { // Downsample output mask to match the AEC3 frequency resolution. - ArrayView<const float> output_mask = + std::span<const float> output_mask = model_runner_->GetOutput(ModelOutputEnum::kEchoMask); DownsampleAndTransformMask(output_mask, output_mask_); if (use_unbounded_mask_) { - ArrayView<const float> output_mask_unbounded = + std::span<const float> output_mask_unbounded = model_runner_->GetOutput(ModelOutputEnum::kUnboundedEchoMask); DownsampleAndTransformMask(output_mask_unbounded, output_mask_unbounded_); @@ -589,8 +589,8 @@ void NeuralResidualEchoEstimatorImpl::DumpInputs( const Block& render, - ArrayView<const std::array<float, kBlockSize>> y, - ArrayView<const std::array<float, kBlockSize>> e) { + std::span<const std::array<float, kBlockSize>> y, + std::span<const std::array<float, kBlockSize>> e) { data_dumper_->DumpWav("ml_ree_mic_input", y[0], 16000, 1); data_dumper_->DumpWav("ml_ree_linear_aec_output", e[0], 16000, 1); data_dumper_->DumpWav("ml_ree_aec_ref", render.View(0, 0), 16000, 1);
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h index 4ee8634..2c2f091 100644 --- a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h +++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl.h
@@ -13,10 +13,10 @@ #include <array> #include <memory> +#include <span> #include <vector> #include "absl/base/nullability.h" -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/neural_residual_echo_estimator.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -45,9 +45,9 @@ virtual ~ModelRunner() = default; virtual int StepSize() const = 0; - virtual ArrayView<float> GetInput( + virtual std::span<float> GetInput( FeatureExtractor::ModelInputEnum input_enum) = 0; - virtual ArrayView<const float> GetOutput( + virtual std::span<const float> GetOutput( FeatureExtractor::ModelOutputEnum output_enum) = 0; virtual const audioproc::ReeModelMetadata& GetMetadata() const = 0; virtual bool Invoke() = 0; @@ -71,14 +71,14 @@ void Estimate( const Block& render, - ArrayView<const std::array<float, kBlockSize>> y, - ArrayView<const std::array<float, kBlockSize>> e, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> S2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const std::array<float, kBlockSize>> y, + std::span<const std::array<float, kBlockSize>> e, + std::span<const std::array<float, kFftLengthBy2Plus1>> S2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, bool dominant_nearend, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2_unbounded) override; + std::span<std::array<float, kFftLengthBy2Plus1>> R2, + std::span<std::array<float, kFftLengthBy2Plus1>> R2_unbounded) override; EchoCanceller3Config GetConfiguration(bool multi_channel) const override; @@ -86,8 +86,8 @@ private: void DumpInputs(const Block& render, - ArrayView<const std::array<float, kBlockSize>> y, - ArrayView<const std::array<float, kBlockSize>> e); + std::span<const std::array<float, kBlockSize>> y, + std::span<const std::array<float, kBlockSize>> e); // Encapsulates all ML model invocation work. const std::unique_ptr<ModelRunner> model_runner_; @@ -100,9 +100,9 @@ std::array<float, kFftLengthBy2Plus1> output_mask_; std::array<float, kFftLengthBy2Plus1> output_mask_unbounded_; - std::vector<ArrayView<const float, kBlockSize>> render_channels_; - std::vector<ArrayView<const float, kBlockSize>> y_channels_; - std::vector<ArrayView<const float, kBlockSize>> e_channels_; + std::vector<std::span<const float, kBlockSize>> render_channels_; + std::vector<std::span<const float, kBlockSize>> y_channels_; + std::vector<std::span<const float, kBlockSize>> e_channels_; static int instance_count_; // Pointer to a data dumper that is used for debugging purposes.
diff --git a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl_unittest.cc b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl_unittest.cc index 3da7b77..a8681fb 100644 --- a/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl_unittest.cc +++ b/modules/audio_processing/aec3/neural_residual_echo_estimator/neural_residual_echo_estimator_impl_unittest.cc
@@ -16,12 +16,12 @@ #include <cstdint> #include <cstring> #include <memory> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "modules/audio_processing/aec3/neural_residual_echo_estimator/neural_feature_extractor.h" @@ -78,36 +78,34 @@ int StepSize() const override { return constants_.step_size; } - ArrayView<float> GetInput(ModelInputEnum input_enum) override { + std::span<float> GetInput(ModelInputEnum input_enum) override { switch (input_enum) { case ModelInputEnum::kMic: - return webrtc::ArrayView<float>(input_mic_.data(), - constants_.frame_size); + return std::span<float>(input_mic_.data(), constants_.frame_size); case ModelInputEnum::kLinearAecOutput: - return webrtc::ArrayView<float>(input_linear_aec_output_.data(), - constants_.frame_size); + return std::span<float>(input_linear_aec_output_.data(), + constants_.frame_size); case ModelInputEnum::kAecRef: - return webrtc::ArrayView<float>(input_aec_ref_.data(), - constants_.frame_size); + return std::span<float>(input_aec_ref_.data(), constants_.frame_size); case ModelInputEnum::kModelState: case ModelInputEnum::kNumInputs: RTC_CHECK(false); - return webrtc::ArrayView<float>(); + return std::span<float>(); } } - ArrayView<const float> GetOutput(ModelOutputEnum output_enum) override { + std::span<const float> GetOutput(ModelOutputEnum output_enum) override { switch (output_enum) { case ModelOutputEnum::kEchoMask: case ModelOutputEnum::kUnboundedEchoMask: - return ArrayView<const float>(output_echo_mask_.data(), + return std::span<const float>(output_echo_mask_.data(), constants_.frame_size_by_2_plus_1); case ModelOutputEnum::kModelState: // Mock model state output if needed, for now return empty - return ArrayView<const float>(); + return std::span<const float>(); default: RTC_CHECK(false); - return ArrayView<float>(); + return std::span<float>(); } }
diff --git a/modules/audio_processing/aec3/refined_filter_update_gain.cc b/modules/audio_processing/aec3/refined_filter_update_gain.cc index 80a55c2..3686903 100644 --- a/modules/audio_processing/aec3/refined_filter_update_gain.cc +++ b/modules/audio_processing/aec3/refined_filter_update_gain.cc
@@ -14,8 +14,8 @@ #include <array> #include <atomic> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/echo_path_variability.h" @@ -71,7 +71,7 @@ const std::array<float, kFftLengthBy2Plus1>& render_power, const RenderSignalAnalyzer& render_signal_analyzer, const SubtractorOutput& subtractor_output, - ArrayView<const float> erl, + std::span<const float> erl, size_t size_partitions, bool saturated_capture_signal, bool disallow_leakage_diverged,
diff --git a/modules/audio_processing/aec3/refined_filter_update_gain.h b/modules/audio_processing/aec3/refined_filter_update_gain.h index 660a013..937ba8f 100644 --- a/modules/audio_processing/aec3/refined_filter_update_gain.h +++ b/modules/audio_processing/aec3/refined_filter_update_gain.h
@@ -16,8 +16,8 @@ #include <array> #include <atomic> #include <memory> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -49,7 +49,7 @@ void Compute(const std::array<float, kFftLengthBy2Plus1>& render_power, const RenderSignalAnalyzer& render_signal_analyzer, const SubtractorOutput& subtractor_output, - ArrayView<const float> erl, + std::span<const float> erl, size_t size_partitions, bool saturated_capture_signal, bool disallow_leakage_diverged,
diff --git a/modules/audio_processing/aec3/render_buffer.h b/modules/audio_processing/aec3/render_buffer.h index 8f76bd0..f25416f 100644 --- a/modules/audio_processing/aec3/render_buffer.h +++ b/modules/audio_processing/aec3/render_buffer.h
@@ -14,9 +14,9 @@ #include <stddef.h> #include <array> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "modules/audio_processing/aec3/block_buffer.h" @@ -48,7 +48,7 @@ } // Get the spectrum from one of the FFTs in the buffer. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Spectrum( + std::span<const std::array<float, kFftLengthBy2Plus1>> Spectrum( int buffer_offset_ffts) const { int position = spectrum_buffer_->OffsetIndex(spectrum_buffer_->read, buffer_offset_ffts); @@ -56,7 +56,7 @@ } // Returns the circular fft buffer. - ArrayView<const std::vector<FftData>> GetFftBuffer() const { + std::span<const std::vector<FftData>> GetFftBuffer() const { return fft_buffer_->buffer; }
diff --git a/modules/audio_processing/aec3/render_delay_buffer.cc b/modules/audio_processing/aec3/render_delay_buffer.cc index b595eef..ecc7431 100644 --- a/modules/audio_processing/aec3/render_delay_buffer.cc +++ b/modules/audio_processing/aec3/render_delay_buffer.cc
@@ -19,9 +19,9 @@ #include <memory> #include <numeric> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec3_fft.h" @@ -104,7 +104,7 @@ int ComputeDelay() const; void ApplyTotalDelay(int delay); void InsertBlock(const Block& block, int previous_write); - bool DetectActiveRender(ArrayView<const float> x) const; + bool DetectActiveRender(std::span<const float> x) const; bool DetectExcessRenderBlocks(); void IncrementWriteIndices(); void IncrementLowRateReadIndices(); @@ -405,7 +405,7 @@ if (render_linear_amplitude_gain_ != 1.f) { for (size_t band = 0; band < num_bands; ++band) { for (size_t ch = 0; ch < num_render_channels; ++ch) { - ArrayView<float, kBlockSize> b_view = b.buffer[b.write].View(band, ch); + std::span<float, kBlockSize> b_view = b.buffer[b.write].View(band, ch); for (float& sample : b_view) { sample *= render_linear_amplitude_gain_; } @@ -428,7 +428,7 @@ } } -bool RenderDelayBufferImpl::DetectActiveRender(ArrayView<const float> x) const { +bool RenderDelayBufferImpl::DetectActiveRender(std::span<const float> x) const { const float x_energy = std::inner_product(x.begin(), x.end(), x.begin(), 0.f); return x_energy > (config_.render_levels.active_render_limit * config_.render_levels.active_render_limit) *
diff --git a/modules/audio_processing/aec3/render_signal_analyzer.cc b/modules/audio_processing/aec3/render_signal_analyzer.cc index ae013e7..9efb4bc 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer.cc +++ b/modules/audio_processing/aec3/render_signal_analyzer.cc
@@ -15,9 +15,9 @@ #include <cmath> #include <cstddef> #include <optional> +#include <span> #include <utility> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" @@ -43,7 +43,7 @@ std::array<size_t, kFftLengthBy2 - 1> channel_counters; channel_counters.fill(0); - ArrayView<const std::array<float, kFftLengthBy2Plus1>> X2 = + std::span<const std::array<float, kFftLengthBy2Plus1>> X2 = render_buffer.Spectrum(*delay_partitions); for (size_t ch = 0; ch < X2.size(); ++ch) { for (size_t k = 1; k < kFftLengthBy2; ++k) { @@ -74,7 +74,7 @@ const Block& x_latest = render_buffer.GetBlock(0); float max_peak_level = 0.f; for (int channel = 0; channel < x_latest.NumChannels(); ++channel) { - ArrayView<const float, kFftLengthBy2Plus1> X2_latest = + std::span<const float, kFftLengthBy2Plus1> X2_latest = render_buffer.Spectrum(0)[channel]; // Identify the spectral peak.
diff --git a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc index 9cb8ebe..7a14adb 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc +++ b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc
@@ -19,7 +19,6 @@ #include <optional> #include <string> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec3_fft.h"
diff --git a/modules/audio_processing/aec3/residual_echo_estimator.cc b/modules/audio_processing/aec3/residual_echo_estimator.cc index 1c4c3a0..65793d4 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator.cc +++ b/modules/audio_processing/aec3/residual_echo_estimator.cc
@@ -14,9 +14,9 @@ #include <array> #include <cstddef> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/neural_residual_echo_estimator.h" #include "api/environment/environment.h" @@ -89,9 +89,9 @@ // Estimates the residual echo power based on the echo return loss enhancement // (ERLE) and the linear power estimate. void LinearEstimate( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> S2_linear, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> erle, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) { + std::span<const std::array<float, kFftLengthBy2Plus1>> S2_linear, + std::span<const std::array<float, kFftLengthBy2Plus1>> erle, + std::span<std::array<float, kFftLengthBy2Plus1>> R2) { RTC_DCHECK_EQ(S2_linear.size(), erle.size()); RTC_DCHECK_EQ(S2_linear.size(), R2.size()); @@ -108,7 +108,7 @@ // gain. void NonLinearEstimate(float echo_path_gain, const std::array<float, kFftLengthBy2Plus1>& X2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) { + std::span<std::array<float, kFftLengthBy2Plus1>> R2) { const size_t num_capture_channels = R2.size(); for (size_t ch = 0; ch < num_capture_channels; ++ch) { for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) { @@ -119,7 +119,7 @@ // Applies a soft noise gate to the echo generating power. void ApplyNoiseGate(const EchoCanceller3Config::EchoModel& config, - ArrayView<float, kFftLengthBy2Plus1> X2) { + std::span<float, kFftLengthBy2Plus1> X2) { for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) { if (config.noise_gate_power > X2[k]) { X2[k] = std::max(0.f, X2[k] - config.noise_gate_slope * @@ -134,7 +134,7 @@ const SpectrumBuffer& spectrum_buffer, const EchoCanceller3Config::EchoModel& echo_model, int filter_delay_blocks, - ArrayView<float, kFftLengthBy2Plus1> X2) { + std::span<float, kFftLengthBy2Plus1> X2) { int idx_stop; int idx_start; GetRenderIndexesToAnalyze(spectrum_buffer, echo_model, filter_delay_blocks, @@ -193,14 +193,14 @@ void ResidualEchoEstimator::Estimate( const AecState& aec_state, const RenderBuffer& render_buffer, - ArrayView<const std::array<float, kFftLengthBy2>> capture, - ArrayView<const std::array<float, kFftLengthBy2>> linear_aec_output, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> S2_linear, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const std::array<float, kFftLengthBy2>> capture, + std::span<const std::array<float, kFftLengthBy2>> linear_aec_output, + std::span<const std::array<float, kFftLengthBy2Plus1>> S2_linear, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, bool dominant_nearend, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2_unbounded) { + std::span<std::array<float, kFftLengthBy2Plus1>> R2, + std::span<std::array<float, kFftLengthBy2Plus1>> R2_unbounded) { RTC_DCHECK_EQ(R2.size(), Y2.size()); RTC_DCHECK_EQ(R2.size(), S2_linear.size()); @@ -323,9 +323,9 @@ void ResidualEchoEstimator::UpdateRenderNoisePower( const RenderBuffer& render_buffer) { std::array<float, kFftLengthBy2Plus1> render_power_data; - ArrayView<const std::array<float, kFftLengthBy2Plus1>> X2 = + std::span<const std::array<float, kFftLengthBy2Plus1>> X2 = render_buffer.Spectrum(0); - ArrayView<const float, kFftLengthBy2Plus1> render_power = X2[/*channel=*/0]; + std::span<const float, kFftLengthBy2Plus1> render_power = X2[/*channel=*/0]; if (num_render_channels_ > 1) { render_power_data.fill(0.f); for (size_t ch = 0; ch < num_render_channels_; ++ch) { @@ -369,9 +369,9 @@ // Compute render power for the reverb. std::array<float, kFftLengthBy2Plus1> render_power_data; - ArrayView<const std::array<float, kFftLengthBy2Plus1>> X2 = + std::span<const std::array<float, kFftLengthBy2Plus1>> X2 = render_buffer.Spectrum(first_reverb_partition); - ArrayView<const float, kFftLengthBy2Plus1> render_power = X2[/*channel=*/0]; + std::span<const float, kFftLengthBy2Plus1> render_power = X2[/*channel=*/0]; if (num_render_channels_ > 1) { render_power_data.fill(0.f); for (size_t ch = 0; ch < num_render_channels_; ++ch) { @@ -397,11 +397,11 @@ } // Adds the estimated power of the reverb to the residual echo power. void ResidualEchoEstimator::AddReverb( - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) const { + std::span<std::array<float, kFftLengthBy2Plus1>> R2) const { const size_t num_capture_channels = R2.size(); // Add the reverb power. - ArrayView<const float, kFftLengthBy2Plus1> reverb_power = + std::span<const float, kFftLengthBy2Plus1> reverb_power = echo_reverb_.reverb(); for (size_t ch = 0; ch < num_capture_channels; ++ch) { for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) {
diff --git a/modules/audio_processing/aec3/residual_echo_estimator.h b/modules/audio_processing/aec3/residual_echo_estimator.h index 22358bc..fe1a4f8 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator.h +++ b/modules/audio_processing/aec3/residual_echo_estimator.h
@@ -13,8 +13,8 @@ #include <array> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/neural_residual_echo_estimator.h" #include "api/environment/environment.h" @@ -40,14 +40,14 @@ void Estimate( const AecState& aec_state, const RenderBuffer& render_buffer, - ArrayView<const std::array<float, kFftLengthBy2>> capture, - ArrayView<const std::array<float, kFftLengthBy2>> linear_aec_output, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> S2_linear, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const std::array<float, kFftLengthBy2>> capture, + std::span<const std::array<float, kFftLengthBy2>> linear_aec_output, + std::span<const std::array<float, kFftLengthBy2Plus1>> S2_linear, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, bool dominant_nearend, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2, - ArrayView<std::array<float, kFftLengthBy2Plus1>> R2_unbounded); + std::span<std::array<float, kFftLengthBy2Plus1>> R2, + std::span<std::array<float, kFftLengthBy2Plus1>> R2_unbounded); private: enum class ReverbType { kLinear, kNonLinear }; @@ -67,7 +67,7 @@ // Adds the estimated unmodelled echo power to the residual echo power // estimate. - void AddReverb(ArrayView<std::array<float, kFftLengthBy2Plus1>> R2) const; + void AddReverb(std::span<std::array<float, kFftLengthBy2Plus1>> R2) const; // Gets the echo path gain to apply. float GetEchoPathGain(const AecState& aec_state,
diff --git a/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc b/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc index 05c8c58..a3351c8 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc +++ b/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc
@@ -16,10 +16,10 @@ #include <memory> #include <numeric> #include <optional> +#include <span> #include <tuple> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -122,7 +122,7 @@ R2_, R2_unbounded_); } - ArrayView<const std::array<float, kFftLengthBy2Plus1>> R2() const { + std::span<const std::array<float, kFftLengthBy2Plus1>> R2() const { return R2_; }
diff --git a/modules/audio_processing/aec3/reverb_decay_estimator.cc b/modules/audio_processing/aec3/reverb_decay_estimator.cc index dbedfc7..b010629 100644 --- a/modules/audio_processing/aec3/reverb_decay_estimator.cc +++ b/modules/audio_processing/aec3/reverb_decay_estimator.cc
@@ -16,8 +16,8 @@ #include <cstddef> #include <numeric> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -34,7 +34,7 @@ -0.5f * kBlocksPerSection * kFftLengthBy2 + 0.5f; // Averages the values in a block of size kFftLengthBy2; -float BlockAverage(ArrayView<const float> v, size_t block_index) { +float BlockAverage(std::span<const float> v, size_t block_index) { constexpr float kOneByFftLengthBy2 = 1.f / kFftLengthBy2; const int i = block_index * kFftLengthBy2; RTC_DCHECK_GE(v.size(), i + kFftLengthBy2); @@ -62,7 +62,7 @@ } // Returns the peak energy of an impulse response. -float BlockEnergyPeak(ArrayView<const float> h, int peak_block) { +float BlockEnergyPeak(std::span<const float> h, int peak_block) { RTC_DCHECK_LE((peak_block + 1) * kFftLengthBy2, h.size()); RTC_DCHECK_GE(peak_block, 0); float peak_value = @@ -73,7 +73,7 @@ } // Returns the average energy of an impulse response block. -float BlockEnergyAverage(ArrayView<const float> h, int block_index) { +float BlockEnergyAverage(std::span<const float> h, int block_index) { RTC_DCHECK_LE((block_index + 1) * kFftLengthBy2, h.size()); RTC_DCHECK_GE(block_index, 0); constexpr float kOneByFftLengthBy2 = 1.f / kFftLengthBy2; @@ -103,7 +103,7 @@ ReverbDecayEstimator::~ReverbDecayEstimator() = default; -void ReverbDecayEstimator::Update(ArrayView<const float> filter, +void ReverbDecayEstimator::Update(std::span<const float> filter, const std::optional<float>& filter_quality, int filter_delay_blocks, bool usable_linear_filter, @@ -159,7 +159,7 @@ late_reverb_end_ = 0; } -void ReverbDecayEstimator::EstimateDecay(ArrayView<const float> filter, +void ReverbDecayEstimator::EstimateDecay(std::span<const float> filter, int peak_block) { auto& h = filter; RTC_DCHECK_EQ(0, h.size() % kFftLengthBy2); @@ -223,7 +223,7 @@ early_reverb_estimator_.Reset(); } -void ReverbDecayEstimator::AnalyzeFilter(ArrayView<const float> filter) { +void ReverbDecayEstimator::AnalyzeFilter(std::span<const float> filter) { auto h = filter.subspan(block_to_analyze_ * kFftLengthBy2, kFftLengthBy2); // Compute squared filter coeffiecients for the block to analyze_;
diff --git a/modules/audio_processing/aec3/reverb_decay_estimator.h b/modules/audio_processing/aec3/reverb_decay_estimator.h index 721cd2b..08fd6ca 100644 --- a/modules/audio_processing/aec3/reverb_decay_estimator.h +++ b/modules/audio_processing/aec3/reverb_decay_estimator.h
@@ -12,10 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AEC3_REVERB_DECAY_ESTIMATOR_H_ #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" - namespace webrtc { class ApmDataDumper; @@ -27,7 +26,7 @@ explicit ReverbDecayEstimator(const EchoCanceller3Config& config); ~ReverbDecayEstimator(); // Updates the decay estimate. - void Update(ArrayView<const float> filter, + void Update(std::span<const float> filter, const std::optional<float>& filter_quality, int filter_delay_blocks, bool usable_linear_filter, @@ -45,8 +44,8 @@ void Dump(ApmDataDumper* data_dumper) const; private: - void EstimateDecay(ArrayView<const float> filter, int peak_block); - void AnalyzeFilter(ArrayView<const float> filter); + void EstimateDecay(std::span<const float> filter, int peak_block); + void AnalyzeFilter(std::span<const float> filter); void ResetDecayEstimation();
diff --git a/modules/audio_processing/aec3/reverb_frequency_response.cc b/modules/audio_processing/aec3/reverb_frequency_response.cc index c375ad1..574eefc 100644 --- a/modules/audio_processing/aec3/reverb_frequency_response.cc +++ b/modules/audio_processing/aec3/reverb_frequency_response.cc
@@ -15,9 +15,9 @@ #include <cstddef> #include <numeric> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" @@ -28,8 +28,8 @@ // Computes the ratio of the energies between the direct path and the tail. The // energy is computed in the power spectrum domain discarding the DC // contributions. -float AverageDecayWithinFilter(ArrayView<const float> freq_resp_direct_path, - ArrayView<const float> freq_resp_tail) { +float AverageDecayWithinFilter(std::span<const float> freq_resp_direct_path, + std::span<const float> freq_resp_tail) { // Skipping the DC for the ratio computation constexpr size_t kSkipBins = 1; RTC_CHECK_EQ(freq_resp_direct_path.size(), freq_resp_tail.size()); @@ -76,10 +76,10 @@ frequency_response, int filter_delay_blocks, float linear_filter_quality) { - ArrayView<const float> freq_resp_tail( + std::span<const float> freq_resp_tail( frequency_response[frequency_response.size() - 1]); - ArrayView<const float> freq_resp_direct_path( + std::span<const float> freq_resp_direct_path( frequency_response[filter_delay_blocks]); float average_decay =
diff --git a/modules/audio_processing/aec3/reverb_frequency_response.h b/modules/audio_processing/aec3/reverb_frequency_response.h index 3fecba7..ee36bce 100644 --- a/modules/audio_processing/aec3/reverb_frequency_response.h +++ b/modules/audio_processing/aec3/reverb_frequency_response.h
@@ -13,9 +13,9 @@ #include <array> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" namespace webrtc { @@ -35,7 +35,7 @@ bool stationary_block); // Returns the estimated frequency response for the reverb. - ArrayView<const float> FrequencyResponse() const { return tail_response_; } + std::span<const float> FrequencyResponse() const { return tail_response_; } private: void Update(const std::vector<std::array<float, kFftLengthBy2Plus1>>&
diff --git a/modules/audio_processing/aec3/reverb_model.cc b/modules/audio_processing/aec3/reverb_model.cc index 7bd719c..63c30cb 100644 --- a/modules/audio_processing/aec3/reverb_model.cc +++ b/modules/audio_processing/aec3/reverb_model.cc
@@ -11,8 +11,7 @@ #include "modules/audio_processing/aec3/reverb_model.h" #include <cstddef> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -27,7 +26,7 @@ } void ReverbModel::UpdateReverbNoFreqShaping( - ArrayView<const float> power_spectrum, + std::span<const float> power_spectrum, float power_spectrum_scaling, float reverb_decay) { if (reverb_decay > 0) { @@ -39,8 +38,8 @@ } } -void ReverbModel::UpdateReverb(ArrayView<const float> power_spectrum, - ArrayView<const float> power_spectrum_scaling, +void ReverbModel::UpdateReverb(std::span<const float> power_spectrum, + std::span<const float> power_spectrum_scaling, float reverb_decay) { if (reverb_decay > 0) { // Update the estimate of the reverberant power.
diff --git a/modules/audio_processing/aec3/reverb_model.h b/modules/audio_processing/aec3/reverb_model.h index 15e2489..a05f380 100644 --- a/modules/audio_processing/aec3/reverb_model.h +++ b/modules/audio_processing/aec3/reverb_model.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_ #include <array> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" namespace webrtc { @@ -29,7 +29,7 @@ void Reset(); // Returns the reverb. - ArrayView<const float, kFftLengthBy2Plus1> reverb() const { return reverb_; } + std::span<const float, kFftLengthBy2Plus1> reverb() const { return reverb_; } // The methods UpdateReverbNoFreqShaping and UpdateReverb update the // estimate of the reverberation contribution to an input/output power @@ -37,13 +37,13 @@ // power spectrum is pre-scaled. Use the method UpdateReverb when a different // scaling should be applied per frequency and UpdateReverb_no_freq_shape if // the same scaling should be used for all the frequencies. - void UpdateReverbNoFreqShaping(ArrayView<const float> power_spectrum, + void UpdateReverbNoFreqShaping(std::span<const float> power_spectrum, float power_spectrum_scaling, float reverb_decay); // Update the reverb based on new data. - void UpdateReverb(ArrayView<const float> power_spectrum, - ArrayView<const float> power_spectrum_scaling, + void UpdateReverb(std::span<const float> power_spectrum, + std::span<const float> power_spectrum_scaling, float reverb_decay); private:
diff --git a/modules/audio_processing/aec3/reverb_model_estimator.cc b/modules/audio_processing/aec3/reverb_model_estimator.cc index 6465299..afbd110 100644 --- a/modules/audio_processing/aec3/reverb_model_estimator.cc +++ b/modules/audio_processing/aec3/reverb_model_estimator.cc
@@ -14,9 +14,9 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/reverb_decay_estimator.h" @@ -41,11 +41,11 @@ ReverbModelEstimator::~ReverbModelEstimator() = default; void ReverbModelEstimator::Update( - ArrayView<const std::vector<float>> impulse_responses, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<float>> impulse_responses, + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> frequency_responses, - ArrayView<const std::optional<float>> linear_filter_qualities, - ArrayView<const int> filter_delays_blocks, + std::span<const std::optional<float>> linear_filter_qualities, + std::span<const int> filter_delays_blocks, const std::vector<bool>& usable_linear_estimates, bool stationary_block) { const size_t num_capture_channels = reverb_decay_estimators_.size();
diff --git a/modules/audio_processing/aec3/reverb_model_estimator.h b/modules/audio_processing/aec3/reverb_model_estimator.h index 08bbc86..50bd97e 100644 --- a/modules/audio_processing/aec3/reverb_model_estimator.h +++ b/modules/audio_processing/aec3/reverb_model_estimator.h
@@ -15,9 +15,9 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" // kFftLengthBy2Plus1 #include "modules/audio_processing/aec3/reverb_decay_estimator.h" @@ -36,11 +36,11 @@ // Updates the estimates based on new data. void Update( - ArrayView<const std::vector<float>> impulse_responses, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<float>> impulse_responses, + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> frequency_responses, - ArrayView<const std::optional<float>> linear_filter_qualities, - ArrayView<const int> filter_delays_blocks, + std::span<const std::optional<float>> linear_filter_qualities, + std::span<const int> filter_delays_blocks, const std::vector<bool>& usable_linear_estimates, bool stationary_block); @@ -54,7 +54,7 @@ // Return the frequency response of the reverberant echo. // TODO(peah): Correct to properly support multiple channels. - ArrayView<const float> GetReverbFrequencyResponse() const { + std::span<const float> GetReverbFrequencyResponse() const { return reverb_frequency_responses_[0].FrequencyResponse(); }
diff --git a/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc b/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc index e3cde9e..8f5be5a 100644 --- a/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc +++ b/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc
@@ -16,9 +16,9 @@ #include <cstddef> #include <numeric> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec3_fft.h" @@ -110,7 +110,7 @@ H_j.Spectrum(Aec3Optimization::kNone, H2_[ch][j]); } } - ArrayView<float> H2_tail(H2_[0][H2_[0].size() - 1]); + std::span<float> H2_tail(H2_[0][H2_[0].size() - 1]); true_power_tail_ = std::accumulate(H2_tail.begin(), H2_tail.end(), 0.f); } void ReverbModelEstimatorTest::RunEstimator() {
diff --git a/modules/audio_processing/aec3/signal_dependent_erle_estimator.cc b/modules/audio_processing/aec3/signal_dependent_erle_estimator.cc index d0a854c..571b482 100644 --- a/modules/audio_processing/aec3/signal_dependent_erle_estimator.cc +++ b/modules/audio_processing/aec3/signal_dependent_erle_estimator.cc
@@ -16,9 +16,9 @@ #include <functional> #include <memory> #include <numeric> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -187,13 +187,13 @@ // correction factor to the erle that is given as an input to this method. void SignalDependentErleEstimator::Update( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_responses, - ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> average_erle, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const std::array<float, kFftLengthBy2Plus1>> average_erle, + std::span<const std::array<float, kFftLengthBy2Plus1>> average_erle_onset_compensated, const std::vector<bool>& converged_filters) { RTC_DCHECK_GT(num_sections_, 1); @@ -241,7 +241,7 @@ // together constitute 90% of the estimated echo energy. void SignalDependentErleEstimator::ComputeNumberOfActiveFilterSections( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_responses) { RTC_DCHECK_GT(num_sections_, 1); // Computes an approximation of the power spectrum if the filter would have @@ -254,17 +254,17 @@ } void SignalDependentErleEstimator::UpdateCorrectionFactors( - ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters) { for (size_t ch = 0; ch < converged_filters.size(); ++ch) { if (converged_filters[ch]) { constexpr float kX2BandEnergyThreshold = 44015068.0f; constexpr float kSmthConstantDecreases = 0.1f; constexpr float kSmthConstantIncreases = kSmthConstantDecreases / 2.f; - auto subband_powers = [](ArrayView<const float> power_spectrum, - ArrayView<float> power_spectrum_subbands) { + auto subband_powers = [](std::span<const float> power_spectrum, + std::span<float> power_spectrum_subbands) { for (size_t subband = 0; subband < kSubbands; ++subband) { RTC_DCHECK_LE(kBandBoundaries[subband + 1], power_spectrum.size()); power_spectrum_subbands[subband] = std::accumulate( @@ -354,7 +354,7 @@ void SignalDependentErleEstimator::ComputeEchoEstimatePerFilterSection( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_responses) { const SpectrumBuffer& spectrum_render_buffer = render_buffer.GetSpectrumBuffer();
diff --git a/modules/audio_processing/aec3/signal_dependent_erle_estimator.h b/modules/audio_processing/aec3/signal_dependent_erle_estimator.h index 4c58bd4..992057d 100644 --- a/modules/audio_processing/aec3/signal_dependent_erle_estimator.h +++ b/modules/audio_processing/aec3/signal_dependent_erle_estimator.h
@@ -14,9 +14,9 @@ #include <array> #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -39,7 +39,7 @@ void Reset(); // Returns the Erle per frequency subband. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Erle( + std::span<const std::array<float, kFftLengthBy2Plus1>> Erle( bool onset_compensated) const { return onset_compensated && use_onset_detection_ ? erle_onset_compensated_ : erle_; @@ -49,13 +49,13 @@ // to be an estimation of the average Erle achieved by the linear filter. void Update( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_response, - ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> average_erle, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const std::array<float, kFftLengthBy2Plus1>> average_erle, + std::span<const std::array<float, kFftLengthBy2Plus1>> average_erle_onset_compensated, const std::vector<bool>& converged_filters); @@ -66,18 +66,18 @@ private: void ComputeNumberOfActiveFilterSections( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_responses); void UpdateCorrectionFactors( - ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters); void ComputeEchoEstimatePerFilterSection( const RenderBuffer& render_buffer, - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> filter_frequency_responses); void ComputeActiveFilterSections();
diff --git a/modules/audio_processing/aec3/signal_dependent_erle_estimator_unittest.cc b/modules/audio_processing/aec3/signal_dependent_erle_estimator_unittest.cc index c834b39..611b25c 100644 --- a/modules/audio_processing/aec3/signal_dependent_erle_estimator_unittest.cc +++ b/modules/audio_processing/aec3/signal_dependent_erle_estimator_unittest.cc
@@ -14,10 +14,10 @@ #include <array> #include <cstddef> #include <memory> +#include <span> #include <tuple> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" @@ -56,14 +56,14 @@ size_t num_capture_channels); ~TestInputs(); const RenderBuffer& GetRenderBuffer() { return *render_buffer_; } - ArrayView<const float, kFftLengthBy2Plus1> GetX2() { return X2_; } - ArrayView<const std::array<float, kFftLengthBy2Plus1>> GetY2() const { + std::span<const float, kFftLengthBy2Plus1> GetX2() { return X2_; } + std::span<const std::array<float, kFftLengthBy2Plus1>> GetY2() const { return Y2_; } - ArrayView<const std::array<float, kFftLengthBy2Plus1>> GetE2() const { + std::span<const std::array<float, kFftLengthBy2Plus1>> GetE2() const { return E2_; } - ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> GetH2() + std::span<const std::vector<std::array<float, kFftLengthBy2Plus1>>> GetH2() const { return H2_; }
diff --git a/modules/audio_processing/aec3/stationarity_estimator.cc b/modules/audio_processing/aec3/stationarity_estimator.cc index cba546b..7b3f8f8 100644 --- a/modules/audio_processing/aec3/stationarity_estimator.cc +++ b/modules/audio_processing/aec3/stationarity_estimator.cc
@@ -14,8 +14,8 @@ #include <array> #include <atomic> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/spectrum_buffer.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -45,7 +45,7 @@ // Update just the noise estimator. Usefull until the delay is known void StationarityEstimator::UpdateNoiseEstimator( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> spectrum) { + std::span<const std::array<float, kFftLengthBy2Plus1>> spectrum) { noise_.Update(spectrum); data_dumper_->DumpRaw("aec3_stationarity_noise_spectrum", noise_.Spectrum()); data_dumper_->DumpRaw("aec3_stationarity_is_block_stationary", @@ -54,7 +54,7 @@ void StationarityEstimator::UpdateStationarityFlags( const SpectrumBuffer& spectrum_buffer, - ArrayView<const float> render_reverb_contribution_spectrum, + std::span<const float> render_reverb_contribution_spectrum, int idx_current, int num_lookahead) { std::array<int, kWindowLength> indexes; @@ -99,7 +99,7 @@ bool StationarityEstimator::EstimateBandStationarity( const SpectrumBuffer& spectrum_buffer, - ArrayView<const float> average_reverb, + std::span<const float> average_reverb, const std::array<int, kWindowLength>& indexes, size_t band) const { constexpr float kThrStationarity = 10.f; @@ -168,12 +168,12 @@ } void StationarityEstimator::NoiseSpectrum::Update( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> spectrum) { + std::span<const std::array<float, kFftLengthBy2Plus1>> spectrum) { RTC_DCHECK_LE(1, spectrum[0].size()); const int num_render_channels = static_cast<int>(spectrum.size()); std::array<float, kFftLengthBy2Plus1> avg_spectrum_data; - ArrayView<const float> avg_spectrum; + std::span<const float> avg_spectrum; if (num_render_channels == 1) { avg_spectrum = spectrum[0]; } else {
diff --git a/modules/audio_processing/aec3/stationarity_estimator.h b/modules/audio_processing/aec3/stationarity_estimator.h index 0c10a09..e0a66ca 100644 --- a/modules/audio_processing/aec3/stationarity_estimator.h +++ b/modules/audio_processing/aec3/stationarity_estimator.h
@@ -15,8 +15,8 @@ #include <atomic> #include <cstddef> #include <memory> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" // kFftLengthBy2Plus1... #include "rtc_base/checks.h" @@ -35,13 +35,13 @@ // Update just the noise estimator. Usefull until the delay is known void UpdateNoiseEstimator( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> spectrum); + std::span<const std::array<float, kFftLengthBy2Plus1>> spectrum); // Update the flag indicating whether this current frame is stationary. For // getting a more robust estimation, it looks at future and/or past frames. void UpdateStationarityFlags( const SpectrumBuffer& spectrum_buffer, - ArrayView<const float> render_reverb_contribution_spectrum, + std::span<const float> render_reverb_contribution_spectrum, int idx_current, int num_lookahead); @@ -61,7 +61,7 @@ // Get an estimation of the stationarity for the current band by looking // at the past/present/future available data. bool EstimateBandStationarity(const SpectrumBuffer& spectrum_buffer, - ArrayView<const float> average_reverb, + std::span<const float> average_reverb, const std::array<int, kWindowLength>& indexes, size_t band) const; @@ -86,10 +86,10 @@ // Update the noise power spectrum with a new frame. void Update( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> spectrum); + std::span<const std::array<float, kFftLengthBy2Plus1>> spectrum); // Get the noise estimation power spectrum. - ArrayView<const float> Spectrum() const { return noise_spectrum_; } + std::span<const float> Spectrum() const { return noise_spectrum_; } // Get the noise power spectrum at a certain band. float Power(size_t band) const {
diff --git a/modules/audio_processing/aec3/subband_erle_estimator.cc b/modules/audio_processing/aec3/subband_erle_estimator.cc index 8db40a2..c71d5e8 100644 --- a/modules/audio_processing/aec3/subband_erle_estimator.cc +++ b/modules/audio_processing/aec3/subband_erle_estimator.cc
@@ -15,9 +15,9 @@ #include <cstddef> #include <functional> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" @@ -83,9 +83,9 @@ } void SubbandErleEstimator::Update( - ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters) { UpdateAccumulatedSpectra(X2, Y2, E2, converged_filters); UpdateBands(converged_filters); @@ -221,9 +221,9 @@ } void SubbandErleEstimator::UpdateAccumulatedSpectra( - ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters) { auto& st = accum_spectra_; RTC_DCHECK_EQ(st.E2.size(), E2.size());
diff --git a/modules/audio_processing/aec3/subband_erle_estimator.h b/modules/audio_processing/aec3/subband_erle_estimator.h index fdfaad8..5e639fe 100644 --- a/modules/audio_processing/aec3/subband_erle_estimator.h +++ b/modules/audio_processing/aec3/subband_erle_estimator.h
@@ -15,9 +15,9 @@ #include <array> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -37,25 +37,25 @@ void Reset(); // Updates the ERLE estimate. - void Update(ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + void Update(std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters); // Returns the ERLE estimate. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Erle( + std::span<const std::array<float, kFftLengthBy2Plus1>> Erle( bool onset_compensated) const { return onset_compensated && use_onset_detection_ ? erle_onset_compensated_ : erle_; } // Returns the non-capped ERLE estimate. - ArrayView<const std::array<float, kFftLengthBy2Plus1>> ErleUnbounded() const { + std::span<const std::array<float, kFftLengthBy2Plus1>> ErleUnbounded() const { return erle_unbounded_; } // Returns the ERLE estimate at onsets (only used for testing). - ArrayView<const std::array<float, kFftLengthBy2Plus1>> ErleDuringOnsets() + std::span<const std::array<float, kFftLengthBy2Plus1>> ErleDuringOnsets() const { return erle_during_onsets_; } @@ -76,9 +76,9 @@ }; void UpdateAccumulatedSpectra( - ArrayView<const float, kFftLengthBy2Plus1> X2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2, + std::span<const float, kFftLengthBy2Plus1> X2, + std::span<const std::array<float, kFftLengthBy2Plus1>> Y2, + std::span<const std::array<float, kFftLengthBy2Plus1>> E2, const std::vector<bool>& converged_filters); void ResetAccumulatedSpectra();
diff --git a/modules/audio_processing/aec3/subband_nearend_detector.cc b/modules/audio_processing/aec3/subband_nearend_detector.cc index 37b3563..e569a3f 100644 --- a/modules/audio_processing/aec3/subband_nearend_detector.cc +++ b/modules/audio_processing/aec3/subband_nearend_detector.cc
@@ -13,8 +13,8 @@ #include <array> #include <cstddef> #include <numeric> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/moving_average.h" @@ -34,10 +34,10 @@ 1.f / (config_.subband2.high - config_.subband2.low + 1)) {} void SubbandNearendDetector::Update( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> /* residual_echo_spectrum */, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, bool /* initial_state */) { nearend_state_ = false;
diff --git a/modules/audio_processing/aec3/subband_nearend_detector.h b/modules/audio_processing/aec3/subband_nearend_detector.h index ab733b9..635e063 100644 --- a/modules/audio_processing/aec3/subband_nearend_detector.h +++ b/modules/audio_processing/aec3/subband_nearend_detector.h
@@ -13,9 +13,9 @@ #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/moving_average.h" @@ -34,10 +34,10 @@ // Updates the state selection based on latest spectral estimates. void Update( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, bool initial_state) override;
diff --git a/modules/audio_processing/aec3/subtractor.cc b/modules/audio_processing/aec3/subtractor.cc index bfce13f..8f9d775 100644 --- a/modules/audio_processing/aec3/subtractor.cc +++ b/modules/audio_processing/aec3/subtractor.cc
@@ -14,9 +14,9 @@ #include <array> #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" @@ -48,7 +48,7 @@ void PredictionError(const Aec3Fft& fft, const FftData& S, - ArrayView<const float> y, + std::span<const float> y, std::array<float, kBlockSize>* e, std::array<float, kBlockSize>* s) { std::array<float, kFftLength> tmp; @@ -64,10 +64,10 @@ } } -void ScaleFilterOutput(ArrayView<const float> y, +void ScaleFilterOutput(std::span<const float> y, float factor, - ArrayView<float> e, - ArrayView<float> s) { + std::span<float> e, + std::span<float> s) { RTC_DCHECK_EQ(y.size(), e.size()); RTC_DCHECK_EQ(y.size(), s.size()); for (size_t k = 0; k < y.size(); ++k) { @@ -197,7 +197,7 @@ const Block& capture, const RenderSignalAnalyzer& render_signal_analyzer, const AecState& aec_state, - ArrayView<SubtractorOutput> outputs) { + std::span<SubtractorOutput> outputs) { RTC_DCHECK_EQ(num_capture_channels_, capture.NumChannels()); // Compute the render powers. @@ -223,7 +223,7 @@ // Process all capture channels for (size_t ch = 0; ch < num_capture_channels_; ++ch) { SubtractorOutput& output = outputs[ch]; - ArrayView<const float> y = capture.View(/*band=*/0, ch); + std::span<const float> y = capture.View(/*band=*/0, ch); FftData& E_refined = output.E_refined; FftData E_coarse; std::array<float, kBlockSize>& e_refined = output.e_refined;
diff --git a/modules/audio_processing/aec3/subtractor.h b/modules/audio_processing/aec3/subtractor.h index 148bdf2..e040290 100644 --- a/modules/audio_processing/aec3/subtractor.h +++ b/modules/audio_processing/aec3/subtractor.h
@@ -15,9 +15,9 @@ #include <cmath> #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "modules/audio_processing/aec3/adaptive_fir_filter.h" @@ -54,7 +54,7 @@ const Block& capture, const RenderSignalAnalyzer& render_signal_analyzer, const AecState& aec_state, - ArrayView<SubtractorOutput> outputs); + std::span<SubtractorOutput> outputs); void HandleEchoPathChange(const EchoPathVariability& echo_path_variability); @@ -77,7 +77,7 @@ void DumpFilters() { data_dumper_->DumpRaw( "aec3_subtractor_h_refined", - ArrayView<const float>( + std::span<const float>( refined_impulse_responses_[0].data(), GetTimeDomainLength( refined_filters_[0]->max_filter_size_partitions()))); @@ -85,7 +85,7 @@ RTC_DCHECK_GT(coarse_impulse_responses_.size(), 0); data_dumper_->DumpRaw( "aec3_subtractor_h_coarse", - ArrayView<const float>( + std::span<const float>( coarse_impulse_responses_[0].data(), GetTimeDomainLength( coarse_filter_[0]->max_filter_size_partitions())));
diff --git a/modules/audio_processing/aec3/subtractor_output.cc b/modules/audio_processing/aec3/subtractor_output.cc index 7a5bd17..811014c 100644 --- a/modules/audio_processing/aec3/subtractor_output.cc +++ b/modules/audio_processing/aec3/subtractor_output.cc
@@ -12,8 +12,7 @@ #include <algorithm> #include <numeric> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -36,7 +35,7 @@ y2 = 0.f; } -void SubtractorOutput::ComputeMetrics(ArrayView<const float> y) { +void SubtractorOutput::ComputeMetrics(std::span<const float> y) { const auto sum_of_squares = [](float a, float b) { return a + b * b; }; y2 = std::accumulate(y.begin(), y.end(), 0.f, sum_of_squares); e2_refined =
diff --git a/modules/audio_processing/aec3/subtractor_output.h b/modules/audio_processing/aec3/subtractor_output.h index 10349f5..6fb1d0d 100644 --- a/modules/audio_processing/aec3/subtractor_output.h +++ b/modules/audio_processing/aec3/subtractor_output.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_H_ #include <array> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/fft_data.h" @@ -44,7 +44,7 @@ void Reset(); // Updates the powers of the signals. - void ComputeMetrics(ArrayView<const float> y); + void ComputeMetrics(std::span<const float> y); }; } // namespace webrtc
diff --git a/modules/audio_processing/aec3/subtractor_output_analyzer.cc b/modules/audio_processing/aec3/subtractor_output_analyzer.cc index f0cb672..52d806c 100644 --- a/modules/audio_processing/aec3/subtractor_output_analyzer.cc +++ b/modules/audio_processing/aec3/subtractor_output_analyzer.cc
@@ -12,8 +12,8 @@ #include <algorithm> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/subtractor_output.h" #include "rtc_base/checks.h" @@ -24,7 +24,7 @@ : filters_converged_(num_capture_channels, false) {} void SubtractorOutputAnalyzer::Update( - ArrayView<const SubtractorOutput> subtractor_output, + std::span<const SubtractorOutput> subtractor_output, bool* any_filter_converged, bool* any_coarse_filter_converged, bool* all_filters_diverged) {
diff --git a/modules/audio_processing/aec3/subtractor_output_analyzer.h b/modules/audio_processing/aec3/subtractor_output_analyzer.h index 760ffe6..9559dab 100644 --- a/modules/audio_processing/aec3/subtractor_output_analyzer.h +++ b/modules/audio_processing/aec3/subtractor_output_analyzer.h
@@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_OUTPUT_ANALYZER_H_ #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/subtractor_output.h" namespace webrtc { @@ -26,7 +26,7 @@ ~SubtractorOutputAnalyzer() = default; // Analyses the subtractor output. - void Update(ArrayView<const SubtractorOutput> subtractor_output, + void Update(std::span<const SubtractorOutput> subtractor_output, bool* any_filter_converged, bool* any_coarse_filter_converged, bool* all_filters_diverged);
diff --git a/modules/audio_processing/aec3/subtractor_unittest.cc b/modules/audio_processing/aec3/subtractor_unittest.cc index 9d2be96..5d30146 100644 --- a/modules/audio_processing/aec3/subtractor_unittest.cc +++ b/modules/audio_processing/aec3/subtractor_unittest.cc
@@ -16,11 +16,11 @@ #include <memory> #include <numeric> #include <optional> +#include <span> #include <string> #include <tuple> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -106,14 +106,14 @@ num_render_channels); for (size_t ch = 0; ch < num_render_channels; ++ch) { x_hp_filter[ch] = std::make_unique<CascadedBiQuadFilter>( - ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients)); } std::vector<std::unique_ptr<CascadedBiQuadFilter>> y_hp_filter( num_capture_channels); for (size_t ch = 0; ch < num_capture_channels; ++ch) { y_hp_filter[ch] = std::make_unique<CascadedBiQuadFilter>( - ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients)); } @@ -130,7 +130,7 @@ } else { for (size_t capture_ch = 0; capture_ch < num_capture_channels; ++capture_ch) { - ArrayView<float> y_view = y.View(/*band=*/0, capture_ch); + std::span<float> y_view = y.View(/*band=*/0, capture_ch); for (size_t render_ch = 0; render_ch < num_render_channels; ++render_ch) { std::array<float, kBlockSize> y_channel;
diff --git a/modules/audio_processing/aec3/suppression_filter.cc b/modules/audio_processing/aec3/suppression_filter.cc index fa44591..b5a6f79 100644 --- a/modules/audio_processing/aec3/suppression_filter.cc +++ b/modules/audio_processing/aec3/suppression_filter.cc
@@ -15,9 +15,9 @@ #include <cmath> #include <cstring> #include <iterator> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "modules/audio_processing/aec3/fft_data.h" @@ -86,11 +86,11 @@ SuppressionFilter::~SuppressionFilter() = default; void SuppressionFilter::ApplyGain( - ArrayView<const FftData> comfort_noise, - ArrayView<const FftData> comfort_noise_high_band, + std::span<const FftData> comfort_noise, + std::span<const FftData> comfort_noise_high_band, const std::array<float, kFftLengthBy2Plus1>& suppression_gain, float high_bands_gain, - ArrayView<const FftData> E_lowest_band, + std::span<const FftData> E_lowest_band, Block* e) { RTC_DCHECK(e); RTC_DCHECK_EQ(e->NumBands(), NumBandsForRate(sample_rate_hz_));
diff --git a/modules/audio_processing/aec3/suppression_filter.h b/modules/audio_processing/aec3/suppression_filter.h index 4a6de28..a37d783 100644 --- a/modules/audio_processing/aec3/suppression_filter.h +++ b/modules/audio_processing/aec3/suppression_filter.h
@@ -13,9 +13,9 @@ #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec3_fft.h" #include "modules/audio_processing/aec3/block.h" @@ -33,11 +33,11 @@ SuppressionFilter(const SuppressionFilter&) = delete; SuppressionFilter& operator=(const SuppressionFilter&) = delete; - void ApplyGain(ArrayView<const FftData> comfort_noise, - ArrayView<const FftData> comfort_noise_high_bands, + void ApplyGain(std::span<const FftData> comfort_noise, + std::span<const FftData> comfort_noise_high_bands, const std::array<float, kFftLengthBy2Plus1>& suppression_gain, float high_bands_gain, - ArrayView<const FftData> E_lowest_band, + std::span<const FftData> E_lowest_band, Block* e); private:
diff --git a/modules/audio_processing/aec3/suppression_gain.cc b/modules/audio_processing/aec3/suppression_gain.cc index 0ba04ae..bd92aff 100644 --- a/modules/audio_processing/aec3/suppression_gain.cc +++ b/modules/audio_processing/aec3/suppression_gain.cc
@@ -18,8 +18,8 @@ #include <memory> #include <numeric> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec_state.h" @@ -84,13 +84,13 @@ // Scales the echo according to assessed audibility at the other end. void WeightEchoForAudibility(const EchoCanceller3Config& config, - ArrayView<const float> echo, - ArrayView<float> weighted_echo) { + std::span<const float> echo, + std::span<float> weighted_echo) { RTC_DCHECK_EQ(kFftLengthBy2Plus1, echo.size()); RTC_DCHECK_EQ(kFftLengthBy2Plus1, weighted_echo.size()); auto weigh = [](float threshold, float normalizer, size_t begin, size_t end, - ArrayView<const float> echo, ArrayView<float> weighted_echo) { + std::span<const float> echo, std::span<float> weighted_echo) { for (size_t k = begin; k < end; ++k) { if (echo[k] < threshold) { float tmp = (threshold - echo[k]) * normalizer; @@ -122,8 +122,8 @@ std::atomic<int> SuppressionGain::instance_count_(0); float SuppressionGain::UpperBandsGain( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, const std::optional<int>& narrow_peak_band, bool saturated_echo, @@ -189,7 +189,7 @@ if (!dominant_nearend_detector_->IsNearendState()) { // Bound the upper gain during significant echo activity. const auto& cfg = config_.suppressor.high_bands_suppression; - auto low_frequency_energy = [](ArrayView<const float> spectrum) { + auto low_frequency_energy = [](std::span<const float> spectrum) { RTC_DCHECK_LE(16, spectrum.size()); return std::accumulate(spectrum.begin() + 1, spectrum.begin() + 16, 0.f); }; @@ -230,12 +230,12 @@ // Compute the minimum gain as the attenuating gain to put the signal just // above the zero sample values. -void SuppressionGain::GetMinGain(ArrayView<const float> weighted_residual_echo, - ArrayView<const float> last_nearend, - ArrayView<const float> last_echo, +void SuppressionGain::GetMinGain(std::span<const float> weighted_residual_echo, + std::span<const float> last_nearend, + std::span<const float> last_echo, bool low_noise_render, bool saturated_echo, - ArrayView<float> min_gain) const { + std::span<float> min_gain) const { if (!saturated_echo) { const float min_echo_power = low_noise_render ? config_.echo_audibility.low_render_limit @@ -271,7 +271,7 @@ // Compute the maximum gain by limiting the gain increase from the previous // gain. -void SuppressionGain::GetMaxGain(ArrayView<float> max_gain) const { +void SuppressionGain::GetMaxGain(std::span<float> max_gain) const { const auto& inc = dominant_nearend_detector_->IsNearendState() ? nearend_params_.max_inc_factor : normal_params_.max_inc_factor; @@ -284,9 +284,9 @@ void SuppressionGain::LowerBandGain( bool low_noise_render, const AecState& aec_state, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> suppressor_input, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> residual_echo, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> comfort_noise, + std::span<const std::array<float, kFftLengthBy2Plus1>> suppressor_input, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo, + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise, bool clock_drift, std::array<float, kFftLengthBy2Plus1>* gain) { gain->fill(1.f); @@ -375,13 +375,13 @@ SuppressionGain::~SuppressionGain() = default; void SuppressionGain::GetGain( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum_unbounded, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, const RenderSignalAnalyzer& render_signal_analyzer, const AecState& aec_state,
diff --git a/modules/audio_processing/aec3/suppression_gain.h b/modules/audio_processing/aec3/suppression_gain.h index b0a56d0..550b533 100644 --- a/modules/audio_processing/aec3/suppression_gain.h +++ b/modules/audio_processing/aec3/suppression_gain.h
@@ -16,9 +16,9 @@ #include <cstddef> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec_state.h" @@ -42,13 +42,13 @@ SuppressionGain& operator=(const SuppressionGain&) = delete; void GetGain( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> nearend_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo_spectrum_unbounded, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, const RenderSignalAnalyzer& render_signal_analyzer, const AecState& aec_state, @@ -67,8 +67,8 @@ private: // Computes the gain to apply for the bands beyond the first band. float UpperBandsGain( - ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> + std::span<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum, + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise_spectrum, const std::optional<int>& narrow_peak_band, bool saturated_echo, @@ -83,20 +83,20 @@ void LowerBandGain( bool stationary_with_low_power, const AecState& aec_state, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> suppressor_input, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> residual_echo, - ArrayView<const std::array<float, kFftLengthBy2Plus1>> comfort_noise, + std::span<const std::array<float, kFftLengthBy2Plus1>> suppressor_input, + std::span<const std::array<float, kFftLengthBy2Plus1>> residual_echo, + std::span<const std::array<float, kFftLengthBy2Plus1>> comfort_noise, bool clock_drift, std::array<float, kFftLengthBy2Plus1>* gain); - void GetMinGain(ArrayView<const float> weighted_residual_echo, - ArrayView<const float> last_nearend, - ArrayView<const float> last_echo, + void GetMinGain(std::span<const float> weighted_residual_echo, + std::span<const float> last_nearend, + std::span<const float> last_echo, bool low_noise_render, bool saturated_echo, - ArrayView<float> min_gain) const; + std::span<float> min_gain) const; - void GetMaxGain(ArrayView<float> max_gain) const; + void GetMaxGain(std::span<float> max_gain) const; class LowNoiseRenderDetector { public:
diff --git a/modules/audio_processing/aec3/vector_math.h b/modules/audio_processing/aec3/vector_math.h index 9fd7792..d8b5ecf 100644 --- a/modules/audio_processing/aec3/vector_math.h +++ b/modules/audio_processing/aec3/vector_math.h
@@ -14,8 +14,8 @@ #include <algorithm> #include <cmath> #include <functional> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/checks.h" @@ -38,8 +38,8 @@ : optimization_(optimization) {} // Elementwise square root. - void SqrtAVX2(ArrayView<float> x); - void Sqrt(ArrayView<float> x) { + void SqrtAVX2(std::span<float> x); + void Sqrt(std::span<float> x) { switch (optimization_) { #if defined(WEBRTC_ARCH_X86_FAMILY) case Aec3Optimization::kSse2: { @@ -112,12 +112,12 @@ } // Elementwise vector multiplication z = x * y. - void MultiplyAVX2(ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> z); - void Multiply(ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> z) { + void MultiplyAVX2(std::span<const float> x, + std::span<const float> y, + std::span<float> z); + void Multiply(std::span<const float> x, + std::span<const float> y, + std::span<float> z) { RTC_DCHECK_EQ(z.size(), x.size()); RTC_DCHECK_EQ(z.size(), y.size()); switch (optimization_) { @@ -167,8 +167,8 @@ } // Elementwise vector accumulation z += x. - void AccumulateAVX2(ArrayView<const float> x, ArrayView<float> z); - void Accumulate(ArrayView<const float> x, ArrayView<float> z) { + void AccumulateAVX2(std::span<const float> x, std::span<float> z); + void Accumulate(std::span<const float> x, std::span<float> z) { RTC_DCHECK_EQ(z.size(), x.size()); switch (optimization_) { #if defined(WEBRTC_ARCH_X86_FAMILY)
diff --git a/modules/audio_processing/aec3/vector_math_avx2.cc b/modules/audio_processing/aec3/vector_math_avx2.cc index da4dd6e..2288420 100644 --- a/modules/audio_processing/aec3/vector_math_avx2.cc +++ b/modules/audio_processing/aec3/vector_math_avx2.cc
@@ -11,8 +11,8 @@ #include <immintrin.h> #include <cmath> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/aec3/vector_math.h" #include "rtc_base/checks.h" @@ -20,7 +20,7 @@ namespace aec3 { // Elementwise square root. -void VectorMath::SqrtAVX2(ArrayView<float> x) { +void VectorMath::SqrtAVX2(std::span<float> x) { const int x_size = static_cast<int>(x.size()); const int vector_limit = x_size >> 3; @@ -37,9 +37,9 @@ } // Elementwise vector multiplication z = x * y. -void VectorMath::MultiplyAVX2(ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float> z) { +void VectorMath::MultiplyAVX2(std::span<const float> x, + std::span<const float> y, + std::span<float> z) { RTC_DCHECK_EQ(z.size(), x.size()); RTC_DCHECK_EQ(z.size(), y.size()); const int x_size = static_cast<int>(x.size()); @@ -59,7 +59,7 @@ } // Elementwise vector accumulation z += x. -void VectorMath::AccumulateAVX2(ArrayView<const float> x, ArrayView<float> z) { +void VectorMath::AccumulateAVX2(std::span<const float> x, std::span<float> z) { RTC_DCHECK_EQ(z.size(), x.size()); const int x_size = static_cast<int>(x.size()); const int vector_limit = x_size >> 3;