Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Unified Diff: webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc

Issue 2834073005: Added ARM Neon SIMD optimizations for AEC3 (Closed)
Patch Set: Changes in response to reviewer comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
diff --git a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
index 6d1a5820fe7f0e6c752d9e84cc212d3406a87c2a..4560958bfd0ef350e46d97a5a3ddcb34484627d0 100644
--- a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
+++ b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
@@ -10,6 +10,7 @@
#include "webrtc/modules/audio_processing/aec3/adaptive_fir_filter.h"
+#include <math.h>
#include <algorithm>
#include <numeric>
#include <string>
@@ -41,10 +42,114 @@ std::string ProduceDebugText(size_t delay) {
} // namespace
+#if defined(WEBRTC_HAS_NEON)
+// Verifies that the optimized methods for filter adaptation are similar to
+// their reference counterparts.
+TEST(AdaptiveFirFilter, FilterAdaptationNeonOptimizations) {
+ RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 12,
+ std::vector<size_t>(1, 12));
+ Random random_generator(42U);
+ std::vector<std::vector<float>> x(3, std::vector<float>(kBlockSize, 0.f));
+ FftData S_C;
+ FftData S_NEON;
+ FftData G;
+ Aec3Fft fft;
+ std::vector<FftData> H_C(10);
+ std::vector<FftData> H_NEON(10);
+ for (auto& H_j : H_C) {
+ H_j.Clear();
+ }
+ for (auto& H_j : H_NEON) {
+ H_j.Clear();
+ }
+
+ for (size_t k = 0; k < 30; ++k) {
+ RandomizeSampleVector(&random_generator, x[0]);
+ render_buffer.Insert(x);
+ }
+
+ for (size_t j = 0; j < G.re.size(); ++j) {
+ G.re[j] = j / 10001.f;
+ }
+ for (size_t j = 1; j < G.im.size() - 1; ++j) {
+ G.im[j] = j / 20001.f;
+ }
+ G.im[0] = 0.f;
+ G.im[G.im.size() - 1] = 0.f;
+
+ AdaptPartitions_NEON(render_buffer, G, H_NEON);
+ AdaptPartitions(render_buffer, G, H_C);
+ AdaptPartitions_NEON(render_buffer, G, H_NEON);
+ AdaptPartitions(render_buffer, G, H_C);
+
+ for (size_t l = 0; l < H_C.size(); ++l) {
+ for (size_t j = 0; j < H_C[l].im.size(); ++j) {
+ EXPECT_NEAR(H_C[l].re[j], H_NEON[l].re[j], fabs(H_C[l].re[j] * 0.00001f));
+ EXPECT_NEAR(H_C[l].im[j], H_NEON[l].im[j], fabs(H_C[l].im[j] * 0.00001f));
+ }
+ }
+
+ ApplyFilter_NEON(render_buffer, H_NEON, &S_NEON);
+ ApplyFilter(render_buffer, H_C, &S_C);
+ for (size_t j = 0; j < S_C.re.size(); ++j) {
+ EXPECT_NEAR(S_C.re[j], S_NEON.re[j], fabs(S_C.re[j] * 0.00001f));
+ EXPECT_NEAR(S_C.im[j], S_NEON.im[j], fabs(S_C.re[j] * 0.00001f));
+ }
+}
+
+// Verifies that the optimized method for frequency response computation is
+// bitexact to the reference counterpart.
+TEST(AdaptiveFirFilter, UpdateFrequencyResponseNeonOptimization) {
+ const size_t kNumPartitions = 12;
+ std::vector<FftData> H(kNumPartitions);
+ std::vector<std::array<float, kFftLengthBy2Plus1>> H2(kNumPartitions);
+ std::vector<std::array<float, kFftLengthBy2Plus1>> H2_NEON(kNumPartitions);
+
+ for (size_t j = 0; j < H.size(); ++j) {
+ for (size_t k = 0; k < H[j].re.size(); ++k) {
+ H[j].re[k] = k + j / 3.f;
+ H[j].im[k] = j + k / 7.f;
+ }
+ }
+
+ UpdateFrequencyResponse(H, &H2);
+ UpdateFrequencyResponse_NEON(H, &H2_NEON);
+
+ for (size_t j = 0; j < H2.size(); ++j) {
+ for (size_t k = 0; k < H[j].re.size(); ++k) {
+ EXPECT_FLOAT_EQ(H2[j][k], H2_NEON[j][k]);
+ }
+ }
+}
+
+// Verifies that the optimized method for echo return loss computation is
+// bitexact to the reference counterpart.
+TEST(AdaptiveFirFilter, UpdateErlNeonOptimization) {
+ const size_t kNumPartitions = 12;
+ std::vector<std::array<float, kFftLengthBy2Plus1>> H2(kNumPartitions);
+ std::array<float, kFftLengthBy2Plus1> erl;
+ std::array<float, kFftLengthBy2Plus1> erl_NEON;
+
+ for (size_t j = 0; j < H2.size(); ++j) {
+ for (size_t k = 0; k < H2[j].size(); ++k) {
+ H2[j][k] = k + j / 3.f;
+ }
+ }
+
+ UpdateErlEstimator(H2, &erl);
+ UpdateErlEstimator_NEON(H2, &erl_NEON);
+
+ for (size_t j = 0; j < erl.size(); ++j) {
+ EXPECT_FLOAT_EQ(erl[j], erl_NEON[j]);
+ }
+}
+
+#endif
+
#if defined(WEBRTC_ARCH_X86_FAMILY)
// Verifies that the optimized methods for filter adaptation are bitexact to
// their reference counterparts.
-TEST(AdaptiveFirFilter, FilterAdaptationOptimizations) {
+TEST(AdaptiveFirFilter, FilterAdaptationSse2Optimizations) {
bool use_sse2 = (WebRtc_GetCPUInfo(kSSE2) != 0);
if (use_sse2) {
RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 12,
@@ -95,7 +200,7 @@ TEST(AdaptiveFirFilter, FilterAdaptationOptimizations) {
// Verifies that the optimized method for frequency response computation is
// bitexact to the reference counterpart.
-TEST(AdaptiveFirFilter, UpdateFrequencyResponseOptimization) {
+TEST(AdaptiveFirFilter, UpdateFrequencyResponseSse2Optimization) {
bool use_sse2 = (WebRtc_GetCPUInfo(kSSE2) != 0);
if (use_sse2) {
const size_t kNumPartitions = 12;
@@ -123,7 +228,7 @@ TEST(AdaptiveFirFilter, UpdateFrequencyResponseOptimization) {
// Verifies that the optimized method for echo return loss computation is
// bitexact to the reference counterpart.
-TEST(AdaptiveFirFilter, UpdateErlOptimization) {
+TEST(AdaptiveFirFilter, UpdateErlSse2Optimization) {
bool use_sse2 = (WebRtc_GetCPUInfo(kSSE2) != 0);
if (use_sse2) {
const size_t kNumPartitions = 12;
« no previous file with comments | « webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc ('k') | webrtc/modules/audio_processing/aec3/aec3_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698