[FFmpeg-cvslog] lavu/libm: add copysign hack

Ganesh Ajjanagadde git at videolan.org
Sat Dec 19 23:07:13 CET 2015


ffmpeg | branch: master | Ganesh Ajjanagadde <gajjanagadde at gmail.com> | Fri Dec 18 11:13:11 2015 -0800| [062e3e23824ba3d25594ea966d7834bcf34db49b] | committer: Ganesh Ajjanagadde

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 at gmail.com>
Reviewed-by: Hendrik Leppkes <h.leppkes at gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=062e3e23824ba3d25594ea966d7834bcf34db49b
---

 configure        |    2 +-
 libavutil/libm.h |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index dc1d2eb..da74616 100755
--- a/configure
+++ b/configure
@@ -2851,7 +2851,7 @@ cropdetect_filter_deps="gpl"
 delogo_filter_deps="gpl"
 deshake_filter_select="pixelutils"
 drawtext_filter_deps="libfreetype"
-dynaudnorm_filter_deps="copysign erf"
+dynaudnorm_filter_deps="erf"
 ebur128_filter_deps="gpl"
 eq_filter_deps="gpl"
 fftfilt_filter_deps="avcodec"
diff --git a/libavutil/libm.h b/libavutil/libm.h
index 6d8bd68..37b8e86 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))



More information about the ffmpeg-cvslog mailing list