OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 /* | 11 /* |
12 * The core AEC algorithm, neon version of speed-critical functions. | 12 * The core AEC algorithm, neon version of speed-critical functions. |
13 * | 13 * |
14 * Based on aec_core_sse2.c. | 14 * Based on aec_core_sse2.c. |
15 */ | 15 */ |
16 | 16 |
17 #include <arm_neon.h> | 17 #include <arm_neon.h> |
18 #include <math.h> | 18 #include <math.h> |
19 #include <string.h> // memset | 19 #include <string.h> // memset |
20 | 20 |
| 21 extern "C" { |
21 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 22 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 23 } |
22 #include "webrtc/modules/audio_processing/aec/aec_common.h" | 24 #include "webrtc/modules/audio_processing/aec/aec_common.h" |
23 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" | 25 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" |
| 26 extern "C" { |
24 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" | 27 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" |
| 28 } |
25 | 29 |
26 enum { kShiftExponentIntoTopMantissa = 8 }; | 30 enum { kShiftExponentIntoTopMantissa = 8 }; |
27 enum { kFloatExponentShift = 23 }; | 31 enum { kFloatExponentShift = 23 }; |
28 | 32 |
29 __inline static float MulRe(float aRe, float aIm, float bRe, float bIm) { | 33 __inline static float MulRe(float aRe, float aIm, float bRe, float bIm) { |
30 return aRe * bRe - aIm * bIm; | 34 return aRe * bRe - aIm * bIm; |
31 } | 35 } |
32 | 36 |
33 __inline static float MulIm(float aRe, float aIm, float bRe, float bIm) { | 37 __inline static float MulIm(float aRe, float aIm, float bRe, float bIm) { |
34 return aRe * bIm + aIm * bRe; | 38 return aRe * bIm + aIm * bRe; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // The Newton-Raphson iteration: | 117 // The Newton-Raphson iteration: |
114 // x[n+1] = x[n] * (3 - d * (x[n] * x[n])) / 2) | 118 // x[n+1] = x[n] * (3 - d * (x[n] * x[n])) / 2) |
115 // converges to (1/√d) if x0 is the result of VRSQRTE applied to d. | 119 // converges to (1/√d) if x0 is the result of VRSQRTE applied to d. |
116 // | 120 // |
117 // Note: The precision did not improve after 2 iterations. | 121 // Note: The precision did not improve after 2 iterations. |
118 for (i = 0; i < 2; i++) { | 122 for (i = 0; i < 2; i++) { |
119 x = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x, x), s), x); | 123 x = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x, x), s), x); |
120 } | 124 } |
121 // sqrt(s) = s * 1/sqrt(s) | 125 // sqrt(s) = s * 1/sqrt(s) |
122 return vmulq_f32(s, x); | 126 return vmulq_f32(s, x); |
123 ; | |
124 } | 127 } |
125 #endif // WEBRTC_ARCH_ARM64 | 128 #endif // WEBRTC_ARCH_ARM64 |
126 | 129 |
127 static void ScaleErrorSignalNEON(int extended_filter_enabled, | 130 static void ScaleErrorSignalNEON(int extended_filter_enabled, |
128 float normal_mu, | 131 float normal_mu, |
129 float normal_error_threshold, | 132 float normal_error_threshold, |
130 float x_pow[PART_LEN1], | 133 float x_pow[PART_LEN1], |
131 float ef[2][PART_LEN1]) { | 134 float ef[2][PART_LEN1]) { |
132 const float mu = extended_filter_enabled ? kExtendedMu : normal_mu; | 135 const float mu = extended_filter_enabled ? kExtendedMu : normal_mu; |
133 const float error_threshold = extended_filter_enabled | 136 const float error_threshold = extended_filter_enabled |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 void WebRtcAec_InitAec_neon(void) { | 721 void WebRtcAec_InitAec_neon(void) { |
719 WebRtcAec_FilterFar = FilterFarNEON; | 722 WebRtcAec_FilterFar = FilterFarNEON; |
720 WebRtcAec_ScaleErrorSignal = ScaleErrorSignalNEON; | 723 WebRtcAec_ScaleErrorSignal = ScaleErrorSignalNEON; |
721 WebRtcAec_FilterAdaptation = FilterAdaptationNEON; | 724 WebRtcAec_FilterAdaptation = FilterAdaptationNEON; |
722 WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppressNEON; | 725 WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppressNEON; |
723 WebRtcAec_SubbandCoherence = SubbandCoherenceNEON; | 726 WebRtcAec_SubbandCoherence = SubbandCoherenceNEON; |
724 WebRtcAec_StoreAsComplex = StoreAsComplexNEON; | 727 WebRtcAec_StoreAsComplex = StoreAsComplexNEON; |
725 WebRtcAec_PartitionDelay = PartitionDelayNEON; | 728 WebRtcAec_PartitionDelay = PartitionDelayNEON; |
726 WebRtcAec_WindowData = WindowDataNEON; | 729 WebRtcAec_WindowData = WindowDataNEON; |
727 } | 730 } |
OLD | NEW |