tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

fft_data_avx2.cc (1241B)


      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 <immintrin.h>
     12 
     13 #include <cstddef>
     14 
     15 #include "api/array_view.h"
     16 #include "modules/audio_processing/aec3/aec3_common.h"
     17 #include "modules/audio_processing/aec3/fft_data.h"
     18 #include "rtc_base/checks.h"
     19 
     20 namespace webrtc {
     21 
     22 // Computes the power spectrum of the data.
     23 void FftData::SpectrumAVX2(ArrayView<float> power_spectrum) const {
     24  RTC_DCHECK_EQ(kFftLengthBy2Plus1, power_spectrum.size());
     25  for (size_t k = 0; k < kFftLengthBy2; k += 8) {
     26    __m256 r = _mm256_loadu_ps(&re[k]);
     27    __m256 i = _mm256_loadu_ps(&im[k]);
     28    __m256 ii = _mm256_mul_ps(i, i);
     29    ii = _mm256_fmadd_ps(r, r, ii);
     30    _mm256_storeu_ps(&power_spectrum[k], ii);
     31  }
     32  power_spectrum[kFftLengthBy2] = re[kFftLengthBy2] * re[kFftLengthBy2] +
     33                                  im[kFftLengthBy2] * im[kFftLengthBy2];
     34 }
     35 
     36 }  // namespace webrtc