[Freeswitch-svn] [commit] r12246 - in freeswitch/trunk/libs: ilbc/src spandsp/src/spandsp voipcodecs/src/voipcodecs

FreeSWITCH SVN mikej at freeswitch.org
Mon Feb 23 09:56:59 PST 2009


Author: mikej
Date: Mon Feb 23 11:56:59 2009
New Revision: 12246

Log:
use compiler intrinsics for windows x64 build (FSBUILD-131)

Modified:
   freeswitch/trunk/libs/ilbc/src/iLBC_decode.c
   freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h
   freeswitch/trunk/libs/voipcodecs/src/voipcodecs/dc_restore.h

Modified: freeswitch/trunk/libs/ilbc/src/iLBC_decode.c
==============================================================================
--- freeswitch/trunk/libs/ilbc/src/iLBC_decode.c	(original)
+++ freeswitch/trunk/libs/ilbc/src/iLBC_decode.c	Mon Feb 23 11:56:59 2009
@@ -41,7 +41,7 @@
 #include "syntFilter.h"
 
 #if (defined(WIN32)  ||  defined(_WIN32)) && !defined(_WIN64)
-    __inline double rint(double dbl)
+    __inline long int rint(double dbl)
     {
         _asm 
     	{
@@ -50,9 +50,15 @@
         }
     }
 #elif defined (_WIN64)
+#include <intrin.h>
     __inline__ long int rint(double x)
     {
-        return (long int) (x);
+#ifdef _M_X64
+		return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+	return (long int) (x);
+#endif
     }
 #endif
 

Modified: freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h	(original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h	Mon Feb 23 11:56:59 2009
@@ -303,29 +303,26 @@
     }
 #elif defined(WIN64)  ||  defined(_WIN64)
     /* x86_64 machines will do best with a simple assignment. */
+#include <intrin.h>
 
     __inline long int lrint(double x)
     {
-        long int i;
-
-        _asm
-        {
-            fld x
-            fistp i
-        };
-        return i;
+#ifdef _M_X64
+		return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+	return (long int) (x);
+#endif
     }
 
     __inline long int lrintf(float x)
     {
-        long int i;
-
-        _asm
-        {
-            fld x
-            fistp i
-        };
-        return i;
+#ifdef _M_X64
+		return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+	return (long int) (x);
+#endif
     }
 
     __inline long int lfastrint(double x)

Modified: freeswitch/trunk/libs/voipcodecs/src/voipcodecs/dc_restore.h
==============================================================================
--- freeswitch/trunk/libs/voipcodecs/src/voipcodecs/dc_restore.h	(original)
+++ freeswitch/trunk/libs/voipcodecs/src/voipcodecs/dc_restore.h	Mon Feb 23 11:56:59 2009
@@ -127,17 +127,34 @@
 	return retval;
 }
 #elif defined(_WIN64)
+#include <intrin.h>
+
     __inline__ long int rint(double x)
     {
-        return (long int) (x);
+#ifdef _M_X64
+		return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+	return (long int) (x);
+#endif
     }
 	__inline__ int rintf(float x)
 	{
-		return (int) rint((double) x);
+#ifdef _M_X64
+		return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+	return (int) (x);
+#endif
 	}
     __inline__ long int lrintf(float x)
     {
-        return (long int) (x);
+#ifdef _M_X64
+		return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+	return (long int) (x);
+#endif
     }
 #endif
 



More information about the Freeswitch-svn mailing list