From 2e4d044cabdc12dd9916ff0d509627f0d201608a Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 8 Feb 2011 01:18:37 +0000 Subject: [PATCH] Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler 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 | 27 +++++++---------- CMakeLists.txt | 8 ++--- ChangeLog.txt | 2 ++ Makefile.am | 2 +- configure.ac | 8 ----- jpgtest.cxx => jpgtest.c | 28 +++++++++--------- rrtimer.h | 64 ---------------------------------------- 7 files changed, 30 insertions(+), 109 deletions(-) rename jpgtest.cxx => jpgtest.c (97%) diff --git a/BUILDING.txt b/BUILDING.txt index 9da5f20..b0792b2 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -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 \ diff --git a/CMakeLists.txt b/CMakeLists.txt index b88da0d..e38d92a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/ChangeLog.txt b/ChangeLog.txt index 87025ec..2265938 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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) ================== diff --git a/Makefile.am b/Makefile.am index 2f7e773..adfa5c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index aa16d83..7b646c2 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 similarity index 97% rename from jpgtest.cxx rename to 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 -#else -#include -#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 @@ -111,4 +48,3 @@ static __inline double rrtime(void) #endif #endif - -- 2.40.0