diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-12-08 03:54:18 -0500 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-12-09 15:26:43 -0500 |
commit | 0f869cba0f271f3d9aee1289d490c44ce1e12975 (patch) | |
tree | 01d8c4ddbcf978b9e22b85fc3545fb2bdfbaa118 /celt/arch.h | |
parent | c94e4bb103e6a989bcd2677c9178ee6ef461912c (diff) | |
download | libopus-0f869cba0f271f3d9aee1289d490c44ce1e12975.tar.gz |
Changes ABS16() and ABS32() to use fabs() in the float build
gcc is better at optimizing it than the ?: version
Diffstat (limited to 'celt/arch.h')
-rw-r--r-- | celt/arch.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/celt/arch.h b/celt/arch.h index 3bbcd366..dcfba763 100644 --- a/celt/arch.h +++ b/celt/arch.h @@ -69,11 +69,8 @@ static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line) #define IMUL32(a,b) ((a)*(b)) -#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ -#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ @@ -108,6 +105,9 @@ typedef opus_val32 celt_ener; #define SCALEIN(a) (a) #define SCALEOUT(a) (a) +#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) +#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) + #ifdef FIXED_DEBUG #include "fixed_debug.h" #else @@ -146,6 +146,10 @@ typedef float celt_ener; #define VERY_LARGE16 1e15f #define Q15_ONE ((opus_val16)1.f) +/* This appears to be the same speed as C99's fabsf() but it's more portable. */ +#define ABS16(x) ((float)fabs(x)) +#define ABS32(x) ((float)fabs(x)) + #define QCONST16(x,bits) (x) #define QCONST32(x,bits) (x) |