| OLD | NEW |
| 1 /* Copyright (C) 2001 Erik de Castro Lopo <erikd AT mega-nerd DOT com> */ | 1 /* Copyright (C) 2001 Erik de Castro Lopo <erikd AT mega-nerd DOT com> */ |
| 2 /* | 2 /* |
| 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 | 6 |
| 7 - Redistributions of source code must retain the above copyright | 7 - Redistributions of source code must retain the above copyright |
| 8 notice, this list of conditions and the following disclaimer. | 8 notice, this list of conditions and the following disclaimer. |
| 9 | 9 |
| 10 - Redistributions in binary form must reproduce the above copyright | 10 - Redistributions in binary form must reproduce the above copyright |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ** | 54 ** |
| 55 ** long int lrintf (float x) ; | 55 ** long int lrintf (float x) ; |
| 56 ** long int lrint (double x) ; | 56 ** long int lrint (double x) ; |
| 57 */ | 57 */ |
| 58 | 58 |
| 59 /* The presence of the required functions are detected during the configure | 59 /* The presence of the required functions are detected during the configure |
| 60 ** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in | 60 ** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in |
| 61 ** the config.h file. | 61 ** the config.h file. |
| 62 */ | 62 */ |
| 63 | 63 |
| 64 #if (HAVE_LRINTF) | 64 /* With GCC, when SSE is available, the fastest conversion is cvtss2si. */ |
| 65 #if defined(__GNUC__) && defined(__SSE__) |
| 66 |
| 67 #include <xmmintrin.h> |
| 68 static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s
s(x));} |
| 69 |
| 70 #elif defined(HAVE_LRINTF) |
| 65 | 71 |
| 66 /* These defines enable functionality introduced with the 1999 ISO C | 72 /* These defines enable functionality introduced with the 1999 ISO C |
| 67 ** standard. They must be defined before the inclusion of math.h to | 73 ** standard. They must be defined before the inclusion of math.h to |
| 68 ** engage them. If optimisation is enabled, these functions will be | 74 ** engage them. If optimisation is enabled, these functions will be |
| 69 ** inlined. With optimisation switched off, you have to link in the | 75 ** inlined. With optimisation switched off, you have to link in the |
| 70 ** maths library using -lm. | 76 ** maths library using -lm. |
| 71 */ | 77 */ |
| 72 | 78 |
| 73 #define _ISOC9X_SOURCE 1 | 79 #define _ISOC9X_SOURCE 1 |
| 74 #define _ISOC99_SOURCE 1 | 80 #define _ISOC99_SOURCE 1 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 static OPUS_INLINE opus_int16 FLOAT2INT16(float x) | 137 static OPUS_INLINE opus_int16 FLOAT2INT16(float x) |
| 132 { | 138 { |
| 133 x = x*CELT_SIG_SCALE; | 139 x = x*CELT_SIG_SCALE; |
| 134 x = MAX32(x, -32768); | 140 x = MAX32(x, -32768); |
| 135 x = MIN32(x, 32767); | 141 x = MIN32(x, 32767); |
| 136 return (opus_int16)float2int(x); | 142 return (opus_int16)float2int(x); |
| 137 } | 143 } |
| 138 #endif /* DISABLE_FLOAT_API */ | 144 #endif /* DISABLE_FLOAT_API */ |
| 139 | 145 |
| 140 #endif /* FLOAT_CAST_H */ | 146 #endif /* FLOAT_CAST_H */ |
| OLD | NEW |