| OLD | NEW |
| 1 /* Copyright (c) 2003-2008 Jean-Marc Valin | 1 /* Copyright (c) 2003-2008 Jean-Marc Valin |
| 2 Copyright (c) 2007-2008 CSIRO | 2 Copyright (c) 2007-2008 CSIRO |
| 3 Copyright (c) 2007-2009 Xiph.Org Foundation | 3 Copyright (c) 2007-2009 Xiph.Org Foundation |
| 4 Written by Jean-Marc Valin */ | 4 Written by Jean-Marc Valin */ |
| 5 /** | 5 /** |
| 6 @file arch.h | 6 @file arch.h |
| 7 @brief Various architecture definitions for CELT | 7 @brief Various architecture definitions for CELT |
| 8 */ | 8 */ |
| 9 /* | 9 /* |
| 10 Redistribution and use in source and binary forms, with or without | 10 Redistribution and use in source and binary forms, with or without |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 #define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);
}} | 63 #define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);
}} |
| 64 #define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed:
" #cond "\n" message);}} | 64 #define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed:
" #cond "\n" message);}} |
| 65 #else | 65 #else |
| 66 #define celt_assert(cond) | 66 #define celt_assert(cond) |
| 67 #define celt_assert2(cond, message) | 67 #define celt_assert2(cond, message) |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 #define IMUL32(a,b) ((a)*(b)) | 70 #define IMUL32(a,b) ((a)*(b)) |
| 71 | 71 |
| 72 #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ | |
| 73 #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ | |
| 74 #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ | 72 #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ |
| 75 #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ | 73 #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ |
| 76 #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ | |
| 77 #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ | 74 #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ |
| 78 #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ | 75 #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ |
| 79 #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ | 76 #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ |
| 80 #define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ | 77 #define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ |
| 81 #define UADD32(a,b) ((a)+(b)) | 78 #define UADD32(a,b) ((a)+(b)) |
| 82 #define USUB32(a,b) ((a)-(b)) | 79 #define USUB32(a,b) ((a)-(b)) |
| 83 | 80 |
| 84 #define PRINT_MIPS(file) | 81 #define PRINT_MIPS(file) |
| 85 | 82 |
| 86 #ifdef FIXED_POINT | 83 #ifdef FIXED_POINT |
| (...skipping 14 matching lines...) Expand all Loading... |
| 101 #define DB_SHIFT 10 | 98 #define DB_SHIFT 10 |
| 102 | 99 |
| 103 #define EPSILON 1 | 100 #define EPSILON 1 |
| 104 #define VERY_SMALL 0 | 101 #define VERY_SMALL 0 |
| 105 #define VERY_LARGE16 ((opus_val16)32767) | 102 #define VERY_LARGE16 ((opus_val16)32767) |
| 106 #define Q15_ONE ((opus_val16)32767) | 103 #define Q15_ONE ((opus_val16)32767) |
| 107 | 104 |
| 108 #define SCALEIN(a) (a) | 105 #define SCALEIN(a) (a) |
| 109 #define SCALEOUT(a) (a) | 106 #define SCALEOUT(a) (a) |
| 110 | 107 |
| 108 #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) |
| 109 #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) |
| 110 |
| 111 static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { |
| 112 return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; |
| 113 } |
| 114 |
| 111 #ifdef FIXED_DEBUG | 115 #ifdef FIXED_DEBUG |
| 112 #include "fixed_debug.h" | 116 #include "fixed_debug.h" |
| 113 #else | 117 #else |
| 114 | 118 |
| 115 #include "fixed_generic.h" | 119 #include "fixed_generic.h" |
| 116 | 120 |
| 117 #ifdef OPUS_ARM_INLINE_EDSP | 121 #ifdef OPUS_ARM_INLINE_EDSP |
| 118 #include "arm/fixed_armv5e.h" | 122 #include "arm/fixed_armv5e.h" |
| 119 #elif defined (OPUS_ARM_INLINE_ASM) | 123 #elif defined (OPUS_ARM_INLINE_ASM) |
| 120 #include "arm/fixed_armv4.h" | 124 #include "arm/fixed_armv4.h" |
| 121 #elif defined (BFIN_ASM) | 125 #elif defined (BFIN_ASM) |
| 122 #include "fixed_bfin.h" | 126 #include "fixed_bfin.h" |
| 123 #elif defined (TI_C5X_ASM) | 127 #elif defined (TI_C5X_ASM) |
| 124 #include "fixed_c5x.h" | 128 #include "fixed_c5x.h" |
| 125 #elif defined (TI_C6X_ASM) | 129 #elif defined (TI_C6X_ASM) |
| 126 #include "fixed_c6x.h" | 130 #include "fixed_c6x.h" |
| 127 #endif | 131 #endif |
| 128 | 132 |
| 129 #endif | 133 #endif |
| 130 | 134 |
| 131 #else /* FIXED_POINT */ | 135 #else /* FIXED_POINT */ |
| 132 | 136 |
| 133 typedef float opus_val16; | 137 typedef float opus_val16; |
| 134 typedef float opus_val32; | 138 typedef float opus_val32; |
| 135 | 139 |
| 136 typedef float celt_sig; | 140 typedef float celt_sig; |
| 137 typedef float celt_norm; | 141 typedef float celt_norm; |
| 138 typedef float celt_ener; | 142 typedef float celt_ener; |
| 139 | 143 |
| 144 #ifdef FLOAT_APPROX |
| 145 /* This code should reliably detect NaN/inf even when -ffast-math is used. |
| 146 Assumes IEEE 754 format. */ |
| 147 static OPUS_INLINE int celt_isnan(float x) |
| 148 { |
| 149 union {float f; opus_uint32 i;} in; |
| 150 in.f = x; |
| 151 return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0; |
| 152 } |
| 153 #else |
| 154 #ifdef __FAST_MATH__ |
| 155 #error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. Thi
s could result in crashes on extreme (e.g. NaN) input |
| 156 #endif |
| 157 #define celt_isnan(x) ((x)!=(x)) |
| 158 #endif |
| 159 |
| 140 #define Q15ONE 1.0f | 160 #define Q15ONE 1.0f |
| 141 | 161 |
| 142 #define NORM_SCALING 1.f | 162 #define NORM_SCALING 1.f |
| 143 | 163 |
| 144 #define EPSILON 1e-15f | 164 #define EPSILON 1e-15f |
| 145 #define VERY_SMALL 1e-30f | 165 #define VERY_SMALL 1e-30f |
| 146 #define VERY_LARGE16 1e15f | 166 #define VERY_LARGE16 1e15f |
| 147 #define Q15_ONE ((opus_val16)1.f) | 167 #define Q15_ONE ((opus_val16)1.f) |
| 148 | 168 |
| 169 /* This appears to be the same speed as C99's fabsf() but it's more portable. */ |
| 170 #define ABS16(x) ((float)fabs(x)) |
| 171 #define ABS32(x) ((float)fabs(x)) |
| 172 |
| 149 #define QCONST16(x,bits) (x) | 173 #define QCONST16(x,bits) (x) |
| 150 #define QCONST32(x,bits) (x) | 174 #define QCONST32(x,bits) (x) |
| 151 | 175 |
| 152 #define NEG16(x) (-(x)) | 176 #define NEG16(x) (-(x)) |
| 153 #define NEG32(x) (-(x)) | 177 #define NEG32(x) (-(x)) |
| 154 #define EXTRACT16(x) (x) | 178 #define EXTRACT16(x) (x) |
| 155 #define EXTEND32(x) (x) | 179 #define EXTEND32(x) (x) |
| 156 #define SHR16(a,shift) (a) | 180 #define SHR16(a,shift) (a) |
| 157 #define SHL16(a,shift) (a) | 181 #define SHL16(a,shift) (a) |
| 158 #define SHR32(a,shift) (a) | 182 #define SHR32(a,shift) (a) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 177 #define MULT16_16_16(a,b) ((a)*(b)) | 201 #define MULT16_16_16(a,b) ((a)*(b)) |
| 178 #define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) | 202 #define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) |
| 179 #define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) | 203 #define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) |
| 180 | 204 |
| 181 #define MULT16_32_Q15(a,b) ((a)*(b)) | 205 #define MULT16_32_Q15(a,b) ((a)*(b)) |
| 182 #define MULT16_32_Q16(a,b) ((a)*(b)) | 206 #define MULT16_32_Q16(a,b) ((a)*(b)) |
| 183 | 207 |
| 184 #define MULT32_32_Q31(a,b) ((a)*(b)) | 208 #define MULT32_32_Q31(a,b) ((a)*(b)) |
| 185 | 209 |
| 186 #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) | 210 #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) |
| 211 #define MAC16_32_Q16(c,a,b) ((c)+(a)*(b)) |
| 187 | 212 |
| 188 #define MULT16_16_Q11_32(a,b) ((a)*(b)) | 213 #define MULT16_16_Q11_32(a,b) ((a)*(b)) |
| 189 #define MULT16_16_Q11(a,b) ((a)*(b)) | 214 #define MULT16_16_Q11(a,b) ((a)*(b)) |
| 190 #define MULT16_16_Q13(a,b) ((a)*(b)) | 215 #define MULT16_16_Q13(a,b) ((a)*(b)) |
| 191 #define MULT16_16_Q14(a,b) ((a)*(b)) | 216 #define MULT16_16_Q14(a,b) ((a)*(b)) |
| 192 #define MULT16_16_Q15(a,b) ((a)*(b)) | 217 #define MULT16_16_Q15(a,b) ((a)*(b)) |
| 193 #define MULT16_16_P15(a,b) ((a)*(b)) | 218 #define MULT16_16_P15(a,b) ((a)*(b)) |
| 194 #define MULT16_16_P13(a,b) ((a)*(b)) | 219 #define MULT16_16_P13(a,b) ((a)*(b)) |
| 195 #define MULT16_16_P14(a,b) ((a)*(b)) | 220 #define MULT16_16_P14(a,b) ((a)*(b)) |
| 196 #define MULT16_32_P16(a,b) ((a)*(b)) | 221 #define MULT16_32_P16(a,b) ((a)*(b)) |
| 197 | 222 |
| 198 #define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) | 223 #define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) |
| 199 #define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) | 224 #define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) |
| 200 | 225 |
| 201 #define SCALEIN(a) ((a)*CELT_SIG_SCALE) | 226 #define SCALEIN(a) ((a)*CELT_SIG_SCALE) |
| 202 #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) | 227 #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) |
| 203 | 228 |
| 229 #define SIG2WORD16(x) (x) |
| 230 |
| 204 #endif /* !FIXED_POINT */ | 231 #endif /* !FIXED_POINT */ |
| 205 | 232 |
| 206 #ifndef GLOBAL_STACK_SIZE | 233 #ifndef GLOBAL_STACK_SIZE |
| 207 #ifdef FIXED_POINT | 234 #ifdef FIXED_POINT |
| 208 #define GLOBAL_STACK_SIZE 100000 | 235 #define GLOBAL_STACK_SIZE 100000 |
| 209 #else | 236 #else |
| 210 #define GLOBAL_STACK_SIZE 100000 | 237 #define GLOBAL_STACK_SIZE 100000 |
| 211 #endif | 238 #endif |
| 212 #endif | 239 #endif |
| 213 | 240 |
| 214 #endif /* ARCH_H */ | 241 #endif /* ARCH_H */ |
| OLD | NEW |