OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 /* This header file includes the inline functions for ARM processors in | 12 /* This header file includes the inline functions for ARM processors in |
13 * the fix point signal processing library. | 13 * the fix point signal processing library. |
14 */ | 14 */ |
15 | 15 |
16 #ifndef WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_ARMV7_H_ | 16 #ifndef WEBRTC_SPL_SPL_INL_ARMV7_H_ |
17 #define WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_ARMV7_H_ | 17 #define WEBRTC_SPL_SPL_INL_ARMV7_H_ |
18 | 18 |
19 /* TODO(kma): Replace some assembly code with GCC intrinsics | 19 /* TODO(kma): Replace some assembly code with GCC intrinsics |
20 * (e.g. __builtin_clz). | 20 * (e.g. __builtin_clz). |
21 */ | 21 */ |
22 | 22 |
23 /* This function produces result that is not bit exact with that by the generic | 23 /* This function produces result that is not bit exact with that by the generic |
24 * C version in some cases, although the former is at least as accurate as the | 24 * C version in some cases, although the former is at least as accurate as the |
25 * later. | 25 * later. |
26 */ | 26 */ |
27 static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) { | 27 static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n)); | 81 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n)); |
82 | 82 |
83 return (int16_t)(32 - tmp); | 83 return (int16_t)(32 - tmp); |
84 } | 84 } |
85 | 85 |
86 static __inline int16_t WebRtcSpl_NormW32(int32_t a) { | 86 static __inline int16_t WebRtcSpl_NormW32(int32_t a) { |
87 int32_t tmp = 0; | 87 int32_t tmp = 0; |
88 | 88 |
89 if (a == 0) { | 89 if (a == 0) { |
90 return 0; | 90 return 0; |
91 } else if (a < 0) { | 91 } |
| 92 else if (a < 0) { |
92 a ^= 0xFFFFFFFF; | 93 a ^= 0xFFFFFFFF; |
93 } | 94 } |
94 | 95 |
95 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); | 96 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); |
96 | 97 |
97 return (int16_t)(tmp - 1); | 98 return (int16_t)(tmp - 1); |
98 } | 99 } |
99 | 100 |
100 static __inline int16_t WebRtcSpl_NormU32(uint32_t a) { | 101 static __inline int16_t WebRtcSpl_NormU32(uint32_t a) { |
101 int tmp = 0; | 102 int tmp = 0; |
102 | 103 |
103 if (a == 0) return 0; | 104 if (a == 0) return 0; |
104 | 105 |
105 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); | 106 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); |
106 | 107 |
107 return (int16_t)tmp; | 108 return (int16_t)tmp; |
108 } | 109 } |
109 | 110 |
110 static __inline int16_t WebRtcSpl_NormW16(int16_t a) { | 111 static __inline int16_t WebRtcSpl_NormW16(int16_t a) { |
111 int32_t tmp = 0; | 112 int32_t tmp = 0; |
112 int32_t a_32 = a; | 113 int32_t a_32 = a; |
113 | 114 |
114 if (a_32 == 0) { | 115 if (a_32 == 0) { |
115 return 0; | 116 return 0; |
116 } else if (a_32 < 0) { | 117 } |
| 118 else if (a_32 < 0) { |
117 a_32 ^= 0xFFFFFFFF; | 119 a_32 ^= 0xFFFFFFFF; |
118 } | 120 } |
119 | 121 |
120 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a_32)); | 122 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a_32)); |
121 | 123 |
122 return (int16_t)(tmp - 17); | 124 return (int16_t)(tmp - 17); |
123 } | 125 } |
124 | 126 |
125 // TODO(kma): add unit test. | 127 // TODO(kma): add unit test. |
126 static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { | 128 static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { |
127 int32_t out = 0; | 129 int32_t out = 0; |
128 | 130 |
129 __asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32)); | 131 __asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32)); |
130 | 132 |
131 return (int16_t)out; | 133 return (int16_t)out; |
132 } | 134 } |
133 | 135 |
134 #endif // WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_ARMV7_H_ | 136 #endif // WEBRTC_SPL_SPL_INL_ARMV7_H_ |
OLD | NEW |