diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-12-18 11:13:11 -0800 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-12-19 14:05:49 -0800 |
commit | 062e3e23824ba3d25594ea966d7834bcf34db49b (patch) | |
tree | 61e249e460dc6811457ef0c98201bb1828ed4ee3 /libavutil/libm.h | |
parent | 0f520e489a659d9ea0fa7467aca3bf85cc006ef7 (diff) | |
download | ffmpeg-062e3e23824ba3d25594ea966d7834bcf34db49b.tar.gz |
lavu/libm: add copysign hack
For systems with broken libms.
Tested with NAN, -NAN, INFINITY, -INFINITY, +/-x for regular double x and
combinations of these.
Old versions of MSVC need some UINT64_C hackery.
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavutil/libm.h')
-rw-r--r-- | libavutil/libm.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavutil/libm.h b/libavutil/libm.h index 6d8bd685b7..37b8e86b5e 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -62,6 +62,15 @@ static av_always_inline float cbrtf(float x) } #endif +#if !HAVE_COPYSIGN +static av_always_inline double copysign(double x, double y) +{ + uint64_t vx = av_double2int(x); + uint64_t vy = av_double2int(y); + return av_int2double((vx & UINT64_C(0x7fffffffffffffff)) | (vy & UINT64_C(0x8000000000000000))); +} +#endif + #if !HAVE_COSF #undef cosf #define cosf(x) ((float)cos(x)) |