1 /* 2 * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/audio_processing/aec3/fft_data.h" 12 13 #include <immintrin.h> 14 15 #include "api/array_view.h" 16 17 namespace webrtc { 18 19 // Computes the power spectrum of the data. SpectrumAVX2(rtc::ArrayView<float> power_spectrum) const20void FftData::SpectrumAVX2(rtc::ArrayView<float> power_spectrum) const { 21 RTC_DCHECK_EQ(kFftLengthBy2Plus1, power_spectrum.size()); 22 for (size_t k = 0; k < kFftLengthBy2; k += 8) { 23 __m256 r = _mm256_loadu_ps(&re[k]); 24 __m256 i = _mm256_loadu_ps(&im[k]); 25 __m256 ii = _mm256_mul_ps(i, i); 26 ii = _mm256_fmadd_ps(r, r, ii); 27 _mm256_storeu_ps(&power_spectrum[k], ii); 28 } 29 power_spectrum[kFftLengthBy2] = re[kFftLengthBy2] * re[kFftLengthBy2] + 30 im[kFftLengthBy2] * im[kFftLengthBy2]; 31 } 32 33 } // namespace webrtc 34