improve log2 test

- add check for native log2 to configure
- use a common define (NOT_HAVE_LOG2) to enable use of local library
  version for non-autoconf platforms without their own version,
  currently msvc and android

This uses a negative (NOT_HAVE_) to simplify the ifdef

Change-Id: Id0610eed507f8bb9c5da338918112853d5c8127a
This commit is contained in:
James Zern 2012-01-04 18:38:07 -08:00
parent e852f83205
commit 992187a380
4 changed files with 12 additions and 3 deletions

View File

@ -38,7 +38,8 @@ LOCAL_SRC_FILES := \
src/utils/tcoder.c \
src/utils/thread.c \
LOCAL_CFLAGS := -Wall -DANDROID -DHAVE_MALLOC_H -DHAVE_PTHREAD -DWEBP_USE_THREAD \
LOCAL_CFLAGS := -Wall -DANDROID -DHAVE_MALLOC_H -DHAVE_PTHREAD \
-DNOT_HAVE_LOG2 -DWEBP_USE_THREAD \
-finline-functions -frename-registers -ffast-math \
-s -fomit-frame-pointer -Isrc/webp

View File

@ -37,7 +37,7 @@ CCNODBG = cl.exe /nologo /O2 /DNDEBUG
CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1
CFLAGS = /Isrc /nologo /W3 /EHsc /FD /c /GS
CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN
CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD
CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD /DNOT_HAVE_LOG2
LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE
LDFLAGS = $(LDFLAGS) $(PLATFORM_LDFLAGS)
LNKDLL = link.exe /DLL

View File

@ -11,6 +11,11 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])
dnl === Check for native log2
AC_SEARCH_LIBS([log2], [m],,
[AC_DEFINE([NOT_HAVE_LOG2], [1],
[Undefine this if you have log2().])])
dnl === Check libz is present
if test "$enable_experimental" = "yes"; then

View File

@ -78,6 +78,9 @@
// Using this simple maintenance, we observed a typical 10-20% reduction
// in the number of calls to VP8PutBit(), leading to 3-5% speed gain.
//
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "./tcoderi.h"
@ -85,7 +88,7 @@
extern "C" {
#endif
#ifdef _MSC_VER
#ifdef NOT_HAVE_LOG2
static double log2(double d) {
const double kLog2Reciprocal = 1.442695040888963;
return log(d) * kLog2Reciprocal;