| 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 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
| 4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
| 5 are met: | 5 are met: |
| 6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
| 7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
| 8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
| 9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
| 10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #ifndef SILK_MACROS_H | 28 #ifndef SILK_MACROS_H |
| 29 #define SILK_MACROS_H | 29 #define SILK_MACROS_H |
| 30 | 30 |
| 31 #ifdef HAVE_CONFIG_H | 31 #ifdef HAVE_CONFIG_H |
| 32 #include "config.h" | 32 #include "config.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #include "opus_types.h" | 35 #include "opus_types.h" |
| 36 #include "opus_defines.h" | 36 #include "opus_defines.h" |
| 37 | 37 |
| 38 #if OPUS_GNUC_PREREQ(3, 0) |
| 39 #define opus_likely(x) (__builtin_expect(!!(x), 1)) |
| 40 #define opus_unlikely(x) (__builtin_expect(!!(x), 0)) |
| 41 #else |
| 42 #define opus_likely(x) (!!(x)) |
| 43 #define opus_unlikely(x) (!!(x)) |
| 44 #endif |
| 45 |
| 38 /* This is an OPUS_INLINE header file for general platform. */ | 46 /* This is an OPUS_INLINE header file for general platform. */ |
| 39 | 47 |
| 40 /* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ | 48 /* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ |
| 49 #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) |
| 50 #define silk_SMULWB(a32, b32) (((a32) * (opus_int64)((opus_int16)(b32
))) >> 16) |
| 51 #else |
| 41 #define silk_SMULWB(a32, b32) ((((a32) >> 16) * (opus_int32)((opus_in
t16)(b32))) + ((((a32) & 0x0000FFFF) * (opus_int32)((opus_int16)(b32))) >> 16)) | 52 #define silk_SMULWB(a32, b32) ((((a32) >> 16) * (opus_int32)((opus_in
t16)(b32))) + ((((a32) & 0x0000FFFF) * (opus_int32)((opus_int16)(b32))) >> 16)) |
| 53 #endif |
| 42 | 54 |
| 43 /* a32 + (b32 * (opus_int32)((opus_int16)(c32))) >> 16 output have to be 32bit i
nt */ | 55 /* a32 + (b32 * (opus_int32)((opus_int16)(c32))) >> 16 output have to be 32bit i
nt */ |
| 56 #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) |
| 57 #define silk_SMLAWB(a32, b32, c32) ((a32) + (((b32) * (opus_int64)((opus_i
nt16)(c32))) >> 16)) |
| 58 #else |
| 44 #define silk_SMLAWB(a32, b32, c32) ((a32) + ((((b32) >> 16) * (opus_int32)
((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32)))
>> 16))) | 59 #define silk_SMLAWB(a32, b32, c32) ((a32) + ((((b32) >> 16) * (opus_int32)
((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32)))
>> 16))) |
| 60 #endif |
| 45 | 61 |
| 46 /* (a32 * (b32 >> 16)) >> 16 */ | 62 /* (a32 * (b32 >> 16)) >> 16 */ |
| 47 #define silk_SMULWT(a32, b32) (((a32) >> 16) * ((b32) >> 16) + ((((a3
2) & 0x0000FFFF) * ((b32) >> 16)) >> 16)) | 63 #define silk_SMULWT(a32, b32) (((a32) >> 16) * ((b32) >> 16) + ((((a3
2) & 0x0000FFFF) * ((b32) >> 16)) >> 16)) |
| 48 | 64 |
| 49 /* a32 + (b32 * (c32 >> 16)) >> 16 */ | 65 /* a32 + (b32 * (c32 >> 16)) >> 16 */ |
| 66 #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) |
| 67 #define silk_SMLAWT(a32, b32, c32) ((a32) + (((b32) * ((opus_int64)(c32) >
> 16)) >> 16)) |
| 68 #else |
| 50 #define silk_SMLAWT(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)
) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16)) | 69 #define silk_SMLAWT(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)
) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16)) |
| 70 #endif |
| 51 | 71 |
| 52 /* (opus_int32)((opus_int16)(a3))) * (opus_int32)((opus_int16)(b32)) output have
to be 32bit int */ | 72 /* (opus_int32)((opus_int16)(a3))) * (opus_int32)((opus_int16)(b32)) output have
to be 32bit int */ |
| 53 #define silk_SMULBB(a32, b32) ((opus_int32)((opus_int16)(a32)) * (opu
s_int32)((opus_int16)(b32))) | 73 #define silk_SMULBB(a32, b32) ((opus_int32)((opus_int16)(a32)) * (opu
s_int32)((opus_int16)(b32))) |
| 54 | 74 |
| 55 /* a32 + (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)) outpu
t have to be 32bit int */ | 75 /* a32 + (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)) outpu
t have to be 32bit int */ |
| 56 #define silk_SMLABB(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32
))) * (opus_int32)((opus_int16)(c32))) | 76 #define silk_SMLABB(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32
))) * (opus_int32)((opus_int16)(c32))) |
| 57 | 77 |
| 58 /* (opus_int32)((opus_int16)(a32)) * (b32 >> 16) */ | 78 /* (opus_int32)((opus_int16)(a32)) * (b32 >> 16) */ |
| 59 #define silk_SMULBT(a32, b32) ((opus_int32)((opus_int16)(a32)) * ((b3
2) >> 16)) | 79 #define silk_SMULBT(a32, b32) ((opus_int32)((opus_int16)(a32)) * ((b3
2) >> 16)) |
| 60 | 80 |
| 61 /* a32 + (opus_int32)((opus_int16)(b32)) * (c32 >> 16) */ | 81 /* a32 + (opus_int32)((opus_int16)(b32)) * (c32 >> 16) */ |
| 62 #define silk_SMLABT(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32
))) * ((c32) >> 16)) | 82 #define silk_SMLABT(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32
))) * ((c32) >> 16)) |
| 63 | 83 |
| 64 /* a64 + (b32 * c32) */ | 84 /* a64 + (b32 * c32) */ |
| 65 #define silk_SMLAL(a64, b32, c32) (silk_ADD64((a64), ((opus_int64)(b32) *
(opus_int64)(c32)))) | 85 #define silk_SMLAL(a64, b32, c32) (silk_ADD64((a64), ((opus_int64)(b32) *
(opus_int64)(c32)))) |
| 66 | 86 |
| 67 /* (a32 * b32) >> 16 */ | 87 /* (a32 * b32) >> 16 */ |
| 88 #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) |
| 89 #define silk_SMULWW(a32, b32) (((opus_int64)(a32) * (b32)) >> 16) |
| 90 #else |
| 68 #define silk_SMULWW(a32, b32) silk_MLA(silk_SMULWB((a32), (b32)), (a3
2), silk_RSHIFT_ROUND((b32), 16)) | 91 #define silk_SMULWW(a32, b32) silk_MLA(silk_SMULWB((a32), (b32)), (a3
2), silk_RSHIFT_ROUND((b32), 16)) |
| 92 #endif |
| 69 | 93 |
| 70 /* a32 + ((b32 * c32) >> 16) */ | 94 /* a32 + ((b32 * c32) >> 16) */ |
| 95 #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) |
| 96 #define silk_SMLAWW(a32, b32, c32) ((a32) + (((opus_int64)(b32) * (c32)) >
> 16)) |
| 97 #else |
| 71 #define silk_SMLAWW(a32, b32, c32) silk_MLA(silk_SMLAWB((a32), (b32), (c32
)), (b32), silk_RSHIFT_ROUND((c32), 16)) | 98 #define silk_SMLAWW(a32, b32, c32) silk_MLA(silk_SMLAWB((a32), (b32), (c32
)), (b32), silk_RSHIFT_ROUND((c32), 16)) |
| 99 #endif |
| 72 | 100 |
| 73 /* add/subtract with output saturated */ | 101 /* add/subtract with output saturated */ |
| 74 #define silk_ADD_SAT32(a, b) ((((opus_uint32)(a) + (opus_uint32)(b))
& 0x80000000) == 0 ? \ | 102 #define silk_ADD_SAT32(a, b) ((((opus_uint32)(a) + (opus_uint32)(b))
& 0x80000000) == 0 ? \ |
| 75 ((((a) & (b)) & 0x80000000) != 0 ? silk_
int32_MIN : (a)+(b)) : \ | 103 ((((a) & (b)) & 0x80000000) != 0 ? silk_
int32_MIN : (a)+(b)) : \ |
| 76 ((((a) | (b)) & 0x80000000) == 0 ? silk_
int32_MAX : (a)+(b)) ) | 104 ((((a) | (b)) & 0x80000000) == 0 ? silk_
int32_MAX : (a)+(b)) ) |
| 77 | 105 |
| 78 #define silk_SUB_SAT32(a, b) ((((opus_uint32)(a)-(opus_uint32)(b)) &
0x80000000) == 0 ? \ | 106 #define silk_SUB_SAT32(a, b) ((((opus_uint32)(a)-(opus_uint32)(b)) &
0x80000000) == 0 ? \ |
| 79 (( (a) & ((b)^0x80000000) & 0x80000000)
? silk_int32_MIN : (a)-(b)) : \ | 107 (( (a) & ((b)^0x80000000) & 0x80000000)
? silk_int32_MIN : (a)-(b)) : \ |
| 80 ((((a)^0x80000000) & (b) & 0x80000000)
? silk_int32_MAX : (a)-(b)) ) | 108 ((((a)^0x80000000) & (b) & 0x80000000)
? silk_int32_MAX : (a)-(b)) ) |
| 81 | 109 |
| 110 #if defined(MIPSr1_ASM) |
| 111 #include "mips/macros_mipsr1.h" |
| 112 #endif |
| 113 |
| 82 #include "ecintrin.h" | 114 #include "ecintrin.h" |
| 83 | 115 #ifndef OVERRIDE_silk_CLZ16 |
| 84 static OPUS_INLINE opus_int32 silk_CLZ16(opus_int16 in16) | 116 static OPUS_INLINE opus_int32 silk_CLZ16(opus_int16 in16) |
| 85 { | 117 { |
| 86 return 32 - EC_ILOG(in16<<16|0x8000); | 118 return 32 - EC_ILOG(in16<<16|0x8000); |
| 87 } | 119 } |
| 120 #endif |
| 88 | 121 |
| 122 #ifndef OVERRIDE_silk_CLZ32 |
| 89 static OPUS_INLINE opus_int32 silk_CLZ32(opus_int32 in32) | 123 static OPUS_INLINE opus_int32 silk_CLZ32(opus_int32 in32) |
| 90 { | 124 { |
| 91 return in32 ? 32 - EC_ILOG(in32) : 32; | 125 return in32 ? 32 - EC_ILOG(in32) : 32; |
| 92 } | 126 } |
| 127 #endif |
| 93 | 128 |
| 94 /* Row based */ | 129 /* Row based */ |
| 95 #define matrix_ptr(Matrix_base_adr, row, column, N) \ | 130 #define matrix_ptr(Matrix_base_adr, row, column, N) \ |
| 96 (*((Matrix_base_adr) + ((row)*(N)+(column)))) | 131 (*((Matrix_base_adr) + ((row)*(N)+(column)))) |
| 97 #define matrix_adr(Matrix_base_adr, row, column, N) \ | 132 #define matrix_adr(Matrix_base_adr, row, column, N) \ |
| 98 ((Matrix_base_adr) + ((row)*(N)+(column))) | 133 ((Matrix_base_adr) + ((row)*(N)+(column))) |
| 99 | 134 |
| 100 /* Column based */ | 135 /* Column based */ |
| 101 #ifndef matrix_c_ptr | 136 #ifndef matrix_c_ptr |
| 102 # define matrix_c_ptr(Matrix_base_adr, row, column, M) \ | 137 # define matrix_c_ptr(Matrix_base_adr, row, column, M) \ |
| 103 (*((Matrix_base_adr) + ((row)+(M)*(column)))) | 138 (*((Matrix_base_adr) + ((row)+(M)*(column)))) |
| 104 #endif | 139 #endif |
| 105 | 140 |
| 106 #ifdef OPUS_ARM_INLINE_ASM | 141 #ifdef OPUS_ARM_INLINE_ASM |
| 107 #include "arm/macros_armv4.h" | 142 #include "arm/macros_armv4.h" |
| 108 #endif | 143 #endif |
| 109 | 144 |
| 110 #ifdef OPUS_ARM_INLINE_EDSP | 145 #ifdef OPUS_ARM_INLINE_EDSP |
| 111 #include "arm/macros_armv5e.h" | 146 #include "arm/macros_armv5e.h" |
| 112 #endif | 147 #endif |
| 113 | 148 |
| 114 #endif /* SILK_MACROS_H */ | 149 #endif /* SILK_MACROS_H */ |
| 115 | 150 |
| OLD | NEW |