• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2013 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 // Modified from the Chromium original:
12 // src/media/base/sinc_resampler.cc
13 
14 #include <arm_neon.h>
15 
16 #include "common_audio/resampler/sinc_resampler.h"
17 
18 namespace webrtc {
19 
Convolve_NEON(const float * input_ptr,const float * k1,const float * k2,double kernel_interpolation_factor)20 float SincResampler::Convolve_NEON(const float* input_ptr,
21                                    const float* k1,
22                                    const float* k2,
23                                    double kernel_interpolation_factor) {
24   float32x4_t m_input;
25   float32x4_t m_sums1 = vmovq_n_f32(0);
26   float32x4_t m_sums2 = vmovq_n_f32(0);
27 
28   const float* upper = input_ptr + kKernelSize;
29   for (; input_ptr < upper;) {
30     m_input = vld1q_f32(input_ptr);
31     input_ptr += 4;
32     m_sums1 = vmlaq_f32(m_sums1, m_input, vld1q_f32(k1));
33     k1 += 4;
34     m_sums2 = vmlaq_f32(m_sums2, m_input, vld1q_f32(k2));
35     k2 += 4;
36   }
37 
38   // Linearly interpolate the two "convolutions".
39   m_sums1 = vmlaq_f32(
40       vmulq_f32(m_sums1, vmovq_n_f32(1.0 - kernel_interpolation_factor)),
41       m_sums2, vmovq_n_f32(kernel_interpolation_factor));
42 
43   // Sum components together.
44   float32x2_t m_half = vadd_f32(vget_high_f32(m_sums1), vget_low_f32(m_sums1));
45   return vget_lane_f32(vpadd_f32(m_half, m_half), 0);
46 }
47 
48 }  // namespace webrtc
49