]> granicus.if.org Git - libjpeg-turbo/commitdiff
Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler
authorDRC <dcommander@users.sourceforge.net>
Tue, 8 Feb 2011 01:18:37 +0000 (01:18 +0000)
committerDRC <dcommander@users.sourceforge.net>
Tue, 8 Feb 2011 01:18:37 +0000 (01:18 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@355 632fc199-4ca6-4c93-a231-07263d6284db

BUILDING.txt
CMakeLists.txt
ChangeLog.txt
Makefile.am
configure.ac
jpgtest.c [moved from jpgtest.cxx with 97% similarity]
rrtimer.h

index 9da5f2009ed9664b4606cd11b6709c0a7b0e0f22..b0792b2d8dd4656d9ff4c1a9b2a980fb678e0e09 100644 (file)
@@ -154,7 +154,7 @@ Build Recipes
 
 Add
 
-  --host i686-pc-linux-gnu CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32
+  --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
 
 to the configure command line.
 
@@ -175,7 +175,7 @@ installed.
 
 Add
 
-  CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32
+  CFLAGS='-O3 -m32' LDFLAGS=-m32
 
 to the configure command line.
 
@@ -187,8 +187,6 @@ Add
 
   --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
   CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-    -mmacosx-version-min=10.4 -O3' \
-    CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
     -mmacosx-version-min=10.4 -O3' \
     LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
     -mmacosx-version-min=10.4'
@@ -203,8 +201,6 @@ MacPorts, must be installed.
 Add
 
   CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-    -mmacosx-version-min=10.4 -O3 -m32' \
-    CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
     -mmacosx-version-min=10.4 -O3 -m32' \
     LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
     -mmacosx-version-min=10.4 -m32'
@@ -217,7 +213,7 @@ to the configure command line.  The OS X 10.4 SDK must be installed.
 
 Add
 
-  --host x86_64-pc-solaris CFLAGS='-O3 -m64' CXXFLAGS='-O3 -m64' LDFLAGS=-m64
+  --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
 
 to the configure command line.
 
@@ -227,8 +223,8 @@ to the configure command line.
 
 Add
 
-  --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CXX='g++ -B/usr/lib32' \
-    CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS='-B/usr/lib32'
+  --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
+    LDFLAGS='-B/usr/lib32'
 
 to the configure command line.  NASM 2.07 or later from FreeBSD ports must be
 installed.
@@ -239,15 +235,14 @@ Sun Studio
 
 Add
 
-  CC=cc CXX=CC
+  CC=cc
 
 to the configure command line.  libjpeg-turbo will automatically be built with
-the maximum optimization level (-xO5) unless you override CFLAGS and CXXFLAGS.
+the maximum optimization level (-xO5) unless you override CFLAGS.
 
 To build a 64-bit version of libjpeg-turbo using Sun Studio, add
 
-  --host x86_64-pc-solaris CC=cc CXX=CC CFLAGS='-xO5 -m64' \
-    CXXFLAGS='-xO5 -m64' LDFLAGS=-m64
+  --host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
 
 to the configure command line.
 
@@ -470,7 +465,7 @@ Build Recipes
 ----------------------------
 
   cd {build_directory}
-  CC=/usr/bin/x86_64-w64-mingw32-gcc CXX=/usr/bin/x86_64-w64-mingw32-g++ \
+  CC=/usr/bin/x86_64-w64-mingw32-gcc \
     cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
     -DCMAKE_AR=/usr/bin/x86_64-w64-mingw32-ar \
     -DCMAKE_RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib {source_directory}
@@ -485,7 +480,7 @@ mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
 ----------------------------
 
   cd {build_directory}
-  CC=/usr/bin/i686-w64-mingw32-gcc CXX=/usr/bin/i686-w64-mingw32-g++ \
+  CC=/usr/bin/i686-w64-mingw32-gcc \
     cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
     -DDCMAKE_AR=/usr/bin/i686-w64-mingw32-ar \
     -DCMAKE_RANLIB=/usr/bin/i686-w64-mingw32-ranlib {source_directory}
@@ -504,7 +499,6 @@ toolchain (which is faster than the Cygwin version):
 
   cd {build_directory}
   CC={mingw-w64_binary_path}/x86_64-w64-mingw32-gcc \
-    CXX={mingw-w64_binary_path}/x86_64-w64-mingw32-g++ \
     cmake -G "MSYS Makefiles" \
     -DCMAKE_AR={mingw-w64_binary_path}/x86_64-w64-mingw32-ar \
     -DCMAKE_RANLIB={mingw-w64_binary_path}/x86_64-w64-mingw32-ranlib \
@@ -517,7 +511,6 @@ MinGW Build on Linux
 
   cd {build_directory}
   CC={mingw_binary_path}/i386-mingw32-gcc \
-    CXX={mingw_binary_path}/i386-mingw32-g++ \
     cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
     -DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
     -DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
index b88da0d48acc10f11b3d615f21912dadcbadb0df..e38d92ab4badb5eb19ee15d3113109f7843c162d 100644 (file)
@@ -76,9 +76,7 @@ endif(WITH_JPEG8)
 if(MSVC)
   # Use the static C library for all build types
   foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
-    CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
-    CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
-    CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+    CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
     if(${var} MATCHES "/MD")
       string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
     endif()
@@ -177,10 +175,10 @@ target_link_libraries(jpegut turbojpeg)
 add_executable(jpegut-static jpegut.c)
 target_link_libraries(jpegut-static turbojpeg-static)
 
-add_executable(jpgtest jpgtest.cxx bmp.c)
+add_executable(jpgtest jpgtest.c bmp.c)
 target_link_libraries(jpgtest turbojpeg)
 
-add_executable(jpgtest-static jpgtest.cxx bmp.c)
+add_executable(jpgtest-static jpgtest.c bmp.c)
 target_link_libraries(jpgtest-static turbojpeg-static)
 
 add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
index 87025ecea6ca18d167a4d786527411e349588432..22659389051d9f733a8288cfea45301b2846a90e 100644 (file)
@@ -7,6 +7,8 @@ forward DCT when generating JPEG images of quality 96 or greater.  This
 reduces compression performance by as much as 15% for these high-quality images
 but is necessary to ensure that the images are perceptually lossless.
 
+[2] Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler.
+
 
 1.0.90 (1.1 beta1)
 ==================
index 2f7e773ecd2ea04b1622292d5b4e386ec800c3c7..adfa5c0de2e3b5c248b765e4d8f326a55241ac1d 100644 (file)
@@ -66,7 +66,7 @@ TSTHDRS = rrutil.h rrtimer.h
 bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom
 noinst_PROGRAMS = jpgtest jpegut
 
-jpgtest_SOURCES = $(TSTHDRS) jpgtest.cxx bmp.h bmp.c
+jpgtest_SOURCES = $(TSTHDRS) jpgtest.c bmp.h bmp.c
 
 jpgtest_LDADD = libturbojpeg.la
 
index aa16d8377e1a9f66e7b7b71483b24c627f5c2704..7b646c29c200dec1c007dcd6009ed52f1e656dd7 100644 (file)
@@ -13,10 +13,8 @@ AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
 
 # Checks for programs.
 SAVED_CFLAGS=${CFLAGS}
-SAVED_CXXFLAGS=${CXXFLAGS}
 AC_PROG_CPP
 AC_PROG_CC
-AC_PROG_CXX
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 AC_PROG_LN_S
@@ -32,9 +30,6 @@ if test "x${GCC}" = "xyes"; then
   if test "x${SAVED_CFLAGS}" = "x"; then
     CFLAGS=-O3
   fi
-  if test "x${SAVED_CXXFLAGS}" = "x"; then
-    CXXFLAGS=-O3
-  fi
 fi
 
 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
@@ -42,9 +37,6 @@ if test "x${SUNCC}" = "xyes"; then
   if test "x${SAVED_CFLAGS}" = "x"; then
     CFLAGS=-xO5
   fi
-  if test "x${SAVED_CXXFLAGS}" = "x"; then
-    CXXFLAGS=-xO5
-  fi
 fi
 
 # Checks for libraries.
similarity index 97%
rename from jpgtest.cxx
rename to jpgtest.c
index 0a90123e3ad393e13fa3da34536504a25e373894..6ec507aa468c159753dd35fcab677fbdebdc5aac 100644 (file)
+++ b/jpgtest.c
@@ -1,6 +1,6 @@
 /* Copyright (C)2004 Landmark Graphics Corporation
  * Copyright (C)2005, 2006 Sun Microsystems, Inc.
- * Copyright (C)2009-2010 D. R. Commander
+ * Copyright (C)2009-2011 D. R. Commander
  *
  * This library is free software and may be redistributed and/or modified under
  * the terms of the wxWindows Library License, Version 3.1 or (at your option)
@@ -64,19 +64,19 @@ void printsigfig(double val, int figs)
        printf(format, val);
 }
 
-void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
+void dotest(unsigned char *srcbuf, int w, int h, int pf, int bu,
        int jpegsub, int qual, char *filename, int dotile, int useppm, int quiet)
 {
        char tempstr[1024];
        FILE *outfile=NULL;  tjhandle hnd;
        unsigned char **jpegbuf=NULL, *rgbbuf=NULL;
-       rrtimer timer; double elapsed;
+       double start, elapsed;
        int jpgbufsize=0, i, j, tilesizex, tilesizey, numtilesx, numtilesy, ITER;
        unsigned long *comptilesize=NULL;
        int flags=(forcemmx?TJ_FORCEMMX:0)|(forcesse?TJ_FORCESSE:0)
                |(forcesse2?TJ_FORCESSE2:0)|(forcesse3?TJ_FORCESSE3:0)
                |(fastupsample?TJ_FASTUPSAMPLE:0);
-       int ps=_ps[pf];
+       int ps=_ps[pf], tilen;
        int pitch=w*ps, yuvsize;
        int hsf=_hsf[jpegsub], vsf=_vsf[jpegsub];
        int pw=PAD(w, hsf), ph=PAD(h, vsf);
@@ -129,10 +129,10 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
                        jpegbuf[0], &comptilesize[0], jpegsub, qual, flags)==-1)
                        _throwtj("executing tjCompress()");
                ITER=0;
-               timer.start();
+               start=rrtime();
                do
                {
-                       jpgbufsize=0;  int tilen=0;
+                       jpgbufsize=0;  tilen=0;
                        for(i=0; i<h; i+=tilesizey)
                        {
                                for(j=0; j<w; j+=tilesizex)
@@ -147,7 +147,7 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
                                }
                        }
                        ITER++;
-               } while((elapsed=timer.elapsed())<5.);
+               } while((elapsed=rrtime()-start)<5.);
                if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
                hnd=NULL;
                if(quiet)
@@ -196,7 +196,7 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
                        tilesizey, ps, flags)==-1)
                        _throwtj("executing tjDecompress()");
                ITER=0;
-               timer.start();
+               start=rrtime();
                do
                {
                        int tilen=0;
@@ -212,7 +212,7 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
                                }
                        }
                        ITER++;
-               }       while((elapsed=timer.elapsed())<5.);
+               }       while((elapsed=rrtime()-start)<5.);
                if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
                hnd=NULL;
                if(quiet)
@@ -301,13 +301,13 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
 }
 
 
-void dodecomptest(char *filename, BMPPIXELFORMAT pf, int bu, int useppm,
+void dodecomptest(char *filename, int pf, int bu, int useppm,
        int quiet)
 {
        char tempstr[1024];
        FILE *file=NULL;  tjhandle hnd;
        unsigned char *jpegbuf=NULL, *rgbbuf=NULL;
-       rrtimer timer; double elapsed;
+       double start, elapsed;
        int w, h, ITER;
        unsigned long jpgbufsize=0;
        int flags=(forcemmx?TJ_FORCEMMX:0)|(forcesse?TJ_FORCESSE:0)
@@ -373,14 +373,14 @@ void dodecomptest(char *filename, BMPPIXELFORMAT pf, int bu, int useppm,
        if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps, flags)==-1)
                _throwtj("executing tjDecompress()");
        ITER=0;
-       timer.start();
+       start=rrtime();
        do
        {
                if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps, flags)
                        ==-1)
                        _throwtj("executing tjDecompress()");
                ITER++;
-       }       while((elapsed=timer.elapsed())<5.);
+       }       while((elapsed=rrtime()-start)<5.);
        if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
        hnd=NULL;
        if(quiet)
@@ -449,7 +449,7 @@ int main(int argc, char *argv[])
 {
        unsigned char *bmpbuf=NULL;  int w, h, i, useppm=0;
        int qual, dotile=0, quiet=0, hiqual=-1;  char *temp;
-       BMPPIXELFORMAT pf=BMP_BGR;
+       int pf=BMP_BGR;
        int bu=0, minarg=2;
 
        printf("\n");
index 4db5e371895a6669d63332bb04eb58288b4ad2fa..3031ef56db0518795f103d7fe7faeb448e63d225 100644 (file)
--- a/rrtimer.h
+++ b/rrtimer.h
 #ifndef __RRTIMER_H__
 #define __RRTIMER_H__
 
-#ifdef __cplusplus
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <sys/time.h>
-#endif
-
-class rrtimer
-{
-       public:
-
-               rrtimer(void) : t1(0.0)
-               {
-                       #ifdef _WIN32
-                       highres=false;  tick=0.001;
-                       LARGE_INTEGER Frequency;
-                       if(QueryPerformanceFrequency(&Frequency)!=0)
-                       {
-                               tick=(double)1.0/(double)(Frequency.QuadPart);
-                               highres=true;
-                       }
-                       #endif
-               }
-
-               void start(void)
-               {
-                       t1=time();
-               }
-
-               double time(void)
-               {
-                       #ifdef _WIN32
-                       if(highres)
-                       {
-                               LARGE_INTEGER Time;
-                               QueryPerformanceCounter(&Time);
-                               return((double)(Time.QuadPart)*tick);
-                       }
-                       else
-                               return((double)GetTickCount()*tick);
-                       #else
-                       struct timeval __tv;
-                       gettimeofday(&__tv, (struct timezone *)NULL);
-                       return((double)(__tv.tv_sec)+(double)(__tv.tv_usec)*0.000001);
-                       #endif
-               }
-
-               double elapsed(void)
-               {
-                       return time()-t1;
-               }
-
-       private:
-
-               #ifdef _WIN32
-               bool highres;  double tick;
-               #endif
-               double t1;
-};
-
-#endif  // __cplusplus
-
 #ifdef _WIN32
 
 #include <windows.h>
@@ -111,4 +48,3 @@ static __inline double rrtime(void)
 #endif
 
 #endif
-