]> git.sesse.net Git - ffmpeg/commitdiff
all: move ff_exp10, ff_exp10f, ff_fast_powf to lavu/ffmath.h
authorGanesh Ajjanagadde <gajjanag@gmail.com>
Tue, 15 Mar 2016 01:28:56 +0000 (21:28 -0400)
committerGanesh Ajjanagadde <gajjanag@gmail.com>
Tue, 22 Mar 2016 17:15:31 +0000 (10:15 -0700)
The idea is to use ffmath.h for internal implementations of math functions.
Currently, it is used for variants of libm functions, but is by no means
limited to such things.

Note that this is not exported; use lavu/mathematics for such purposes.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>
20 files changed:
libavcodec/aacenc_utils.h
libavcodec/aacpsy.c
libavcodec/acelp_pitch_delay.c
libavcodec/cngdec.c
libavcodec/dcaenc.c
libavcodec/imc.c
libavcodec/on2avc.c
libavcodec/opus.c
libavcodec/wmadec.c
libavcodec/wmaenc.c
libavcodec/wmaprodec.c
libavfilter/af_anequalizer.c
libavfilter/af_compand.c
libavfilter/af_volume.c
libavfilter/f_ebur128.c
libavfilter/vaf_spectrumsynth.c
libavfilter/vsrc_testsrc.c
libavutil/eval.c
libavutil/ffmath.h [new file with mode: 0644]
libavutil/internal.h

index 07f733746bd16c1c0bfa04b9a970a87b3e8ea4c3..bb1dcb4361626a2090dcc1f03e984fbfaa5abb51 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef AVCODEC_AACENC_UTILS_H
 #define AVCODEC_AACENC_UTILS_H
 
-#include "libavutil/internal.h"
+#include "libavutil/ffmath.h"
 #include "aac.h"
 #include "aacenctab.h"
 #include "aactab.h"
index 8643fe703695d602724876eb5988a53c983c06b2..0898bafd24172b5522fdc8c12613cd454e9731c6 100644 (file)
@@ -25,8 +25,7 @@
  */
 
 #include "libavutil/attributes.h"
-#include "libavutil/internal.h"
-#include "libavutil/libm.h"
+#include "libavutil/ffmath.h"
 
 #include "avcodec.h"
 #include "aactab.h"
index c2533b1eb1a6dbe2296d6d7f6b9149e52ef3248e..8ec1ba3a8396b827a19b7e573aad296502249b8a 100644 (file)
@@ -21,9 +21,8 @@
  */
 
 #include "libavutil/common.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/internal.h"
-#include "libavutil/libm.h"
 #include "libavutil/mathematics.h"
 #include "avcodec.h"
 #include "acelp_pitch_delay.h"
index 02510860429261e3c1b416aae3539519f1ebedf0..34f881448de86275fd88567df5a5ee52e2b7d95d 100644 (file)
@@ -22,7 +22,7 @@
 #include <math.h>
 
 #include "libavutil/common.h"
-#include "libavutil/internal.h"
+#include "libavutil/ffmath.h"
 #include "avcodec.h"
 #include "celp_filters.h"
 #include "internal.h"
index 70e92300b6892a852acf5821c22ff55172049eb8..ab40e37b320bf1336914b4f2de0b6eda8339dec2 100644 (file)
@@ -24,7 +24,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
-#include "libavutil/internal.h"
+#include "libavutil/ffmath.h"
 #include "avcodec.h"
 #include "dca.h"
 #include "dcadata.h"
index 085ec09565877ba0c3f5eda788ef83ce092bc013..850bc9de9abaacef2a034af9a894e0578f076d0e 100644 (file)
@@ -35,9 +35,9 @@
 #include <stdio.h>
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/internal.h"
-#include "libavutil/libm.h"
 #include "avcodec.h"
 #include "bswapdsp.h"
 #include "get_bits.h"
index 62c71ccea53515c14c646cab29d1ff577b6791b0..3064c6fc6aef93c705f0cd17ff74255e0939e8da 100644 (file)
@@ -21,8 +21,8 @@
  */
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/internal.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "fft.h"
index f2b8ecc4112ee35053dac391cf556d7c4777ede9..47f26572048c0601f9e57c92cc00dbfc224a7796 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdint.h>
 
 #include "libavutil/error.h"
-#include "libavutil/internal.h"
+#include "libavutil/ffmath.h"
 
 #include "opus.h"
 #include "vorbis.h"
index 1a8432376bbb42e1fda57e4f9d935dd74fbe6522..7130bf62cc3514c20e16a78b404e0b1373498e04 100644 (file)
@@ -34,8 +34,7 @@
  */
 
 #include "libavutil/attributes.h"
-#include "libavutil/internal.h"
-#include "libavutil/libm.h"
+#include "libavutil/ffmath.h"
 
 #include "avcodec.h"
 #include "internal.h"
index d0727e69b20176d2650dd13fd8aadaef0fd54119..418e9586f68fc13fc76aa06b7082f456c683810e 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #include "libavutil/attributes.h"
-#include "libavutil/internal.h"
+#include "libavutil/ffmath.h"
 
 #include "avcodec.h"
 #include "internal.h"
index 2ea59e9251e4a254bd2c5d0cf07ae498907d7fd4..2cc1b093fbf5b724d948cc5f5dd6e99a2076364c 100644 (file)
@@ -88,8 +88,8 @@
 
 #include <inttypes.h>
 
+#include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/internal.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
index a344c77535c2470ea9730024bb85ad113d4015ec..24034602fd056bbd113e7bfcfb2cb9c8cafa2548 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avstring.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
index b74636409c32b1b6cd174cbcd467218f380e0b2f..0bb719fae5a38cefda20d5e027bda90a40319408 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/opt.h"
 #include "libavutil/samplefmt.h"
 #include "audio.h"
index 3913e7b261a82c508a501c9f5eca372d39ed14b8..4d6b91645a1accb684798a50da8e908a0c77f586 100644 (file)
@@ -27,6 +27,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/eval.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
index c4b30b4926b5d71a475855ee2859d538c9bd9a57..59eaedd92697220b66ba5c2ce65f048ae4a80d8d 100644 (file)
@@ -33,6 +33,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/dict.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/xga_font_data.h"
 #include "libavutil/opt.h"
 #include "libavutil/timestamp.h"
index 8d4014eae89c941f45b4f41907bcf188fd8a7405..ee394b49e3dbee14341c78956149b852cee5b0c1 100644 (file)
@@ -27,6 +27,7 @@
 #include "libavcodec/avfft.h"
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
index a75dd4c37e2d0c7a6108a8015ad5b56824bccafc..f0c09859649330a94b525e4452b028d51c0c6f44 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
+#include "libavutil/ffmath.h"
 #include "libavutil/opt.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
index 2acbbb47d16ced35675255e522976c6af8635fa5..37b8511845b5112f39a6e94f60eebe2c7f8a55e5 100644 (file)
@@ -31,6 +31,7 @@
 #include "avutil.h"
 #include "common.h"
 #include "eval.h"
+#include "ffmath.h"
 #include "internal.h"
 #include "log.h"
 #include "mathematics.h"
diff --git a/libavutil/ffmath.h b/libavutil/ffmath.h
new file mode 100644 (file)
index 0000000..aad1347
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * copyright (c) 2016 Ganesh Ajjanagadde <gajjanag@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * internal math functions header
+ */
+
+#ifndef AVUTIL_FFMATH_H
+#define AVUTIL_FFMATH_H
+
+#include "attributes.h"
+#include "libm.h"
+
+/**
+ * Compute 10^x for floating point values. Note: this function is by no means
+ * "correctly rounded", and is meant as a fast, reasonably accurate approximation.
+ * For instance, maximum relative error for the double precision variant is
+ * ~ 1e-13 for very small and very large values.
+ * This is ~2x faster than GNU libm's approach, which is still off by 2ulp on
+ * some inputs.
+ * @param x exponent
+ * @return 10^x
+ */
+static av_always_inline double ff_exp10(double x)
+{
+    return exp2(M_LOG2_10 * x);
+}
+
+static av_always_inline float ff_exp10f(float x)
+{
+    return exp2f(M_LOG2_10 * x);
+}
+
+/**
+ * Compute x^y for floating point x, y. Note: this function is faster than the
+ * libm variant due to mainly 2 reasons:
+ * 1. It does not handle any edge cases. In particular, this is only guaranteed
+ * to work correctly for x > 0.
+ * 2. It is not as accurate as a standard nearly "correctly rounded" libm variant.
+ * @param x base
+ * @param y exponent
+ * @return x^y
+ */
+static av_always_inline float ff_fast_powf(float x, float y)
+{
+    return expf(logf(x) * y);
+}
+
+#endif /* AVUTIL_FFMATH_H */
index 340e18bc5dd76192b4db296b9edcf51ded88f5c4..61784b5128fe3c1e0ad5e6916d3914e48a87f916 100644 (file)
@@ -294,42 +294,6 @@ static av_always_inline av_const int64_t ff_rint64_clip(double a, int64_t amin,
     return res;
 }
 
-/**
- * Compute 10^x for floating point values. Note: this function is by no means
- * "correctly rounded", and is meant as a fast, reasonably accurate approximation.
- * For instance, maximum relative error for the double precision variant is
- * ~ 1e-13 for very small and very large values.
- * This is ~2x faster than GNU libm's approach, which is still off by 2ulp on
- * some inputs.
- * @param x exponent
- * @return 10^x
- */
-static av_always_inline double ff_exp10(double x)
-{
-    return exp2(M_LOG2_10 * x);
-}
-
-static av_always_inline float ff_exp10f(float x)
-{
-    return exp2f(M_LOG2_10 * x);
-}
-
-/**
- * Compute x^y for floating point x, y. Note: this function is faster than the
- * libm variant due to mainly 2 reasons:
- * 1. It does not handle any edge cases. In particular, this is only guaranteed
- * to work correctly for x > 0.
- * 2. It is not as accurate as a standard nearly "correctly rounded" libm variant.
- * @param x base
- * @param y exponent
- * @return x^y
- */
-static av_always_inline float ff_fast_powf(float x, float y)
-{
-    return expf(logf(x) * y);
-}
-
-
 /**
  * A wrapper for open() setting O_CLOEXEC.
  */