]> git.sesse.net Git - ffmpeg/commitdiff
Fix build on configurations without fast av_log2()
authorMåns Rullgård <mans@mansr.com>
Tue, 9 Mar 2010 01:19:28 +0000 (01:19 +0000)
committerMåns Rullgård <mans@mansr.com>
Tue, 9 Mar 2010 01:19:28 +0000 (01:19 +0000)
This is a bit hackish.  I will try to think of something nicer, but
this will do for now.

Originally committed as revision 22366 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavutil/common.h
libavutil/intmath.h

index 3f81de4f006fe5f610aafb0352c12e02b993fbaf..fae0b5b09bcd7122d22f765a96ca10be18aa6020 100644 (file)
 #include <string.h>
 #include "attributes.h"
 
-#ifdef HAVE_AV_CONFIG_H
-#   include "config.h"
-#   include "intmath.h"
-#endif
-
 //rounded division & shift
 #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
 /* assume b>0 */
@@ -62,8 +57,7 @@ extern const uint8_t ff_log2_tab[256];
 
 extern const uint8_t av_reverse[256];
 
-#ifndef av_log2
-static inline av_const int av_log2(unsigned int v)
+static inline av_const int av_log2_c(unsigned int v)
 {
     int n = 0;
     if (v & 0xffff0000) {
@@ -78,10 +72,8 @@ static inline av_const int av_log2(unsigned int v)
 
     return n;
 }
-#endif
 
-#ifndef av_log2_16bit
-static inline av_const int av_log2_16bit(unsigned int v)
+static inline av_const int av_log2_16bit_c(unsigned int v)
 {
     int n = 0;
     if (v & 0xff00) {
@@ -92,6 +84,17 @@ static inline av_const int av_log2_16bit(unsigned int v)
 
     return n;
 }
+
+#ifdef HAVE_AV_CONFIG_H
+#   include "config.h"
+#   include "intmath.h"
+#endif
+
+#ifndef av_log2
+#   define av_log2       av_log2_c
+#endif
+#ifndef av_log2_16bit
+#   define av_log2_16bit av_log2_16bit_c
 #endif
 
 /**
index 02870cb282cb608c2e642f683612aa8f7d7b5727..95ee1ff65c1e4ff504ca7565a0ed1185d5aacb0c 100644 (file)
@@ -21,8 +21,9 @@
 #ifndef AVUTIL_INTMATH_H
 #define AVUTIL_INTMATH_H
 
+#include <stdint.h>
 #include "config.h"
-#include "common.h"
+#include "attributes.h"
 
 extern const uint32_t ff_inverse[257];
 
@@ -56,6 +57,22 @@ extern const uint32_t ff_inverse[257];
 
 #endif /* FASTDIV */
 
+/*
+ * Get definition of av_log2_c from common.h.  In the event we got
+ * here through common.h including this file, including it again will
+ * be a no-op due to multi-inclusion guards, so we must duplicate the
+ * fallback defines here.
+ */
+
+#include "common.h"
+
+#ifndef av_log2
+#   define av_log2       av_log2_c
+#endif
+#ifndef av_log2_16bit
+#   define av_log2_16bit av_log2_16bit_c
+#endif
+
 extern const uint8_t ff_sqrt_tab[256];
 
 static inline av_const unsigned int ff_sqrt(unsigned int a)