Browse code

Add a log2 replacement for systems that haven't quite caught up with the C99 standard library.

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

Alex Converse authored on 2009/07/11 04:20:06
Showing 2 changed files
... ...
@@ -911,6 +911,7 @@ HAVE_LIST="
911 911
     libdc1394_1
912 912
     libdc1394_2
913 913
     llrint
914
+    log2
914 915
     loongson
915 916
     lrint
916 917
     lrintf
... ...
@@ -2078,7 +2079,7 @@ check_lib math.h sin -lm
2078 2078
 check_lib va/va.h vaInitialize -lva
2079 2079
 
2080 2080
 # test for C99 functions in math.h
2081
-for func in llrint lrint lrintf round roundf truncf; do
2081
+for func in llrint log2 lrint lrintf round roundf truncf; do
2082 2082
     check_exec <<EOF && enable $func || disable $func
2083 2083
 #include <math.h>
2084 2084
 int main(void) { return ($func(3.999f) > 0)?0:1; }
... ...
@@ -265,6 +265,13 @@ static av_always_inline av_const long long llrint(double x)
265 265
 }
266 266
 #endif /* HAVE_LLRINT */
267 267
 
268
+#if !HAVE_LOG2
269
+static av_always_inline av_const double log2(double x)
270
+{
271
+    return log(x) * 1.44269504088896340736;
272
+}
273
+#endif /* HAVE_LOG2 */
274
+
268 275
 #if !HAVE_LRINT
269 276
 static av_always_inline av_const long int lrint(double x)
270 277
 {