aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/intmath.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-21 13:29:03 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-21 13:35:42 +0200
commitdcbff35199e1596d9d1200e734ef4a4c306e50f1 (patch)
treee173e3208ed6a79a0648e4324c3cc398b7d176ca /libavutil/intmath.h
parent05f228b0a01e8b97ba73a15c1eccb6b0a9060633 (diff)
parentd15c21e5fa3961f10026da1a3080a3aa3cf4cec9 (diff)
downloadffmpeg-dcbff35199e1596d9d1200e734ef4a4c306e50f1.tar.gz
Merge commit 'd15c21e5fa3961f10026da1a3080a3aa3cf4cec9'
* commit 'd15c21e5fa3961f10026da1a3080a3aa3cf4cec9': avutil: Add a copy of ff_sqrt_tab back into avutil to restore ABI compatibility avutil: make some tables visible again avutil: remove inline av_log2 from public API celp_math: rename ff_log2 to ff_log2_q15 Conflicts: libavutil/libavutil.v Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/intmath.h')
-rw-r--r--libavutil/intmath.h51
1 files changed, 46 insertions, 5 deletions
diff --git a/libavutil/intmath.h b/libavutil/intmath.h
index da333bc6d2..1e58cfba73 100644
--- a/libavutil/intmath.h
+++ b/libavutil/intmath.h
@@ -21,6 +21,8 @@
#ifndef AVUTIL_INTMATH_H
#define AVUTIL_INTMATH_H
+#include <stdint.h>
+
#include "config.h"
#include "attributes.h"
@@ -35,15 +37,54 @@
#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
-#ifndef av_log2
-# define av_log2(x) (31 - __builtin_clz((x)|1))
-# ifndef av_log2_16bit
-# define av_log2_16bit av_log2
+#ifndef ff_log2
+# define ff_log2(x) (31 - __builtin_clz((x)|1))
+# ifndef ff_log2_16bit
+# define ff_log2_16bit av_log2
# endif
-#endif /* av_log2 */
+#endif /* ff_log2 */
#endif /* AV_GCC_VERSION_AT_LEAST(3,4) */
+extern const uint8_t ff_log2_tab[256];
+
+#ifndef ff_log2
+#define ff_log2 ff_log2_c
+static av_always_inline av_const int ff_log2_c(unsigned int v)
+{
+ int n = 0;
+ if (v & 0xffff0000) {
+ v >>= 16;
+ n += 16;
+ }
+ if (v & 0xff00) {
+ v >>= 8;
+ n += 8;
+ }
+ n += ff_log2_tab[v];
+
+ return n;
+}
+#endif
+
+#ifndef ff_log2_16bit
+#define ff_log2_16bit ff_log2_16bit_c
+static av_always_inline av_const int ff_log2_16bit_c(unsigned int v)
+{
+ int n = 0;
+ if (v & 0xff00) {
+ v >>= 8;
+ n += 8;
+ }
+ n += ff_log2_tab[v];
+
+ return n;
+}
+#endif
+
+#define av_log2 ff_log2
+#define av_log2_16bit ff_log2_16bit
+
/**
* @}
*/