Replace ArrayView with std::span in modules/audio_processing ArrayView is an alias to std::span. This change switch to use std::span directly instead of through the alias. 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 Replace ExpectArrayViewEquality helper with ElementsAreArray matcher in pffft_wrapper_unittest.cc Bug: webrtc:439801349 Change-Id: I9503bc9003ee6a7e349459989b03f59a7de37ea6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/460320 Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Evan Shrubsole <eshr@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47270}
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index 2997c45..e169aa7 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn
@@ -57,7 +57,6 @@ defines = [] deps = [ - "../../api:array_view", "../../api/audio:audio_frame_api", "../../api/audio:audio_processing", "../../common_audio", @@ -80,7 +79,6 @@ deps = [ ":audio_buffer", - "../../api:array_view", "../../rtc_base:checks", "utility:cascaded_biquad_filter", ] @@ -98,7 +96,6 @@ deps = [ ":audio_buffer", - "../../api:array_view", "../../rtc_base:checks", "utility:cascaded_biquad_filter", ] @@ -174,7 +171,6 @@ ":high_pass_filter", ":post_filter", ":rms_level", - "../../api:array_view", "../../api:field_trials_view", "../../api:function_view", "../../api:make_ref_counted", @@ -245,7 +241,6 @@ ] deps = [ ":apm_logging", - "../../api:array_view", "../../api/audio:audio_processing", "../../rtc_base:checks", "../../rtc_base:logging", @@ -259,10 +254,7 @@ "rms_level.cc", "rms_level.h", ] - deps = [ - "../../api:array_view", - "../../rtc_base:checks", - ] + deps = [ "../../rtc_base:checks" ] } rtc_library("audio_processing_statistics") { @@ -294,7 +286,6 @@ "logging/apm_data_dumper.h", ] deps = [ - "../../api:array_view", "../../common_audio", "../../rtc_base:checks", "../../rtc_base:stringutils", @@ -311,7 +302,6 @@ ":aec_dump_interface", ":audio_buffer", ":audio_processing", - "../../api:array_view", "../../api:scoped_refptr", "../../api/audio:audio_processing", "../../api/audio:audio_processing_statistics", @@ -363,7 +353,6 @@ ":high_pass_filter", ":mocks", ":post_filter", - "../../api:array_view", "../../api:make_ref_counted", "../../api:ref_count", "../../api:scoped_refptr", @@ -485,7 +474,6 @@ deps = [ ":audio_processing", ":audioproc_test_utils", - "../../api:array_view", "../../api:scoped_refptr", "../../api/audio:audio_processing", "../../api/audio:builtin_audio_processing_builder", @@ -512,7 +500,6 @@ "test/fake_recording_device.h", ] deps = [ - "../../api:array_view", "../../api/audio:audio_frame_api", "../../common_audio", "../../rtc_base:checks", @@ -639,7 +626,6 @@ deps = [ ":audio_buffer", ":audio_processing", - "../../api:array_view", "../../api/audio:audio_frame_api", "../../api/audio:audio_processing", "../../common_audio",
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn index 090fbd4..d2a4a5f 100644 --- a/modules/audio_processing/agc/BUILD.gn +++ b/modules/audio_processing/agc/BUILD.gn
@@ -24,7 +24,6 @@ "..:apm_logging", "..:audio_buffer", "..:audio_frame_view", - "../../../api:array_view", "../../../api:field_trials_view", "../../../api/audio:audio_processing", "../../../api/environment", @@ -52,7 +51,6 @@ "utility.h", ] deps = [ - "../../../api:array_view", "../../../rtc_base:checks", "../vad", ] @@ -108,7 +106,6 @@ ":level_estimation", "..:audio_buffer", "..:mocks", - "../../../api:array_view", "../../../api:field_trials", "../../../api/audio:audio_processing", "../../../api/environment",
diff --git a/modules/audio_processing/agc/agc.cc b/modules/audio_processing/agc/agc.cc index 29e84b4..fb5a9ed 100644 --- a/modules/audio_processing/agc/agc.cc +++ b/modules/audio_processing/agc/agc.cc
@@ -13,9 +13,9 @@ #include <cmath> #include <cstdint> #include <cstdlib> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc/loudness_histogram.h" #include "modules/audio_processing/agc/utility.h" #include "rtc_base/checks.h" @@ -39,7 +39,7 @@ Agc::~Agc() = default; -void Agc::Process(ArrayView<const int16_t> audio) { +void Agc::Process(std::span<const int16_t> audio) { const int sample_rate_hz = audio.size() * kNum10msFramesInOneSecond; RTC_DCHECK_LE(sample_rate_hz, kMaxSampleRateHz); vad_.ProcessChunk(audio.data(), audio.size(), sample_rate_hz);
diff --git a/modules/audio_processing/agc/agc.h b/modules/audio_processing/agc/agc.h index dfc769b..f5bd192 100644 --- a/modules/audio_processing/agc/agc.h +++ b/modules/audio_processing/agc/agc.h
@@ -13,8 +13,8 @@ #include <cstdint> #include <memory> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/vad/voice_activity_detector.h" namespace webrtc { @@ -28,7 +28,7 @@ // `audio` must be mono; in a multi-channel stream, provide the first (usually // left) channel. - virtual void Process(ArrayView<const int16_t> audio); + virtual void Process(std::span<const int16_t> audio); // Retrieves the difference between the target RMS level and the current // signal RMS level in dB. Returns true if an update is available and false
diff --git a/modules/audio_processing/agc/agc_manager_direct.cc b/modules/audio_processing/agc/agc_manager_direct.cc index a8d9ebd..3d5f7fa 100644 --- a/modules/audio_processing/agc/agc_manager_direct.cc +++ b/modules/audio_processing/agc/agc_manager_direct.cc
@@ -19,8 +19,8 @@ #include <cstdio> #include <memory> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" @@ -200,7 +200,7 @@ is_first_frame_ = true; } -void MonoAgc::Process(ArrayView<const int16_t> audio, +void MonoAgc::Process(std::span<const int16_t> audio, std::optional<int> rms_error_override) { new_compression_to_set_ = std::nullopt;
diff --git a/modules/audio_processing/agc/agc_manager_direct.h b/modules/audio_processing/agc/agc_manager_direct.h index 5bbbf67..04b2e1b 100644 --- a/modules/audio_processing/agc/agc_manager_direct.h +++ b/modules/audio_processing/agc/agc_manager_direct.h
@@ -15,9 +15,9 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/environment/environment.h" #include "modules/audio_processing/agc/agc.h" @@ -217,7 +217,7 @@ // the (digital) compression gain to be applied by `agc_`. Must be called // after `HandleClipping()`. If `rms_error_override` has a value, RMS error // from AGC is overridden by it. - void Process(ArrayView<const int16_t> audio, + void Process(std::span<const int16_t> audio, std::optional<int> rms_error_override); // Returns the recommended input volume. Must be called after `Process()`.
diff --git a/modules/audio_processing/agc/mock_agc.h b/modules/audio_processing/agc/mock_agc.h index f958d16..8086aa9 100644 --- a/modules/audio_processing/agc/mock_agc.h +++ b/modules/audio_processing/agc/mock_agc.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AGC_MOCK_AGC_H_ #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc/agc.h" #include "test/gmock.h" @@ -22,7 +22,7 @@ class MockAgc : public Agc { public: ~MockAgc() override {} - MOCK_METHOD(void, Process, (ArrayView<const int16_t> audio), (override)); + MOCK_METHOD(void, Process, (std::span<const int16_t> audio), (override)); MOCK_METHOD(bool, GetRmsErrorDb, (int* error), (override)); MOCK_METHOD(void, Reset, (), (override)); MOCK_METHOD(int, set_target_level_dbfs, (int level), (override));
diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn index 0de1c32..92276ee 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn
@@ -28,7 +28,6 @@ deps = [ ":common", "..:apm_logging", - "../../../api:array_view", "../../../api:field_trials_view", "../../../api/audio:audio_processing", "../../../rtc_base:checks", @@ -94,10 +93,7 @@ "biquad_filter.cc", "biquad_filter.h", ] - deps = [ - "../../../api:array_view", - "../../../rtc_base:checks", - ] + deps = [ "../../../rtc_base:checks" ] } rtc_library("clipping_predictor") { @@ -150,7 +146,6 @@ ":common", "..:apm_logging", "..:audio_frame_view", - "../../../api:array_view", "../../../api/audio:audio_frame_api", "../../../common_audio", "../../../rtc_base:checks", @@ -216,7 +211,6 @@ ":input_volume_stats_reporter", "..:audio_buffer", "..:audio_frame_view", - "../../../api:array_view", "../../../api:field_trials_view", "../../../api/audio:audio_processing", "../../../rtc_base:checks", @@ -370,7 +364,6 @@ sources = [ "biquad_filter_unittest.cc" ] deps = [ ":biquad_filter", - "../../../api:array_view", "../../../rtc_base:gunit_helpers", "../../../test:test_support", ] @@ -397,7 +390,6 @@ ":test_utils", "..:apm_logging", "..:audio_frame_view", - "../../../api:array_view", "../../../api/audio:audio_frame_api", "../../../common_audio", "../../../rtc_base:checks", @@ -424,7 +416,6 @@ ":input_volume_controller", "..:audio_buffer", "..:audio_frame_view", - "../../../api:array_view", "../../../api/audio:audio_processing", "../../../api/environment:environment_factory", "../../../rtc_base:checks", @@ -462,7 +453,6 @@ deps = [ ":common", ":vad_wrapper", - "../../../api:array_view", "../../../api/audio:audio_frame_api", "../../../rtc_base:checks", "../../../rtc_base:gunit_helpers",
diff --git a/modules/audio_processing/agc2/biquad_filter.cc b/modules/audio_processing/agc2/biquad_filter.cc index 9ff831a..e64521c 100644 --- a/modules/audio_processing/agc2/biquad_filter.cc +++ b/modules/audio_processing/agc2/biquad_filter.cc
@@ -11,8 +11,8 @@ #include "modules/audio_processing/agc2/biquad_filter.h" #include <cstddef> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -31,7 +31,7 @@ state_ = {}; } -void BiQuadFilter::Process(ArrayView<const float> x, ArrayView<float> y) { +void BiQuadFilter::Process(std::span<const float> x, std::span<float> y) { RTC_DCHECK_EQ(x.size(), y.size()); const float config_a0 = config_.a[0]; const float config_a1 = config_.a[1];
diff --git a/modules/audio_processing/agc2/biquad_filter.h b/modules/audio_processing/agc2/biquad_filter.h index 766a750..8613500 100644 --- a/modules/audio_processing/agc2/biquad_filter.h +++ b/modules/audio_processing/agc2/biquad_filter.h
@@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_PROCESSING_AGC2_BIQUAD_FILTER_H_ #define MODULES_AUDIO_PROCESSING_AGC2_BIQUAD_FILTER_H_ -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -41,7 +41,7 @@ // Filters `x` and writes the output in `y`, which must have the same length // of `x`. In-place processing is supported. - void Process(ArrayView<const float> x, ArrayView<float> y); + void Process(std::span<const float> x, std::span<float> y); private: Config config_;
diff --git a/modules/audio_processing/agc2/biquad_filter_unittest.cc b/modules/audio_processing/agc2/biquad_filter_unittest.cc index bdfdfba..f0906c8 100644 --- a/modules/audio_processing/agc2/biquad_filter_unittest.cc +++ b/modules/audio_processing/agc2/biquad_filter_unittest.cc
@@ -17,7 +17,8 @@ // TODO(bugs.webrtc.org/8948): Add when the issue is fixed. // #include "test/fpe_observer.h" -#include "api/array_view.h" +#include <span> + #include "test/gtest.h" namespace webrtc { @@ -58,11 +59,11 @@ {{24.84286614f, -62.18094158f, 57.91488056f, -106.65685933f, 13.38760103f, -36.60367134f, -94.44880104f, -3.59920354f}}}}; -// Fails for every pair from two equally sized ArrayView<float> views +// Fails for every pair from two equally sized std::span<float> views // such that their relative error is above a given threshold. If the expected // value of a pair is 0, `tolerance` is used to check the absolute error. -void ExpectNearRelative(ArrayView<const float> expected, - ArrayView<const float> computed, +void ExpectNearRelative(std::span<const float> expected, + std::span<const float> computed, const float tolerance) { // The relative error is undefined when the expected value is 0. // When that happens, check the absolute error instead. `safe_den` is used
diff --git a/modules/audio_processing/agc2/fixed_digital_level_estimator.cc b/modules/audio_processing/agc2/fixed_digital_level_estimator.cc index a84bb2c..99a4534 100644 --- a/modules/audio_processing/agc2/fixed_digital_level_estimator.cc +++ b/modules/audio_processing/agc2/fixed_digital_level_estimator.cc
@@ -15,7 +15,6 @@ #include <cmath> #include <cstddef> -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_view.h" #include "modules/audio_processing/agc2/agc2_common.h"
diff --git a/modules/audio_processing/agc2/limiter.cc b/modules/audio_processing/agc2/limiter.cc index faa252c..c564a83 100644 --- a/modules/audio_processing/agc2/limiter.cc +++ b/modules/audio_processing/agc2/limiter.cc
@@ -14,9 +14,9 @@ #include <array> #include <cmath> #include <cstddef> +#include <span> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_view.h" #include "modules/audio_processing/agc2/agc2_common.h" #include "modules/audio_processing/agc2/interpolated_gain_curve.h" @@ -38,7 +38,7 @@ void InterpolateFirstSubframe(float last_factor, float current_factor, - ArrayView<float> subframe) { + std::span<float> subframe) { const int n = dchecked_cast<int>(subframe.size()); constexpr float p = kAttackFirstSubframeInterpolationPower; for (int i = 0; i < n; ++i) {
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn index 075e2a8..53c9af2 100644 --- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn +++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -32,7 +32,6 @@ ":rnn_vad_spectral_features", "..:biquad_filter", "..:cpu_features", - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:safe_compare", "../../../../rtc_base:safe_conversions", @@ -47,7 +46,6 @@ ] deps = [ ":rnn_vad_common", - "../../../../api:array_view", "../../../../rtc_base:checks", "../../utility:pffft_wrapper", ] @@ -71,7 +69,6 @@ "lp_residual.h", ] deps = [ - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:safe_compare", ] @@ -95,7 +92,6 @@ ":rnn_vad_common", ":vector_math", "..:cpu_features", - "../../../../api:array_view", "../../../../api:function_view", "../../../../rtc_base:checks", "../../../../rtc_base:safe_conversions", @@ -111,7 +107,6 @@ sources = [ "vector_math.h" ] deps = [ "..:cpu_features", - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:safe_conversions", "../../../../rtc_base/system:arch", @@ -131,7 +126,6 @@ } deps = [ ":vector_math", - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:safe_conversions", ] @@ -157,7 +151,6 @@ ":rnn_vad_common", ":vector_math", "..:cpu_features", - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:gtest_prod", "../../../../rtc_base:safe_compare", @@ -171,18 +164,12 @@ rtc_source_set("rnn_vad_ring_buffer") { sources = [ "ring_buffer.h" ] - deps = [ - "../../../../api:array_view", - "../../../../rtc_base:checks", - ] + deps = [ "../../../../rtc_base:checks" ] } rtc_source_set("rnn_vad_sequence_buffer") { sources = [ "sequence_buffer.h" ] - deps = [ - "../../../../api:array_view", - "../../../../rtc_base:checks", - ] + deps = [ "../../../../rtc_base:checks" ] } rtc_library("rnn_vad_spectral_features") { @@ -196,7 +183,6 @@ ":rnn_vad_common", ":rnn_vad_ring_buffer", ":rnn_vad_symmetric_matrix_buffer", - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:safe_compare", "../../utility:pffft_wrapper", @@ -206,7 +192,6 @@ rtc_source_set("rnn_vad_symmetric_matrix_buffer") { sources = [ "symmetric_matrix_buffer.h" ] deps = [ - "../../../../api:array_view", "../../../../rtc_base:checks", "../../../../rtc_base:safe_compare", ] @@ -222,7 +207,6 @@ deps = [ ":rnn_vad", ":rnn_vad_common", - "../../../../api:array_view", "../../../../api:scoped_refptr", "../../../../rtc_base:checks", "../../../../rtc_base:safe_compare", @@ -290,7 +274,6 @@ ":vector_math", "..:cpu_features", "../..:audioproc_test_utils", - "../../../../api:array_view", "../../../../common_audio/", "../../../../rtc_base:checks", "../../../../rtc_base:logging",
diff --git a/modules/audio_processing/agc2/rnn_vad/auto_correlation.cc b/modules/audio_processing/agc2/rnn_vad/auto_correlation.cc index b5f9f75..971e00d 100644 --- a/modules/audio_processing/agc2/rnn_vad/auto_correlation.cc +++ b/modules/audio_processing/agc2/rnn_vad/auto_correlation.cc
@@ -11,8 +11,8 @@ #include "modules/audio_processing/agc2/rnn_vad/auto_correlation.h" #include <algorithm> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/utility/pffft_wrapper.h" #include "rtc_base/checks.h" @@ -47,8 +47,8 @@ // inverted lag equal to 0 that corresponds to a lag equal to the maximum // pitch period. void AutoCorrelationCalculator::ComputeOnPitchBuffer( - ArrayView<const float, kBufSize12kHz> pitch_buf, - ArrayView<float, kNumLags12kHz> auto_corr) { + std::span<const float, kBufSize12kHz> pitch_buf, + std::span<float, kNumLags12kHz> auto_corr) { RTC_DCHECK_LT(auto_corr.size(), kMaxPitch12kHz); RTC_DCHECK_GT(pitch_buf.size(), kMaxPitch12kHz); constexpr int kFftFrameSize = 1 << kAutoCorrelationFftOrder;
diff --git a/modules/audio_processing/agc2/rnn_vad/auto_correlation.h b/modules/audio_processing/agc2/rnn_vad/auto_correlation.h index 127b259..edda13f 100644 --- a/modules/audio_processing/agc2/rnn_vad/auto_correlation.h +++ b/modules/audio_processing/agc2/rnn_vad/auto_correlation.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_AUTO_CORRELATION_H_ #include <memory> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/utility/pffft_wrapper.h" @@ -32,8 +32,8 @@ // Computes the auto-correlation coefficients for a target pitch interval. // `auto_corr` indexes are inverted lags. - void ComputeOnPitchBuffer(ArrayView<const float, kBufSize12kHz> pitch_buf, - ArrayView<float, kNumLags12kHz> auto_corr); + void ComputeOnPitchBuffer(std::span<const float, kBufSize12kHz> pitch_buf, + std::span<float, kNumLags12kHz> auto_corr); private: Pffft fft_;
diff --git a/modules/audio_processing/agc2/rnn_vad/features_extraction.cc b/modules/audio_processing/agc2/rnn_vad/features_extraction.cc index 1dbfa1a..53362ea 100644 --- a/modules/audio_processing/agc2/rnn_vad/features_extraction.cc +++ b/modules/audio_processing/agc2/rnn_vad/features_extraction.cc
@@ -12,8 +12,8 @@ #include <array> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/biquad_filter.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" @@ -55,8 +55,8 @@ } bool FeaturesExtractor::CheckSilenceComputeFeatures( - ArrayView<const float, kFrameSize10ms24kHz> samples, - ArrayView<float, kFeatureVectorSize> feature_vector) { + std::span<const float, kFrameSize10ms24kHz> samples, + std::span<float, kFeatureVectorSize> feature_vector) { // Pre-processing. if (use_high_pass_filter_) { std::array<float, kFrameSize10ms24kHz> samples_filtered;
diff --git a/modules/audio_processing/agc2/rnn_vad/features_extraction.h b/modules/audio_processing/agc2/rnn_vad/features_extraction.h index 2928a7f..f952045 100644 --- a/modules/audio_processing/agc2/rnn_vad/features_extraction.h +++ b/modules/audio_processing/agc2/rnn_vad/features_extraction.h
@@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_FEATURES_EXTRACTION_H_ #define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_FEATURES_EXTRACTION_H_ +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/biquad_filter.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" @@ -37,8 +37,8 @@ // `feature_vector` is partially written and therefore must not be used to // feed the VAD RNN. bool CheckSilenceComputeFeatures( - ArrayView<const float, kFrameSize10ms24kHz> samples, - ArrayView<float, kFeatureVectorSize> feature_vector); + std::span<const float, kFrameSize10ms24kHz> samples, + std::span<float, kFeatureVectorSize> feature_vector); private: const bool use_high_pass_filter_; @@ -47,11 +47,11 @@ BiQuadFilter hpf_; SequenceBuffer<float, kBufSize24kHz, kFrameSize10ms24kHz, kFrameSize20ms24kHz> pitch_buf_24kHz_; - ArrayView<const float, kBufSize24kHz> pitch_buf_24kHz_view_; + std::span<const float, kBufSize24kHz> pitch_buf_24kHz_view_; std::vector<float> lp_residual_; - ArrayView<float, kBufSize24kHz> lp_residual_view_; + std::span<float, kBufSize24kHz> lp_residual_view_; PitchEstimator pitch_estimator_; - ArrayView<const float, kFrameSize20ms24kHz> reference_frame_view_; + std::span<const float, kFrameSize20ms24kHz> reference_frame_view_; SpectralFeaturesExtractor spectral_features_extractor_; int pitch_period_48kHz_; };
diff --git a/modules/audio_processing/agc2/rnn_vad/features_extraction_unittest.cc b/modules/audio_processing/agc2/rnn_vad/features_extraction_unittest.cc index 7c0b575..b63198d 100644 --- a/modules/audio_processing/agc2/rnn_vad/features_extraction_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/features_extraction_unittest.cc
@@ -11,9 +11,9 @@ #include "modules/audio_processing/agc2/rnn_vad/features_extraction.h" #include <cmath> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "rtc_base/numerics/safe_compare.h" @@ -43,7 +43,7 @@ pitch_period <= kMaxPitch24kHz; } -void CreatePureTone(float amplitude, float freq_hz, ArrayView<float> dst) { +void CreatePureTone(float amplitude, float freq_hz, std::span<float> dst) { for (int i = 0; SafeLt(i, dst.size()); ++i) { dst[i] = amplitude * std::sin(2.f * kPi * freq_hz * i / kSampleRate24kHz); } @@ -53,8 +53,8 @@ // For every frame, the output is written into `feature_vector`. Returns true // if silence is detected in the last frame. bool FeedTestData(FeaturesExtractor& features_extractor, - ArrayView<const float> samples, - ArrayView<float, kFeatureVectorSize> feature_vector) { + std::span<const float> samples, + std::span<float, kFeatureVectorSize> feature_vector) { // TODO(bugs.webrtc.org/8948): Add when the issue is fixed. // FloatingPointExceptionObserver fpe_observer; bool is_silence = true; @@ -81,7 +81,7 @@ std::vector<float> samples(kNumTestDataSize); std::vector<float> feature_vector(kFeatureVectorSize); ASSERT_EQ(kFeatureVectorSize, dchecked_cast<int>(feature_vector.size())); - ArrayView<float, kFeatureVectorSize> feature_vector_view( + std::span<float, kFeatureVectorSize> feature_vector_view( feature_vector.data(), kFeatureVectorSize); // Extract the normalized scalar feature that is proportional to the estimated
diff --git a/modules/audio_processing/agc2/rnn_vad/lp_residual.cc b/modules/audio_processing/agc2/rnn_vad/lp_residual.cc index 46cb1eb..5960552 100644 --- a/modules/audio_processing/agc2/rnn_vad/lp_residual.cc +++ b/modules/audio_processing/agc2/rnn_vad/lp_residual.cc
@@ -14,8 +14,8 @@ #include <array> #include <cmath> #include <numeric> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_compare.h" @@ -26,8 +26,8 @@ // Computes auto-correlation coefficients for `x` and writes them in // `auto_corr`. The lag values are in {0, ..., max_lag - 1}, where max_lag // equals the size of `auto_corr`. -void ComputeAutoCorrelation(ArrayView<const float> x, - ArrayView<float, kNumLpcCoefficients> auto_corr) { +void ComputeAutoCorrelation(std::span<const float> x, + std::span<float, kNumLpcCoefficients> auto_corr) { constexpr int max_lag = auto_corr.size(); RTC_DCHECK_LT(max_lag, x.size()); for (int lag = 0; lag < max_lag; ++lag) { @@ -37,7 +37,7 @@ } // Applies denoising to the auto-correlation coefficients. -void DenoiseAutoCorrelation(ArrayView<float, kNumLpcCoefficients> auto_corr) { +void DenoiseAutoCorrelation(std::span<float, kNumLpcCoefficients> auto_corr) { // Assume -40 dB white noise floor. auto_corr[0] *= 1.0001f; // Hard-coded values obtained as @@ -52,8 +52,8 @@ // Computes the initial inverse filter coefficients given the auto-correlation // coefficients of an input frame. void ComputeInitialInverseFilterCoefficients( - ArrayView<const float, kNumLpcCoefficients> auto_corr, - ArrayView<float, kNumLpcCoefficients - 1> lpc_coeffs) { + std::span<const float, kNumLpcCoefficients> auto_corr, + std::span<float, kNumLpcCoefficients - 1> lpc_coeffs) { float error = auto_corr[0]; for (int i = 0; i < kNumLpcCoefficients - 1; ++i) { float reflection_coeff = 0.f; @@ -87,8 +87,8 @@ } // namespace void ComputeAndPostProcessLpcCoefficients( - ArrayView<const float> x, - ArrayView<float, kNumLpcCoefficients> lpc_coeffs) { + std::span<const float> x, + std::span<float, kNumLpcCoefficients> lpc_coeffs) { std::array<float, kNumLpcCoefficients> auto_corr; ComputeAutoCorrelation(x, auto_corr); if (auto_corr[0] == 0.f) { // Empty frame. @@ -113,9 +113,9 @@ static_assert(kNumLpcCoefficients == 5, "Update `lpc_coeffs(_pre)`."); } -void ComputeLpResidual(ArrayView<const float, kNumLpcCoefficients> lpc_coeffs, - ArrayView<const float> x, - ArrayView<float> y) { +void ComputeLpResidual(std::span<const float, kNumLpcCoefficients> lpc_coeffs, + std::span<const float> x, + std::span<float> y) { RTC_DCHECK_GT(x.size(), kNumLpcCoefficients); RTC_DCHECK_EQ(x.size(), y.size()); // The code below implements the following operation:
diff --git a/modules/audio_processing/agc2/rnn_vad/lp_residual.h b/modules/audio_processing/agc2/rnn_vad/lp_residual.h index f29dfe0..1151637 100644 --- a/modules/audio_processing/agc2/rnn_vad/lp_residual.h +++ b/modules/audio_processing/agc2/rnn_vad/lp_residual.h
@@ -13,7 +13,7 @@ #include <stddef.h> -#include "api/array_view.h" +#include <span> namespace webrtc { namespace rnn_vad { @@ -24,15 +24,15 @@ // Given a frame `x`, computes a post-processed version of LPC coefficients // tailored for pitch estimation. void ComputeAndPostProcessLpcCoefficients( - ArrayView<const float> x, - ArrayView<float, kNumLpcCoefficients> lpc_coeffs); + std::span<const float> x, + std::span<float, kNumLpcCoefficients> lpc_coeffs); // Computes the LP residual for the input frame `x` and the LPC coefficients // `lpc_coeffs`. `y` and `x` can point to the same array for in-place // computation. -void ComputeLpResidual(ArrayView<const float, kNumLpcCoefficients> lpc_coeffs, - ArrayView<const float> x, - ArrayView<float> y); +void ComputeLpResidual(std::span<const float, kNumLpcCoefficients> lpc_coeffs, + std::span<const float> x, + std::span<float> y); } // namespace rnn_vad } // namespace webrtc
diff --git a/modules/audio_processing/agc2/rnn_vad/pitch_search.cc b/modules/audio_processing/agc2/rnn_vad/pitch_search.cc index d6fe28b..cd734d2 100644 --- a/modules/audio_processing/agc2/rnn_vad/pitch_search.cc +++ b/modules/audio_processing/agc2/rnn_vad/pitch_search.cc
@@ -11,8 +11,8 @@ #include "modules/audio_processing/agc2/rnn_vad/pitch_search.h" #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h" @@ -30,11 +30,11 @@ PitchEstimator::~PitchEstimator() = default; int PitchEstimator::Estimate( - ArrayView<const float, kBufSize24kHz> pitch_buffer) { - ArrayView<float, kBufSize12kHz> pitch_buffer_12kHz_view( + std::span<const float, kBufSize24kHz> pitch_buffer) { + std::span<float, kBufSize12kHz> pitch_buffer_12kHz_view( pitch_buffer_12kHz_.data(), kBufSize12kHz); RTC_DCHECK_EQ(pitch_buffer_12kHz_.size(), pitch_buffer_12kHz_view.size()); - ArrayView<float, kNumLags12kHz> auto_correlation_12kHz_view( + std::span<float, kNumLags12kHz> auto_correlation_12kHz_view( auto_correlation_12kHz_.data(), kNumLags12kHz); RTC_DCHECK_EQ(auto_correlation_12kHz_.size(), auto_correlation_12kHz_view.size()); @@ -54,7 +54,7 @@ // Refine the initial pitch period estimation from 12 kHz to 48 kHz. // Pre-compute frame energies at 24 kHz. - ArrayView<float, kRefineNumLags24kHz> y_energy_24kHz_view( + std::span<float, kRefineNumLags24kHz> y_energy_24kHz_view( y_energy_24kHz_.data(), kRefineNumLags24kHz); RTC_DCHECK_EQ(y_energy_24kHz_.size(), y_energy_24kHz_view.size()); ComputeSlidingFrameSquareEnergies24kHz(pitch_buffer, y_energy_24kHz_view,
diff --git a/modules/audio_processing/agc2/rnn_vad/pitch_search.h b/modules/audio_processing/agc2/rnn_vad/pitch_search.h index 2804424..9f228bc 100644 --- a/modules/audio_processing/agc2/rnn_vad/pitch_search.h +++ b/modules/audio_processing/agc2/rnn_vad/pitch_search.h
@@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_H_ #define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_H_ +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/auto_correlation.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" @@ -31,7 +31,7 @@ PitchEstimator& operator=(const PitchEstimator&) = delete; ~PitchEstimator(); // Returns the estimated pitch period at 48 kHz. - int Estimate(ArrayView<const float, kBufSize24kHz> pitch_buffer); + int Estimate(std::span<const float, kBufSize24kHz> pitch_buffer); private: FRIEND_TEST_ALL_PREFIXES(RnnVadTest, PitchSearchWithinTolerance);
diff --git a/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.cc b/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.cc index 084eb21..25f33fa 100644 --- a/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.cc +++ b/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.cc
@@ -15,8 +15,8 @@ #include <cmath> #include <cstddef> #include <cstdlib> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/vector_math.h" @@ -27,7 +27,7 @@ namespace { float ComputeAutoCorrelation(int inverted_lag, - ArrayView<const float, kBufSize24kHz> pitch_buffer, + std::span<const float, kBufSize24kHz> pitch_buffer, const VectorMath& vector_math) { RTC_DCHECK_LT(inverted_lag, kBufSize24kHz); RTC_DCHECK_LT(inverted_lag, kRefineNumLags24kHz); @@ -65,7 +65,7 @@ // output sample rate is twice as that of `lag`. int PitchPseudoInterpolationLagPitchBuf( int lag, - ArrayView<const float, kBufSize24kHz> pitch_buffer, + std::span<const float, kBufSize24kHz> pitch_buffer, const VectorMath& vector_math) { int offset = 0; // Cannot apply pseudo-interpolation at the boundaries. @@ -158,8 +158,8 @@ // the inverted lags for the computed auto correlation values. void ComputeAutoCorrelation( Range inverted_lags, - ArrayView<const float, kBufSize24kHz> pitch_buffer, - ArrayView<float, kInitialNumLags24kHz> auto_correlation, + std::span<const float, kBufSize24kHz> pitch_buffer, + std::span<float, kInitialNumLags24kHz> auto_correlation, InvertedLagsIndex& inverted_lags_index, const VectorMath& vector_math) { // Check valid range. @@ -186,10 +186,10 @@ // Searches the strongest pitch period at 24 kHz and returns its inverted lag at // 48 kHz. int ComputePitchPeriod48kHz( - ArrayView<const float, kBufSize24kHz> /* pitch_buffer */, - ArrayView<const int> inverted_lags, - ArrayView<const float, kInitialNumLags24kHz> auto_correlation, - ArrayView<const float, kRefineNumLags24kHz> y_energy, + std::span<const float, kBufSize24kHz> /* pitch_buffer */, + std::span<const int> inverted_lags, + std::span<const float, kInitialNumLags24kHz> auto_correlation, + std::span<const float, kRefineNumLags24kHz> y_energy, const VectorMath& /* vector_math */) { static_assert(kMaxPitch24kHz > kInitialNumLags24kHz, ""); static_assert(kMaxPitch24kHz < kBufSize24kHz, ""); @@ -287,8 +287,8 @@ } // namespace -void Decimate2x(ArrayView<const float, kBufSize24kHz> src, - ArrayView<float, kBufSize12kHz> dst) { +void Decimate2x(std::span<const float, kBufSize24kHz> src, + std::span<float, kBufSize12kHz> dst) { // TODO(bugs.webrtc.org/9076): Consider adding anti-aliasing filter. static_assert(2 * kBufSize12kHz == kBufSize24kHz, ""); for (int i = 0; i < kBufSize12kHz; ++i) { @@ -297,8 +297,8 @@ } void ComputeSlidingFrameSquareEnergies24kHz( - ArrayView<const float, kBufSize24kHz> pitch_buffer, - ArrayView<float, kRefineNumLags24kHz> y_energy, + std::span<const float, kBufSize24kHz> pitch_buffer, + std::span<float, kRefineNumLags24kHz> y_energy, AvailableCpuFeatures cpu_features) { VectorMath vector_math(cpu_features); static_assert(kFrameSize20ms24kHz < kBufSize24kHz, ""); @@ -317,8 +317,8 @@ } CandidatePitchPeriods ComputePitchPeriod12kHz( - ArrayView<const float, kBufSize12kHz> pitch_buffer, - ArrayView<const float, kNumLags12kHz> auto_correlation, + std::span<const float, kBufSize12kHz> pitch_buffer, + std::span<const float, kNumLags12kHz> auto_correlation, AvailableCpuFeatures cpu_features) { static_assert(kMaxPitch12kHz > kNumLags12kHz, ""); static_assert(kMaxPitch12kHz < kBufSize12kHz, ""); @@ -376,8 +376,8 @@ } int ComputePitchPeriod48kHz( - ArrayView<const float, kBufSize24kHz> pitch_buffer, - ArrayView<const float, kRefineNumLags24kHz> y_energy, + std::span<const float, kBufSize24kHz> pitch_buffer, + std::span<const float, kRefineNumLags24kHz> y_energy, CandidatePitchPeriods pitch_candidates, AvailableCpuFeatures cpu_features) { // Compute the auto-correlation terms only for neighbors of the two pitch @@ -414,8 +414,8 @@ } PitchInfo ComputeExtendedPitchPeriod48kHz( - ArrayView<const float, kBufSize24kHz> pitch_buffer, - ArrayView<const float, kRefineNumLags24kHz> y_energy, + std::span<const float, kBufSize24kHz> pitch_buffer, + std::span<const float, kRefineNumLags24kHz> y_energy, int initial_pitch_period_48kHz, PitchInfo last_pitch_48kHz, AvailableCpuFeatures cpu_features) {
diff --git a/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h b/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h index 5609d5a..9ff1d27 100644 --- a/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h +++ b/modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_INTERNAL_H_ #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" @@ -21,8 +21,8 @@ namespace rnn_vad { // Performs 2x decimation without any anti-aliasing filter. -void Decimate2x(ArrayView<const float, kBufSize24kHz> src, - ArrayView<float, kBufSize12kHz> dst); +void Decimate2x(std::span<const float, kBufSize24kHz> src, + std::span<float, kBufSize12kHz> dst); // Key concepts and keywords used below in this file. // @@ -62,8 +62,8 @@ // Computes the sum of squared samples for every sliding frame `y` in the pitch // buffer. The indexes of `y_energy` are inverted lags. void ComputeSlidingFrameSquareEnergies24kHz( - ArrayView<const float, kBufSize24kHz> pitch_buffer, - ArrayView<float, kRefineNumLags24kHz> y_energy, + std::span<const float, kBufSize24kHz> pitch_buffer, + std::span<float, kRefineNumLags24kHz> y_energy, AvailableCpuFeatures cpu_features); // Top-2 pitch period candidates. Unit: number of samples - i.e., inverted lags. @@ -76,16 +76,16 @@ // pitch buffer and the auto-correlation values (having inverted lags as // indexes). CandidatePitchPeriods ComputePitchPeriod12kHz( - ArrayView<const float, kBufSize12kHz> pitch_buffer, - ArrayView<const float, kNumLags12kHz> auto_correlation, + std::span<const float, kBufSize12kHz> pitch_buffer, + std::span<const float, kNumLags12kHz> auto_correlation, AvailableCpuFeatures cpu_features); // Computes the pitch period at 48 kHz given a view on the 24 kHz pitch buffer, // the energies for the sliding frames `y` at 24 kHz and the pitch period // candidates at 24 kHz (encoded as inverted lag). int ComputePitchPeriod48kHz( - ArrayView<const float, kBufSize24kHz> pitch_buffer, - ArrayView<const float, kRefineNumLags24kHz> y_energy, + std::span<const float, kBufSize24kHz> pitch_buffer, + std::span<const float, kRefineNumLags24kHz> y_energy, CandidatePitchPeriods pitch_candidates_24kHz, AvailableCpuFeatures cpu_features); @@ -99,8 +99,8 @@ // `y` at 24 kHz, the initial 48 kHz estimation (computed by // `ComputePitchPeriod48kHz()`) and the last estimated pitch. PitchInfo ComputeExtendedPitchPeriod48kHz( - ArrayView<const float, kBufSize24kHz> pitch_buffer, - ArrayView<const float, kRefineNumLags24kHz> y_energy, + std::span<const float, kBufSize24kHz> pitch_buffer, + std::span<const float, kRefineNumLags24kHz> y_energy, int initial_pitch_period_48kHz, PitchInfo last_pitch_48kHz, AvailableCpuFeatures cpu_features);
diff --git a/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc b/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc index 8235cca..3f39e4f 100644 --- a/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc
@@ -11,10 +11,10 @@ #include "modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h" #include <array> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/test_utils.h" @@ -93,7 +93,7 @@ PitchTestData test_data; std::vector<float> y_energy(kRefineNumLags24kHz); - ArrayView<float, kRefineNumLags24kHz> y_energy_view(y_energy.data(), + std::span<float, kRefineNumLags24kHz> y_energy_view(y_energy.data(), kRefineNumLags24kHz); ComputeSlidingFrameSquareEnergies24kHz(test_data.PitchBuffer24kHzView(), y_energy_view, cpu_features); @@ -128,7 +128,7 @@ PitchTestData test_data; std::vector<float> y_energy(kRefineNumLags24kHz); - ArrayView<float, kRefineNumLags24kHz> y_energy_view(y_energy.data(), + std::span<float, kRefineNumLags24kHz> y_energy_view(y_energy.data(), kRefineNumLags24kHz); ComputeSlidingFrameSquareEnergies24kHz(test_data.PitchBuffer24kHzView(), y_energy_view, params.cpu_features); @@ -179,7 +179,7 @@ PitchTestData test_data; std::vector<float> y_energy(kRefineNumLags24kHz); - ArrayView<float, kRefineNumLags24kHz> y_energy_view(y_energy.data(), + std::span<float, kRefineNumLags24kHz> y_energy_view(y_energy.data(), kRefineNumLags24kHz); ComputeSlidingFrameSquareEnergies24kHz(test_data.PitchBuffer24kHzView(), y_energy_view, params.cpu_features);
diff --git a/modules/audio_processing/agc2/rnn_vad/ring_buffer.h b/modules/audio_processing/agc2/rnn_vad/ring_buffer.h index 61ecc38..6c8e4db 100644 --- a/modules/audio_processing/agc2/rnn_vad/ring_buffer.h +++ b/modules/audio_processing/agc2/rnn_vad/ring_buffer.h
@@ -13,9 +13,9 @@ #include <array> #include <cstring> +#include <span> #include <type_traits> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -37,7 +37,7 @@ // Set the ring buffer values to zero. void Reset() { buffer_.fill(0); } // Replace the least recently pushed array in the buffer with `new_values`. - void Push(ArrayView<const T, S> new_values) { + void Push(std::span<const T, S> new_values) { std::memcpy(buffer_.data() + S * tail_, new_values.data(), S * sizeof(T)); tail_ += 1; if (tail_ == N) @@ -46,13 +46,13 @@ // Return an array view onto the array with a given delay. A view on the last // and least recently push array is returned when `delay` is 0 and N - 1 // respectively. - ArrayView<const T, S> GetArrayView(int delay) const { + std::span<const T, S> GetArrayView(int delay) const { RTC_DCHECK_LE(0, delay); RTC_DCHECK_LT(delay, N); int offset = tail_ - 1 - delay; if (offset < 0) offset += N; - return ArrayView<const T, S>(buffer_.data() + S * offset, S); + return std::span<const T, S>(buffer_.data() + S * offset, S); } private:
diff --git a/modules/audio_processing/agc2/rnn_vad/ring_buffer_unittest.cc b/modules/audio_processing/agc2/rnn_vad/ring_buffer_unittest.cc index 82bd01f..14f51ab 100644 --- a/modules/audio_processing/agc2/rnn_vad/ring_buffer_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/ring_buffer_unittest.cc
@@ -13,8 +13,8 @@ #include <array> #include <cstddef> #include <cstdint> +#include <span> -#include "api/array_view.h" #include "test/gmock.h" #include "test/gtest.h" @@ -31,7 +31,7 @@ SCOPED_TRACE(S); std::array<T, S> prev_pushed_array; std::array<T, S> pushed_array; - ArrayView<const T, S> pushed_array_view(pushed_array.data(), S); + std::span<const T, S> pushed_array_view(pushed_array.data(), S); // Init. RingBuffer<T, S, N> ring_buf;
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn.cc b/modules/audio_processing/agc2/rnn_vad/rnn.cc index 775ea86..62195cf 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn.cc
@@ -10,7 +10,8 @@ #include "modules/audio_processing/agc2/rnn_vad/rnn.h" -#include "api/array_view.h" +#include <span> + #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/rnn_fc.h" @@ -79,7 +80,7 @@ } float RnnVad::ComputeVadProbability( - ArrayView<const float, kFeatureVectorSize> feature_vector, + std::span<const float, kFeatureVectorSize> feature_vector, bool is_silence) { if (is_silence) { Reset();
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn.h b/modules/audio_processing/agc2/rnn_vad/rnn.h index 7b47d23..caa2d36 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn.h +++ b/modules/audio_processing/agc2/rnn_vad/rnn.h
@@ -13,8 +13,8 @@ #include <stddef.h> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/rnn_fc.h" @@ -35,7 +35,7 @@ // Observes `feature_vector` and `is_silence`, updates the RNN and returns the // current voice probability. float ComputeVadProbability( - ArrayView<const float, kFeatureVectorSize> feature_vector, + std::span<const float, kFeatureVectorSize> feature_vector, bool is_silence); private:
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_fc.cc b/modules/audio_processing/agc2/rnn_vad/rnn_fc.cc index 0c4b7bb..011c773 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_fc.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_fc.cc
@@ -12,10 +12,10 @@ #include <algorithm> #include <cstdint> +#include <span> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/function_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "rtc_base/checks.h" @@ -27,7 +27,7 @@ namespace rnn_vad { namespace { -std::vector<float> GetScaledParams(ArrayView<const int8_t> params) { +std::vector<float> GetScaledParams(std::span<const int8_t> params) { std::vector<float> scaled_params(params.size()); std::transform(params.begin(), params.end(), scaled_params.begin(), [](int8_t x) -> float { @@ -39,7 +39,7 @@ // TODO(bugs.chromium.org/10480): Hard-code optimized layout and remove this // function to improve setup time. // Casts and scales `weights` and re-arranges the layout. -std::vector<float> PreprocessWeights(ArrayView<const int8_t> weights, +std::vector<float> PreprocessWeights(std::span<const int8_t> weights, int output_size) { if (output_size == 1) { return GetScaledParams(weights); @@ -72,8 +72,8 @@ FullyConnectedLayer::FullyConnectedLayer( const int input_size, const int output_size, - const ArrayView<const int8_t> bias, - const ArrayView<const int8_t> weights, + const std::span<const int8_t> bias, + const std::span<const int8_t> weights, ActivationFunction activation_function, const AvailableCpuFeatures& cpu_features, absl::string_view layer_name) @@ -95,9 +95,9 @@ FullyConnectedLayer::~FullyConnectedLayer() = default; -void FullyConnectedLayer::ComputeOutput(ArrayView<const float> input) { +void FullyConnectedLayer::ComputeOutput(std::span<const float> input) { RTC_DCHECK_EQ(input.size(), input_size_); - ArrayView<const float> weights(weights_); + std::span<const float> weights(weights_); for (int o = 0; o < output_size_; ++o) { output_[o] = activation_function_( bias_[o] + vector_math_.DotProduct(
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_fc.h b/modules/audio_processing/agc2/rnn_vad/rnn_fc.h index 12ed2f5..bde2d67 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_fc.h +++ b/modules/audio_processing/agc2/rnn_vad/rnn_fc.h
@@ -13,10 +13,10 @@ #include <array> #include <cstdint> +#include <span> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/function_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/vector_math.h" @@ -37,8 +37,8 @@ // Ctor. `output_size` cannot be greater than `kFullyConnectedLayerMaxUnits`. FullyConnectedLayer(int input_size, int output_size, - ArrayView<const int8_t> bias, - ArrayView<const int8_t> weights, + std::span<const int8_t> bias, + std::span<const int8_t> weights, ActivationFunction activation_function, const AvailableCpuFeatures& cpu_features, absl::string_view layer_name); @@ -54,12 +54,12 @@ int size() const { return output_size_; } // Returns the output buffer. - ArrayView<const float> output() const { - return MakeArrayView(output_.data(), output_size_); + std::span<const float> output() const { + return std::span(output_.data(), output_size_); } // Computes the fully-connected layer output. - void ComputeOutput(ArrayView<const float> input); + void ComputeOutput(std::span<const float> input); private: const int input_size_;
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc b/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc index 705f43a..db85581 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc
@@ -13,7 +13,6 @@ #include <array> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/test_utils.h" #include "modules/audio_processing/test/performance_timer.h"
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_gru.cc b/modules/audio_processing/agc2/rnn_vad/rnn_gru.cc index 5bd7119..a31b48a 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_gru.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_gru.cc
@@ -14,10 +14,10 @@ #include <array> #include <cstddef> #include <cstdint> +#include <span> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/vector_math.h" #include "rtc_base/checks.h" @@ -31,7 +31,7 @@ constexpr int kNumGruGates = 3; // Update, reset, output. -std::vector<float> PreprocessGruTensor(ArrayView<const int8_t> tensor_src, +std::vector<float> PreprocessGruTensor(std::span<const int8_t> tensor_src, int output_size) { // Transpose, cast and scale. // `n` is the size of the first dimension of the 3-dim tensor `weights`. @@ -64,12 +64,12 @@ void ComputeUpdateResetGate(int input_size, int output_size, const VectorMath& vector_math, - ArrayView<const float> input, - ArrayView<const float> state, - ArrayView<const float> bias, - ArrayView<const float> weights, - ArrayView<const float> recurrent_weights, - ArrayView<float> gate) { + std::span<const float> input, + std::span<const float> state, + std::span<const float> bias, + std::span<const float> weights, + std::span<const float> recurrent_weights, + std::span<float> gate) { RTC_DCHECK_EQ(input.size(), input_size); RTC_DCHECK_EQ(state.size(), output_size); RTC_DCHECK_EQ(bias.size(), output_size); @@ -100,13 +100,13 @@ void ComputeStateGate(int input_size, int output_size, const VectorMath& vector_math, - ArrayView<const float> input, - ArrayView<const float> update, - ArrayView<const float> reset, - ArrayView<const float> bias, - ArrayView<const float> weights, - ArrayView<const float> recurrent_weights, - ArrayView<float> state) { + std::span<const float> input, + std::span<const float> update, + std::span<const float> reset, + std::span<const float> bias, + std::span<const float> weights, + std::span<const float> recurrent_weights, + std::span<float> state) { RTC_DCHECK_EQ(input.size(), input_size); RTC_DCHECK_GE(update.size(), output_size); // `update` is over-allocated. RTC_DCHECK_GE(reset.size(), output_size); // `reset` is over-allocated. @@ -134,9 +134,9 @@ GatedRecurrentLayer::GatedRecurrentLayer( const int input_size, const int output_size, - const ArrayView<const int8_t> bias, - const ArrayView<const int8_t> weights, - const ArrayView<const int8_t> recurrent_weights, + const std::span<const int8_t> bias, + const std::span<const int8_t> weights, + const std::span<const int8_t> recurrent_weights, const AvailableCpuFeatures& cpu_features, absl::string_view layer_name) : input_size_(input_size), @@ -167,19 +167,19 @@ state_.fill(0.f); } -void GatedRecurrentLayer::ComputeOutput(ArrayView<const float> input) { +void GatedRecurrentLayer::ComputeOutput(std::span<const float> input) { RTC_DCHECK_EQ(input.size(), input_size_); // The tensors below are organized as a sequence of flattened tensors for the // `update`, `reset` and `state` gates. - ArrayView<const float> bias(bias_); - ArrayView<const float> weights(weights_); - ArrayView<const float> recurrent_weights(recurrent_weights_); + std::span<const float> bias(bias_); + std::span<const float> weights(weights_); + std::span<const float> recurrent_weights(recurrent_weights_); // Strides to access to the flattened tensors for a specific gate. const int stride_weights = input_size_ * output_size_; const int stride_recurrent_weights = output_size_ * output_size_; - ArrayView<float> state(state_.data(), output_size_); + std::span<float> state(state_.data(), output_size_); // Update gate. std::array<float, kGruLayerMaxUnits> update;
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_gru.h b/modules/audio_processing/agc2/rnn_vad/rnn_gru.h index 367f3cd..502802d 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_gru.h +++ b/modules/audio_processing/agc2/rnn_vad/rnn_gru.h
@@ -13,10 +13,10 @@ #include <array> #include <cstdint> +#include <span> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/vector_math.h" @@ -33,9 +33,9 @@ // Ctor. `output_size` cannot be greater than `kGruLayerMaxUnits`. GatedRecurrentLayer(int input_size, int output_size, - ArrayView<const int8_t> bias, - ArrayView<const int8_t> weights, - ArrayView<const int8_t> recurrent_weights, + std::span<const int8_t> bias, + std::span<const int8_t> weights, + std::span<const int8_t> recurrent_weights, const AvailableCpuFeatures& cpu_features, absl::string_view layer_name); GatedRecurrentLayer(const GatedRecurrentLayer&) = delete; @@ -50,14 +50,14 @@ int size() const { return output_size_; } // Returns the output buffer. - ArrayView<const float> output() const { - return MakeArrayView(state_.data(), output_size_); + std::span<const float> output() const { + return std::span(state_.data(), output_size_); } // Resets the GRU state. void Reset(); // Computes the recurrent layer output and updates the status. - void ComputeOutput(ArrayView<const float> input); + void ComputeOutput(std::span<const float> input); private: const int input_size_;
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc b/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc index 738c221..044bb3b 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc
@@ -14,9 +14,9 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/test_utils.h" #include "modules/audio_processing/test/performance_timer.h" @@ -31,8 +31,8 @@ namespace { void TestGatedRecurrentLayer(GatedRecurrentLayer& gru, - ArrayView<const float> input_sequence, - ArrayView<const float> expected_output_sequence) { + std::span<const float> input_sequence, + std::span<const float> expected_output_sequence) { const int input_sequence_length = CheckedDivExact( dchecked_cast<int>(input_sequence.size()), gru.input_size()); const int output_sequence_length = CheckedDivExact( @@ -138,7 +138,7 @@ /*cpu_features=*/GetParam(), /*layer_name=*/"GRU"); - ArrayView<const float> input_sequence(gru_input_sequence); + std::span<const float> input_sequence(gru_input_sequence); ASSERT_EQ(input_sequence.size() % kInputLayerOutputSize, static_cast<size_t>(0)); const int input_sequence_length =
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_unittest.cc b/modules/audio_processing/agc2/rnn_vad/rnn_unittest.cc index a944e2b..b5a8a79 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_unittest.cc
@@ -12,7 +12,6 @@ #include <array> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "test/gtest.h"
diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc b/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc index 37e3197..7ab9ce1 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc
@@ -11,9 +11,9 @@ #include <array> #include <cstdlib> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "common_audio/resampler/push_sinc_resampler.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" @@ -141,7 +141,7 @@ perf_timer.StartTimer(); for (int i = 0; i < num_frames; ++i) { bool is_silence = features_extractor.CheckSilenceComputeFeatures( - ArrayView<const float, kFrameSize10ms24kHz>( + std::span<const float, kFrameSize10ms24kHz>( &prefetched_decimated_samples[i * kFrameSize10ms24kHz], kFrameSize10ms24kHz), feature_vector);
diff --git a/modules/audio_processing/agc2/rnn_vad/sequence_buffer.h b/modules/audio_processing/agc2/rnn_vad/sequence_buffer.h index 6870f95..9526d6e 100644 --- a/modules/audio_processing/agc2/rnn_vad/sequence_buffer.h +++ b/modules/audio_processing/agc2/rnn_vad/sequence_buffer.h
@@ -13,10 +13,10 @@ #include <algorithm> #include <cstring> +#include <span> #include <type_traits> #include <vector> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -50,18 +50,18 @@ // Sets the sequence buffer values to zero. void Reset() { std::fill(buffer_.begin(), buffer_.end(), 0); } // Returns a view on the whole buffer. - ArrayView<const T, S> GetBufferView() const { - return ArrayView<const T, S>(buffer_.data(), S); + std::span<const T, S> GetBufferView() const { + return std::span<const T, S>(buffer_.data(), S); } // Returns a view on the M most recent values of the buffer. - ArrayView<const T, M> GetMostRecentValuesView() const { + std::span<const T, M> GetMostRecentValuesView() const { static_assert(M <= S, "The number of most recent values cannot be larger than the " "sequence buffer size."); - return ArrayView<const T, M>(buffer_.data() + S - M, M); + return std::span<const T, M>(buffer_.data() + S - M, M); } // Shifts left the buffer by N items and add new N items at the end. - void Push(ArrayView<const T, N> new_values) { + void Push(std::span<const T, N> new_values) { // Make space for the new values. if (S > N) std::memmove(buffer_.data(), buffer_.data() + N, (S - N) * sizeof(T));
diff --git a/modules/audio_processing/agc2/rnn_vad/spectral_features.cc b/modules/audio_processing/agc2/rnn_vad/spectral_features.cc index 1712c7d..ea4dcaf 100644 --- a/modules/audio_processing/agc2/rnn_vad/spectral_features.cc +++ b/modules/audio_processing/agc2/rnn_vad/spectral_features.cc
@@ -15,8 +15,8 @@ #include <cmath> #include <limits> #include <numeric> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/ring_buffer.h" #include "modules/audio_processing/agc2/rnn_vad/spectral_features_internal.h" @@ -34,7 +34,7 @@ // Computes the new cepstral difference stats and pushes them into the passed // symmetric matrix buffer. void UpdateCepstralDifferenceStats( - ArrayView<const float, kNumBands> new_cepstral_coeffs, + std::span<const float, kNumBands> new_cepstral_coeffs, const RingBuffer<float, kNumBands, kCepstralCoeffsHistorySize>& ring_buf, SymmetricMatrixBuffer<float, kCepstralCoeffsHistorySize>* sym_matrix_buf) { RTC_DCHECK(sym_matrix_buf); @@ -71,7 +71,7 @@ // applied. The Fourier coefficient corresponding to the Nyquist frequency is // set to zero (it is never used and this allows to simplify the code). void ComputeWindowedForwardFft( - ArrayView<const float, kFrameSize20ms24kHz> frame, + std::span<const float, kFrameSize20ms24kHz> frame, const std::array<float, kFrameSize20ms24kHz / 2>& half_window, Pffft::FloatBuffer* fft_input_buffer, Pffft::FloatBuffer* fft_output_buffer, @@ -109,13 +109,13 @@ } bool SpectralFeaturesExtractor::CheckSilenceComputeFeatures( - ArrayView<const float, kFrameSize20ms24kHz> reference_frame, - ArrayView<const float, kFrameSize20ms24kHz> lagged_frame, - ArrayView<float, kNumBands - kNumLowerBands> higher_bands_cepstrum, - ArrayView<float, kNumLowerBands> average, - ArrayView<float, kNumLowerBands> first_derivative, - ArrayView<float, kNumLowerBands> second_derivative, - ArrayView<float, kNumLowerBands> bands_cross_corr, + std::span<const float, kFrameSize20ms24kHz> reference_frame, + std::span<const float, kFrameSize20ms24kHz> lagged_frame, + std::span<float, kNumBands - kNumLowerBands> higher_bands_cepstrum, + std::span<float, kNumLowerBands> average, + std::span<float, kNumLowerBands> first_derivative, + std::span<float, kNumLowerBands> second_derivative, + std::span<float, kNumLowerBands> bands_cross_corr, float* variability) { // Compute the Opus band energies for the reference frame. ComputeWindowedForwardFft(reference_frame, half_window_, fft_buffer_.get(), @@ -161,9 +161,9 @@ } void SpectralFeaturesExtractor::ComputeAvgAndDerivatives( - ArrayView<float, kNumLowerBands> average, - ArrayView<float, kNumLowerBands> first_derivative, - ArrayView<float, kNumLowerBands> second_derivative) const { + std::span<float, kNumLowerBands> average, + std::span<float, kNumLowerBands> first_derivative, + std::span<float, kNumLowerBands> second_derivative) const { auto curr = cepstral_coeffs_ring_buf_.GetArrayView(0); auto prev1 = cepstral_coeffs_ring_buf_.GetArrayView(1); auto prev2 = cepstral_coeffs_ring_buf_.GetArrayView(2); @@ -181,7 +181,7 @@ } void SpectralFeaturesExtractor::ComputeNormalizedCepstralCorrelation( - ArrayView<float, kNumLowerBands> bands_cross_corr) { + std::span<float, kNumLowerBands> bands_cross_corr) { spectral_correlator_.ComputeCrossCorrelation( reference_frame_fft_->GetConstView(), lagged_frame_fft_->GetConstView(), bands_cross_corr_);
diff --git a/modules/audio_processing/agc2/rnn_vad/spectral_features.h b/modules/audio_processing/agc2/rnn_vad/spectral_features.h index 6994e45..fe15f4b 100644 --- a/modules/audio_processing/agc2/rnn_vad/spectral_features.h +++ b/modules/audio_processing/agc2/rnn_vad/spectral_features.h
@@ -14,8 +14,8 @@ #include <array> #include <cstddef> #include <memory> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/ring_buffer.h" #include "modules/audio_processing/agc2/rnn_vad/spectral_features_internal.h" @@ -39,22 +39,22 @@ // detects silence and computes features. If silence is detected, the output // is neither computed nor written. bool CheckSilenceComputeFeatures( - ArrayView<const float, kFrameSize20ms24kHz> reference_frame, - ArrayView<const float, kFrameSize20ms24kHz> lagged_frame, - ArrayView<float, kNumBands - kNumLowerBands> higher_bands_cepstrum, - ArrayView<float, kNumLowerBands> average, - ArrayView<float, kNumLowerBands> first_derivative, - ArrayView<float, kNumLowerBands> second_derivative, - ArrayView<float, kNumLowerBands> bands_cross_corr, + std::span<const float, kFrameSize20ms24kHz> reference_frame, + std::span<const float, kFrameSize20ms24kHz> lagged_frame, + std::span<float, kNumBands - kNumLowerBands> higher_bands_cepstrum, + std::span<float, kNumLowerBands> average, + std::span<float, kNumLowerBands> first_derivative, + std::span<float, kNumLowerBands> second_derivative, + std::span<float, kNumLowerBands> bands_cross_corr, float* variability); private: void ComputeAvgAndDerivatives( - ArrayView<float, kNumLowerBands> average, - ArrayView<float, kNumLowerBands> first_derivative, - ArrayView<float, kNumLowerBands> second_derivative) const; + std::span<float, kNumLowerBands> average, + std::span<float, kNumLowerBands> first_derivative, + std::span<float, kNumLowerBands> second_derivative) const; void ComputeNormalizedCepstralCorrelation( - ArrayView<float, kNumLowerBands> bands_cross_corr); + std::span<float, kNumLowerBands> bands_cross_corr); float ComputeVariability() const; const std::array<float, kFrameSize20ms24kHz / 2> half_window_;
diff --git a/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.cc b/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.cc index 7cbdcec..d370ac7 100644 --- a/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.cc +++ b/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.cc
@@ -14,8 +14,8 @@ #include <array> #include <cmath> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_compare.h" @@ -95,15 +95,15 @@ SpectralCorrelator::~SpectralCorrelator() = default; void SpectralCorrelator::ComputeAutoCorrelation( - ArrayView<const float> x, - ArrayView<float, kOpusBands24kHz> auto_corr) const { + std::span<const float> x, + std::span<float, kOpusBands24kHz> auto_corr) const { ComputeCrossCorrelation(x, x, auto_corr); } void SpectralCorrelator::ComputeCrossCorrelation( - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float, kOpusBands24kHz> cross_corr) const { + std::span<const float> x, + std::span<const float> y, + std::span<float, kOpusBands24kHz> cross_corr) const { RTC_DCHECK_EQ(x.size(), kFrameSize20ms24kHz); RTC_DCHECK_EQ(x.size(), y.size()); RTC_DCHECK_EQ(x[1], 0.f) << "The Nyquist coefficient must be zeroed."; @@ -126,8 +126,8 @@ } void ComputeSmoothedLogMagnitudeSpectrum( - ArrayView<const float> bands_energy, - ArrayView<float, kNumBands> log_bands_energy) { + std::span<const float> bands_energy, + std::span<float, kNumBands> log_bands_energy) { RTC_DCHECK_LE(bands_energy.size(), kNumBands); constexpr float kOneByHundred = 1e-2f; constexpr float kLogOneByHundred = -2.f; @@ -161,9 +161,9 @@ return dct_table; } -void ComputeDct(ArrayView<const float> in, - ArrayView<const float, kNumBands * kNumBands> dct_table, - ArrayView<float> out) { +void ComputeDct(std::span<const float> in, + std::span<const float, kNumBands * kNumBands> dct_table, + std::span<float> out) { // DCT scaling factor - i.e., sqrt(2 / kNumBands). constexpr float kDctScalingFactor = 0.301511345f; constexpr float kDctScalingFactorError =
diff --git a/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.h b/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.h index 4d9fd52..4434291 100644 --- a/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.h +++ b/modules/audio_processing/agc2/rnn_vad/spectral_features_internal.h
@@ -14,9 +14,9 @@ #include <stddef.h> #include <array> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" namespace webrtc { @@ -55,8 +55,8 @@ // - be encoded as vectors of interleaved real-complex FFT coefficients // where x[1] = y[1] = 0 (the Nyquist frequency coefficient is omitted). void ComputeAutoCorrelation( - ArrayView<const float> x, - ArrayView<float, kOpusBands24kHz> auto_corr) const; + std::span<const float> x, + std::span<float, kOpusBands24kHz> auto_corr) const; // Computes the band-wise spectral cross-correlations. // `x` and `y` must: @@ -64,9 +64,9 @@ // - be encoded as vectors of interleaved real-complex FFT coefficients where // x[1] = y[1] = 0 (the Nyquist frequency coefficient is omitted). void ComputeCrossCorrelation( - ArrayView<const float> x, - ArrayView<const float> y, - ArrayView<float, kOpusBands24kHz> cross_corr) const; + std::span<const float> x, + std::span<const float> y, + std::span<float, kOpusBands24kHz> cross_corr) const; private: const std::vector<float> weights_; // Weights for each Fourier coefficient. @@ -77,8 +77,8 @@ // computes the log magnitude spectrum applying smoothing both over time and // over frequency. Declared here for unit testing. void ComputeSmoothedLogMagnitudeSpectrum( - ArrayView<const float> bands_energy, - ArrayView<float, kNumBands> log_bands_energy); + std::span<const float> bands_energy, + std::span<float, kNumBands> log_bands_energy); // TODO(bugs.webrtc.org/10480): Move to anonymous namespace in // spectral_features.cc. Creates a DCT table for arrays having size equal to @@ -90,9 +90,9 @@ // In-place computation is not allowed and `out` can be smaller than `in` in // order to only compute the first DCT coefficients. Declared here for unit // testing. -void ComputeDct(ArrayView<const float> in, - ArrayView<const float, kNumBands * kNumBands> dct_table, - ArrayView<float> out); +void ComputeDct(std::span<const float> in, + std::span<const float, kNumBands * kNumBands> dct_table, + std::span<float> out); } // namespace rnn_vad } // namespace webrtc
diff --git a/modules/audio_processing/agc2/rnn_vad/spectral_features_internal_unittest.cc b/modules/audio_processing/agc2/rnn_vad/spectral_features_internal_unittest.cc index 668a4ee..63bf3cf 100644 --- a/modules/audio_processing/agc2/rnn_vad/spectral_features_internal_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/spectral_features_internal_unittest.cc
@@ -13,9 +13,9 @@ #include <algorithm> #include <array> #include <numeric> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/test_utils.h" #include "modules/audio_processing/utility/pffft_wrapper.h" @@ -73,7 +73,7 @@ int i = 0; for (int band_size : GetOpusScaleNumBins24kHz20ms()) { SCOPED_TRACE(band_size); - ArrayView<float> band_weights(weights.data() + i, band_size); + std::span<float> band_weights(weights.data() + i, band_size); float prev = -1.f; for (float weight : band_weights) { EXPECT_LT(prev, weight);
diff --git a/modules/audio_processing/agc2/rnn_vad/spectral_features_unittest.cc b/modules/audio_processing/agc2/rnn_vad/spectral_features_unittest.cc index 7c94033..6a01ab0 100644 --- a/modules/audio_processing/agc2/rnn_vad/spectral_features_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/spectral_features_unittest.cc
@@ -12,8 +12,8 @@ #include <algorithm> #include <array> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "modules/audio_processing/agc2/rnn_vad/test_utils.h" #include "rtc_base/numerics/safe_compare.h" @@ -28,40 +28,40 @@ constexpr int kTestFeatureVectorSize = kNumBands + 3 * kNumLowerBands + 1; // Writes non-zero sample values. -void WriteTestData(ArrayView<float> samples) { +void WriteTestData(std::span<float> samples) { for (int i = 0; SafeLt(i, samples.size()); ++i) { samples[i] = i % 100; } } -ArrayView<float, kNumBands - kNumLowerBands> GetHigherBandsSpectrum( - ArrayView<float, kTestFeatureVectorSize> feature_vector) { +std::span<float, kNumBands - kNumLowerBands> GetHigherBandsSpectrum( + std::span<float, kTestFeatureVectorSize> feature_vector) { return feature_vector.subspan<kNumLowerBands, kNumBands - kNumLowerBands>(); } -ArrayView<float, kNumLowerBands> GetAverage( - ArrayView<float, kTestFeatureVectorSize> feature_vector) { +std::span<float, kNumLowerBands> GetAverage( + std::span<float, kTestFeatureVectorSize> feature_vector) { return feature_vector.first<kNumLowerBands>(); } -ArrayView<float, kNumLowerBands> GetFirstDerivative( - ArrayView<float, kTestFeatureVectorSize> feature_vector) { +std::span<float, kNumLowerBands> GetFirstDerivative( + std::span<float, kTestFeatureVectorSize> feature_vector) { return feature_vector.subspan<kNumBands, kNumLowerBands>(); } -ArrayView<float, kNumLowerBands> GetSecondDerivative( - ArrayView<float, kTestFeatureVectorSize> feature_vector) { +std::span<float, kNumLowerBands> GetSecondDerivative( + std::span<float, kTestFeatureVectorSize> feature_vector) { return feature_vector.subspan<kNumBands + kNumLowerBands, kNumLowerBands>(); } -ArrayView<float, kNumLowerBands> GetCepstralCrossCorrelation( - ArrayView<float, kTestFeatureVectorSize> feature_vector) { +std::span<float, kNumLowerBands> GetCepstralCrossCorrelation( + std::span<float, kTestFeatureVectorSize> feature_vector) { return feature_vector .subspan<kNumBands + 2 * kNumLowerBands, kNumLowerBands>(); } float* GetCepstralVariability( - ArrayView<float, kTestFeatureVectorSize> feature_vector) { + std::span<float, kTestFeatureVectorSize> feature_vector) { return &feature_vector[kNumBands + 3 * kNumLowerBands]; } @@ -73,7 +73,7 @@ // Initialize. SpectralFeaturesExtractor sfe; std::array<float, kFrameSize20ms24kHz> samples; - ArrayView<float, kFrameSize20ms24kHz> samples_view(samples); + std::span<float, kFrameSize20ms24kHz> samples_view(samples); bool is_silence; std::array<float, kTestFeatureVectorSize> feature_vector; @@ -118,7 +118,7 @@ // Initialize. SpectralFeaturesExtractor sfe; std::array<float, kFrameSize20ms24kHz> samples; - ArrayView<float, kFrameSize20ms24kHz> samples_view(samples); + std::span<float, kFrameSize20ms24kHz> samples_view(samples); WriteTestData(samples); // Fill the spectral features with test data.
diff --git a/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer.h b/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer.h index bd1ace8..ad189db 100644 --- a/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer.h +++ b/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer.h
@@ -14,10 +14,10 @@ #include <algorithm> #include <array> #include <cstring> +#include <span> #include <type_traits> #include <utility> -#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_compare.h" @@ -52,7 +52,7 @@ // most recent one in the ring buffer, whereas the last element in `values` // must correspond to the comparison between the most recent item and the // oldest one in the ring buffer. - void Push(ArrayView<T, S - 1> values) { + void Push(std::span<T, S - 1> values) { // Move the lower-right sub-matrix of size (S-2) x (S-2) one row up and one // column left. std::memmove(buf_.data(), buf_.data() + S, (buf_.size() - S) * sizeof(T));
diff --git a/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer_unittest.cc b/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer_unittest.cc index 43ca270..8c45d01 100644 --- a/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/symmetric_matrix_buffer_unittest.cc
@@ -12,9 +12,9 @@ #include <algorithm> #include <array> +#include <span> #include <utility> -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/ring_buffer.h" #include "test/gtest.h" @@ -62,7 +62,7 @@ for (int t = 1; t <= 100; ++t) { // Evolution steps. SCOPED_TRACE(t); const int t_removed = ring_buf.GetArrayView(kRingBufSize - 1)[0]; - ring_buf.Push(ArrayView<int, 1>(&t, 1)); + ring_buf.Push(std::span<int, 1>(&t, 1)); // The head of the ring buffer is `t`. ASSERT_EQ(t, ring_buf.GetArrayView(0)[0]); // Create the comparisons between `t` and the older elements in the ring
diff --git a/modules/audio_processing/agc2/rnn_vad/test_utils.cc b/modules/audio_processing/agc2/rnn_vad/test_utils.cc index de30450..251a425 100644 --- a/modules/audio_processing/agc2/rnn_vad/test_utils.cc +++ b/modules/audio_processing/agc2/rnn_vad/test_utils.cc
@@ -15,13 +15,13 @@ #include <fstream> #include <ios> #include <memory> +#include <span> #include <string> #include <type_traits> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_compare.h" @@ -49,7 +49,7 @@ ~FloatFileReader() override = default; int size() const override { return size_; } - bool ReadChunk(ArrayView<float> dst) override { + bool ReadChunk(std::span<float> dst) override { const std::streamsize bytes_to_read = dst.size() * sizeof(T); if (std::is_same<T, float>::value) { is_.read(reinterpret_cast<char*>(dst.data()), bytes_to_read); @@ -77,8 +77,8 @@ using test::ResourcePath; -void ExpectEqualFloatArray(ArrayView<const float> expected, - ArrayView<const float> computed) { +void ExpectEqualFloatArray(std::span<const float> expected, + std::span<const float> computed) { ASSERT_EQ(expected.size(), computed.size()); for (int i = 0; SafeLt(i, expected.size()); ++i) { SCOPED_TRACE(i); @@ -86,8 +86,8 @@ } } -void ExpectNearAbsolute(ArrayView<const float> expected, - ArrayView<const float> computed, +void ExpectNearAbsolute(std::span<const float> expected, + std::span<const float> computed, float tolerance) { ASSERT_EQ(expected.size(), computed.size()); for (int i = 0; SafeLt(i, expected.size()); ++i) {
diff --git a/modules/audio_processing/agc2/rnn_vad/test_utils.h b/modules/audio_processing/agc2/rnn_vad/test_utils.h index 4345b04..f8b4ff8 100644 --- a/modules/audio_processing/agc2/rnn_vad/test_utils.h +++ b/modules/audio_processing/agc2/rnn_vad/test_utils.h
@@ -16,10 +16,10 @@ #include <ios> #include <limits> #include <memory> +#include <span> #include <string> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" namespace webrtc { @@ -27,15 +27,15 @@ constexpr float kFloatMin = std::numeric_limits<float>::min(); -// Fails for every pair from two equally sized webrtc::ArrayView<float> views +// Fails for every pair from two equally sized std::span<float> views // such that the values in the pair do not match. -void ExpectEqualFloatArray(ArrayView<const float> expected, - ArrayView<const float> computed); +void ExpectEqualFloatArray(std::span<const float> expected, + std::span<const float> computed); -// Fails for every pair from two equally sized webrtc::ArrayView<float> views +// Fails for every pair from two equally sized std::span<float> views // such that their absolute error is above a given threshold. -void ExpectNearAbsolute(ArrayView<const float> expected, - ArrayView<const float> computed, +void ExpectNearAbsolute(std::span<const float> expected, + std::span<const float> computed, float tolerance); // File reader interface. @@ -49,7 +49,7 @@ // values are correctly read. If the number of remaining bytes in the file is // not sufficient to read `dst.size()` float values, `dst` is partially // modified and false is returned. - virtual bool ReadChunk(ArrayView<float> dst) = 0; + virtual bool ReadChunk(std::span<float> dst) = 0; // Reads a single float value, advances the internal file position according // to the number of read bytes and returns true if the value is correctly // read. If the number of remaining bytes in the file is not sufficient to @@ -90,13 +90,13 @@ public: PitchTestData(); ~PitchTestData(); - ArrayView<const float, kBufSize24kHz> PitchBuffer24kHzView() const { + std::span<const float, kBufSize24kHz> PitchBuffer24kHzView() const { return pitch_buffer_24k_; } - ArrayView<const float, kRefineNumLags24kHz> SquareEnergies24kHzView() const { + std::span<const float, kRefineNumLags24kHz> SquareEnergies24kHzView() const { return square_energies_24k_; } - ArrayView<const float, kNumLags12kHz> AutoCorrelation12kHzView() const { + std::span<const float, kNumLags12kHz> AutoCorrelation12kHzView() const { return auto_correlation_12k_; } @@ -114,7 +114,7 @@ FileWriter(const FileWriter&) = delete; FileWriter& operator=(const FileWriter&) = delete; ~FileWriter() = default; - void WriteChunk(ArrayView<const float> value) { + void WriteChunk(std::span<const float> value) { const std::streamsize bytes_to_write = value.size() * sizeof(float); os_.write(reinterpret_cast<const char*>(value.data()), bytes_to_write); }
diff --git a/modules/audio_processing/agc2/rnn_vad/vector_math.h b/modules/audio_processing/agc2/rnn_vad/vector_math.h index 0cf4e34..0bfe5af 100644 --- a/modules/audio_processing/agc2/rnn_vad/vector_math.h +++ b/modules/audio_processing/agc2/rnn_vad/vector_math.h
@@ -22,8 +22,8 @@ #endif #include <numeric> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" @@ -40,7 +40,7 @@ : cpu_features_(cpu_features) {} // Computes the dot product between two equally sized vectors. - float DotProduct(ArrayView<const float> x, ArrayView<const float> y) const { + float DotProduct(std::span<const float> x, std::span<const float> y) const { RTC_DCHECK_EQ(x.size(), y.size()); #if defined(WEBRTC_ARCH_X86_FAMILY) if (cpu_features_.avx2) { @@ -101,8 +101,8 @@ } private: - float DotProductAvx2(ArrayView<const float> x, - ArrayView<const float> y) const; + float DotProductAvx2(std::span<const float> x, + std::span<const float> y) const; const AvailableCpuFeatures cpu_features_; };
diff --git a/modules/audio_processing/agc2/rnn_vad/vector_math_avx2.cc b/modules/audio_processing/agc2/rnn_vad/vector_math_avx2.cc index 71466da..98c4fdc 100644 --- a/modules/audio_processing/agc2/rnn_vad/vector_math_avx2.cc +++ b/modules/audio_processing/agc2/rnn_vad/vector_math_avx2.cc
@@ -10,7 +10,8 @@ #include <immintrin.h> -#include "api/array_view.h" +#include <span> + #include "modules/audio_processing/agc2/rnn_vad/vector_math.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" @@ -18,8 +19,8 @@ namespace webrtc { namespace rnn_vad { -float VectorMath::DotProductAvx2(ArrayView<const float> x, - ArrayView<const float> y) const { +float VectorMath::DotProductAvx2(std::span<const float> x, + std::span<const float> y) const { RTC_DCHECK(cpu_features_.avx2); RTC_DCHECK_EQ(x.size(), y.size()); __m256 accumulator = _mm256_setzero_ps();
diff --git a/modules/audio_processing/agc2/vad_wrapper_unittest.cc b/modules/audio_processing/agc2/vad_wrapper_unittest.cc index 7d51591..e159354 100644 --- a/modules/audio_processing/agc2/vad_wrapper_unittest.cc +++ b/modules/audio_processing/agc2/vad_wrapper_unittest.cc
@@ -12,11 +12,11 @@ #include <limits> #include <memory> +#include <span> #include <tuple> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_view.h" #include "modules/audio_processing/agc2/agc2_common.h" #include "rtc_base/checks.h" @@ -43,7 +43,7 @@ public: MOCK_METHOD(int, SampleRateHz, (), (const, override)); MOCK_METHOD(void, Reset, (), (override)); - MOCK_METHOD(float, Analyze, (ArrayView<const float> frame), (override)); + MOCK_METHOD(float, Analyze, (std::span<const float> frame), (override)); }; // Checks that the ctor and `Initialize()` read the sample rate of the wrapped @@ -159,7 +159,7 @@ .Times(AnyNumber()) .WillRepeatedly(Return(vad_sample_rate_hz())); EXPECT_CALL(*vad, Reset).Times(1); - EXPECT_CALL(*vad, Analyze(Truly([this](ArrayView<const float> frame) { + EXPECT_CALL(*vad, Analyze(Truly([this](std::span<const float> frame) { return SafeEq(frame.size(), CheckedDivExact(vad_sample_rate_hz(), kNumFramesPerSecond)); }))).Times(1);
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index e86cc3c..89d537f 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc
@@ -18,13 +18,13 @@ #include <cstring> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio/audio_view.h" @@ -1248,7 +1248,7 @@ *capture_buffer); } - capture_input_rms_.Analyze(ArrayView<const float>( + capture_input_rms_.Analyze(std::span<const float>( capture_buffer->channels_const()[0], capture_nonlocked_.capture_processing_format.num_frames())); const bool log_rms = ++capture_rms_interval_counter_ >= 1000; @@ -1395,7 +1395,7 @@ } if (submodules_.echo_detector) { - submodules_.echo_detector->AnalyzeCaptureAudio(ArrayView<const float>( + submodules_.echo_detector->AnalyzeCaptureAudio(std::span<const float>( capture_buffer->channels()[0], capture_buffer->num_frames())); } @@ -1419,7 +1419,7 @@ submodules_.capture_post_processor->Process(capture_buffer); } - capture_output_rms_.Analyze(ArrayView<const float>( + capture_output_rms_.Analyze(std::span<const float>( capture_buffer->channels_const()[0], capture_nonlocked_.capture_processing_format.num_frames())); if (log_rms) { @@ -1479,7 +1479,7 @@ if (!capture_.capture_output_used_last_frame && capture_.capture_output_used) { for (size_t ch = 0; ch < capture_buffer->num_channels(); ++ch) { - ArrayView<float> channel_view(capture_buffer->channels()[ch], + std::span<float> channel_view(capture_buffer->channels()[ch], capture_buffer->num_frames()); std::fill(channel_view.begin(), channel_view.end(), 0.f); } @@ -1642,7 +1642,7 @@ } bool AudioProcessingImpl::GetLinearAecOutput( - ArrayView<std::array<float, 160>> linear_output) const { + std::span<std::array<float, 160>> linear_output) const { MutexLock lock(&mutex_capture_); AudioBuffer* linear_aec_buffer = capture_.linear_aec_output.get(); @@ -1653,8 +1653,8 @@ for (size_t ch = 0; ch < linear_aec_buffer->num_channels(); ++ch) { RTC_DCHECK_EQ(linear_output[ch].size(), linear_aec_buffer->num_frames()); - ArrayView<const float> channel_view = - ArrayView<const float>(linear_aec_buffer->channels_const()[ch], + std::span<const float> channel_view = + std::span<const float>(linear_aec_buffer->channels_const()[ch], linear_aec_buffer->num_frames()); FloatS16ToFloat(channel_view.data(), channel_view.size(), linear_output[ch].data());
diff --git a/modules/audio_processing/audio_processing_impl.h b/modules/audio_processing/audio_processing_impl.h index c058961..2d50d8d 100644 --- a/modules/audio_processing/audio_processing_impl.h +++ b/modules/audio_processing/audio_processing_impl.h
@@ -17,12 +17,12 @@ #include <cstdio> #include <memory> #include <optional> +#include <span> #include <utility> #include <vector> #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio/echo_canceller3_config.h" @@ -104,7 +104,7 @@ const StreamConfig& output_config, float* const* dest) override; bool GetLinearAecOutput( - ArrayView<std::array<float, 160>> linear_output) const override; + std::span<std::array<float, 160>> linear_output) const override; void set_output_will_be_muted(bool muted) override; void HandleCaptureOutputUsedSetting(bool capture_output_used) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_capture_);
diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc index debd5b1..3bd808d 100644 --- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc
@@ -11,9 +11,9 @@ #include <algorithm> #include <cstddef> #include <cstdint> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/environment/environment_factory.h" @@ -226,7 +226,7 @@ std::vector<TestConfig> out; for (auto test_config : in) { - auto available_rates = ArrayView<const int>(sample_rates); + auto available_rates = std::span<const int>(sample_rates); for (auto rate : available_rates) { test_config.initial_sample_rate_hz = rate; @@ -460,7 +460,7 @@ void PopulateAudioFrame(float amplitude, size_t num_channels, size_t samples_per_channel, - ArrayView<int16_t> frame, + std::span<int16_t> frame, RandomGenerator* rand_gen) { ASSERT_GT(amplitude, 0); ASSERT_LE(amplitude, 32767);
diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc index 27a4134..2bbf10b 100644 --- a/modules/audio_processing/audio_processing_impl_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_unittest.cc
@@ -15,12 +15,12 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <span> #include <string> #include <tuple> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/audio/echo_control.h" @@ -90,12 +90,12 @@ : analyze_render_audio_called_(false), last_render_audio_first_sample_(0.f) {} ~TestEchoDetector() override = default; - void AnalyzeRenderAudio(ArrayView<const float> render_audio) override { + void AnalyzeRenderAudio(std::span<const float> render_audio) override { last_render_audio_first_sample_ = render_audio[0]; analyze_render_audio_called_ = true; } void AnalyzeCaptureAudio( - ArrayView<const float> /* capture_audio */) override {} + std::span<const float> /* capture_audio */) override {} void Initialize(int /* capture_sample_rate_hz */, int /* num_capture_channels */, int /* render_sample_rate_hz */, @@ -125,7 +125,7 @@ void Initialize(int /* sample_rate_hz */, int /* num_channels */) override {} void Process(AudioBuffer* audio) override { for (size_t k = 0; k < audio->num_channels(); ++k) { - ArrayView<float> channel_view(audio->channels()[k], audio->num_frames()); + std::span<float> channel_view(audio->channels()[k], audio->num_frames()); std::transform(channel_view.begin(), channel_view.end(), channel_view.begin(), ProcessSample); }
diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc index 7078370..e77357d 100644 --- a/modules/audio_processing/audio_processing_unittest.cc +++ b/modules/audio_processing/audio_processing_unittest.cc
@@ -21,6 +21,7 @@ #include <memory> #include <numeric> #include <queue> +#include <span> #include <string> #include <tuple> #include <utility> @@ -28,7 +29,6 @@ #include "absl/flags/flag.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio/audio_view.h" #include "api/audio/builtin_audio_processing_builder.h" @@ -316,8 +316,8 @@ // and contain the same data. If they differ and `kDumpWhenExpectMessageEqFails` // is true, checks the equality of a subset of `audioproc::Event` (nested) // fields. -bool ExpectMessageEq(ArrayView<const uint8_t> actual, - ArrayView<const uint8_t> expected) { +bool ExpectMessageEq(std::span<const uint8_t> actual, + std::span<const uint8_t> expected) { EXPECT_EQ(actual.size(), expected.size()); if (actual.size() != expected.size()) { return false; @@ -839,7 +839,7 @@ tmp_frame.CopyFrom(frame_); auto compute_power = [](const Int16FrameData& frame) { - ArrayView<const int16_t> data = frame.view().data(); + std::span<const int16_t> data = frame.view().data(); return std::accumulate(data.begin(), data.end(), 0.0f, [](float a, float b) { return a + b * b; }) / data.size() / 32768 / 32768; @@ -942,7 +942,7 @@ tmp_frame.CopyFrom(frame_); auto compute_power = [](const Int16FrameData& frame) { - ArrayView<const int16_t> data = frame.view().data(); + std::span<const int16_t> data = frame.view().data(); return std::accumulate(data.begin(), data.end(), 0.0f, [](float a, float b) { return a + b * b; }) / data.size() / 32768 / 32768; @@ -2051,10 +2051,10 @@ // Validates that running the audio processing module using various combinations // of sample rates and number of channels works as intended. -void RunApmRateAndChannelTest(ArrayView<const int> sample_rates_hz, - ArrayView<const int> render_channel_counts, - ArrayView<const int> capture_channel_counts, - ArrayView<const bool> mono_capture_output) { +void RunApmRateAndChannelTest(std::span<const int> sample_rates_hz, + std::span<const int> render_channel_counts, + std::span<const int> capture_channel_counts, + std::span<const bool> mono_capture_output) { AudioProcessing::Config apm_config; apm_config.pipeline.multi_channel_render = true; apm_config.pipeline.multi_channel_capture = true; @@ -2326,11 +2326,11 @@ // The echo detector is included in processing when enabled. EXPECT_CALL(*mock_echo_detector, AnalyzeRenderAudio(_)) - .WillOnce([](ArrayView<const float> render_audio) { + .WillOnce([](std::span<const float> render_audio) { EXPECT_EQ(render_audio.size(), 160u); }); EXPECT_CALL(*mock_echo_detector, AnalyzeCaptureAudio(_)) - .WillOnce([](ArrayView<const float> capture_audio) { + .WillOnce([](std::span<const float> capture_audio) { EXPECT_EQ(capture_audio.size(), 160u); }); EXPECT_CALL(*mock_echo_detector, GetMetrics()).Times(1); @@ -2356,12 +2356,12 @@ /*render_sample_rate_hz=*/48000, _)) .Times(1); EXPECT_CALL(*mock_echo_detector, AnalyzeRenderAudio(_)) - .WillOnce([](ArrayView<const float> render_audio) { + .WillOnce([](std::span<const float> render_audio) { EXPECT_EQ(render_audio.size(), 480u); }); EXPECT_CALL(*mock_echo_detector, AnalyzeCaptureAudio(_)) .Times(2) - .WillRepeatedly([](ArrayView<const float> capture_audio) { + .WillRepeatedly([](std::span<const float> capture_audio) { EXPECT_EQ(capture_audio.size(), 480u); }); EXPECT_CALL(*mock_echo_detector, GetMetrics()).Times(2);
diff --git a/modules/audio_processing/capture_levels_adjuster/BUILD.gn b/modules/audio_processing/capture_levels_adjuster/BUILD.gn index 20b2e39..b8df947 100644 --- a/modules/audio_processing/capture_levels_adjuster/BUILD.gn +++ b/modules/audio_processing/capture_levels_adjuster/BUILD.gn
@@ -22,7 +22,6 @@ deps = [ "..:audio_buffer", - "../../../api:array_view", "../../../rtc_base:checks", "../../../rtc_base:safe_minmax", ]
diff --git a/modules/audio_processing/capture_levels_adjuster/audio_samples_scaler.cc b/modules/audio_processing/capture_levels_adjuster/audio_samples_scaler.cc index a2430ab..b32f8d2 100644 --- a/modules/audio_processing/capture_levels_adjuster/audio_samples_scaler.cc +++ b/modules/audio_processing/capture_levels_adjuster/audio_samples_scaler.cc
@@ -11,8 +11,8 @@ #include <algorithm> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_minmax.h" @@ -40,7 +40,7 @@ if (previous_gain_ == target_gain_) { // Apply a non-changing gain. for (size_t channel = 0; channel < audio_buffer.num_channels(); ++channel) { - ArrayView<float> channel_view(audio_buffer.channels()[channel], + std::span<float> channel_view(audio_buffer.channels()[channel], samples_per_channel_); for (float& sample : channel_view) { sample *= gain; @@ -55,7 +55,7 @@ for (size_t channel = 0; channel < audio_buffer.num_channels(); ++channel) { gain = previous_gain_; - ArrayView<float> channel_view(audio_buffer.channels()[channel], + std::span<float> channel_view(audio_buffer.channels()[channel], samples_per_channel_); for (float& sample : channel_view) { gain = std::min(gain + increment, target_gain_); @@ -67,7 +67,7 @@ for (size_t channel = 0; channel < audio_buffer.num_channels(); ++channel) { gain = previous_gain_; - ArrayView<float> channel_view(audio_buffer.channels()[channel], + std::span<float> channel_view(audio_buffer.channels()[channel], samples_per_channel_); for (float& sample : channel_view) { gain = std::max(gain + increment, target_gain_); @@ -80,7 +80,7 @@ // Saturate the samples to be in the S16 range. for (size_t channel = 0; channel < audio_buffer.num_channels(); ++channel) { - ArrayView<float> channel_view(audio_buffer.channels()[channel], + std::span<float> channel_view(audio_buffer.channels()[channel], samples_per_channel_); for (float& sample : channel_view) { constexpr float kMinFloatS16Value = -32768.f;
diff --git a/modules/audio_processing/capture_mixer/BUILD.gn b/modules/audio_processing/capture_mixer/BUILD.gn index ec4653d..16dfba7 100644 --- a/modules/audio_processing/capture_mixer/BUILD.gn +++ b/modules/audio_processing/capture_mixer/BUILD.gn
@@ -30,10 +30,7 @@ defines = [] - deps = [ - "../../../api:array_view", - "../../../rtc_base:checks", - ] + deps = [ "../../../rtc_base:checks" ] } rtc_library("capture_mixer_unittests") { @@ -51,7 +48,6 @@ deps = [ ":capture_mixer", "..:audioproc_test_utils", - "../../../api:array_view", "../../../rtc_base:gunit_helpers", "../../../rtc_base:stringutils", "../../../test:test_support",
diff --git a/modules/audio_processing/capture_mixer/audio_content_analyzer.cc b/modules/audio_processing/capture_mixer/audio_content_analyzer.cc index 4f07942..db47fb1 100644 --- a/modules/audio_processing/capture_mixer/audio_content_analyzer.cc +++ b/modules/audio_processing/capture_mixer/audio_content_analyzer.cc
@@ -10,8 +10,7 @@ #include "modules/audio_processing/capture_mixer/audio_content_analyzer.h" #include <cstddef> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -19,8 +18,8 @@ : dc_levels_estimator_(num_samples_per_channel), saturation_estimator_(num_samples_per_channel) {} -bool AudioContentAnalyzer::Analyze(ArrayView<const float> channel0, - ArrayView<const float> channel1) { +bool AudioContentAnalyzer::Analyze(std::span<const float> channel0, + std::span<const float> channel1) { ++num_frames_analyzed_; // Exclude the first frame from the analysis to avoid reacting on any @@ -40,7 +39,7 @@ return false; } - ArrayView<const float, 2> dc_levels = dc_levels_estimator_.GetLevels(); + std::span<const float, 2> dc_levels = dc_levels_estimator_.GetLevels(); energy_estimator_.Update(channel0, channel1, dc_levels); saturation_estimator_.Update(channel0, channel1, dc_levels);
diff --git a/modules/audio_processing/capture_mixer/audio_content_analyzer.h b/modules/audio_processing/capture_mixer/audio_content_analyzer.h index e4d8eb1..436c15c 100644 --- a/modules/audio_processing/capture_mixer/audio_content_analyzer.h +++ b/modules/audio_processing/capture_mixer/audio_content_analyzer.h
@@ -12,7 +12,8 @@ #include <stddef.h> -#include "api/array_view.h" +#include <span> + #include "modules/audio_processing/capture_mixer/dc_levels_estimator.h" #include "modules/audio_processing/capture_mixer/energy_estimator.h" #include "modules/audio_processing/capture_mixer/saturation_estimator.h" @@ -33,17 +34,17 @@ // Analyzes the provided audio samples for the two channels. // Updates the internal energy, and saturation estimators. // Returns true if the current frame is considered to contain activity. - bool Analyze(ArrayView<const float> channel0, - ArrayView<const float> channel1); + bool Analyze(std::span<const float> channel0, + std::span<const float> channel1); // Returns the current average energy estimates for the two channels. - ArrayView<const float, 2> GetChannelEnergies() const { + std::span<const float, 2> GetChannelEnergies() const { return energy_estimator_.GetChannelEnergies(); } // Returns the number of frames since the last activity was detected in each // of the channels. - ArrayView<const int, 2> GetNumFramesSinceActivity() const { + std::span<const int, 2> GetNumFramesSinceActivity() const { return saturation_estimator_.GetNumFramesSinceActivity(); } @@ -51,7 +52,7 @@ // saturation factor is a value between 0 and 1, where 1 means that the signal // has recently been fully saturated and 0 means that no saturation has been // observed in the resent past. - ArrayView<const float, 2> GetSaturationFactors() const { + std::span<const float, 2> GetSaturationFactors() const { return saturation_estimator_.GetSaturationFactors(); }
diff --git a/modules/audio_processing/capture_mixer/audio_content_analyzer_unittest.cc b/modules/audio_processing/capture_mixer/audio_content_analyzer_unittest.cc index 51abf94..ded4c0e 100644 --- a/modules/audio_processing/capture_mixer/audio_content_analyzer_unittest.cc +++ b/modules/audio_processing/capture_mixer/audio_content_analyzer_unittest.cc
@@ -13,7 +13,6 @@ #include <tuple> #include <vector> -#include "api/array_view.h" #include "test/gtest.h" namespace webrtc {
diff --git a/modules/audio_processing/capture_mixer/capture_mixer.cc b/modules/audio_processing/capture_mixer/capture_mixer.cc index d1d0116..cbbfb92 100644 --- a/modules/audio_processing/capture_mixer/capture_mixer.cc +++ b/modules/audio_processing/capture_mixer/capture_mixer.cc
@@ -10,8 +10,8 @@ #include "modules/audio_processing/capture_mixer/capture_mixer.h" #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/capture_mixer/channel_content_remixer.h" #include "rtc_base/checks.h" @@ -28,8 +28,8 @@ remixing_logic_(num_samples_per_channel) {} void CaptureMixer::Mix(size_t num_output_channels, - ArrayView<float> channel0, - ArrayView<float> channel1) { + std::span<float> channel0, + std::span<float> channel1) { RTC_DCHECK_GE(num_output_channels, 1); RTC_DCHECK_LE(num_output_channels, 2); @@ -45,11 +45,11 @@ return; } - ArrayView<const float, 2> average_energies = + std::span<const float, 2> average_energies = audio_content_analyzer_.GetChannelEnergies(); - ArrayView<const int, 2> num_frames_since_activity = + std::span<const int, 2> num_frames_since_activity = audio_content_analyzer_.GetNumFramesSinceActivity(); - ArrayView<const float, 2> saturation_factors = + std::span<const float, 2> saturation_factors = audio_content_analyzer_.GetSaturationFactors(); mixing_variant_ = remixing_logic_.SelectStereoChannelMixing(
diff --git a/modules/audio_processing/capture_mixer/capture_mixer.h b/modules/audio_processing/capture_mixer/capture_mixer.h index 88c35f9..2cc9605 100644 --- a/modules/audio_processing/capture_mixer/capture_mixer.h +++ b/modules/audio_processing/capture_mixer/capture_mixer.h
@@ -12,7 +12,8 @@ #include <stddef.h> -#include "api/array_view.h" +#include <span> + #include "modules/audio_processing/capture_mixer/audio_content_analyzer.h" #include "modules/audio_processing/capture_mixer/channel_content_remixer.h" #include "modules/audio_processing/capture_mixer/remixing_logic.h" @@ -26,8 +27,8 @@ CaptureMixer& operator=(const CaptureMixer&) = delete; void Mix(size_t num_output_channels, - ArrayView<float> channel0, - ArrayView<float> channel1); + std::span<float> channel0, + std::span<float> channel1); private: AudioContentAnalyzer audio_content_analyzer_;
diff --git a/modules/audio_processing/capture_mixer/channel_content_remixer.cc b/modules/audio_processing/capture_mixer/channel_content_remixer.cc index 073abdb..8293f47 100644 --- a/modules/audio_processing/capture_mixer/channel_content_remixer.cc +++ b/modules/audio_processing/capture_mixer/channel_content_remixer.cc
@@ -11,8 +11,8 @@ #include <algorithm> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -28,8 +28,8 @@ bool ChannelContentRemixer::Mix(size_t num_output_channels, StereoMixingVariant mixing_variant, - ArrayView<float> channel0, - ArrayView<float> channel1) { + std::span<float> channel0, + std::span<float> channel1) { RTC_DCHECK_EQ(channel0.size(), num_samples_per_channel_); RTC_DCHECK_EQ(channel1.size(), num_samples_per_channel_); @@ -304,14 +304,14 @@ } void ChannelContentRemixer::CopyChannelContent( - ArrayView<const float> source, - ArrayView<float> destination) const { + std::span<const float> source, + std::span<float> destination) const { std::copy(source.begin(), source.end(), destination.begin()); } void ChannelContentRemixer::StoreChannelAverageIntoBothChannels( - ArrayView<float> channel0, - ArrayView<float> channel1) const { + std::span<float> channel0, + std::span<float> channel1) const { for (size_t k = 0; k < channel0.size(); ++k) { float average = (channel0[k] + channel1[k]) * 0.5f; channel0[k] = average; @@ -320,9 +320,9 @@ } void ChannelContentRemixer::CrossFadeFromSingleChannelToSingleChannel( - ArrayView<const float> crossfade_from, - ArrayView<const float> crossfade_to, - ArrayView<float> destination, + std::span<const float> crossfade_from, + std::span<const float> crossfade_to, + std::span<float> destination, size_t& crossfade_sample_counter) const { for (size_t k = 0; k < destination.size(); ++k, ++crossfade_sample_counter) { const float scaling = @@ -333,9 +333,9 @@ } void ChannelContentRemixer::CrossFadeFromSingleChannelContentToAverage( - ArrayView<const float> crossfade_from, - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<const float> crossfade_from, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const { for (size_t k = 0; k < channel0.size(); ++k, ++crossfade_sample_counter) { const float scaling = @@ -350,9 +350,9 @@ } void ChannelContentRemixer::CrossFadeFromAverageToSingleChannelContent( - ArrayView<const float> crossfade_to, - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<const float> crossfade_to, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const { for (size_t k = 0; k < channel0.size(); ++k, ++crossfade_sample_counter) { const float scaling = @@ -366,8 +366,8 @@ } void ChannelContentRemixer::CrossFadeFromAverageToBothChannels( - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const { for (size_t k = 0; k < channel0.size(); ++k, ++crossfade_sample_counter) { const float scaling = @@ -381,8 +381,8 @@ } void ChannelContentRemixer::CrossFadeFromBothChannelsToAverage( - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const { for (size_t k = 0; k < channel0.size(); ++k, ++crossfade_sample_counter) { const float scaling = @@ -395,9 +395,9 @@ } void ChannelContentRemixer::CrossFadeFromAverageInToChannel0( - ArrayView<const float> crossfade_to, - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<const float> crossfade_to, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const { for (size_t k = 0; k < channel0.size(); ++k, ++crossfade_sample_counter) { const float scaling = @@ -409,9 +409,9 @@ } void ChannelContentRemixer::CrossFadeChannel0ToAverage( - ArrayView<const float> crossfade_from, - ArrayView<float> channel0, - ArrayView<const float> channel1, + std::span<const float> crossfade_from, + std::span<float> channel0, + std::span<const float> channel1, size_t& crossfade_sample_counter) const { for (size_t k = 0; k < channel0.size(); ++k, ++crossfade_sample_counter) { const float scaling = @@ -423,8 +423,8 @@ } void ChannelContentRemixer::StoreChannelAverageIntoChannel0( - ArrayView<float> channel0, - ArrayView<const float> channel1) const { + std::span<float> channel0, + std::span<const float> channel1) const { for (size_t k = 0; k < channel0.size(); ++k) { float average = (channel0[k] + channel1[k]) * 0.5f; channel0[k] = average;
diff --git a/modules/audio_processing/capture_mixer/channel_content_remixer.h b/modules/audio_processing/capture_mixer/channel_content_remixer.h index 39d52bb..3226dbe 100644 --- a/modules/audio_processing/capture_mixer/channel_content_remixer.h +++ b/modules/audio_processing/capture_mixer/channel_content_remixer.h
@@ -11,8 +11,7 @@ #define MODULES_AUDIO_PROCESSING_CAPTURE_MIXER_CHANNEL_CONTENT_REMIXER_H_ #include <cstddef> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -50,8 +49,8 @@ // crossfades are completed. bool Mix(size_t num_output_channels, StereoMixingVariant mixing_variant, - ArrayView<float> channel0, - ArrayView<float> channel1); + std::span<float> channel0, + std::span<float> channel1); private: const size_t num_samples_per_channel_; @@ -67,63 +66,63 @@ bool IsCrossfadeCompleted(); // Copies content from source to destination. - void CopyChannelContent(ArrayView<const float> source, - ArrayView<float> destination) const; + void CopyChannelContent(std::span<const float> source, + std::span<float> destination) const; // Calculates the average of channel0 and channel1 and writes it to both. - void StoreChannelAverageIntoBothChannels(ArrayView<float> channel0, - ArrayView<float> channel1) const; + void StoreChannelAverageIntoBothChannels(std::span<float> channel0, + std::span<float> channel1) const; // Performs a linear cross-fade from `crossfade_from` to `crossfade_to` into // `destination`. void CrossFadeFromSingleChannelToSingleChannel( - ArrayView<const float> crossfade_from, - ArrayView<const float> crossfade_to, - ArrayView<float> destination, + std::span<const float> crossfade_from, + std::span<const float> crossfade_to, + std::span<float> destination, size_t& crossfade_sample_counter) const; // Cross-fades from a single channel to the average of both channels. void CrossFadeFromSingleChannelContentToAverage( - ArrayView<const float> crossfade_from, - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<const float> crossfade_from, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const; // Cross-fades from the average of both channels to a single channel. void CrossFadeFromAverageToSingleChannelContent( - ArrayView<const float> crossfade_to, - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<const float> crossfade_to, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const; // Cross-fades from the average of both channels to using both channels // independently. void CrossFadeFromAverageToBothChannels( - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const; // Cross-fades from using both channels independently to their average. void CrossFadeFromBothChannelsToAverage( - ArrayView<float> channel0, - ArrayView<float> channel1, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const; // specific helper for Mix when num_output_channels == 1. - void CrossFadeFromAverageInToChannel0(ArrayView<const float> crossfade_to, - ArrayView<float> channel0, - ArrayView<float> channel1, + void CrossFadeFromAverageInToChannel0(std::span<const float> crossfade_to, + std::span<float> channel0, + std::span<float> channel1, size_t& crossfade_sample_counter) const; // specific helper for Mix when num_output_channels == 1. - void CrossFadeChannel0ToAverage(ArrayView<const float> crossfade_from, - ArrayView<float> channel0, - ArrayView<const float> channel1, + void CrossFadeChannel0ToAverage(std::span<const float> crossfade_from, + std::span<float> channel0, + std::span<const float> channel1, size_t& crossfade_sample_counter) const; // specific helper for Mix when num_output_channels == 1. - void StoreChannelAverageIntoChannel0(ArrayView<float> channel0, - ArrayView<const float> channel1) const; + void StoreChannelAverageIntoChannel0(std::span<float> channel0, + std::span<const float> channel1) const; }; } // namespace webrtc
diff --git a/modules/audio_processing/capture_mixer/channel_content_remixer_unittest.cc b/modules/audio_processing/capture_mixer/channel_content_remixer_unittest.cc index 48ca99c..bfc2ef7 100644 --- a/modules/audio_processing/capture_mixer/channel_content_remixer_unittest.cc +++ b/modules/audio_processing/capture_mixer/channel_content_remixer_unittest.cc
@@ -12,10 +12,10 @@ #include <algorithm> #include <cstddef> +#include <span> #include <tuple> #include <vector> -#include "api/array_view.h" #include "test/gtest.h" namespace webrtc { @@ -33,7 +33,7 @@ void VerifyCrossFade(float value_begin, float value_end, - ArrayView<const float> channel_data) { + std::span<const float> channel_data) { const float one_by_num_samples_per_channel = 1.0f / channel_data.size(); for (size_t k = 0; k < channel_data.size(); ++k) { const float expected_value = @@ -44,7 +44,7 @@ } void VerifyConstantValue(float expected_value, - ArrayView<const float> channel_data) { + std::span<const float> channel_data) { for (size_t k = 0; k < channel_data.size(); ++k) { EXPECT_NEAR(channel_data[k], expected_value, 1e-3); }
diff --git a/modules/audio_processing/capture_mixer/dc_levels_estimator.cc b/modules/audio_processing/capture_mixer/dc_levels_estimator.cc index 5f8d1fd..1651d37 100644 --- a/modules/audio_processing/capture_mixer/dc_levels_estimator.cc +++ b/modules/audio_processing/capture_mixer/dc_levels_estimator.cc
@@ -11,15 +11,14 @@ #include <cstddef> #include <numeric> - -#include "api/array_view.h" +#include <span> namespace webrtc { namespace { void UpdateDcEstimate(float one_by_num_samples_per_channel, - ArrayView<const float> audio, + std::span<const float> audio, float& dc_estimate) { constexpr float kForgettingFactor = 0.05f; float mean = std::accumulate(audio.begin(), audio.end(), 0.0f) * @@ -34,8 +33,8 @@ dc_levels_.fill(0.0f); } -void DcLevelsEstimator::Update(ArrayView<const float> channel0, - ArrayView<const float> channel1) { +void DcLevelsEstimator::Update(std::span<const float> channel0, + std::span<const float> channel1) { UpdateDcEstimate(one_by_num_samples_per_channel_, channel0, dc_levels_[0]); UpdateDcEstimate(one_by_num_samples_per_channel_, channel1, dc_levels_[1]); }
diff --git a/modules/audio_processing/capture_mixer/dc_levels_estimator.h b/modules/audio_processing/capture_mixer/dc_levels_estimator.h index 8ab00ad..b7181fe 100644 --- a/modules/audio_processing/capture_mixer/dc_levels_estimator.h +++ b/modules/audio_processing/capture_mixer/dc_levels_estimator.h
@@ -13,8 +13,7 @@ #include <stddef.h> #include <array> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -30,10 +29,10 @@ // Updates the DC level estimates. // `channel0` and `channel1` contain the samples of the two channels. - void Update(ArrayView<const float> channel0, ArrayView<const float> channel1); + void Update(std::span<const float> channel0, std::span<const float> channel1); // Returns the current DC level estimates for the two channels. - ArrayView<const float, 2> GetLevels() const { return dc_levels_; } + std::span<const float, 2> GetLevels() const { return dc_levels_; } private: const float one_by_num_samples_per_channel_;
diff --git a/modules/audio_processing/capture_mixer/dc_levels_estimator_unittest.cc b/modules/audio_processing/capture_mixer/dc_levels_estimator_unittest.cc index e6676f4..ad5d8e4 100644 --- a/modules/audio_processing/capture_mixer/dc_levels_estimator_unittest.cc +++ b/modules/audio_processing/capture_mixer/dc_levels_estimator_unittest.cc
@@ -13,10 +13,10 @@ #include <algorithm> #include <numbers> +#include <span> #include <tuple> #include <vector> -#include "api/array_view.h" #include "test/gtest.h" namespace webrtc { @@ -25,8 +25,8 @@ void PopulateStereoChannelsWithSinusoid(int sample_rate_hz, float dc_level, int& generated_sample_counter, - ArrayView<float> channel0, - ArrayView<float> channel1) { + std::span<float> channel0, + std::span<float> channel1) { constexpr float kPi = std::numbers::pi; constexpr float kApmlitudeScaling = 1000.0f; constexpr float kBaseSinusoidFrequencyHz = 100.0f; @@ -78,7 +78,7 @@ estimator.Update(channel0, channel1); } - ArrayView<const float> levels = estimator.GetLevels(); + std::span<const float> levels = estimator.GetLevels(); for (const float level : levels) { EXPECT_NEAR(level, true_dc_level,
diff --git a/modules/audio_processing/capture_mixer/energy_estimator.cc b/modules/audio_processing/capture_mixer/energy_estimator.cc index 8a43798..e471aa6 100644 --- a/modules/audio_processing/capture_mixer/energy_estimator.cc +++ b/modules/audio_processing/capture_mixer/energy_estimator.cc
@@ -9,13 +9,13 @@ */ #include "modules/audio_processing/capture_mixer/energy_estimator.h" -#include "api/array_view.h" +#include <span> namespace webrtc { namespace { -void UpdateChannelEnergyEstimate(ArrayView<const float> audio, +void UpdateChannelEnergyEstimate(std::span<const float> audio, float dc_level, float& channel_energy_estimate) { float energy = 0.0f; @@ -35,9 +35,9 @@ average_energy_in_channels_.fill(0.0f); } -void AverageEnergyEstimator::Update(ArrayView<const float> channel0, - ArrayView<const float> channel1, - ArrayView<const float, 2> dc_levels) { +void AverageEnergyEstimator::Update(std::span<const float> channel0, + std::span<const float> channel1, + std::span<const float, 2> dc_levels) { UpdateChannelEnergyEstimate(channel0, dc_levels[0], average_energy_in_channels_[0]); UpdateChannelEnergyEstimate(channel1, dc_levels[1],
diff --git a/modules/audio_processing/capture_mixer/energy_estimator.h b/modules/audio_processing/capture_mixer/energy_estimator.h index 3b3fa8f..cc32cb1 100644 --- a/modules/audio_processing/capture_mixer/energy_estimator.h +++ b/modules/audio_processing/capture_mixer/energy_estimator.h
@@ -13,8 +13,7 @@ #include <stddef.h> #include <array> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -31,12 +30,12 @@ // `channel0` and `channel1` contain the samples of the two channels. // `dc_levels` contains the estimated DC offsets for the two channels, which // are subtracted from the samples before energy calculation. - void Update(ArrayView<const float> channel0, - ArrayView<const float> channel1, - ArrayView<const float, 2> dc_levels); + void Update(std::span<const float> channel0, + std::span<const float> channel1, + std::span<const float, 2> dc_levels); // Returns the current average energy estimates for the two channels. - ArrayView<const float, 2> GetChannelEnergies() const { + std::span<const float, 2> GetChannelEnergies() const { return average_energy_in_channels_; }
diff --git a/modules/audio_processing/capture_mixer/energy_estimator_unittest.cc b/modules/audio_processing/capture_mixer/energy_estimator_unittest.cc index 715f700..31b0c3d 100644 --- a/modules/audio_processing/capture_mixer/energy_estimator_unittest.cc +++ b/modules/audio_processing/capture_mixer/energy_estimator_unittest.cc
@@ -11,10 +11,10 @@ #include <array> #include <cstddef> +#include <span> #include <tuple> #include <vector> -#include "api/array_view.h" #include "test/gtest.h" namespace webrtc { @@ -63,7 +63,7 @@ estimator.Update(channel0, channel1, dc_levels); } - ArrayView<const float, 2> energies = estimator.GetChannelEnergies(); + std::span<const float, 2> energies = estimator.GetChannelEnergies(); constexpr float kToleranceError = 0.0001f; const float expected_energy_channel_0 =
diff --git a/modules/audio_processing/capture_mixer/remixing_logic.cc b/modules/audio_processing/capture_mixer/remixing_logic.cc index d490fb5..d96bd63 100644 --- a/modules/audio_processing/capture_mixer/remixing_logic.cc +++ b/modules/audio_processing/capture_mixer/remixing_logic.cc
@@ -11,8 +11,8 @@ #include <cstddef> #include <optional> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/capture_mixer/channel_content_remixer.h" #include "rtc_base/checks.h" @@ -33,7 +33,7 @@ } bool EnoughContentForUpdatingMixing( - ArrayView<const int, 2> num_frames_since_activity) { + std::span<const int, 2> num_frames_since_activity) { const bool channel0_inactive = num_frames_since_activity[0] > kInactivityThresholdFrames; const bool channel1_inactive = @@ -44,8 +44,8 @@ bool SingleSilentChannelDetected( size_t num_samples_per_channel, - ArrayView<const float, 2> average_energies, - ArrayView<const int, 2> num_frames_since_activity) { + std::span<const float, 2> average_energies, + std::span<const int, 2> num_frames_since_activity) { RTC_DCHECK(EnoughContentForUpdatingMixing(num_frames_since_activity)); const bool channel0_inactive = @@ -72,7 +72,7 @@ } std::optional<int> IdentifyLargelyImbalancedChannel( - ArrayView<const float, 2> average_energies) { + std::span<const float, 2> average_energies) { constexpr float kEnergyRatioThreshold = 50.0f; const float& energy0 = average_energies[0]; const float& energy1 = average_energies[1]; @@ -87,8 +87,8 @@ } std::optional<int> IdentifyModerateImbalancedAndSaturatedChannel( - ArrayView<const float, 2> average_energies, - ArrayView<const float, 2> saturation_factors) { + std::span<const float, 2> average_energies, + std::span<const float, 2> saturation_factors) { constexpr float kEnergyRatioModerateThreshold = 4.0f; constexpr float kSignificantSaturationThreshold = 0.8f; constexpr float kNoSaturationThreshold = 0.1f; @@ -127,9 +127,9 @@ : settings_(settings), num_samples_per_channel_(num_samples_per_channel) {} StereoMixingVariant RemixingLogic::SelectStereoChannelMixing( - ArrayView<const float, 2> average_energies, - ArrayView<const int, 2> num_frames_since_activity, - ArrayView<const float, 2> saturation_factors) { + std::span<const float, 2> average_energies, + std::span<const int, 2> num_frames_since_activity, + std::span<const float, 2> saturation_factors) { // Only update the mixing when there is sufficient audio activity. if (!EnoughContentForUpdatingMixing(num_frames_since_activity)) { return mixing_; @@ -173,8 +173,8 @@ } bool RemixingLogic::HandleAnySilentChannels( - ArrayView<const float, 2> average_energies, - ArrayView<const int, 2> num_frames_since_activity) { + std::span<const float, 2> average_energies, + std::span<const int, 2> num_frames_since_activity) { RTC_DCHECK(mode_ != Mode::kSilentChannel || mixing_ == StereoMixingVariant::kUseAverage); @@ -209,8 +209,8 @@ } bool RemixingLogic::HandleAnyImbalancedAndSaturatedChannels( - ArrayView<const float, 2> average_energies, - ArrayView<const float, 2> saturation_factors) { + std::span<const float, 2> average_energies, + std::span<const float, 2> saturation_factors) { RTC_DCHECK(mode_ != Mode::kSaturatedChannel || (mixing_ == StereoMixingVariant::kUseChannel0 || mixing_ == StereoMixingVariant::kUseChannel1)); @@ -257,7 +257,7 @@ } bool RemixingLogic::HandleAnyLargelyImbalancedChannels( - ArrayView<const float, 2> average_energies) { + std::span<const float, 2> average_energies) { RTC_DCHECK(mode_ != Mode::kImbalancedChannels || (mixing_ == StereoMixingVariant::kUseChannel0 || mixing_ == StereoMixingVariant::kUseChannel1));
diff --git a/modules/audio_processing/capture_mixer/remixing_logic.h b/modules/audio_processing/capture_mixer/remixing_logic.h index 4104fc7..d5653c9 100644 --- a/modules/audio_processing/capture_mixer/remixing_logic.h +++ b/modules/audio_processing/capture_mixer/remixing_logic.h
@@ -12,7 +12,8 @@ #include <stddef.h> -#include "api/array_view.h" +#include <span> + #include "modules/audio_processing/capture_mixer/channel_content_remixer.h" namespace webrtc { @@ -48,29 +49,29 @@ // active. `saturation_factors`: Saturation measure for each channel. Returns // the chosen StereoMixingVariant. StereoMixingVariant SelectStereoChannelMixing( - ArrayView<const float, 2> average_energies, - ArrayView<const int, 2> num_frames_since_activity, - ArrayView<const float, 2> saturation_factors); + std::span<const float, 2> average_energies, + std::span<const int, 2> num_frames_since_activity, + std::span<const float, 2> saturation_factors); private: // Checks if any channel is silent and updates the mode and mixing variant // accordingly. Returns true if a mode change occurred. bool HandleAnySilentChannels( - ArrayView<const float, 2> average_energies, - ArrayView<const int, 2> num_frames_since_activity); + std::span<const float, 2> average_energies, + std::span<const int, 2> num_frames_since_activity); // Checks for channels that are moderately imbalanced and have differing // saturation levels, updating mode and mixing variant to favor the less // saturated channel. Returns true if a mode change occurred. bool HandleAnyImbalancedAndSaturatedChannels( - ArrayView<const float, 2> average_energies, - ArrayView<const float, 2> saturation_factors); + std::span<const float, 2> average_energies, + std::span<const float, 2> saturation_factors); // Checks for channels with a large energy imbalance and updates mode and // mixing variant to favor the louder channel. Returns true if a mode change // occurred. bool HandleAnyLargelyImbalancedChannels( - ArrayView<const float, 2> average_energies); + std::span<const float, 2> average_energies); // Represents the current state of the remixing logic. enum class Mode {
diff --git a/modules/audio_processing/capture_mixer/saturation_estimator.cc b/modules/audio_processing/capture_mixer/saturation_estimator.cc index 4c6df83..fffcd12 100644 --- a/modules/audio_processing/capture_mixer/saturation_estimator.cc +++ b/modules/audio_processing/capture_mixer/saturation_estimator.cc
@@ -12,15 +12,14 @@ #include <math.h> #include <cstddef> - -#include "api/array_view.h" +#include <span> namespace webrtc { namespace { void AnalyzeChannel(float one_by_num_samples_per_channel, - ArrayView<const float> audio, + std::span<const float> audio, float dc_level, int& num_frames_since_activity, float& saturation_factors) { @@ -59,9 +58,9 @@ saturation_factors_.fill(0.0f); } -void SaturationEstimator::Update(ArrayView<const float> channel0, - ArrayView<const float> channel1, - ArrayView<const float, 2> dc_levels) { +void SaturationEstimator::Update(std::span<const float> channel0, + std::span<const float> channel1, + std::span<const float, 2> dc_levels) { AnalyzeChannel(one_by_num_samples_per_channel_, channel0, dc_levels[0], num_frames_since_activity_[0], saturation_factors_[0]); AnalyzeChannel(one_by_num_samples_per_channel_, channel1, dc_levels[1],
diff --git a/modules/audio_processing/capture_mixer/saturation_estimator.h b/modules/audio_processing/capture_mixer/saturation_estimator.h index d1cd384..87d8cb9 100644 --- a/modules/audio_processing/capture_mixer/saturation_estimator.h +++ b/modules/audio_processing/capture_mixer/saturation_estimator.h
@@ -13,8 +13,7 @@ #include <stddef.h> #include <array> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -32,13 +31,13 @@ // `channel0` and `channel1` contain the samples of the two channels. // `dc_levels` contains the estimated DC offsets for the two channels, which // are subtracted from the samples before saturation calculation. - void Update(ArrayView<const float> channel0, - ArrayView<const float> channel1, - ArrayView<const float, 2> dc_levels); + void Update(std::span<const float> channel0, + std::span<const float> channel1, + std::span<const float, 2> dc_levels); // Returns the number of frames since the last activity was detected in each // of the channels. - ArrayView<const int, 2> GetNumFramesSinceActivity() const { + std::span<const int, 2> GetNumFramesSinceActivity() const { return num_frames_since_activity_; } @@ -46,7 +45,7 @@ // saturation factor is a value between 0 and 1, where 1 means that the signal // has recently been fully saturated and 0 means that no saturation has been // observed in the resent past. - ArrayView<const float, 2> GetSaturationFactors() const { + std::span<const float, 2> GetSaturationFactors() const { return saturation_factors_; }
diff --git a/modules/audio_processing/capture_mixer/saturation_estimator_unittest.cc b/modules/audio_processing/capture_mixer/saturation_estimator_unittest.cc index 24c5a38..682486f 100644 --- a/modules/audio_processing/capture_mixer/saturation_estimator_unittest.cc +++ b/modules/audio_processing/capture_mixer/saturation_estimator_unittest.cc
@@ -11,10 +11,10 @@ #include <algorithm> #include <array> +#include <span> #include <tuple> #include <vector> -#include "api/array_view.h" #include "test/gtest.h" namespace webrtc { @@ -56,7 +56,7 @@ constexpr int kNumFramesToAnalyze = 10; for (int k = 0; k < kNumFramesToAnalyze; ++k) { estimator.Update(channel, channel, dc_levels); - ArrayView<const int, 2> num_frames_since_activity = + std::span<const int, 2> num_frames_since_activity = estimator.GetNumFramesSinceActivity(); EXPECT_EQ(num_frames_since_activity[0], k + 1); EXPECT_EQ(num_frames_since_activity[1], k + 1); @@ -81,7 +81,7 @@ constexpr int kNumFramesToAnalyze = 10; for (int k = 0; k < kNumFramesToAnalyze; ++k) { estimator.Update(channel, channel, dc_levels); - ArrayView<const int, 2> num_frames_since_activity = + std::span<const int, 2> num_frames_since_activity = estimator.GetNumFramesSinceActivity(); EXPECT_EQ(num_frames_since_activity[0], 0); EXPECT_EQ(num_frames_since_activity[1], 0); @@ -108,7 +108,7 @@ estimator.Update(channel, channel, dc_levels); } - ArrayView<const int, 2> num_frames_since_activity = + std::span<const int, 2> num_frames_since_activity = estimator.GetNumFramesSinceActivity(); EXPECT_EQ(num_frames_since_activity[0], 1); EXPECT_EQ(num_frames_since_activity[1], 1); @@ -153,7 +153,7 @@ constexpr int kNumFramesToAnalyze = 10; for (int k = 0; k < kNumFramesToAnalyze; ++k) { estimator.Update(channel, channel, dc_levels); - ArrayView<const float, 2> saturation_factors = + std::span<const float, 2> saturation_factors = estimator.GetSaturationFactors(); EXPECT_EQ(saturation_factors[0], 0.0f); EXPECT_EQ(saturation_factors[1], 0.0f); @@ -179,7 +179,7 @@ std::vector<float> previous_factors(2, 0.0f); for (int k = 0; k < kNumFramesToAnalyze; ++k) { estimator.Update(channel, channel, dc_levels); - ArrayView<const float, 2> saturation_factors = + std::span<const float, 2> saturation_factors = estimator.GetSaturationFactors(); EXPECT_GT(saturation_factors[0], 0.0f); EXPECT_GT(saturation_factors[1], 0.0f); @@ -209,7 +209,7 @@ for (int k = 0; k < kNumFramesToAnalyze; ++k) { estimator.Update(channel, channel, dc_levels); } - ArrayView<const float, 2> saturation_factors = + std::span<const float, 2> saturation_factors = estimator.GetSaturationFactors(); EXPECT_GT(saturation_factors[0], 0.99f); EXPECT_GT(saturation_factors[1], 0.99f); @@ -233,7 +233,7 @@ num_samples_per_channel, dc_level + sign * kSampleValueSaturation); estimator.Update(channel, channel, dc_levels); } - ArrayView<const float, 2> saturation_factors = + std::span<const float, 2> saturation_factors = estimator.GetSaturationFactors(); EXPECT_GT(saturation_factors[0], 0.0f); EXPECT_GT(saturation_factors[1], 0.0f);
diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc index 9b29e7b..7e40e9f 100644 --- a/modules/audio_processing/gain_control_impl.cc +++ b/modules/audio_processing/gain_control_impl.cc
@@ -15,9 +15,9 @@ #include <cstddef> #include <cstdint> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "common_audio/include/audio_util.h" #include "modules/audio_processing/agc/gain_control.h" @@ -112,7 +112,7 @@ GainControlImpl::~GainControlImpl() = default; void GainControlImpl::ProcessRenderAudio( - ArrayView<const int16_t> packed_render_audio) { + std::span<const int16_t> packed_render_audio) { for (size_t ch = 0; ch < mono_agcs_.size(); ++ch) { WebRtcAgc_AddFarend(mono_agcs_[ch]->state, packed_render_audio.data(), packed_render_audio.size()); @@ -125,7 +125,7 @@ RTC_DCHECK_GE(AudioBuffer::kMaxSplitFrameLength, audio.num_frames_per_band()); std::array<int16_t, AudioBuffer::kMaxSplitFrameLength> mixed_16_kHz_render_data; - ArrayView<const int16_t> mixed_16_kHz_render(mixed_16_kHz_render_data.data(), + std::span<const int16_t> mixed_16_kHz_render(mixed_16_kHz_render_data.data(), audio.num_frames_per_band()); if (audio.num_channels() == 1) { FloatS16ToS16(audio.split_bands_const(0)[kBand0To8kHz],
diff --git a/modules/audio_processing/gain_control_impl.h b/modules/audio_processing/gain_control_impl.h index 8a3e94d..cd8c912 100644 --- a/modules/audio_processing/gain_control_impl.h +++ b/modules/audio_processing/gain_control_impl.h
@@ -16,9 +16,9 @@ #include <memory> #include <optional> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/agc/gain_control.h" namespace webrtc { @@ -34,7 +34,7 @@ ~GainControlImpl() override; - void ProcessRenderAudio(ArrayView<const int16_t> packed_render_audio); + void ProcessRenderAudio(std::span<const int16_t> packed_render_audio); int AnalyzeCaptureAudio(const AudioBuffer& audio); int ProcessCaptureAudio(AudioBuffer* audio, bool stream_has_echo);
diff --git a/modules/audio_processing/gain_control_unittest.cc b/modules/audio_processing/gain_control_unittest.cc index 41123b9..1ecb623 100644 --- a/modules/audio_processing/gain_control_unittest.cc +++ b/modules/audio_processing/gain_control_unittest.cc
@@ -11,9 +11,9 @@ #include <cstddef> #include <cstdint> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/audio_processing/audio_buffer.h" @@ -77,7 +77,7 @@ int analog_level_min, int analog_level_max, int achieved_stream_analog_level_reference, - ArrayView<const float> output_reference) { + std::span<const float> output_reference) { GainControlImpl gain_controller; SetupComponent(sample_rate_hz, mode, target_level_dbfs, stream_analog_level, compression_gain_db, enable_limiter, analog_level_min,
diff --git a/modules/audio_processing/high_pass_filter.cc b/modules/audio_processing/high_pass_filter.cc index 85b6460..7c64d61 100644 --- a/modules/audio_processing/high_pass_filter.cc +++ b/modules/audio_processing/high_pass_filter.cc
@@ -12,9 +12,9 @@ #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" #include "rtc_base/checks.h" @@ -54,23 +54,23 @@ .a = {-1.9983570340145236f, 0.9984928491805198f}}, }}; -ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients> ChooseCoefficients( +std::span<const CascadedBiQuadFilter::BiQuadCoefficients> ChooseCoefficients( int sample_rate_hz) { switch (sample_rate_hz) { case 16000: - return ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + return std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients16kHz); case 32000: - return ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + return std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients32kHz); case 48000: - return ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + return std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients48kHz); default: RTC_DCHECK_NOTREACHED(); } RTC_DCHECK_NOTREACHED(); - return ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + return std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients16kHz); } @@ -92,14 +92,14 @@ RTC_DCHECK_EQ(filters_.size(), audio->num_channels()); if (use_split_band_data) { for (size_t k = 0; k < audio->num_channels(); ++k) { - ArrayView<float> channel_data = ArrayView<float>( + std::span<float> channel_data = std::span<float>( audio->split_bands(k)[0], audio->num_frames_per_band()); filters_[k]->Process(channel_data); } } else { for (size_t k = 0; k < audio->num_channels(); ++k) { - ArrayView<float> channel_data = - ArrayView<float>(&audio->channels()[k][0], audio->num_frames()); + std::span<float> channel_data = + std::span<float>(&audio->channels()[k][0], audio->num_frames()); filters_[k]->Process(channel_data); } }
diff --git a/modules/audio_processing/high_pass_filter_unittest.cc b/modules/audio_processing/high_pass_filter_unittest.cc index 93a56ae..76c4051 100644 --- a/modules/audio_processing/high_pass_filter_unittest.cc +++ b/modules/audio_processing/high_pass_filter_unittest.cc
@@ -11,9 +11,9 @@ #include <cmath> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/test/audio_buffer_tools.h" @@ -124,7 +124,7 @@ // Method for forming a vector out of an array. // TODO(peah): Remove once braced initialization is allowed. -std::vector<float> CreateVector(const ArrayView<const float>& array_view) { +std::vector<float> CreateVector(const std::span<const float>& array_view) { std::vector<float> v; for (auto value : array_view) { v.push_back(value); @@ -230,8 +230,8 @@ for (bool use_audio_buffer_interface : {true, false}) { RunBitexactnessTest(1, use_audio_buffer_interface, - CreateVector(ArrayView<const float>(kReferenceInput)), - CreateVector(ArrayView<const float>(kReference))); + CreateVector(std::span<const float>(kReferenceInput)), + CreateVector(std::span<const float>(kReference))); } } @@ -324,8 +324,8 @@ for (bool use_audio_buffer_interface : {true, false}) { RunBitexactnessTest(1, use_audio_buffer_interface, - CreateVector(ArrayView<const float>(kReferenceInput)), - CreateVector(ArrayView<const float>(kReference))); + CreateVector(std::span<const float>(kReferenceInput)), + CreateVector(std::span<const float>(kReference))); } }
diff --git a/modules/audio_processing/include/mock_audio_processing.h b/modules/audio_processing/include/mock_audio_processing.h index 25ae9f8..2b6f468 100644 --- a/modules/audio_processing/include/mock_audio_processing.h +++ b/modules/audio_processing/include/mock_audio_processing.h
@@ -16,11 +16,11 @@ #include <cstdint> #include <cstdio> #include <memory> +#include <span> #include <string> #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio/echo_control.h" @@ -91,11 +91,11 @@ (override)); MOCK_METHOD(void, AnalyzeRenderAudio, - (webrtc::ArrayView<const float> render_audio), + (std::span<const float> render_audio), (override)); MOCK_METHOD(void, AnalyzeCaptureAudio, - (webrtc::ArrayView<const float> capture_audio), + (std::span<const float> capture_audio), (override)); MOCK_METHOD(Metrics, GetMetrics, (), (const, override)); }; @@ -155,7 +155,7 @@ (override)); MOCK_METHOD(bool, GetLinearAecOutput, - ((webrtc::ArrayView<std::array<float, 160>> linear_output)), + ((std::span<std::array<float, 160>> linear_output)), (const, override)); MOCK_METHOD(int, set_stream_delay_ms, (int delay), (override)); MOCK_METHOD(int, stream_delay_ms, (), (const, override));
diff --git a/modules/audio_processing/logging/apm_data_dumper.h b/modules/audio_processing/logging/apm_data_dumper.h index e49845f..5b3afd1 100644 --- a/modules/audio_processing/logging/apm_data_dumper.h +++ b/modules/audio_processing/logging/apm_data_dumper.h
@@ -19,8 +19,9 @@ #include <unordered_map> #endif +#include <span> + #include "absl/strings/string_view.h" -#include "api/array_view.h" #if WEBRTC_APM_DEBUG_DUMP == 1 #include "common_audio/wav_file.h" #include "rtc_base/checks.h" @@ -123,12 +124,12 @@ [[maybe_unused]] const double* v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 - DumpRaw(name, ArrayView<const double>(v, v_length), dump_set); + DumpRaw(name, std::span<const double>(v, v_length), dump_set); #endif } void DumpRaw([[maybe_unused]] absl::string_view name, - [[maybe_unused]] ArrayView<const double> v, + [[maybe_unused]] std::span<const double> v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) @@ -160,12 +161,12 @@ [[maybe_unused]] const float* v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 - DumpRaw(name, ArrayView<const float>(v, v_length), dump_set); + DumpRaw(name, std::span<const float>(v, v_length), dump_set); #endif } void DumpRaw([[maybe_unused]] absl::string_view name, - [[maybe_unused]] ArrayView<const float> v, + [[maybe_unused]] std::span<const float> v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) @@ -196,12 +197,12 @@ [[maybe_unused]] const bool* v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 - DumpRaw(name, ArrayView<const bool>(v, v_length), dump_set); + DumpRaw(name, std::span<const bool>(v, v_length), dump_set); #endif } void DumpRaw([[maybe_unused]] absl::string_view name, - [[maybe_unused]] ArrayView<const bool> v, + [[maybe_unused]] std::span<const bool> v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) @@ -236,12 +237,12 @@ [[maybe_unused]] const int16_t* v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 - DumpRaw(name, ArrayView<const int16_t>(v, v_length), dump_set); + DumpRaw(name, std::span<const int16_t>(v, v_length), dump_set); #endif } void DumpRaw([[maybe_unused]] absl::string_view name, - [[maybe_unused]] ArrayView<const int16_t> v, + [[maybe_unused]] std::span<const int16_t> v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) @@ -273,12 +274,12 @@ [[maybe_unused]] const int32_t* v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 - DumpRaw(name, ArrayView<const int32_t>(v, v_length), dump_set); + DumpRaw(name, std::span<const int32_t>(v, v_length), dump_set); #endif } void DumpRaw([[maybe_unused]] absl::string_view name, - [[maybe_unused]] ArrayView<const int32_t> v, + [[maybe_unused]] std::span<const int32_t> v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) @@ -310,12 +311,12 @@ [[maybe_unused]] const size_t* v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 - DumpRaw(name, ArrayView<const size_t>(v, v_length), dump_set); + DumpRaw(name, std::span<const size_t>(v, v_length), dump_set); #endif } void DumpRaw([[maybe_unused]] absl::string_view name, - [[maybe_unused]] ArrayView<const size_t> v, + [[maybe_unused]] std::span<const size_t> v, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) @@ -335,13 +336,13 @@ [[maybe_unused]] int num_channels, [[maybe_unused]] int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 - DumpWav(name, ArrayView<const float>(v, v_length), sample_rate_hz, + DumpWav(name, std::span<const float>(v, v_length), sample_rate_hz, num_channels, dump_set); #endif } void DumpWav([[maybe_unused]] absl::string_view name, - [[maybe_unused]] ArrayView<const float> v, + [[maybe_unused]] std::span<const float> v, [[maybe_unused]] int sample_rate_hz, [[maybe_unused]] int num_channels, [[maybe_unused]] int dump_set = kDefaultDumpSet) {
diff --git a/modules/audio_processing/ns/BUILD.gn b/modules/audio_processing/ns/BUILD.gn index e90ef0e..83cce60 100644 --- a/modules/audio_processing/ns/BUILD.gn +++ b/modules/audio_processing/ns/BUILD.gn
@@ -52,7 +52,6 @@ "..:apm_logging", "..:audio_buffer", "..:high_pass_filter", - "../../../api:array_view", "../../../common_audio:common_audio_c", "../../../common_audio/third_party/ooura:fft_size_128", "../../../common_audio/third_party/ooura:fft_size_256", @@ -78,7 +77,6 @@ "..:audio_buffer", "..:audio_processing", "..:high_pass_filter", - "../../../api:array_view", "../../../rtc_base:checks", "../../../rtc_base:safe_minmax", "../../../rtc_base:stringutils",
diff --git a/modules/audio_processing/ns/fast_math.cc b/modules/audio_processing/ns/fast_math.cc index 7d52252..9f5ed6c 100644 --- a/modules/audio_processing/ns/fast_math.cc +++ b/modules/audio_processing/ns/fast_math.cc
@@ -14,8 +14,8 @@ #include <cstddef> #include <cstdint> #include <numbers> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -60,7 +60,7 @@ return FastLog2f(x) * kLogOf2; } -void LogApproximation(ArrayView<const float> x, ArrayView<float> y) { +void LogApproximation(std::span<const float> x, std::span<float> y) { for (size_t k = 0; k < x.size(); ++k) { y[k] = LogApproximation(x[k]); } @@ -71,13 +71,13 @@ return PowApproximation(10.f, x * kLog10Ofe); } -void ExpApproximation(ArrayView<const float> x, ArrayView<float> y) { +void ExpApproximation(std::span<const float> x, std::span<float> y) { for (size_t k = 0; k < x.size(); ++k) { y[k] = ExpApproximation(x[k]); } } -void ExpApproximationSignFlip(ArrayView<const float> x, ArrayView<float> y) { +void ExpApproximationSignFlip(std::span<const float> x, std::span<float> y) { for (size_t k = 0; k < x.size(); ++k) { y[k] = ExpApproximation(-x[k]); }
diff --git a/modules/audio_processing/ns/fast_math.h b/modules/audio_processing/ns/fast_math.h index 598b31c..1064780 100644 --- a/modules/audio_processing/ns/fast_math.h +++ b/modules/audio_processing/ns/fast_math.h
@@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_PROCESSING_NS_FAST_MATH_H_ #define MODULES_AUDIO_PROCESSING_NS_FAST_MATH_H_ -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -20,7 +20,7 @@ // Log base conversion log(x) = log2(x)/log2(e). float LogApproximation(float x); -void LogApproximation(ArrayView<const float> x, ArrayView<float> y); +void LogApproximation(std::span<const float> x, std::span<float> y); // 2^x approximation. float Pow2Approximation(float p); @@ -30,8 +30,8 @@ // e^x approximation. float ExpApproximation(float x); -void ExpApproximation(ArrayView<const float> x, ArrayView<float> y); -void ExpApproximationSignFlip(ArrayView<const float> x, ArrayView<float> y); +void ExpApproximation(std::span<const float> x, std::span<float> y); +void ExpApproximationSignFlip(std::span<const float> x, std::span<float> y); } // namespace webrtc #endif // MODULES_AUDIO_PROCESSING_NS_FAST_MATH_H_
diff --git a/modules/audio_processing/ns/histograms.h b/modules/audio_processing/ns/histograms.h index 3f44454..3f65917 100644 --- a/modules/audio_processing/ns/histograms.h +++ b/modules/audio_processing/ns/histograms.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_NS_HISTOGRAMS_H_ #include <array> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/signal_model.h" namespace webrtc { @@ -35,11 +35,11 @@ void Update(const SignalModel& features_); // Methods for accessing the histograms. - ArrayView<const int, kHistogramSize> get_lrt() const { return lrt_; } - ArrayView<const int, kHistogramSize> get_spectral_flatness() const { + std::span<const int, kHistogramSize> get_lrt() const { return lrt_; } + std::span<const int, kHistogramSize> get_spectral_flatness() const { return spectral_flatness_; } - ArrayView<const int, kHistogramSize> get_spectral_diff() const { + std::span<const int, kHistogramSize> get_spectral_diff() const { return spectral_diff_; }
diff --git a/modules/audio_processing/ns/noise_estimator.cc b/modules/audio_processing/ns/noise_estimator.cc index 00b647c..4661b6d 100644 --- a/modules/audio_processing/ns/noise_estimator.cc +++ b/modules/audio_processing/ns/noise_estimator.cc
@@ -15,8 +15,8 @@ #include <cstddef> #include <cstdint> #include <numbers> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/fast_math.h" #include "modules/audio_processing/ns/ns_common.h" #include "modules/audio_processing/ns/suppression_params.h" @@ -70,7 +70,7 @@ void NoiseEstimator::PreUpdate( int32_t num_analyzed_frames, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum) { quantile_noise_estimator_.Estimate(signal_spectrum, noise_spectrum_); @@ -159,8 +159,8 @@ } void NoiseEstimator::PostUpdate( - ArrayView<const float> speech_probability, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum) { + std::span<const float> speech_probability, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum) { // Time-avg parameter for noise_spectrum update. constexpr float kNoiseUpdate = 0.9f;
diff --git a/modules/audio_processing/ns/noise_estimator.h b/modules/audio_processing/ns/noise_estimator.h index 2ae89d5..fd06b3b 100644 --- a/modules/audio_processing/ns/noise_estimator.h +++ b/modules/audio_processing/ns/noise_estimator.h
@@ -13,8 +13,8 @@ #include <array> #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/ns_common.h" #include "modules/audio_processing/ns/quantile_noise_estimator.h" #include "modules/audio_processing/ns/suppression_params.h" @@ -32,29 +32,29 @@ // Performs the first step of the estimator update. void PreUpdate(int32_t num_analyzed_frames, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum); // Performs the second step of the estimator update. - void PostUpdate(ArrayView<const float> speech_probability, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum); + void PostUpdate(std::span<const float> speech_probability, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum); // Returns the noise spectral estimate. - ArrayView<const float, kFftSizeBy2Plus1> get_noise_spectrum() const { + std::span<const float, kFftSizeBy2Plus1> get_noise_spectrum() const { return noise_spectrum_; } // Returns the noise from the previous frame. - ArrayView<const float, kFftSizeBy2Plus1> get_prev_noise_spectrum() const { + std::span<const float, kFftSizeBy2Plus1> get_prev_noise_spectrum() const { return prev_noise_spectrum_; } // Returns a noise spectral estimate based on white and pink noise parameters. - ArrayView<const float, kFftSizeBy2Plus1> get_parametric_noise_spectrum() + std::span<const float, kFftSizeBy2Plus1> get_parametric_noise_spectrum() const { return parametric_noise_spectrum_; } - ArrayView<const float, kFftSizeBy2Plus1> get_conservative_noise_spectrum() + std::span<const float, kFftSizeBy2Plus1> get_conservative_noise_spectrum() const { return conservative_noise_spectrum_; }
diff --git a/modules/audio_processing/ns/noise_suppressor.cc b/modules/audio_processing/ns/noise_suppressor.cc index 47030c2..5f535e5 100644 --- a/modules/audio_processing/ns/noise_suppressor.cc +++ b/modules/audio_processing/ns/noise_suppressor.cc
@@ -16,8 +16,8 @@ #include <cstdlib> #include <cstring> #include <memory> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/ns/fast_math.h" #include "modules/audio_processing/ns/ns_common.h" @@ -76,7 +76,7 @@ 0.99986614f}; // Applies the filterbank window to a buffer. -void ApplyFilterBankWindow(ArrayView<float, kFftSize> x) { +void ApplyFilterBankWindow(std::span<float, kFftSize> x) { for (size_t i = 0; i < 96; ++i) { x[i] = kBlocks160w256FirstHalf[i] * x[i]; } @@ -88,9 +88,9 @@ } // Extends a frame with previous data. -void FormExtendedFrame(ArrayView<const float, kNsFrameSize> frame, - ArrayView<float, kFftSize - kNsFrameSize> old_data, - ArrayView<float, kFftSize> extended_frame) { +void FormExtendedFrame(std::span<const float, kNsFrameSize> frame, + std::span<float, kFftSize - kNsFrameSize> old_data, + std::span<float, kFftSize> extended_frame) { std::copy(old_data.begin(), old_data.end(), extended_frame.begin()); std::copy(frame.begin(), frame.end(), extended_frame.begin() + old_data.size()); @@ -99,9 +99,9 @@ } // Uses overlap-and-add to produce an output frame. -void OverlapAndAdd(ArrayView<const float, kFftSize> extended_frame, - ArrayView<float, kOverlapSize> overlap_memory, - ArrayView<float, kNsFrameSize> output_frame) { +void OverlapAndAdd(std::span<const float, kFftSize> extended_frame, + std::span<float, kOverlapSize> overlap_memory, + std::span<float, kNsFrameSize> output_frame) { for (size_t i = 0; i < kOverlapSize; ++i) { output_frame[i] = overlap_memory[i] + extended_frame[i]; } @@ -113,9 +113,9 @@ } // Produces a delayed frame. -void DelaySignal(ArrayView<const float, kNsFrameSize> frame, - ArrayView<float, kFftSize - kNsFrameSize> delay_buffer, - ArrayView<float, kNsFrameSize> delayed_frame) { +void DelaySignal(std::span<const float, kNsFrameSize> frame, + std::span<float, kFftSize - kNsFrameSize> delay_buffer, + std::span<float, kNsFrameSize> delayed_frame) { constexpr size_t kSamplesFromFrame = kNsFrameSize - (kFftSize - kNsFrameSize); std::copy(delay_buffer.begin(), delay_buffer.end(), delayed_frame.begin()); std::copy(frame.begin(), frame.begin() + kSamplesFromFrame, @@ -126,7 +126,7 @@ } // Computes the energy of an extended frame. -float ComputeEnergyOfExtendedFrame(ArrayView<const float, kFftSize> x) { +float ComputeEnergyOfExtendedFrame(std::span<const float, kFftSize> x) { float energy = 0.f; for (float x_k : x) { energy += x_k * x_k; @@ -137,8 +137,8 @@ // Computes the energy of an extended frame based on its subcomponents. float ComputeEnergyOfExtendedFrame( - ArrayView<const float, kNsFrameSize> frame, - ArrayView<float, kFftSize - kNsFrameSize> old_data) { + std::span<const float, kNsFrameSize> frame, + std::span<float, kFftSize - kNsFrameSize> old_data) { float energy = 0.f; for (float v : old_data) { energy += v * v; @@ -152,9 +152,9 @@ // Computes the magnitude spectrum based on an FFT output. void ComputeMagnitudeSpectrum( - ArrayView<const float, kFftSize> real, - ArrayView<const float, kFftSize> imag, - ArrayView<float, kFftSizeBy2Plus1> signal_spectrum) { + std::span<const float, kFftSize> real, + std::span<const float, kFftSize> imag, + std::span<float, kFftSizeBy2Plus1> signal_spectrum) { signal_spectrum[0] = fabsf(real[0]) + 1.f; signal_spectrum[kFftSizeBy2Plus1 - 1] = fabsf(real[kFftSizeBy2Plus1 - 1]) + 1.f; @@ -166,13 +166,13 @@ } // Compute prior and post SNR. -void ComputeSnr(ArrayView<const float, kFftSizeBy2Plus1> filter, - ArrayView<const float> prev_signal_spectrum, - ArrayView<const float> signal_spectrum, - ArrayView<const float> prev_noise_spectrum, - ArrayView<const float> noise_spectrum, - ArrayView<float> prior_snr, - ArrayView<float> post_snr) { +void ComputeSnr(std::span<const float, kFftSizeBy2Plus1> filter, + std::span<const float> prev_signal_spectrum, + std::span<const float> signal_spectrum, + std::span<const float> prev_noise_spectrum, + std::span<const float> noise_spectrum, + std::span<float> prior_snr, + std::span<float> post_snr) { for (size_t i = 0; i < kFftSizeBy2Plus1; ++i) { // Previous post SNR. // Previous estimate: based on previous frame with gain filter. @@ -193,10 +193,10 @@ // Computes the attenuating gain for the noise suppression of the upper bands. float ComputeUpperBandsGain( float minimum_attenuating_gain, - ArrayView<const float, kFftSizeBy2Plus1> filter, - ArrayView<const float> speech_probability, - ArrayView<const float, kFftSizeBy2Plus1> prev_analysis_signal_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum) { + std::span<const float, kFftSizeBy2Plus1> filter, + std::span<const float> speech_probability, + std::span<const float, kFftSizeBy2Plus1> prev_analysis_signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum) { // Average speech prob and filter gain for the end of the lowest band. constexpr int kNumAvgBins = 32; constexpr float kOneByNumAvgBins = 1.f / kNumAvgBins; @@ -277,13 +277,13 @@ } void NoiseSuppressor::AggregateWienerFilters( - ArrayView<float, kFftSizeBy2Plus1> filter) const { - ArrayView<const float, kFftSizeBy2Plus1> filter0 = + std::span<float, kFftSizeBy2Plus1> filter) const { + std::span<const float, kFftSizeBy2Plus1> filter0 = channels_[0]->wiener_filter.get_filter(); std::copy(filter0.begin(), filter0.end(), filter.begin()); for (size_t ch = 1; ch < num_channels_; ++ch) { - ArrayView<const float, kFftSizeBy2Plus1> filter_ch = + std::span<const float, kFftSizeBy2Plus1> filter_ch = channels_[ch]->wiener_filter.get_filter(); for (size_t k = 0; k < kFftSizeBy2Plus1; ++k) { @@ -301,7 +301,7 @@ // Check for zero frames. bool zero_frame = true; for (size_t ch = 0; ch < num_channels_; ++ch) { - ArrayView<const float, kNsFrameSize> y_band0( + std::span<const float, kNsFrameSize> y_band0( &audio.split_bands_const(ch)[0][0], kNsFrameSize); float energy = ComputeEnergyOfExtendedFrame( y_band0, channels_[ch]->analyze_analysis_memory); @@ -331,7 +331,7 @@ // Analyze all channels. for (size_t ch = 0; ch < num_channels_; ++ch) { std::unique_ptr<ChannelState>& ch_p = channels_[ch]; - ArrayView<const float, kNsFrameSize> y_band0( + std::span<const float, kNsFrameSize> y_band0( &audio.split_bands_const(ch)[0][0], kNsFrameSize); // Form an extended frame and apply analysis filter bank windowing. @@ -389,34 +389,34 @@ void NoiseSuppressor::Process(AudioBuffer* audio) { // Select the space for storing data during the processing. std::array<FilterBankState, kMaxNumChannelsOnStack> filter_bank_states_stack; - ArrayView<FilterBankState> filter_bank_states(filter_bank_states_stack.data(), + std::span<FilterBankState> filter_bank_states(filter_bank_states_stack.data(), num_channels_); std::array<float, kMaxNumChannelsOnStack> upper_band_gains_stack; - ArrayView<float> upper_band_gains(upper_band_gains_stack.data(), + std::span<float> upper_band_gains(upper_band_gains_stack.data(), num_channels_); std::array<float, kMaxNumChannelsOnStack> energies_before_filtering_stack; - ArrayView<float> energies_before_filtering( + std::span<float> energies_before_filtering( energies_before_filtering_stack.data(), num_channels_); std::array<float, kMaxNumChannelsOnStack> gain_adjustments_stack; - ArrayView<float> gain_adjustments(gain_adjustments_stack.data(), + std::span<float> gain_adjustments(gain_adjustments_stack.data(), num_channels_); if (NumChannelsOnHeap(num_channels_) > 0) { // If the stack-allocated space is too small, use the heap for storing the // data. - filter_bank_states = ArrayView<FilterBankState>( + filter_bank_states = std::span<FilterBankState>( filter_bank_states_heap_.data(), num_channels_); upper_band_gains = - ArrayView<float>(upper_band_gains_heap_.data(), num_channels_); + std::span<float>(upper_band_gains_heap_.data(), num_channels_); energies_before_filtering = - ArrayView<float>(energies_before_filtering_heap_.data(), num_channels_); + std::span<float>(energies_before_filtering_heap_.data(), num_channels_); gain_adjustments = - ArrayView<float>(gain_adjustments_heap_.data(), num_channels_); + std::span<float>(gain_adjustments_heap_.data(), num_channels_); } // Compute the suppression filters for all channels. for (size_t ch = 0; ch < num_channels_; ++ch) { // Form an extended frame and apply analysis filter bank windowing. - ArrayView<float, kNsFrameSize> y_band0(&audio->split_bands(ch)[0][0], + std::span<float, kNsFrameSize> y_band0(&audio->split_bands(ch)[0][0], kNsFrameSize); FormExtendedFrame(y_band0, channels_[ch]->process_analysis_memory, @@ -463,7 +463,7 @@ // Aggregate the Wiener filters for all channels. std::array<float, kFftSizeBy2Plus1> filter_data; - ArrayView<const float, kFftSizeBy2Plus1> filter = filter_data; + std::span<const float, kFftSizeBy2Plus1> filter = filter_data; if (num_channels_ == 1) { filter = channels_[0]->wiener_filter.get_filter(); } else { @@ -515,7 +515,7 @@ // Use overlap-and-add to form the output frame of the lowest band. for (size_t ch = 0; ch < num_channels_; ++ch) { - ArrayView<float, kNsFrameSize> y_band0(&audio->split_bands(ch)[0][0], + std::span<float, kNsFrameSize> y_band0(&audio->split_bands(ch)[0][0], kNsFrameSize); OverlapAndAdd(filter_bank_states[ch].extended_frame, channels_[ch]->process_synthesis_memory, y_band0); @@ -533,7 +533,7 @@ for (size_t b = 1; b < num_bands_; ++b) { // Delay the upper bands to match the delay of the filterbank applied to // the lowest band. - ArrayView<float, kNsFrameSize> y_band(&audio->split_bands(ch)[b][0], + std::span<float, kNsFrameSize> y_band(&audio->split_bands(ch)[b][0], kNsFrameSize); std::array<float, kNsFrameSize> delayed_frame; DelaySignal(y_band, channels_[ch]->process_delay_memory[b - 1], @@ -550,7 +550,7 @@ // Limit the output the allowed range. for (size_t ch = 0; ch < num_channels_; ++ch) { for (size_t b = 0; b < num_bands_; ++b) { - ArrayView<float, kNsFrameSize> y_band(&audio->split_bands(ch)[b][0], + std::span<float, kNsFrameSize> y_band(&audio->split_bands(ch)[b][0], kNsFrameSize); for (size_t j = 0; j < kNsFrameSize; j++) { y_band[j] = std::min(std::max(y_band[j], -32768.f), 32767.f);
diff --git a/modules/audio_processing/ns/noise_suppressor.h b/modules/audio_processing/ns/noise_suppressor.h index 59312ef..5e71dec 100644 --- a/modules/audio_processing/ns/noise_suppressor.h +++ b/modules/audio_processing/ns/noise_suppressor.h
@@ -15,9 +15,9 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/ns/noise_estimator.h" #include "modules/audio_processing/ns/ns_common.h" @@ -87,7 +87,7 @@ std::vector<std::unique_ptr<ChannelState>> channels_; // Aggregates the Wiener filters into a single filter to use. - void AggregateWienerFilters(ArrayView<float, kFftSizeBy2Plus1> filter) const; + void AggregateWienerFilters(std::span<float, kFftSizeBy2Plus1> filter) const; }; } // namespace webrtc
diff --git a/modules/audio_processing/ns/ns_fft.cc b/modules/audio_processing/ns/ns_fft.cc index 07e6373..4311219 100644 --- a/modules/audio_processing/ns/ns_fft.cc +++ b/modules/audio_processing/ns/ns_fft.cc
@@ -12,8 +12,8 @@ #include <array> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "common_audio/third_party/ooura/fft_size_256/fft4g.h" #include "modules/audio_processing/ns/ns_common.h" @@ -29,9 +29,9 @@ tables_.data()); } -void NrFft::Fft(ArrayView<float, kFftSize> time_data, - ArrayView<float, kFftSize> real, - ArrayView<float, kFftSize> imag) { +void NrFft::Fft(std::span<float, kFftSize> time_data, + std::span<float, kFftSize> real, + std::span<float, kFftSize> imag) { WebRtc_rdft(kFftSize, 1, time_data.data(), bit_reversal_state_.data(), tables_.data()); @@ -47,9 +47,9 @@ } } -void NrFft::Ifft(ArrayView<const float> real, - ArrayView<const float> imag, - ArrayView<float> time_data) { +void NrFft::Ifft(std::span<const float> real, + std::span<const float> imag, + std::span<float> time_data) { time_data[0] = real[0]; time_data[1] = real[kFftSizeBy2Plus1 - 1]; for (size_t i = 1; i < kFftSizeBy2Plus1 - 1; ++i) {
diff --git a/modules/audio_processing/ns/ns_fft.h b/modules/audio_processing/ns/ns_fft.h index 7887251..358d231 100644 --- a/modules/audio_processing/ns/ns_fft.h +++ b/modules/audio_processing/ns/ns_fft.h
@@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_NS_NS_FFT_H_ #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/ns/ns_common.h" namespace webrtc { @@ -27,14 +27,14 @@ NrFft& operator=(const NrFft&) = delete; // Transforms the signal from time to frequency domain. - void Fft(ArrayView<float, kFftSize> time_data, - ArrayView<float, kFftSize> real, - ArrayView<float, kFftSize> imag); + void Fft(std::span<float, kFftSize> time_data, + std::span<float, kFftSize> real, + std::span<float, kFftSize> imag); // Transforms the signal from frequency to time domain. - void Ifft(ArrayView<const float> real, - ArrayView<const float> imag, - ArrayView<float> time_data); + void Ifft(std::span<const float> real, + std::span<const float> imag, + std::span<float> time_data); private: std::vector<size_t> bit_reversal_state_;
diff --git a/modules/audio_processing/ns/prior_signal_model_estimator.cc b/modules/audio_processing/ns/prior_signal_model_estimator.cc index f401764..dcfe297 100644 --- a/modules/audio_processing/ns/prior_signal_model_estimator.cc +++ b/modules/audio_processing/ns/prior_signal_model_estimator.cc
@@ -12,8 +12,8 @@ #include <algorithm> #include <cmath> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/histograms.h" #include "modules/audio_processing/ns/ns_common.h" #include "rtc_base/checks.h" @@ -25,7 +25,7 @@ // Identifies the first of the two largest peaks in the histogram. void FindFirstOfTwoLargestPeaks( float bin_size, - ArrayView<const int, kHistogramSize> spectral_flatness, + std::span<const int, kHistogramSize> spectral_flatness, float* peak_position, int* peak_weight) { RTC_DCHECK(peak_position); @@ -66,7 +66,7 @@ } } -void UpdateLrt(ArrayView<const int, kHistogramSize> lrt_histogram, +void UpdateLrt(std::span<const int, kHistogramSize> lrt_histogram, float* prior_model_lrt, bool* low_lrt_fluctuations) { RTC_DCHECK(prior_model_lrt);
diff --git a/modules/audio_processing/ns/quantile_noise_estimator.cc b/modules/audio_processing/ns/quantile_noise_estimator.cc index fec852b..d322f62 100644 --- a/modules/audio_processing/ns/quantile_noise_estimator.cc +++ b/modules/audio_processing/ns/quantile_noise_estimator.cc
@@ -14,8 +14,8 @@ #include <array> #include <cmath> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/fast_math.h" #include "modules/audio_processing/ns/ns_common.h" @@ -33,8 +33,8 @@ } void QuantileNoiseEstimator::Estimate( - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, - ArrayView<float, kFftSizeBy2Plus1> noise_spectrum) { + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<float, kFftSizeBy2Plus1> noise_spectrum) { std::array<float, kFftSizeBy2Plus1> log_spectrum; LogApproximation(signal_spectrum, log_spectrum); @@ -82,7 +82,7 @@ if (quantile_index_to_return >= 0) { ExpApproximation( - ArrayView<const float>(&log_quantile_[quantile_index_to_return], + std::span<const float>(&log_quantile_[quantile_index_to_return], kFftSizeBy2Plus1), quantile_); }
diff --git a/modules/audio_processing/ns/quantile_noise_estimator.h b/modules/audio_processing/ns/quantile_noise_estimator.h index 79a1b3e..6eaf9d2 100644 --- a/modules/audio_processing/ns/quantile_noise_estimator.h +++ b/modules/audio_processing/ns/quantile_noise_estimator.h
@@ -14,8 +14,8 @@ #include <math.h> #include <array> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/ns_common.h" namespace webrtc { @@ -30,8 +30,8 @@ QuantileNoiseEstimator& operator=(const QuantileNoiseEstimator&) = delete; // Estimate noise. - void Estimate(ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, - ArrayView<float, kFftSizeBy2Plus1> noise_spectrum); + void Estimate(std::span<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<float, kFftSizeBy2Plus1> noise_spectrum); private: std::array<float, kSimult * kFftSizeBy2Plus1> density_;
diff --git a/modules/audio_processing/ns/signal_model_estimator.cc b/modules/audio_processing/ns/signal_model_estimator.cc index 84f175f..0c45bd2 100644 --- a/modules/audio_processing/ns/signal_model_estimator.cc +++ b/modules/audio_processing/ns/signal_model_estimator.cc
@@ -12,8 +12,8 @@ #include <cstddef> #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/fast_math.h" #include "modules/audio_processing/ns/ns_common.h" #include "rtc_base/checks.h" @@ -27,8 +27,8 @@ // Computes the difference measure between input spectrum and a template/learned // noise spectrum. float ComputeSpectralDiff( - ArrayView<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum, float diff_normalization) { // spectral_diff = var(signal_spectrum) - cov(signal_spectrum, magnAvgPause)^2 @@ -67,7 +67,7 @@ // Updates the spectral flatness based on the input spectrum. void UpdateSpectralFlatness( - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum, float* spectral_flatness) { RTC_DCHECK(spectral_flatness); @@ -100,9 +100,9 @@ } // Updates the log LRT measures. -void UpdateSpectralLrt(ArrayView<const float, kFftSizeBy2Plus1> prior_snr, - ArrayView<const float, kFftSizeBy2Plus1> post_snr, - ArrayView<float, kFftSizeBy2Plus1> avg_log_lrt, +void UpdateSpectralLrt(std::span<const float, kFftSizeBy2Plus1> prior_snr, + std::span<const float, kFftSizeBy2Plus1> post_snr, + std::span<float, kFftSizeBy2Plus1> avg_log_lrt, float* lrt) { RTC_DCHECK(lrt); @@ -135,10 +135,10 @@ // Update the noise features. void SignalModelEstimator::Update( - ArrayView<const float, kFftSizeBy2Plus1> prior_snr, - ArrayView<const float, kFftSizeBy2Plus1> post_snr, - ArrayView<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> prior_snr, + std::span<const float, kFftSizeBy2Plus1> post_snr, + std::span<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum, float signal_energy) { // Compute spectral flatness on input spectrum.
diff --git a/modules/audio_processing/ns/signal_model_estimator.h b/modules/audio_processing/ns/signal_model_estimator.h index 540e478..ef0e5e4 100644 --- a/modules/audio_processing/ns/signal_model_estimator.h +++ b/modules/audio_processing/ns/signal_model_estimator.h
@@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_NS_SIGNAL_MODEL_ESTIMATOR_H_ #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/histograms.h" #include "modules/audio_processing/ns/ns_common.h" #include "modules/audio_processing/ns/prior_signal_model.h" @@ -32,10 +32,10 @@ void AdjustNormalization(int32_t num_analyzed_frames, float signal_energy); void Update( - ArrayView<const float, kFftSizeBy2Plus1> prior_snr, - ArrayView<const float, kFftSizeBy2Plus1> post_snr, - ArrayView<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> prior_snr, + std::span<const float, kFftSizeBy2Plus1> post_snr, + std::span<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum, float signal_energy);
diff --git a/modules/audio_processing/ns/speech_probability_estimator.cc b/modules/audio_processing/ns/speech_probability_estimator.cc index 0f73693..44b90fe 100644 --- a/modules/audio_processing/ns/speech_probability_estimator.cc +++ b/modules/audio_processing/ns/speech_probability_estimator.cc
@@ -15,8 +15,8 @@ #include <cmath> #include <cstddef> #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/fast_math.h" #include "modules/audio_processing/ns/ns_common.h" #include "modules/audio_processing/ns/prior_signal_model.h" @@ -30,10 +30,10 @@ void SpeechProbabilityEstimator::Update( int32_t num_analyzed_frames, - ArrayView<const float, kFftSizeBy2Plus1> prior_snr, - ArrayView<const float, kFftSizeBy2Plus1> post_snr, - ArrayView<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> prior_snr, + std::span<const float, kFftSizeBy2Plus1> post_snr, + std::span<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum, float signal_energy) { // Update models.
diff --git a/modules/audio_processing/ns/speech_probability_estimator.h b/modules/audio_processing/ns/speech_probability_estimator.h index 8651e8a..0516a6d 100644 --- a/modules/audio_processing/ns/speech_probability_estimator.h +++ b/modules/audio_processing/ns/speech_probability_estimator.h
@@ -13,8 +13,8 @@ #include <array> #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/ns_common.h" #include "modules/audio_processing/ns/signal_model_estimator.h" @@ -31,15 +31,15 @@ // Compute speech probability. void Update( int32_t num_analyzed_frames, - ArrayView<const float, kFftSizeBy2Plus1> prior_snr, - ArrayView<const float, kFftSizeBy2Plus1> post_snr, - ArrayView<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, + std::span<const float, kFftSizeBy2Plus1> prior_snr, + std::span<const float, kFftSizeBy2Plus1> post_snr, + std::span<const float, kFftSizeBy2Plus1> conservative_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum, float signal_spectral_sum, float signal_energy); float get_prior_probability() const { return prior_speech_prob_; } - ArrayView<const float> get_probability() { return speech_probability_; } + std::span<const float> get_probability() { return speech_probability_; } private: SignalModelEstimator signal_model_estimator_;
diff --git a/modules/audio_processing/ns/wiener_filter.cc b/modules/audio_processing/ns/wiener_filter.cc index ff8ec4d..521fd71 100644 --- a/modules/audio_processing/ns/wiener_filter.cc +++ b/modules/audio_processing/ns/wiener_filter.cc
@@ -15,8 +15,8 @@ #include <cstdio> #include <cstdlib> #include <cstring> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/fast_math.h" #include "modules/audio_processing/ns/ns_common.h" #include "modules/audio_processing/ns/suppression_params.h" @@ -32,10 +32,10 @@ void WienerFilter::Update( int32_t num_analyzed_frames, - ArrayView<const float, kFftSizeBy2Plus1> noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> prev_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> parametric_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum) { + std::span<const float, kFftSizeBy2Plus1> noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> prev_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> parametric_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum) { for (size_t i = 0; i < kFftSizeBy2Plus1; ++i) { // Previous estimate based on previous frame with gain filter. float prev_tsa = spectrum_prev_process_[i] /
diff --git a/modules/audio_processing/ns/wiener_filter.h b/modules/audio_processing/ns/wiener_filter.h index d34cd56..5f956b7 100644 --- a/modules/audio_processing/ns/wiener_filter.h +++ b/modules/audio_processing/ns/wiener_filter.h
@@ -13,8 +13,8 @@ #include <array> #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/ns/ns_common.h" #include "modules/audio_processing/ns/suppression_params.h" @@ -30,10 +30,10 @@ // Updates the filter estimate. void Update( int32_t num_analyzed_frames, - ArrayView<const float, kFftSizeBy2Plus1> noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> prev_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> parametric_noise_spectrum, - ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum); + std::span<const float, kFftSizeBy2Plus1> noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> prev_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> parametric_noise_spectrum, + std::span<const float, kFftSizeBy2Plus1> signal_spectrum); // Compute an overall gain scaling factor. float ComputeOverallScalingFactor(int32_t num_analyzed_frames, @@ -42,7 +42,7 @@ float energy_after_filtering) const; // Returns the filter. - ArrayView<const float, kFftSizeBy2Plus1> get_filter() const { + std::span<const float, kFftSizeBy2Plus1> get_filter() const { return filter_; }
diff --git a/modules/audio_processing/post_filter.cc b/modules/audio_processing/post_filter.cc index ab089b1..919d7cf 100644 --- a/modules/audio_processing/post_filter.cc +++ b/modules/audio_processing/post_filter.cc
@@ -13,9 +13,9 @@ #include <array> #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" #include "rtc_base/checks.h" @@ -52,7 +52,7 @@ } PostFilter::PostFilter( - ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients, + std::span<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients, size_t num_channels) { RTC_DCHECK(!coefficients.empty()); @@ -65,8 +65,8 @@ void PostFilter::Process(AudioBuffer& audio) { RTC_DCHECK_EQ(filters_.size(), audio.num_channels()); for (size_t k = 0; k < audio.num_channels(); ++k) { - ArrayView<float> channel_data = - ArrayView<float>(&audio.channels()[k][0], audio.num_frames()); + std::span<float> channel_data = + std::span<float>(&audio.channels()[k][0], audio.num_frames()); filters_[k]->Process(channel_data); } }
diff --git a/modules/audio_processing/post_filter.h b/modules/audio_processing/post_filter.h index cce4260..2817c6e 100644 --- a/modules/audio_processing/post_filter.h +++ b/modules/audio_processing/post_filter.h
@@ -13,9 +13,9 @@ #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" @@ -39,7 +39,7 @@ private: PostFilter( - ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients, + std::span<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients, size_t num_channels); std::vector<std::unique_ptr<CascadedBiQuadFilter>> filters_;
diff --git a/modules/audio_processing/post_filter_unittest.cc b/modules/audio_processing/post_filter_unittest.cc index cc62f13..facb613 100644 --- a/modules/audio_processing/post_filter_unittest.cc +++ b/modules/audio_processing/post_filter_unittest.cc
@@ -13,9 +13,9 @@ #include <cmath> #include <memory> #include <numbers> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/test/audio_buffer_tools.h" @@ -48,7 +48,7 @@ return frame_output; } -float ComputePower(ArrayView<const float> audio) { +float ComputePower(std::span<const float> audio) { double energy = 0.0; std::for_each(audio.begin(), audio.end(), [&energy](float x) { energy += x * x; });
diff --git a/modules/audio_processing/residual_echo_detector.cc b/modules/audio_processing/residual_echo_detector.cc index 67e2552..4db2a1e 100644 --- a/modules/audio_processing/residual_echo_detector.cc +++ b/modules/audio_processing/residual_echo_detector.cc
@@ -15,8 +15,8 @@ #include <cstddef> #include <numeric> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/checks.h" @@ -27,7 +27,7 @@ namespace { -float Power(ArrayView<const float> input) { +float Power(std::span<const float> input) { if (input.empty()) { return 0.f; } @@ -58,7 +58,7 @@ ResidualEchoDetector::~ResidualEchoDetector() = default; void ResidualEchoDetector::AnalyzeRenderAudio( - ArrayView<const float> render_audio) { + std::span<const float> render_audio) { // Dump debug data assuming 48 kHz sample rate (if this assumption is not // valid the dumped audio will need to be converted offline accordingly). data_dumper_->DumpWav("ed_render", render_audio.size(), render_audio.data(), @@ -79,7 +79,7 @@ } void ResidualEchoDetector::AnalyzeCaptureAudio( - ArrayView<const float> capture_audio) { + std::span<const float> capture_audio) { // Dump debug data assuming 48 kHz sample rate (if this assumption is not // valid the dumped audio will need to be converted offline accordingly). data_dumper_->DumpWav("ed_capture", capture_audio.size(),
diff --git a/modules/audio_processing/residual_echo_detector.h b/modules/audio_processing/residual_echo_detector.h index 292b6ce..4c5823e 100644 --- a/modules/audio_processing/residual_echo_detector.h +++ b/modules/audio_processing/residual_echo_detector.h
@@ -14,9 +14,9 @@ #include <atomic> #include <cstddef> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/echo_detector/circular_buffer.h" #include "modules/audio_processing/echo_detector/mean_variance_estimator.h" @@ -34,10 +34,10 @@ ~ResidualEchoDetector() override; // This function should be called while holding the render lock. - void AnalyzeRenderAudio(ArrayView<const float> render_audio) override; + void AnalyzeRenderAudio(std::span<const float> render_audio) override; // This function should be called while holding the capture lock. - void AnalyzeCaptureAudio(ArrayView<const float> capture_audio) override; + void AnalyzeCaptureAudio(std::span<const float> capture_audio) override; // This function should be called while holding the capture lock. void Initialize(int capture_sample_rate_hz,
diff --git a/modules/audio_processing/rms_level.cc b/modules/audio_processing/rms_level.cc index 8ae21fc..8cfab7f 100644 --- a/modules/audio_processing/rms_level.cc +++ b/modules/audio_processing/rms_level.cc
@@ -16,8 +16,8 @@ #include <cstdint> #include <numeric> #include <optional> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -61,7 +61,7 @@ block_size_ = std::nullopt; } -void RmsLevel::Analyze(ArrayView<const int16_t> data) { +void RmsLevel::Analyze(std::span<const int16_t> data) { if (data.empty()) { return; } @@ -78,7 +78,7 @@ max_sum_square_ = std::max(max_sum_square_, sum_square); } -void RmsLevel::Analyze(ArrayView<const float> data) { +void RmsLevel::Analyze(std::span<const float> data) { if (data.empty()) { return; }
diff --git a/modules/audio_processing/rms_level.h b/modules/audio_processing/rms_level.h index 879fdff..0d804d0 100644 --- a/modules/audio_processing/rms_level.h +++ b/modules/audio_processing/rms_level.h
@@ -15,8 +15,7 @@ #include <stdint.h> #include <optional> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -45,8 +44,8 @@ void Reset(); // Pass each chunk of audio to Analyze() to accumulate the level. - void Analyze(ArrayView<const int16_t> data); - void Analyze(ArrayView<const float> data); + void Analyze(std::span<const int16_t> data); + void Analyze(std::span<const float> data); // If all samples with the given `length` have a magnitude of zero, this is // a shortcut to avoid some computation.
diff --git a/modules/audio_processing/rms_level_unittest.cc b/modules/audio_processing/rms_level_unittest.cc index ed9372d..0fc3c26 100644 --- a/modules/audio_processing/rms_level_unittest.cc +++ b/modules/audio_processing/rms_level_unittest.cc
@@ -14,9 +14,9 @@ #include <cstdint> #include <memory> #include <numbers> +#include <span> #include <vector> -#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/gtest.h" @@ -26,7 +26,7 @@ constexpr int kSampleRateHz = 48000; constexpr size_t kBlockSizeSamples = kSampleRateHz / 100; -std::unique_ptr<RmsLevel> RunTest(ArrayView<const int16_t> input) { +std::unique_ptr<RmsLevel> RunTest(std::span<const int16_t> input) { std::unique_ptr<RmsLevel> level(new RmsLevel); for (size_t n = 0; n + kBlockSizeSamples <= input.size(); n += kBlockSizeSamples) { @@ -35,7 +35,7 @@ return level; } -std::unique_ptr<RmsLevel> RunTest(ArrayView<const float> input) { +std::unique_ptr<RmsLevel> RunTest(std::span<const float> input) { std::unique_ptr<RmsLevel> level(new RmsLevel); for (size_t n = 0; n + kBlockSizeSamples <= input.size(); n += kBlockSizeSamples) {
diff --git a/modules/audio_processing/splitting_filter.cc b/modules/audio_processing/splitting_filter.cc index 6513bf8..76d77ab 100644 --- a/modules/audio_processing/splitting_filter.cc +++ b/modules/audio_processing/splitting_filter.cc
@@ -13,8 +13,8 @@ #include <array> #include <cstddef> #include <cstring> +#include <span> -#include "api/array_view.h" #include "common_audio/channel_buffer.h" #include "common_audio/signal_processing/include/signal_processing_library.h" #include "modules/audio_processing/three_band_filter_bank.h" @@ -113,10 +113,10 @@ for (size_t i = 0; i < three_band_filter_banks_.size(); ++i) { three_band_filter_banks_[i].Analysis( - ArrayView<const float, ThreeBandFilterBank::kFullBandSize>( + std::span<const float, ThreeBandFilterBank::kFullBandSize>( data->channels_view()[i].data(), ThreeBandFilterBank::kFullBandSize), - ArrayView<const ArrayView<float>, ThreeBandFilterBank::kNumBands>( + std::span<const std::span<float>, ThreeBandFilterBank::kNumBands>( bands->bands_view(i).data(), ThreeBandFilterBank::kNumBands)); } } @@ -134,9 +134,9 @@ for (size_t i = 0; i < data->num_channels(); ++i) { three_band_filter_banks_[i].Synthesis( - ArrayView<const ArrayView<float>, ThreeBandFilterBank::kNumBands>( + std::span<const std::span<float>, ThreeBandFilterBank::kNumBands>( bands->bands_view(i).data(), ThreeBandFilterBank::kNumBands), - ArrayView<float, ThreeBandFilterBank::kFullBandSize>( + std::span<float, ThreeBandFilterBank::kFullBandSize>( data->channels_view()[i].data(), ThreeBandFilterBank::kFullBandSize)); }
diff --git a/modules/audio_processing/test/audio_buffer_tools.cc b/modules/audio_processing/test/audio_buffer_tools.cc index 8c9f58e..1fa7d86 100644 --- a/modules/audio_processing/test/audio_buffer_tools.cc +++ b/modules/audio_processing/test/audio_buffer_tools.cc
@@ -11,9 +11,9 @@ #include "modules/audio_processing/test/audio_buffer_tools.h" #include <cstring> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/audio_buffer.h" #include "rtc_base/checks.h" @@ -33,7 +33,7 @@ } void CopyVectorToAudioBuffer(const StreamConfig& stream_config, - ArrayView<const float> source, + std::span<const float> source, AudioBuffer* destination) { std::vector<float*> input; std::vector<float> input_samples;
diff --git a/modules/audio_processing/test/audio_buffer_tools.h b/modules/audio_processing/test/audio_buffer_tools.h index a324bb2..8bdebe0 100644 --- a/modules/audio_processing/test/audio_buffer_tools.h +++ b/modules/audio_processing/test/audio_buffer_tools.h
@@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_TEST_AUDIO_BUFFER_TOOLS_H_ #define MODULES_AUDIO_PROCESSING_TEST_AUDIO_BUFFER_TOOLS_H_ +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/audio_buffer.h" @@ -22,7 +22,7 @@ // Copies a vector into an audiobuffer. void CopyVectorToAudioBuffer(const StreamConfig& stream_config, - ArrayView<const float> source, + std::span<const float> source, AudioBuffer* destination); // Extracts a vector from an audiobuffer.
diff --git a/modules/audio_processing/test/bitexactness_tools.cc b/modules/audio_processing/test/bitexactness_tools.cc index 64538b3..01ba02c 100644 --- a/modules/audio_processing/test/bitexactness_tools.cc +++ b/modules/audio_processing/test/bitexactness_tools.cc
@@ -15,10 +15,10 @@ #include <cstddef> #include <cstdint> #include <ostream> // no-presubmit-check TODO(webrtc:8982) +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "rtc_base/checks.h" #include "test/gtest.h" @@ -62,7 +62,7 @@ void ReadFloatSamplesFromStereoFile(size_t samples_per_channel, size_t num_channels, InputAudioFile* stereo_pcm_file, - ArrayView<float> data) { + std::span<float> data) { RTC_DCHECK_LE(num_channels, 2); RTC_DCHECK_EQ(data.size(), samples_per_channel * num_channels); std::vector<int16_t> read_samples(samples_per_channel * 2); @@ -80,8 +80,8 @@ ::testing::AssertionResult VerifyDeinterleavedArray( size_t samples_per_channel, size_t num_channels, - ArrayView<const float> reference, - ArrayView<const float> output, + std::span<const float> reference, + std::span<const float> output, float element_error_bound) { // Form vectors to compare the reference to. Only the first values of the // outputs are compared in order not having to specify all preceeding frames @@ -100,8 +100,8 @@ return VerifyArray(reference, output_to_verify, element_error_bound); } -::testing::AssertionResult VerifyArray(ArrayView<const float> reference, - ArrayView<const float> output, +::testing::AssertionResult VerifyArray(std::span<const float> reference, + std::span<const float> output, float element_error_bound) { // The vectors are deemed to be bitexact only if // a) output have a size at least as long as the reference. @@ -127,7 +127,7 @@ // Lambda function that produces a formatted string with the data in the // vector. - auto print_vector_in_c_format = [](ArrayView<const float> v, + auto print_vector_in_c_format = [](std::span<const float> v, size_t num_values_to_print) { std::string s = "{ "; for (size_t k = 0; k < std::min(num_values_to_print, v.size()); ++k) {
diff --git a/modules/audio_processing/test/bitexactness_tools.h b/modules/audio_processing/test/bitexactness_tools.h index f87658e..6f8a1f4 100644 --- a/modules/audio_processing/test/bitexactness_tools.h +++ b/modules/audio_processing/test/bitexactness_tools.h
@@ -13,9 +13,9 @@ #define MODULES_AUDIO_PROCESSING_TEST_BITEXACTNESS_TOOLS_H_ #include <cstddef> +#include <span> #include <string> -#include "api/array_view.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "test/gtest.h" @@ -34,21 +34,21 @@ void ReadFloatSamplesFromStereoFile(size_t samples_per_channel, size_t num_channels, InputAudioFile* stereo_pcm_file, - ArrayView<float> data); + std::span<float> data); // Verifies a frame against a reference and returns the results as an // AssertionResult. ::testing::AssertionResult VerifyDeinterleavedArray( size_t samples_per_channel, size_t num_channels, - ArrayView<const float> reference, - ArrayView<const float> output, + std::span<const float> reference, + std::span<const float> output, float element_error_bound); // Verifies a vector against a reference and returns the results as an // AssertionResult. -::testing::AssertionResult VerifyArray(ArrayView<const float> reference, - ArrayView<const float> output, +::testing::AssertionResult VerifyArray(std::span<const float> reference, + std::span<const float> output, float element_error_bound); } // namespace test
diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn index 28f27da..88e2613 100644 --- a/modules/audio_processing/test/conversational_speech/BUILD.gn +++ b/modules/audio_processing/test/conversational_speech/BUILD.gn
@@ -45,7 +45,6 @@ "wavreader_interface.h", ] deps = [ - "../../../../api:array_view", "../../../../common_audio", "../../../../rtc_base:checks", "../../../../rtc_base:logging", @@ -68,7 +67,6 @@ ] deps = [ ":lib", - "../../../../api:array_view", "../../../../common_audio", "../../../../rtc_base:logging", "../../../../rtc_base:safe_conversions",
diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader.h b/modules/audio_processing/test/conversational_speech/mock_wavreader.h index 32acec6..a188158 100644 --- a/modules/audio_processing/test/conversational_speech/mock_wavreader.h +++ b/modules/audio_processing/test/conversational_speech/mock_wavreader.h
@@ -13,8 +13,8 @@ #include <cstddef> #include <cstdint> +#include <span> -#include "api/array_view.h" #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h" #include "test/gmock.h" @@ -27,11 +27,8 @@ MockWavReader(int sample_rate, size_t num_channels, size_t num_samples); ~MockWavReader() override; - MOCK_METHOD(size_t, ReadFloatSamples, (webrtc::ArrayView<float>), (override)); - MOCK_METHOD(size_t, - ReadInt16Samples, - (webrtc::ArrayView<int16_t>), - (override)); + MOCK_METHOD(size_t, ReadFloatSamples, (std::span<float>), (override)); + MOCK_METHOD(size_t, ReadInt16Samples, (std::span<int16_t>), (override)); MOCK_METHOD(int, SampleRate, (), (const, override)); MOCK_METHOD(size_t, NumChannels, (), (const, override));
diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.cc b/modules/audio_processing/test/conversational_speech/multiend_call.cc index d0b5d7c..bf3f19c 100644 --- a/modules/audio_processing/test/conversational_speech/multiend_call.cc +++ b/modules/audio_processing/test/conversational_speech/multiend_call.cc
@@ -15,13 +15,13 @@ #include <iterator> #include <map> #include <memory> +#include <span> #include <string> #include <tuple> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/test/conversational_speech/timing.h" #include "modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h" #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h" @@ -34,7 +34,7 @@ namespace conversational_speech { MultiEndCall::MultiEndCall( - ArrayView<const Turn> timing, + std::span<const Turn> timing, absl::string_view audiotracks_path, std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory) : timing_(timing),
diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.h b/modules/audio_processing/test/conversational_speech/multiend_call.h index 4ea53c9..fbf926b 100644 --- a/modules/audio_processing/test/conversational_speech/multiend_call.h +++ b/modules/audio_processing/test/conversational_speech/multiend_call.h
@@ -16,11 +16,11 @@ #include <map> #include <memory> #include <set> +#include <span> #include <string> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "modules/audio_processing/test/conversational_speech/timing.h" #include "modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h" #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h" @@ -51,7 +51,7 @@ }; MultiEndCall( - ArrayView<const Turn> timing, + std::span<const Turn> timing, absl::string_view audiotracks_path, std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory); ~MultiEndCall(); @@ -84,7 +84,7 @@ // only up to 2 speakers. Rejects unordered turns and self cross-talk. bool CheckTiming(); - ArrayView<const Turn> timing_; + std::span<const Turn> timing_; std::string audiotracks_path_; std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory_; std::set<std::string> speaker_names_;
diff --git a/modules/audio_processing/test/conversational_speech/simulator.cc b/modules/audio_processing/test/conversational_speech/simulator.cc index f95b508..2dcfbdb 100644 --- a/modules/audio_processing/test/conversational_speech/simulator.cc +++ b/modules/audio_processing/test/conversational_speech/simulator.cc
@@ -16,13 +16,13 @@ #include <map> #include <memory> #include <set> +#include <span> #include <string> #include <tuple> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "common_audio/include/audio_util.h" #include "common_audio/wav_file.h" #include "modules/audio_processing/test/conversational_speech/multiend_call.h" @@ -134,7 +134,7 @@ // previously written samples in `wav_writer` is less than `interval_begin`, it // adds zeros as left padding. The padding corresponds to intervals during which // a speaker is not active. -void PadLeftWriteChunk(ArrayView<const int16_t> source_samples, +void PadLeftWriteChunk(std::span<const int16_t> source_samples, size_t interval_begin, WavWriter* wav_writer) { // Add left padding. @@ -163,9 +163,9 @@ } } -void ScaleSignal(ArrayView<const int16_t> source_samples, +void ScaleSignal(std::span<const int16_t> source_samples, int gain, - ArrayView<int16_t> output_samples) { + std::span<int16_t> output_samples) { const float gain_linear = DbToRatio(gain); RTC_DCHECK_EQ(source_samples.size(), output_samples.size()); std::transform(source_samples.begin(), source_samples.end(),
diff --git a/modules/audio_processing/test/conversational_speech/timing.cc b/modules/audio_processing/test/conversational_speech/timing.cc index 6f21113..bd1998e 100644 --- a/modules/audio_processing/test/conversational_speech/timing.cc +++ b/modules/audio_processing/test/conversational_speech/timing.cc
@@ -12,11 +12,11 @@ #include <fstream> #include <iostream> +#include <span> #include <string> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/string_encode.h" #include "rtc_base/string_to_number.h" @@ -62,7 +62,7 @@ } void SaveTiming(absl::string_view timing_filepath, - ArrayView<const Turn> timing) { + std::span<const Turn> timing) { std::ofstream outfile(std::string{timing_filepath}); RTC_CHECK(outfile.is_open()); for (const Turn& turn : timing) {
diff --git a/modules/audio_processing/test/conversational_speech/timing.h b/modules/audio_processing/test/conversational_speech/timing.h index 56e19c6..edf8cd6 100644 --- a/modules/audio_processing/test/conversational_speech/timing.h +++ b/modules/audio_processing/test/conversational_speech/timing.h
@@ -11,11 +11,11 @@ #ifndef MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_TIMING_H_ #define MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_TIMING_H_ +#include <span> #include <string> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" namespace webrtc { namespace test { @@ -42,7 +42,7 @@ // Writes a list of turns into a file. void SaveTiming(absl::string_view timing_filepath, - ArrayView<const Turn> timing); + std::span<const Turn> timing); } // namespace conversational_speech } // namespace test
diff --git a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc index 4cd7d09..63f4d68 100644 --- a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc +++ b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc
@@ -13,9 +13,9 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <span> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "common_audio/wav_file.h" #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h" @@ -31,11 +31,11 @@ : wav_reader_(filepath) {} ~WavReaderAdaptor() override = default; - size_t ReadFloatSamples(ArrayView<float> samples) override { + size_t ReadFloatSamples(std::span<float> samples) override { return wav_reader_.ReadSamples(samples.size(), samples.data()); } - size_t ReadInt16Samples(ArrayView<int16_t> samples) override { + size_t ReadInt16Samples(std::span<int16_t> samples) override { return wav_reader_.ReadSamples(samples.size(), samples.data()); }
diff --git a/modules/audio_processing/test/conversational_speech/wavreader_interface.h b/modules/audio_processing/test/conversational_speech/wavreader_interface.h index c589c57..012c704 100644 --- a/modules/audio_processing/test/conversational_speech/wavreader_interface.h +++ b/modules/audio_processing/test/conversational_speech/wavreader_interface.h
@@ -13,8 +13,7 @@ #include <cstddef> #include <cstdint> - -#include "api/array_view.h" +#include <span> namespace webrtc { namespace test { @@ -25,8 +24,8 @@ virtual ~WavReaderInterface() = default; // Returns the number of samples read. - virtual size_t ReadFloatSamples(ArrayView<float> samples) = 0; - virtual size_t ReadInt16Samples(ArrayView<int16_t> samples) = 0; + virtual size_t ReadFloatSamples(std::span<float> samples) = 0; + virtual size_t ReadInt16Samples(std::span<int16_t> samples) = 0; // Getters. virtual int SampleRate() const = 0;
diff --git a/modules/audio_processing/test/echo_canceller_test_tools.cc b/modules/audio_processing/test/echo_canceller_test_tools.cc index 0d0e407..1e0c849 100644 --- a/modules/audio_processing/test/echo_canceller_test_tools.cc +++ b/modules/audio_processing/test/echo_canceller_test_tools.cc
@@ -12,20 +12,20 @@ #include <algorithm> #include <cstddef> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/random.h" namespace webrtc { -void RandomizeSampleVector(Random* random_generator, ArrayView<float> v) { +void RandomizeSampleVector(Random* random_generator, std::span<float> v) { RandomizeSampleVector(random_generator, v, /*amplitude=*/32767.f); } void RandomizeSampleVector(Random* random_generator, - ArrayView<float> v, + std::span<float> v, float amplitude) { for (auto& v_k : v) { v_k = 2 * amplitude * random_generator->Rand<float>() - amplitude; @@ -33,7 +33,7 @@ } template <typename T> -void DelayBuffer<T>::Delay(ArrayView<const T> x, ArrayView<T> x_delayed) { +void DelayBuffer<T>::Delay(std::span<const T> x, std::span<T> x_delayed) { RTC_DCHECK_EQ(x.size(), x_delayed.size()); if (buffer_.empty()) { std::copy(x.begin(), x.end(), x_delayed.begin());
diff --git a/modules/audio_processing/test/echo_canceller_test_tools.h b/modules/audio_processing/test/echo_canceller_test_tools.h index f8a805a..cb5ef85 100644 --- a/modules/audio_processing/test/echo_canceller_test_tools.h +++ b/modules/audio_processing/test/echo_canceller_test_tools.h
@@ -12,19 +12,19 @@ #define MODULES_AUDIO_PROCESSING_TEST_ECHO_CANCELLER_TEST_TOOLS_H_ #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "rtc_base/random.h" namespace webrtc { // Randomizes the elements in a vector with values -32767.f:32767.f. -void RandomizeSampleVector(Random* random_generator, ArrayView<float> v); +void RandomizeSampleVector(Random* random_generator, std::span<float> v); // Randomizes the elements in a vector with values -amplitude:amplitude. void RandomizeSampleVector(Random* random_generator, - ArrayView<float> v, + std::span<float> v, float amplitude); // Class for delaying a signal a fixed number of samples. @@ -35,7 +35,7 @@ ~DelayBuffer() = default; // Produces a delayed signal copy of x. - void Delay(ArrayView<const T> x, ArrayView<T> x_delayed); + void Delay(std::span<const T> x, std::span<T> x_delayed); private: std::vector<T> buffer_;
diff --git a/modules/audio_processing/test/echo_canceller_test_tools_unittest.cc b/modules/audio_processing/test/echo_canceller_test_tools_unittest.cc index b22bd45..c1340c8 100644 --- a/modules/audio_processing/test/echo_canceller_test_tools_unittest.cc +++ b/modules/audio_processing/test/echo_canceller_test_tools_unittest.cc
@@ -12,9 +12,9 @@ #include <algorithm> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/random.h" #include "test/gtest.h" @@ -32,8 +32,8 @@ constexpr size_t kBlockSize = 50; for (size_t k = 0; k < CheckedDivExact(v.size(), kBlockSize); ++k) { delay_buffer.Delay( - ArrayView<const float>(&v[k * kBlockSize], kBlockSize), - ArrayView<float>(&v_delayed[k * kBlockSize], kBlockSize)); + std::span<const float>(&v[k * kBlockSize], kBlockSize), + std::span<float>(&v_delayed[k * kBlockSize], kBlockSize)); } for (size_t k = kDelay; k < v.size(); ++k) { EXPECT_EQ(v[k - kDelay], v_delayed[k]); @@ -50,8 +50,8 @@ std::vector<int> v_delayed = v; const size_t kBlockSize = 50; for (size_t k = 0; k < CheckedDivExact(v.size(), kBlockSize); ++k) { - delay_buffer.Delay(ArrayView<const int>(&v[k * kBlockSize], kBlockSize), - ArrayView<int>(&v_delayed[k * kBlockSize], kBlockSize)); + delay_buffer.Delay(std::span<const int>(&v[k * kBlockSize], kBlockSize), + std::span<int>(&v_delayed[k * kBlockSize], kBlockSize)); } for (size_t k = kDelay; k < v.size(); ++k) { EXPECT_EQ(v[k - kDelay], v_delayed[k]);
diff --git a/modules/audio_processing/test/fake_recording_device.cc b/modules/audio_processing/test/fake_recording_device.cc index 6706fe5..a3f90ff 100644 --- a/modules/audio_processing/test/fake_recording_device.cc +++ b/modules/audio_processing/test/fake_recording_device.cc
@@ -14,8 +14,8 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> -#include "api/array_view.h" #include "common_audio/channel_buffer.h" #include "common_audio/include/audio_util.h" #include "modules/audio_processing/agc2/gain_map_internal.h" @@ -43,7 +43,7 @@ void set_mic_level(const int level) { mic_level_ = level; } void set_undo_mic_level(const int level) { undo_mic_level_ = level; } virtual ~FakeRecordingDeviceWorker() = default; - virtual void ModifyBufferInt16(ArrayView<int16_t> buffer) = 0; + virtual void ModifyBufferInt16(std::span<int16_t> buffer) = 0; virtual void ModifyBufferFloat(ChannelBuffer<float>* buffer) = 0; protected: @@ -62,7 +62,7 @@ explicit FakeRecordingDeviceIdentity(const int initial_mic_level) : FakeRecordingDeviceWorker(initial_mic_level) {} ~FakeRecordingDeviceIdentity() override = default; - void ModifyBufferInt16(ArrayView<int16_t> /* buffer */) override {} + void ModifyBufferInt16(std::span<int16_t> /* buffer */) override {} void ModifyBufferFloat(ChannelBuffer<float>* /* buffer */) override {} }; @@ -73,7 +73,7 @@ explicit FakeRecordingDeviceLinear(const int initial_mic_level) : FakeRecordingDeviceWorker(initial_mic_level) {} ~FakeRecordingDeviceLinear() override = default; - void ModifyBufferInt16(ArrayView<int16_t> buffer) override { + void ModifyBufferInt16(std::span<int16_t> buffer) override { const size_t number_of_samples = buffer.size(); int16_t* data = buffer.data(); // If an undo level is specified, virtually restore the unmodified @@ -115,7 +115,7 @@ explicit FakeRecordingDeviceAgc(const int initial_mic_level) : FakeRecordingDeviceWorker(initial_mic_level) {} ~FakeRecordingDeviceAgc() override = default; - void ModifyBufferInt16(ArrayView<int16_t> buffer) override { + void ModifyBufferInt16(std::span<int16_t> buffer) override { const float scaling_factor = ComputeAgcLinearFactor(undo_mic_level_, mic_level_); const size_t number_of_samples = buffer.size(); @@ -178,7 +178,7 @@ worker_->set_undo_mic_level(level); } -void FakeRecordingDevice::SimulateAnalogGain(ArrayView<int16_t> buffer) { +void FakeRecordingDevice::SimulateAnalogGain(std::span<int16_t> buffer) { RTC_DCHECK(worker_); worker_->ModifyBufferInt16(buffer); }
diff --git a/modules/audio_processing/test/fake_recording_device.h b/modules/audio_processing/test/fake_recording_device.h index 0fcb4d1..84c34ff 100644 --- a/modules/audio_processing/test/fake_recording_device.h +++ b/modules/audio_processing/test/fake_recording_device.h
@@ -13,8 +13,8 @@ #include <cstdint> #include <memory> +#include <span> -#include "api/array_view.h" #include "common_audio/channel_buffer.h" namespace webrtc { @@ -53,7 +53,7 @@ // If `real_device_level` is a valid level, the unmodified mic signal is // virtually restored. To skip the latter step set `real_device_level` to // an empty value. - void SimulateAnalogGain(ArrayView<int16_t> buffer); + void SimulateAnalogGain(std::span<int16_t> buffer); // Simulates the analog gain. // If `real_device_level` is a valid level, the unmodified mic signal is
diff --git a/modules/audio_processing/three_band_filter_bank.cc b/modules/audio_processing/three_band_filter_bank.cc index a04852a..0b12b93 100644 --- a/modules/audio_processing/three_band_filter_bank.cc +++ b/modules/audio_processing/three_band_filter_bank.cc
@@ -35,8 +35,8 @@ #include <algorithm> #include <array> #include <numbers> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -109,11 +109,11 @@ // Filters the input signal `in` with the filter `filter` using a shift by // `in_shift`, taking into account the previous state. -void FilterCore(ArrayView<const float, kFilterSize> filter, - ArrayView<const float, ThreeBandFilterBank::kSplitBandSize> in, +void FilterCore(std::span<const float, kFilterSize> filter, + std::span<const float, ThreeBandFilterBank::kSplitBandSize> in, const int in_shift, - ArrayView<float, ThreeBandFilterBank::kSplitBandSize> out, - ArrayView<float, kMemorySize> state) { + std::span<float, ThreeBandFilterBank::kSplitBandSize> out, + std::span<float, kMemorySize> state) { constexpr int kMaxInShift = (kStride - 1); RTC_DCHECK_GE(in_shift, 0); RTC_DCHECK_LE(in_shift, kMaxInShift); @@ -176,8 +176,8 @@ // of `kSparsity`. // 3. Modulating with cosines and accumulating to get the desired band. void ThreeBandFilterBank::Analysis( - ArrayView<const float, kFullBandSize> in, - ArrayView<const ArrayView<float>, ThreeBandFilterBank::kNumBands> out) { + std::span<const float, kFullBandSize> in, + std::span<const std::span<float>, ThreeBandFilterBank::kNumBands> out) { // Initialize the output to zero. for (int band = 0; band < ThreeBandFilterBank::kNumBands; ++band) { RTC_DCHECK_EQ(out[band].size(), kSplitBandSize); @@ -204,10 +204,10 @@ ? index : (index < kZeroFilterIndex2 ? index - 1 : index - 2); - ArrayView<const float, kFilterSize> filter(kFilterCoeffs[filter_index]); - ArrayView<const float, kDctSize> dct_modulation( + std::span<const float, kFilterSize> filter(kFilterCoeffs[filter_index]); + std::span<const float, kDctSize> dct_modulation( kDctModulation[filter_index]); - ArrayView<float, kMemorySize> state(state_analysis_[filter_index]); + std::span<float, kMemorySize> state(state_analysis_[filter_index]); // Filter. std::array<float, kSplitBandSize> out_subsampled; @@ -231,8 +231,8 @@ // `kSparsity` signals with different delays. // 3. Parallel to serial upsampling by a factor of `kNumBands`. void ThreeBandFilterBank::Synthesis( - ArrayView<const ArrayView<float>, ThreeBandFilterBank::kNumBands> in, - ArrayView<float, kFullBandSize> out) { + std::span<const std::span<float>, ThreeBandFilterBank::kNumBands> in, + std::span<float, kFullBandSize> out) { std::fill(out.begin(), out.end(), 0); for (int upsampling_index = 0; upsampling_index < kSubSampling; ++upsampling_index) { @@ -247,10 +247,10 @@ ? index : (index < kZeroFilterIndex2 ? index - 1 : index - 2); - ArrayView<const float, kFilterSize> filter(kFilterCoeffs[filter_index]); - ArrayView<const float, kDctSize> dct_modulation( + std::span<const float, kFilterSize> filter(kFilterCoeffs[filter_index]); + std::span<const float, kDctSize> dct_modulation( kDctModulation[filter_index]); - ArrayView<float, kMemorySize> state(state_synthesis_[filter_index]); + std::span<float, kMemorySize> state(state_synthesis_[filter_index]); // Prepare filter input by modulating the banded input. std::array<float, kSplitBandSize> in_subsampled;
diff --git a/modules/audio_processing/three_band_filter_bank.h b/modules/audio_processing/three_band_filter_bank.h index 84feb39..2ee95f8 100644 --- a/modules/audio_processing/three_band_filter_bank.h +++ b/modules/audio_processing/three_band_filter_bank.h
@@ -13,8 +13,7 @@ #include <array> #include <cstring> - -#include "api/array_view.h" +#include <span> namespace webrtc { @@ -55,13 +54,13 @@ // Splits `in` of size kFullBandSize into 3 downsampled frequency bands in // `out`, each of size 160. - void Analysis(ArrayView<const float, kFullBandSize> in, - ArrayView<const ArrayView<float>, kNumBands> out); + void Analysis(std::span<const float, kFullBandSize> in, + std::span<const std::span<float>, kNumBands> out); // Merges the 3 downsampled frequency bands in `in`, each of size 160, into // `out`, which is of size kFullBandSize. - void Synthesis(ArrayView<const ArrayView<float>, kNumBands> in, - ArrayView<float, kFullBandSize> out); + void Synthesis(std::span<const std::span<float>, kNumBands> in, + std::span<float, kFullBandSize> out); private: std::array<std::array<float, kMemorySize>, kNumNonZeroFilters>
diff --git a/modules/audio_processing/utility/BUILD.gn b/modules/audio_processing/utility/BUILD.gn index 63ee6d0..413aba4 100644 --- a/modules/audio_processing/utility/BUILD.gn +++ b/modules/audio_processing/utility/BUILD.gn
@@ -13,10 +13,7 @@ "cascaded_biquad_filter.cc", "cascaded_biquad_filter.h", ] - deps = [ - "../../../api:array_view", - "../../../rtc_base:checks", - ] + deps = [ "../../../rtc_base:checks" ] } rtc_library("legacy_delay_estimator") { @@ -37,7 +34,6 @@ "pffft_wrapper.h", ] deps = [ - "../../../api:array_view", "../../../rtc_base:checks", "//third_party/pffft", ] @@ -52,7 +48,6 @@ ":cascaded_biquad_filter", "../../../rtc_base:checks", "../../../test:test_support", - "//api:array_view", "//rtc_base:checks", "//testing/gtest", ] @@ -74,7 +69,6 @@ sources = [ "pffft_wrapper_unittest.cc" ] deps = [ ":pffft_wrapper", - "../../../api:array_view", "../../../test:test_support", "//testing/gtest", "//third_party/pffft",
diff --git a/modules/audio_processing/utility/cascaded_biquad_filter.cc b/modules/audio_processing/utility/cascaded_biquad_filter.cc index 53c9d15..2abbda0 100644 --- a/modules/audio_processing/utility/cascaded_biquad_filter.cc +++ b/modules/audio_processing/utility/cascaded_biquad_filter.cc
@@ -11,9 +11,9 @@ #include <algorithm> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -23,7 +23,7 @@ } CascadedBiQuadFilter::CascadedBiQuadFilter( - ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients) { + std::span<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients) { for (const auto& single_biquad_coefficients : coefficients) { biquads_.push_back(BiQuad(single_biquad_coefficients)); } @@ -31,8 +31,8 @@ CascadedBiQuadFilter::~CascadedBiQuadFilter() = default; -void CascadedBiQuadFilter::Process(ArrayView<const float> x, - ArrayView<float> y) { +void CascadedBiQuadFilter::Process(std::span<const float> x, + std::span<float> y) { if (!biquads_.empty()) { ApplyBiQuad(x, y, &biquads_[0]); for (size_t k = 1; k < biquads_.size(); ++k) { @@ -43,7 +43,7 @@ } } -void CascadedBiQuadFilter::Process(ArrayView<float> y) { +void CascadedBiQuadFilter::Process(std::span<float> y) { for (auto& biquad : biquads_) { ApplyBiQuad(y, y, &biquad); } @@ -55,8 +55,8 @@ } } -void CascadedBiQuadFilter::ApplyBiQuad(ArrayView<const float> x, - ArrayView<float> y, +void CascadedBiQuadFilter::ApplyBiQuad(std::span<const float> x, + std::span<float> y, CascadedBiQuadFilter::BiQuad* biquad) { RTC_DCHECK_EQ(x.size(), y.size()); const float c_a_0 = biquad->coefficients.a[0];
diff --git a/modules/audio_processing/utility/cascaded_biquad_filter.h b/modules/audio_processing/utility/cascaded_biquad_filter.h index 25d8d50..3f1ab71 100644 --- a/modules/audio_processing/utility/cascaded_biquad_filter.h +++ b/modules/audio_processing/utility/cascaded_biquad_filter.h
@@ -13,10 +13,9 @@ #include <stddef.h> +#include <span> #include <vector> -#include "api/array_view.h" - namespace webrtc { // Applies a number of biquads in a cascaded manner. The filter implementation @@ -38,21 +37,21 @@ }; CascadedBiQuadFilter( - ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients); + std::span<const CascadedBiQuadFilter::BiQuadCoefficients> coefficients); ~CascadedBiQuadFilter(); CascadedBiQuadFilter(const CascadedBiQuadFilter&) = delete; CascadedBiQuadFilter& operator=(const CascadedBiQuadFilter&) = delete; // Applies the biquads on the values in x in order to form the output in y. - void Process(ArrayView<const float> x, ArrayView<float> y); + void Process(std::span<const float> x, std::span<float> y); // Applies the biquads on the values in y in an in-place manner. - void Process(ArrayView<float> y); + void Process(std::span<float> y); // Resets the filter to its initial state. void Reset(); private: - void ApplyBiQuad(ArrayView<const float> x, - ArrayView<float> y, + void ApplyBiQuad(std::span<const float> x, + std::span<float> y, CascadedBiQuadFilter::BiQuad* biquad); std::vector<BiQuad> biquads_;
diff --git a/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc b/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc index 23e1e87..c6e14df 100644 --- a/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc +++ b/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc
@@ -12,9 +12,9 @@ #include <array> #include <cstddef> +#include <span> #include <vector> -#include "api/array_view.h" #include "rtc_base/checks.h" #include "test/gtest.h" @@ -61,7 +61,7 @@ std::vector<float> values = CreateInputWithIncreasingValues(1000); CascadedBiQuadFilter filter( - (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kBlockingCoefficients))); filter.Process(values); @@ -78,7 +78,7 @@ } CascadedBiQuadFilter filter( - (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients))); filter.Process(values); @@ -90,7 +90,7 @@ // Verifies that the reset functionality works as intended. TEST(CascadedBiquadFilter, HighPassConfigurationResetFunctionality) { CascadedBiQuadFilter filter( - (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kHighPassFilterCoefficients))); std::vector<float> values1(100, 1.f); @@ -114,7 +114,7 @@ std::vector<float> output(input.size()); CascadedBiQuadFilter filter( - (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kTransparentCoefficients))); filter.Process(input, output); @@ -127,7 +127,7 @@ std::vector<float> output(input.size()); CascadedBiQuadFilter filter( - (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kCascadedCoefficients))); filter.Process(input, output); @@ -145,7 +145,7 @@ std::vector<float> output(input.size() - 1); CascadedBiQuadFilter filter( - (ArrayView<const CascadedBiQuadFilter::BiQuadCoefficients>( + (std::span<const CascadedBiQuadFilter::BiQuadCoefficients>( kTransparentCoefficients))); EXPECT_DEATH(filter.Process(input, output), ""); }
diff --git a/modules/audio_processing/utility/pffft_wrapper.cc b/modules/audio_processing/utility/pffft_wrapper.cc index 59b5900..87f5e95 100644 --- a/modules/audio_processing/utility/pffft_wrapper.cc +++ b/modules/audio_processing/utility/pffft_wrapper.cc
@@ -12,8 +12,8 @@ #include <cstddef> #include <memory> +#include <span> -#include "api/array_view.h" #include "rtc_base/checks.h" #include "third_party/pffft/src/pffft.h" @@ -38,11 +38,11 @@ pffft_aligned_free(data_); } -ArrayView<const float> Pffft::FloatBuffer::GetConstView() const { +std::span<const float> Pffft::FloatBuffer::GetConstView() const { return {data_, size_}; } -ArrayView<float> Pffft::FloatBuffer::GetView() { +std::span<float> Pffft::FloatBuffer::GetView() { return {data_, size_}; }
diff --git a/modules/audio_processing/utility/pffft_wrapper.h b/modules/audio_processing/utility/pffft_wrapper.h index 590310e..0a0a708 100644 --- a/modules/audio_processing/utility/pffft_wrapper.h +++ b/modules/audio_processing/utility/pffft_wrapper.h
@@ -13,8 +13,7 @@ #include <cstddef> #include <memory> - -#include "api/array_view.h" +#include <span> // Forward declaration. struct PFFFT_Setup; @@ -35,8 +34,8 @@ FloatBuffer& operator=(const FloatBuffer&) = delete; ~FloatBuffer(); - ArrayView<const float> GetConstView() const; - ArrayView<float> GetView(); + std::span<const float> GetConstView() const; + std::span<float> GetView(); private: friend class Pffft; @@ -68,7 +67,7 @@ // Creates a buffer of the right size. std::unique_ptr<FloatBuffer> CreateBuffer() const; - // TODO(https://crbug.com/webrtc/9577): Overload with ArrayView args. + // TODO(https://crbug.com/webrtc/9577): Overload with std::span args. // Computes the forward fast Fourier transform. void ForwardTransform(const FloatBuffer& in, FloatBuffer* out, bool ordered); // Computes the backward fast Fourier transform.
diff --git a/modules/audio_processing/utility/pffft_wrapper_unittest.cc b/modules/audio_processing/utility/pffft_wrapper_unittest.cc index f1ce520..c7704e7 100644 --- a/modules/audio_processing/utility/pffft_wrapper_unittest.cc +++ b/modules/audio_processing/utility/pffft_wrapper_unittest.cc
@@ -13,8 +13,9 @@ #include <algorithm> #include <cstdlib> #include <memory> +#include <span> -#include "api/array_view.h" +#include "test/gmock.h" #include "test/gtest.h" #include "third_party/pffft/src/pffft.h" @@ -22,6 +23,8 @@ namespace test { namespace { +using ::testing::ElementsAreArray; + constexpr size_t kMaxValidSizeCheck = 1024; constexpr int kFftSizes[] = {16, 32, 64, 96, 128, 160, 192, 256, @@ -41,15 +44,6 @@ return std::rand() / static_cast<double>(RAND_MAX); } -void ExpectArrayViewsEquality(ArrayView<const float> a, - ArrayView<const float> b) { - ASSERT_EQ(a.size(), b.size()); - for (size_t i = 0; i < a.size(); ++i) { - SCOPED_TRACE(i); - EXPECT_EQ(a[i], b[i]); - } -} - // Compares the output of the PFFFT C++ wrapper to that of the C PFFFT. // Bit-exactness is expected. void PffftValidateWrapper(size_t fft_size, bool complex_fft) { @@ -75,8 +69,8 @@ auto out_wrapper = pffft_wrapper.CreateBuffer(); // Input and output buffers views. - ArrayView<float> in_view(in, num_floats); - ArrayView<float> out_view(out, num_floats); + std::span<float> in_view(in, num_floats); + std::span<float> out_view(out, num_floats); auto in_wrapper_view = in_wrapper->GetView(); EXPECT_EQ(in_wrapper_view.size(), num_floats); auto out_wrapper_view = out_wrapper->GetConstView(); @@ -91,7 +85,7 @@ pffft_transform(pffft_status, in, out, scratch, PFFFT_FORWARD); pffft_wrapper.ForwardTransform(*in_wrapper, out_wrapper.get(), /*ordered=*/false); - ExpectArrayViewsEquality(out_view, out_wrapper_view); + EXPECT_THAT(out_wrapper_view, ElementsAreArray(out_view)); // Copy the FFT results into the input buffers to compute the backward FFT. std::copy(out_view.begin(), out_view.end(), in_view.begin()); @@ -102,7 +96,7 @@ pffft_transform(pffft_status, in, out, scratch, PFFFT_BACKWARD); pffft_wrapper.BackwardTransform(*in_wrapper, out_wrapper.get(), /*ordered=*/false); - ExpectArrayViewsEquality(out_view, out_wrapper_view); + EXPECT_THAT(out_wrapper_view, ElementsAreArray(out_view)); pffft_destroy_setup(pffft_status); pffft_aligned_free(in);
diff --git a/modules/audio_processing/vad/voice_activity_detector.h b/modules/audio_processing/vad/voice_activity_detector.h index 5754e89..64c42a4 100644 --- a/modules/audio_processing/vad/voice_activity_detector.h +++ b/modules/audio_processing/vad/voice_activity_detector.h
@@ -33,7 +33,7 @@ ~VoiceActivityDetector(); // Processes each audio chunk and estimates the voice probability. - // TODO(bugs.webrtc.org/7494): Switch to ArrayView and remove + // TODO(bugs.webrtc.org/7494): Switch to std::span and remove // `sample_rate_hz`. void ProcessChunk(const int16_t* audio, size_t length, int sample_rate_hz);