aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2011-02-07 08:06:16 +0000
committerdcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2011-02-07 08:06:16 +0000
commit3a3438c6a9283d723e128d5f2647336649332b85 (patch)
tree91cb92dc6ffb015a2eb44caf156b6ca0a02b4b1b
parent24ad037d54cd80b426c151552d83474dc362fba5 (diff)
Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler
git-svn-id: svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk@354 632fc199-4ca6-4c93-a231-07263d6284db
-rw-r--r--BUILDING.txt27
-rw-r--r--CMakeLists.txt8
-rw-r--r--ChangeLog.txt2
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac8
-rw-r--r--jpgtest.c (renamed from jpgtest.cxx)28
-rw-r--r--rrtimer.h64
7 files changed, 30 insertions, 109 deletions
diff --git a/BUILDING.txt b/BUILDING.txt
index 938e1c2..3737987 100644
--- a/BUILDING.txt
+++ b/BUILDING.txt
@@ -169,7 +169,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.
@@ -190,7 +190,7 @@ installed.
Add
- CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32
+ CFLAGS='-O3 -m32' LDFLAGS=-m32
to the configure command line.
@@ -203,8 +203,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'
@@ -219,8 +217,6 @@ 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'
@@ -232,7 +228,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.
@@ -242,8 +238,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.
@@ -254,15 +250,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.
@@ -502,7 +497,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}
@@ -517,7 +512,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}
@@ -536,7 +531,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 \
@@ -549,7 +543,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 \
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b690e9..87538c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,9 +86,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()
@@ -203,10 +201,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
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 5c5a05d..7167cb0 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -3,6 +3,8 @@
[1] Added a JNI wrapper for TurboJPEG/OSS. See java/README for more details.
+[2] Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler.
+
1.1.0
=====
diff --git a/Makefile.am b/Makefile.am
index e5fb1f0..84dcad4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,7 +79,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
diff --git a/configure.ac b/configure.ac
index 23c80ee..57724f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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.
diff --git a/jpgtest.cxx b/jpgtest.c
index 0a90123..6ec507a 100644
--- a/jpgtest.cxx
+++ 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");
diff --git a/rrtimer.h b/rrtimer.h
index 4db5e37..3031ef5 100644
--- a/rrtimer.h
+++ b/rrtimer.h
@@ -15,69 +15,6 @@
#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
-