diff --git a/libs/ilbc/src/iLBC_decode.c b/libs/ilbc/src/iLBC_decode.c index 55d080e071..fc46fe408c 100644 --- a/libs/ilbc/src/iLBC_decode.c +++ b/libs/ilbc/src/iLBC_decode.c @@ -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 __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 diff --git a/libs/spandsp/src/spandsp/fast_convert.h b/libs/spandsp/src/spandsp/fast_convert.h index a09882edfb..2e794a2701 100644 --- a/libs/spandsp/src/spandsp/fast_convert.h +++ b/libs/spandsp/src/spandsp/fast_convert.h @@ -303,29 +303,26 @@ extern "C" } #elif defined(WIN64) || defined(_WIN64) /* x86_64 machines will do best with a simple assignment. */ +#include __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) diff --git a/libs/voipcodecs/src/voipcodecs/dc_restore.h b/libs/voipcodecs/src/voipcodecs/dc_restore.h index 6bd5cf7fba..89d98b1ea0 100644 --- a/libs/voipcodecs/src/voipcodecs/dc_restore.h +++ b/libs/voipcodecs/src/voipcodecs/dc_restore.h @@ -127,17 +127,34 @@ __inline long lrintf (float flt) return retval; } #elif defined(_WIN64) +#include + __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