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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #include <xmmintrin.h> | 94 #include <xmmintrin.h> |
95 | 95 |
96 __inline long int float2int(float value) | 96 __inline long int float2int(float value) |
97 { | 97 { |
98 return _mm_cvtss_si32(_mm_load_ss(&value)); | 98 return _mm_cvtss_si32(_mm_load_ss(&value)); |
99 } | 99 } |
100 #elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined (WIN32) || defined (_W
IN32)) | 100 #elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined (WIN32) || defined (_W
IN32)) |
101 #include <math.h> | 101 #include <math.h> |
102 | 102 |
103 /* Win32 doesn't seem to have these functions. | 103 /* Win32 doesn't seem to have these functions. |
104 ** Therefore implement inline versions of these functions here. | 104 ** Therefore implement OPUS_INLINE versions of these functions here
. |
105 */ | 105 */ |
106 | 106 |
107 __inline long int | 107 __inline long int |
108 float2int (float flt) | 108 float2int (float flt) |
109 { int intgr; | 109 { int intgr; |
110 | 110 |
111 _asm | 111 _asm |
112 { fld flt | 112 { fld flt |
113 fistp intgr | 113 fistp intgr |
114 } ; | 114 } ; |
115 | 115 |
116 return intgr ; | 116 return intgr ; |
117 } | 117 } |
118 | 118 |
119 #else | 119 #else |
120 | 120 |
121 #if (defined(__GNUC__) && defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 1
99901L) | 121 #if (defined(__GNUC__) && defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 1
99901L) |
122 /* supported by gcc in C99 mode, but not by all other compilers */ | 122 /* supported by gcc in C99 mode, but not by all other compilers */ |
123 #warning "Don't have the functions lrint() and lrintf ()." | 123 #warning "Don't have the functions lrint() and lrintf ()." |
124 #warning "Replacing these functions with a standard C cast." | 124 #warning "Replacing these functions with a standard C cast." |
125 #endif /* __STDC_VERSION__ >= 199901L */ | 125 #endif /* __STDC_VERSION__ >= 199901L */ |
126 #include <math.h> | 126 #include <math.h> |
127 #define float2int(flt) ((int)(floor(.5+flt))) | 127 #define float2int(flt) ((int)(floor(.5+flt))) |
128 #endif | 128 #endif |
129 | 129 |
130 #ifndef DISABLE_FLOAT_API | 130 #ifndef DISABLE_FLOAT_API |
131 static inline opus_int16 FLOAT2INT16(float x) | 131 static OPUS_INLINE opus_int16 FLOAT2INT16(float x) |
132 { | 132 { |
133 x = x*CELT_SIG_SCALE; | 133 x = x*CELT_SIG_SCALE; |
134 x = MAX32(x, -32768); | 134 x = MAX32(x, -32768); |
135 x = MIN32(x, 32767); | 135 x = MIN32(x, 32767); |
136 return (opus_int16)float2int(x); | 136 return (opus_int16)float2int(x); |
137 } | 137 } |
138 #endif /* DISABLE_FLOAT_API */ | 138 #endif /* DISABLE_FLOAT_API */ |
139 | 139 |
140 #endif /* FLOAT_CAST_H */ | 140 #endif /* FLOAT_CAST_H */ |
OLD | NEW |