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_SPL_SPL_INL_ARMV7_H_ | 16 #ifndef WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_ARMV7_H_ |
17 #define WEBRTC_SPL_SPL_INL_ARMV7_H_ | 17 #define WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_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 } | 91 } else if (a < 0) { |
92 else if (a < 0) { | |
93 a ^= 0xFFFFFFFF; | 92 a ^= 0xFFFFFFFF; |
94 } | 93 } |
95 | 94 |
96 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); | 95 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); |
97 | 96 |
98 return (int16_t)(tmp - 1); | 97 return (int16_t)(tmp - 1); |
99 } | 98 } |
100 | 99 |
101 static __inline int16_t WebRtcSpl_NormU32(uint32_t a) { | 100 static __inline int16_t WebRtcSpl_NormU32(uint32_t a) { |
102 int tmp = 0; | 101 int tmp = 0; |
103 | 102 |
104 if (a == 0) return 0; | 103 if (a == 0) return 0; |
105 | 104 |
106 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); | 105 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); |
107 | 106 |
108 return (int16_t)tmp; | 107 return (int16_t)tmp; |
109 } | 108 } |
110 | 109 |
111 static __inline int16_t WebRtcSpl_NormW16(int16_t a) { | 110 static __inline int16_t WebRtcSpl_NormW16(int16_t a) { |
112 int32_t tmp = 0; | 111 int32_t tmp = 0; |
113 int32_t a_32 = a; | 112 int32_t a_32 = a; |
114 | 113 |
115 if (a_32 == 0) { | 114 if (a_32 == 0) { |
116 return 0; | 115 return 0; |
117 } | 116 } else if (a_32 < 0) { |
118 else if (a_32 < 0) { | |
119 a_32 ^= 0xFFFFFFFF; | 117 a_32 ^= 0xFFFFFFFF; |
120 } | 118 } |
121 | 119 |
122 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a_32)); | 120 __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a_32)); |
123 | 121 |
124 return (int16_t)(tmp - 17); | 122 return (int16_t)(tmp - 17); |
125 } | 123 } |
126 | 124 |
127 // TODO(kma): add unit test. | 125 // TODO(kma): add unit test. |
128 static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { | 126 static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { |
129 int32_t out = 0; | 127 int32_t out = 0; |
130 | 128 |
131 __asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32)); | 129 __asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32)); |
132 | 130 |
133 return (int16_t)out; | 131 return (int16_t)out; |
134 } | 132 } |
135 | 133 |
136 #endif // WEBRTC_SPL_SPL_INL_ARMV7_H_ | 134 #endif // WEBRTC_COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_ARMV7_H_ |
OLD | NEW |