diff options
| author | Aaron Boxer <boxerab@gmail.com> | 2015-06-20 00:01:19 -0400 |
|---|---|---|
| committer | Antonin Descampe <antonin@gmail.com> | 2015-07-03 15:22:58 +0200 |
| commit | 63476863856513a5bc3aa40654395977b0f9f9df (patch) | |
| tree | a30639326713dde90aaddba6c6d76ba9d2aac410 /src/lib | |
| parent | 1a8f929111d43b44dcc380a7d8fb43500edcfd8a (diff) | |
fixed a few bugs
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/openjp2/opj_includes.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/lib/openjp2/opj_includes.h b/src/lib/openjp2/opj_includes.h index 8fbe1a53..d0130028 100644 --- a/src/lib/openjp2/opj_includes.h +++ b/src/lib/openjp2/opj_includes.h @@ -118,15 +118,20 @@ #endif #endif + + /* MSVC before 2013 and Borland C do not have lrintf */ -#if defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(_MSC_VER) +#include <intrin.h> static INLINE long lrintf(float f){ #ifdef _M_X64 - return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); + return _mm_cvt_ss2si(_mm_load_ss(&f)); + + // commented out line breaks many tests + ///return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); #else int i; - - _asm{ + _asm{ fld f fistp i }; @@ -136,6 +141,25 @@ static INLINE long lrintf(float f){ } #endif +#if defined(__BORLANDC__) +static INLINE long lrintf(float f) { +#ifdef _M_X64 + return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); +#else + int i; + + _asm { + fld f + fistp i + }; + + return i; +#endif +} +#endif + + + #if defined(_MSC_VER) && (_MSC_VER < 1400) #define vsnprintf _vsnprintf #endif |
