The following tiny patches make opus and opusfile to use xmm intrinsics
for lrintf() with mingw-w64 builds when targetting x64 instead of their
default x87 asm.
Regards.
--
O.S.
diff --git a/celt/float_cast.h b/celt/float_cast.h
index ed5a39b..b9b8484 100644
--- a/celt/float_cast.h
+++ b/celt/float_cast.h
@@ -61,7 +61,14 @@
** the config.h file.
*/
-#if (HAVE_LRINTF)
+#if (defined(__GNUC__) && defined(_WIN64))
+ #include <xmmintrin.h>
+ static __inline long int float2int(float value)
+ {
+ return _mm_cvtss_si32(_mm_load_ss(&value));
+ }
+
+#elif (HAVE_LRINTF)
/* These defines enable functionality introduced with the 1999 ISO C
** standard. They must be defined before the inclusion of math.h to
index 1441b97..29f185b 100644
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -25,7 +25,9 @@
#include <limits.h>
#include <string.h>
#include <math.h>
-
+#if (defined(__GNUC__) && defined(_WIN64))
+#include <xmmintrin.h>
+#endif
#include "opusfile.h"
/*This implementation is largely based off of libvorbisfile.
@@ -2961,8 +2963,11 @@ int op_read_float_stereo(OggOpusFile *_of,float
*_pcm,int _buf_size){
#else
-# if defined(OP_HAVE_LRINTF)
-# include <math.h>
+# if (defined(__GNUC__) && defined(_WIN64))
+ static __inline long int op_float2int(float _x) {
+ return _mm_cvtss_si32(_mm_load_ss(&_x));
+ }
+# elif defined(OP_HAVE_LRINTF)
# define op_float2int(_x) (lrintf(_x))
# else
# define op_float2int(_x) ((int)((_x)+((_x)<0?-0.5F:0.5F)))