blob: e909a6c5dec32f316aebf82bddff9852ce0e05c4 [file] [log] [blame]
andrew@webrtc.org5dea86a2013-05-08 20:35:43 +00001/*
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 "webrtc/common_audio/resampler/sinc_resampler.h"
15
16#include <arm_neon.h>
17
18namespace webrtc {
19
20float SincResampler::Convolve_NEON(const float* input_ptr, const float* k1,
21 const float* k2,
22 double kernel_interpolation_factor) {
23 float32x4_t m_input;
24 float32x4_t m_sums1 = vmovq_n_f32(0);
25 float32x4_t m_sums2 = vmovq_n_f32(0);
26
27 const float* upper = input_ptr + kKernelSize;
28 for (; input_ptr < upper; ) {
29 m_input = vld1q_f32(input_ptr);
30 input_ptr += 4;
31 m_sums1 = vmlaq_f32(m_sums1, m_input, vld1q_f32(k1));
32 k1 += 4;
33 m_sums2 = vmlaq_f32(m_sums2, m_input, vld1q_f32(k2));
34 k2 += 4;
35 }
36
37 // Linearly interpolate the two "convolutions".
38 m_sums1 = vmlaq_f32(
39 vmulq_f32(m_sums1, vmovq_n_f32(1.0 - kernel_interpolation_factor)),
40 m_sums2, vmovq_n_f32(kernel_interpolation_factor));
41
42 // Sum components together.
43 float32x2_t m_half = vadd_f32(vget_high_f32(m_sums1), vget_low_f32(m_sums1));
44 return vget_lane_f32(vpadd_f32(m_half, m_half), 0);
45}
46
47} // namespace webrtc