OLD | NEW |
1 /*********************************************************************** | 1 /*********************************************************************** |
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
3 Copyright (c) 2013 Parrot | 3 Copyright (c) 2013 Parrot |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 - Redistributions of source code must retain the above copyright notice, | 7 - Redistributions of source code must retain the above copyright notice, |
8 this list of conditions and the following disclaimer. | 8 this list of conditions and the following disclaimer. |
9 - Redistributions in binary form must reproduce the above copyright | 9 - Redistributions in binary form must reproduce the above copyright |
10 notice, this list of conditions and the following disclaimer in the | 10 notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 POSSIBILITY OF SUCH DAMAGE. | 26 POSSIBILITY OF SUCH DAMAGE. |
27 ***********************************************************************/ | 27 ***********************************************************************/ |
28 | 28 |
29 #ifndef SILK_MACROS_ARMv5E_H | 29 #ifndef SILK_MACROS_ARMv5E_H |
30 #define SILK_MACROS_ARMv5E_H | 30 #define SILK_MACROS_ARMv5E_H |
31 | 31 |
| 32 /* This macro only avoids the undefined behaviour from a left shift of |
| 33 a negative value. It should only be used in macros that can't include |
| 34 SigProc_FIX.h. In other cases, use silk_LSHIFT32(). */ |
| 35 #define SAFE_SHL(a,b) ((opus_int32)((opus_uint32)(a) << (b))) |
| 36 |
32 /* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ | 37 /* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ |
33 #undef silk_SMULWB | 38 #undef silk_SMULWB |
34 static OPUS_INLINE opus_int32 silk_SMULWB_armv5e(opus_int32 a, opus_int16 b) | 39 static OPUS_INLINE opus_int32 silk_SMULWB_armv5e(opus_int32 a, opus_int16 b) |
35 { | 40 { |
36 int res; | 41 int res; |
37 __asm__( | 42 __asm__( |
38 "#silk_SMULWB\n\t" | 43 "#silk_SMULWB\n\t" |
39 "smulwb %0, %1, %2\n\t" | 44 "smulwb %0, %1, %2\n\t" |
40 : "=r"(res) | 45 : "=r"(res) |
41 : "r"(a), "r"(b) | 46 : "r"(a), "r"(b) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 #define silk_SUB_SAT32(a, b) (silk_SUB_SAT32_armv5e(a, b)) | 188 #define silk_SUB_SAT32(a, b) (silk_SUB_SAT32_armv5e(a, b)) |
184 | 189 |
185 #undef silk_CLZ16 | 190 #undef silk_CLZ16 |
186 static OPUS_INLINE opus_int32 silk_CLZ16_armv5(opus_int16 in16) | 191 static OPUS_INLINE opus_int32 silk_CLZ16_armv5(opus_int16 in16) |
187 { | 192 { |
188 int res; | 193 int res; |
189 __asm__( | 194 __asm__( |
190 "#silk_CLZ16\n\t" | 195 "#silk_CLZ16\n\t" |
191 "clz %0, %1;\n" | 196 "clz %0, %1;\n" |
192 : "=r"(res) | 197 : "=r"(res) |
193 : "r"(in16<<16|0x8000) | 198 : "r"(SAFE_SHL(in16,16)|0x8000) |
194 ); | 199 ); |
195 return res; | 200 return res; |
196 } | 201 } |
197 #define silk_CLZ16(in16) (silk_CLZ16_armv5(in16)) | 202 #define silk_CLZ16(in16) (silk_CLZ16_armv5(in16)) |
198 | 203 |
199 #undef silk_CLZ32 | 204 #undef silk_CLZ32 |
200 static OPUS_INLINE opus_int32 silk_CLZ32_armv5(opus_int32 in32) | 205 static OPUS_INLINE opus_int32 silk_CLZ32_armv5(opus_int32 in32) |
201 { | 206 { |
202 int res; | 207 int res; |
203 __asm__( | 208 __asm__( |
204 "#silk_CLZ32\n\t" | 209 "#silk_CLZ32\n\t" |
205 "clz %0, %1\n\t" | 210 "clz %0, %1\n\t" |
206 : "=r"(res) | 211 : "=r"(res) |
207 : "r"(in32) | 212 : "r"(in32) |
208 ); | 213 ); |
209 return res; | 214 return res; |
210 } | 215 } |
211 #define silk_CLZ32(in32) (silk_CLZ32_armv5(in32)) | 216 #define silk_CLZ32(in32) (silk_CLZ32_armv5(in32)) |
212 | 217 |
| 218 #undef SAFE_SHL |
| 219 |
213 #endif /* SILK_MACROS_ARMv5E_H */ | 220 #endif /* SILK_MACROS_ARMv5E_H */ |
OLD | NEW |