-## Process this file with automake to produce Makefile.in
-#
-# Automake Makefile for the JPEG library
-#
-# This file is written by Bob Friesenhahn, Guido Vollbeding
-#
-
-# Sources to build library
-LIBSOURCES = jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c \
- jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \
- jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c \
- jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \
- jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \
- jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c \
- jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \
- jquant2.c jutils.c jmemmgr.c @MEMORYMGR@.c
-
-# System dependent sources
-SYSDEPSOURCES = jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemmac.c
-
-# Headers which are installed to support the library
-INSTINCLUDES = jerror.h jmorecfg.h jpeglib.h
-
-# Headers which are not installed
-OTHERINCLUDES = cderror.h cdjpeg.h jdct.h jinclude.h jmemsys.h jpegint.h \
- jversion.h transupp.h
-
-# Manual pages (Automake uses 'MANS' for itself)
-DISTMANS= cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1
-
-# Other documentation files
-DOCS= README install.txt usage.txt wizard.txt example.c libjpeg.txt \
- structure.txt coderules.txt filelist.txt change.log
-
-# Makefiles for various systems
-MKFILES= configure Makefile.in makefile.ansi makefile.unix makefile.bcc \
- makefile.mc6 makefile.dj makefile.wat makefile.vc makejdsw.vc6 \
- makeadsw.vc6 makejdep.vc6 makejdsp.vc6 makejmak.vc6 makecdep.vc6 \
- makecdsp.vc6 makecmak.vc6 makeddep.vc6 makeddsp.vc6 makedmak.vc6 \
- maketdep.vc6 maketdsp.vc6 maketmak.vc6 makerdep.vc6 makerdsp.vc6 \
- makermak.vc6 makewdep.vc6 makewdsp.vc6 makewmak.vc6 makejsln.v10 \
- makeasln.v10 makejvcx.v10 makejfil.v10 makecvcx.v10 makecfil.v10 \
- makedvcx.v10 makedfil.v10 maketvcx.v10 maketfil.v10 makervcx.v10 \
- makerfil.v10 makewvcx.v10 makewfil.v10 makeproj.mac makcjpeg.st \
- makdjpeg.st makljpeg.st maktjpeg.st makefile.manx makefile.sas \
- makefile.mms makefile.vms makvms.opt
-
-# Configuration files
-CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \
- jconfig.vc jconfig.mac jconfig.st jconfig.manx jconfig.sas \
- jconfig.vms
-
-# Support scripts for configure
-CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp missing
-
-# Miscellaneous support files
-OTHERFILES= jconfig.txt ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm \
- libjpeg.map
-
-# Test support files
-TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \
- testimgp.jpg
-
-# libtool libraries to build
-lib_LTLIBRARIES = libjpeg.la
-
-# Library sources for libjpeg.la
-libjpeg_la_SOURCES = $(LIBSOURCES)
-
-# LDFLAGS for libjpeg.la
-libjpeg_la_LDFLAGS = -no-undefined \
- -version-info $(JPEG_LIB_VERSION)
-
-if HAVE_LD_VERSION_SCRIPT
- libjpeg_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libjpeg.map
+lib_LTLIBRARIES = libjpeg.la libturbojpeg.la
- libjpeg_la_LDFLAGS = -version-number 62:0:0 -no-undefined
++libjpeg_la_LDFLAGS = -version-number ${JPEG_LIB_VERSION}:0:0 -no-undefined
+libturbojpeg_la_LDFLAGS = -avoid-version -no-undefined
+include_HEADERS = jerror.h jmorecfg.h jpeglib.h turbojpeg.h
+nodist_include_HEADERS = jconfig.h
+
+HDRS = jchuff.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h jmorecfg.h \
+ jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h
+
+libjpeg_la_SOURCES = $(HDRS) jcapimin.c jcapistd.c jccoefct.c jccolor.c \
+ jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \
+ jcomapi.c jcparam.c jcphuff.c jcprepct.c jcsample.c jctrans.c \
+ jdapimin.c jdapistd.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \
+ jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \
+ jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c \
+ jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c \
+ jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c
+
+libturbojpeg_la_SOURCES = $(libjpeg_la_SOURCES) turbojpegl.c turbojpeg.h \
+ turbojpeg-mapfile
+
+if VERSION_SCRIPT
+
+libturbojpeg_la_LDFLAGS += $(VERSION_SCRIPT_FLAG)$(srcdir)/turbojpeg-mapfile
+
endif
-# Executables to build
+if WITH_SIMD
+
+SUBDIRS = simd
+libjpeg_la_LIBADD = simd/libsimd.la
+libturbojpeg_la_LIBADD = simd/libsimd.la
+
+else
+
+libjpeg_la_SOURCES += jsimd_none.c
+
+endif
+
+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_LDADD = libturbojpeg.la
+
+jpegut_SOURCES = $(TSTHDRS) jpegut.c bmp.h bmp.c
+
+jpegut_LDADD = libturbojpeg.la
+
+cjpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c cjpeg.c rdbmp.c rdgif.c \
+ rdppm.c rdswitch.c rdtarga.c
+
+cjpeg_LDADD = libjpeg.la
+
+cjpeg_CFLAGS = -DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED \
+ -DTARGA_SUPPORTED
+
+djpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c djpeg.c rdcolmap.c rdswitch.c \
+ wrbmp.c wrgif.c wrppm.c wrtarga.c
+
+djpeg_LDADD = libjpeg.la
+
+djpeg_CFLAGS = -DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED \
+ -DTARGA_SUPPORTED
+
+jpegtran_SOURCES = jpegtran.c rdswitch.c cdjpeg.c transupp.c transupp.h
+
+jpegtran_LDADD = libjpeg.la
-# Executable sources & libs
-cjpeg_SOURCES = cjpeg.c rdppm.c rdgif.c rdtarga.c rdrle.c rdbmp.c \
- rdswitch.c cdjpeg.c
-cjpeg_LDADD = libjpeg.la
-djpeg_SOURCES = djpeg.c wrppm.c wrgif.c wrtarga.c wrrle.c wrbmp.c \
- rdcolmap.c cdjpeg.c
-djpeg_LDADD = libjpeg.la
-jpegtran_SOURCES = jpegtran.c rdswitch.c cdjpeg.c transupp.c
-jpegtran_LDADD = libjpeg.la
rdjpgcom_SOURCES = rdjpgcom.c
+
+rdjpgcom_LDADD = libjpeg.la
+
wrjpgcom_SOURCES = wrjpgcom.c
-# Manual pages to install
-man_MANS = $(DISTMANS)
+wrjpgcom_LDADD = libjpeg.la
-# Headers to install
-include_HEADERS = $(INSTINCLUDES)
-# Other distributed headers
-noinst_HEADERS = $(OTHERINCLUDES)
+dist_man1_MANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1
-# Other distributed files
-EXTRA_DIST = $(DOCS) $(DISTMANS) $(MKFILES) $(CONFIGFILES) $(SYSDEPSOURCES) \
- $(OTHERFILES) $(TESTFILES)
+DOCS= README install.doc usage.doc wizard.doc example.c libjpeg.doc \
+ structure.doc coderules.doc filelist.doc jconfig.doc change.log \
+ README-turbo.txt rdrle.c wrrle.c LICENSE.txt LGPL.txt BUILDING.txt \
+ ChangeLog.txt
-# Files to be cleaned
-CLEANFILES = testout.ppm testout.bmp testout.jpg testoutp.ppm testoutp.jpg \
- testoutt.jpg
+TESTFILES= testorig.jpg testorig.ppm testimg.bmp testimgflt.jpg \
+ testimgfst.jpg testimgint.jpg testimgp.jpg testimgflt.ppm testimgfst.ppm \
+ testimgint.ppm testimgflt-nosimd.jpg
-# Install jconfig.h
-install-data-local:
- $(mkinstalldirs) $(DESTDIR)$(includedir)
- $(INSTALL_HEADER) jconfig.h $(DESTDIR)$(includedir)/jconfig.h
+EXTRA_DIST = win release $(DOCS) $(TESTFILES)
-# Uninstall jconfig.h
-uninstall-local:
- rm -f $(DESTDIR)$(includedir)/jconfig.h
+dist-hook:
+ rm -rf `find $(distdir) -name .svn`
-# Run tests
-test: check-local
-check-local:
- rm -f testout*
- ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg
+
+if WITH_SIMD
+
+test: testclean all
+ ./jpegut
+ ./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testorig.ppm
+ ./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testorig.ppm
+ ./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testorig.ppm
+ cmp $(srcdir)/testimgint.jpg testoutint.jpg
+ cmp $(srcdir)/testimgfst.jpg testoutfst.jpg
+ cmp $(srcdir)/testimgflt.jpg testoutflt.jpg
+ ./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testorig.jpg
+ ./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testorig.jpg
+ ./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testorig.jpg
+ cmp $(srcdir)/testimgint.ppm testoutint.ppm
+ cmp $(srcdir)/testimgfst.ppm testoutfst.ppm
+ cmp $(srcdir)/testimgflt.ppm testoutflt.ppm
+ ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg
+ cmp $(srcdir)/testimg.bmp testout.bmp
+ ./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testorig.ppm
+ cmp $(srcdir)/testimgp.jpg testoutp.jpg
+ ./jpegtran -outfile testoutt.jpg testoutp.jpg
+ cmp $(srcdir)/testimgint.jpg testoutt.jpg
+
+else
+
+test: testclean all
+ ./jpegut
+ ./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testorig.ppm
+ ./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testorig.ppm
+ ./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testorig.ppm
+ cmp $(srcdir)/testimgint.jpg testoutint.jpg
+ cmp $(srcdir)/testimgfst.jpg testoutfst.jpg
+ cmp $(srcdir)/testimgflt-nosimd.jpg testoutflt.jpg
+ ./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testorig.jpg
+ ./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testorig.jpg
+ ./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testorig.jpg
+ cmp $(srcdir)/testimgint.ppm testoutint.ppm
+ cmp $(srcdir)/testimgfst.ppm testoutfst.ppm
+ cmp $(srcdir)/testorig.ppm testoutflt.ppm
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg
- ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm
- ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg
- ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm
- ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg
- cmp $(srcdir)/testimg.ppm testout.ppm
cmp $(srcdir)/testimg.bmp testout.bmp
- cmp $(srcdir)/testimg.jpg testout.jpg
- cmp $(srcdir)/testimg.ppm testoutp.ppm
+ ./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgp.jpg testoutp.jpg
- cmp $(srcdir)/testorig.jpg testoutt.jpg
+ ./jpegtran -outfile testoutt.jpg testoutp.jpg
+ cmp $(srcdir)/testimgint.jpg testoutt.jpg
+
+endif
+
+testclean:
+ rm -f testout*
+ rm -f *_GRAYQ[0-9]*.bmp
+ rm -f *_GRAYQ[0-9]*.ppm
+ rm -f *_GRAYQ[0-9]*.jpg
+ rm -f *_420Q[0-9]*.bmp
+ rm -f *_420Q[0-9]*.ppm
+ rm -f *_420Q[0-9]*.jpg
+ rm -f *_422Q[0-9]*.bmp
+ rm -f *_422Q[0-9]*.ppm
+ rm -f *_422Q[0-9]*.jpg
+ rm -f *_444Q[0-9]*.bmp
+ rm -f *_444Q[0-9]*.ppm
+ rm -f *_444Q[0-9]*.jpg
+
+rpm: all
+ sh $(srcdir)/release/makerpm ${PACKAGE_NAME} ${VERSION} ${BUILD} \
+ ${RPMARCH} ${srcdir}
+
+srpm: dist-gzip
+ sh $(srcdir)/release/makesrpm ${PACKAGE_NAME} ${VERSION} ${BUILD} ${srcdir}
+
+deb: all
+ sh $(srcdir)/release/makedpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \
+ ${DEBARCH} ${srcdir}
+
+if X86_64
+
+udmg: all
+ sh $(srcdir)/release/makemacpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \
+ ${srcdir} universal
+
+endif
+
+dmg: all
+ sh $(srcdir)/release/makemacpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} ${srcdir}
+
+if X86_64
+
+sunpkg: all
+ sh $(srcdir)/release/makesunpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \
+ ${DEBARCH} ${srcdir} $(CC) $(CXX) combined
+
+nsi: all
+ makensis -nocd -DVERSION=$(VERSION) -DAPPNAME=libjpeg-turbo-gcc64 \
+ -DWLIBDIR=.libs -DWSRCDIR=$(srcdir) -DWBLDDIR=. -DWHDRDIR=. -DWIN64 \
+ -DPLATFORM="GCC 64-bit" -DGCC $(srcdir)/release/libjpeg-turbo.nsi
+
+else
+
+sunpkg: all
+ sh $(srcdir)/release/makesunpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \
+ ${DEBARCH} ${srcdir} $(CC) $(CXX)
+
+nsi: all
+ makensis -nocd -DVERSION=$(VERSION) -DAPPNAME=libjpeg-turbo-gcc \
+ -DWLIBDIR=.libs -DWSRCDIR=$(srcdir) -DWBLDDIR=. -DWHDRDIR=. \
+ -DPLATFORM="GCC" -DGCC $(srcdir)/release/libjpeg-turbo.nsi
+
+endif
+
+cygwinpkg: all
+ sh $(srcdir)/release/makecygwinpkg ${PACKAGE_NAME} ${VERSION} ${srcdir}
-# IJG auto-configuration source file.
+# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-#
-# Configure script for IJG libjpeg
-#
+AC_PREREQ([2.56])
+AC_INIT([libjpeg-turbo], [1.0.1])
+BUILD=`date +%Y%m%d`
-AC_INIT([libjpeg], [8.0.2])
+AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
+AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
-# Directory where autotools helper scripts lives.
-AC_CONFIG_AUX_DIR([.])
+# Always build with prototypes
+AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
-# Generate configuration headers.
-AC_CONFIG_HEADERS([jconfig.h:jconfig.cfg])
-
-# Hack: disable autoheader so that it doesn't overwrite our cfg template.
-AUTOHEADER="echo autoheader ignored"
-
-# Check system type
-AC_CANONICAL_TARGET
-
-# Initialize Automake
-# Don't require all the GNU mandated files
-AM_INIT_AUTOMAKE([-Wall -Werror ansi2knr no-dist foreign])
-
-# Make --enable-silent-rules the default.
-# To get verbose build output you may configure
-# with --disable-silent-rules or use "make V=1".
-AM_SILENT_RULES([yes])
-
-# This is required when using the de-ANSI-fication feature.
-AM_C_PROTOTYPES
-
-# Add configure option --enable-maintainer-mode which enables
-# dependency checking and generation useful to package maintainers.
-# This is made an option to avoid confusing end users.
-AM_MAINTAINER_MODE
-
-# Check for programs
-AC_PROG_CC
-AC_PROG_CC_STDC
+# Checks for programs.
+SAVED_CFLAGS=${CFLAGS}
+SAVED_CXXFLAGS=${CXXFLAGS}
AC_PROG_CPP
+AC_PROG_CC
+AC_PROG_CXX
AC_PROG_INSTALL
-AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
AC_PROG_LN_S
-# Check if LD supports linker scripts,
-# and define automake conditional HAVE_LD_VERSION_SCRIPT if so.
-AC_ARG_ENABLE([ld-version-script],
- AS_HELP_STRING([--enable-ld-version-script],
- [enable linker version script (default is enabled when possible)]),
- [have_ld_version_script=$enableval], [])
-if test -z "$have_ld_version_script"; then
- AC_MSG_CHECKING([if LD -Wl,--version-script works])
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
- cat > conftest.map <<EOF
-VERS_1 {
- global: sym;
-};
-
-VERS_2 {
- global: sym;
-} VERS_1;
-EOF
- AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
- [have_ld_version_script=yes], [have_ld_version_script=no])
- rm -f conftest.map
- LDFLAGS="$save_LDFLAGS"
- AC_MSG_RESULT($have_ld_version_script)
-fi
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
-
-# See if compiler supports prototypes.
-AC_MSG_CHECKING(for function prototypes)
-AC_CACHE_VAL(ijg_cv_have_prototypes,
-[AC_TRY_COMPILE([
-int testfunction (int arg1, int * arg2); /* check prototypes */
-struct methods_struct { /* check method-pointer declarations */
- int (*error_exit) (char *msgtext);
- int (*trace_message) (char *msgtext);
- int (*another_method) (void);
-};
-int testfunction (int arg1, int * arg2) /* check definitions */
-{ return arg2[arg1]; }
-int test2function (void) /* check void arg list */
-{ return 0; }
-], [ ], ijg_cv_have_prototypes=yes, ijg_cv_have_prototypes=no)])
-AC_MSG_RESULT($ijg_cv_have_prototypes)
-if test $ijg_cv_have_prototypes = yes; then
- AC_DEFINE([HAVE_PROTOTYPES],[1],[Compiler supports function prototypes.])
+# Check whether compiler supports pointers to undefined structures
+AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
+AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
+AC_MSG_RESULT(yes),
+[AC_MSG_RESULT(no)
+AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])])
+
+AC_MSG_CHECKING([whether the linker supports version scripts])
+VERSION_SCRIPT=no
+LDVER=`$LD --help </dev/null 2>&1 | grep "\-\-version-script"`
+if test "$LDVER"; then
+ VERSION_SCRIPT=yes
+ VERSION_SCRIPT_FLAG=-Wl,--version-script,
+ AC_MSG_RESULT(yes)
else
- echo Your compiler does not seem to know about function prototypes.
- echo Perhaps it needs a special switch to enable ANSI C mode.
- echo If so, we recommend running configure like this:
- echo " ./configure CC='cc -switch'"
- echo where -switch is the proper switch.
+ LDVER=`$LD --help </dev/null 2>&1 | grep "\-M"`
+ if test "$LDVER"; then
+ VERSION_SCRIPT=yes
+ VERSION_SCRIPT_FLAG=-Wl,-M,
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
fi
-# Check header files
-AC_CHECK_HEADERS(stddef.h stdlib.h locale.h)
-AC_CHECK_HEADER(string.h, , AC_DEFINE([NEED_BSD_STRINGS],[1],[Compiler has <strings.h> rather than standard <string.h>.]))
+AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
+AC_SUBST(VERSION_SCRIPT_FLAG)
-# See whether type size_t is defined in any ANSI-standard places;
-# if not, perhaps it is defined in <sys/types.h>.
-AC_MSG_CHECKING(for size_t)
-AC_TRY_COMPILE([
-#ifdef HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <stdio.h>
-#ifdef NEED_BSD_STRINGS
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-typedef size_t my_size_t;
-], [ my_size_t foovar; ], ijg_size_t_ok=yes,
-[ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
-AC_MSG_RESULT($ijg_size_t_ok)
-if test "$ijg_size_t_ok" != yes; then
-AC_CHECK_HEADER(sys/types.h, [AC_DEFINE([NEED_SYS_TYPES_H],[1],[Need to include <sys/types.h> in order to obtain size_t.])
-AC_EGREP_CPP(size_t, [#include <sys/types.h>],
-[ijg_size_t_ok="size_t is in sys/types.h"], ijg_size_t_ok=no)],
-ijg_size_t_ok=no)
-AC_MSG_RESULT($ijg_size_t_ok)
-if test "$ijg_size_t_ok" = no; then
- echo Type size_t is not defined in any of the usual places.
- echo Try putting '"typedef unsigned int size_t;"' in jconfig.h.
-fi
+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
-# Check compiler characteristics
-AC_MSG_CHECKING(for type unsigned char)
-AC_TRY_COMPILE(, [ unsigned char un_char; ],
-[AC_MSG_RESULT(yes)
-AC_DEFINE([HAVE_UNSIGNED_CHAR],[1],[Compiler supports 'unsigned char'.])], AC_MSG_RESULT(no))
-dnl
-AC_MSG_CHECKING(for type unsigned short)
-AC_TRY_COMPILE(, [ unsigned short un_short; ],
-[AC_MSG_RESULT(yes)
-AC_DEFINE([HAVE_UNSIGNED_SHORT],[1],[Compiler supports 'unsigned short'.])], AC_MSG_RESULT(no))
-dnl
-AC_MSG_CHECKING(for type void)
-AC_TRY_COMPILE([
-/* Caution: a C++ compiler will insist on valid prototypes */
-typedef void * void_ptr; /* check void * */
-#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */
-typedef void (*void_func) (int a, int b);
-#else
-typedef void (*void_func) ();
-#endif
-
-#ifdef HAVE_PROTOTYPES /* check void function result */
-void test3function (void_ptr arg1, void_func arg2)
-#else
-void test3function (arg1, arg2)
- void_ptr arg1;
- void_func arg2;
-#endif
-{
- char * locptr = (char *) arg1; /* check casting to and from void * */
- arg1 = (void *) locptr;
- (*arg2) (1, 2); /* check call of fcn returning void */
-}
-], [ ], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
-AC_DEFINE([void],[char],[Define 'void' as 'char' for archaic compilers that don't understand it.])])
-AC_C_CONST
-
-# Check for non-broken inline under various spellings
-AC_MSG_CHECKING(for inline)
-ijg_cv_inline=""
-AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
-int bar() { return foo();], ijg_cv_inline="__inline__",
-AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
-int bar() { return foo();], ijg_cv_inline="__inline",
-AC_TRY_COMPILE(, [} inline int foo() { return 0; }
-int bar() { return foo();], ijg_cv_inline="inline")))
-AC_MSG_RESULT($ijg_cv_inline)
-AC_DEFINE_UNQUOTED([INLINE],[$ijg_cv_inline],[How to obtain function inlining.])
-
-# We cannot check for bogus warnings, but at least we can check for errors
-AC_MSG_CHECKING(for broken incomplete types)
-AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
-AC_MSG_RESULT(ok),
-[AC_MSG_RESULT(broken)
-AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to unspecified structures.])])
-
-# Test whether global names are unique to at least 15 chars
-AC_MSG_CHECKING(for short external names)
-AC_TRY_LINK([
-int possibly_duplicate_function () { return 0; }
-int possibly_dupli_function () { return 1; }
-], [ ], AC_MSG_RESULT(ok), [AC_MSG_RESULT(short)
-AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES],[1],[Linker requires that global names be unique in first 15 characters.])])
-
-# Run-time checks
-AC_MSG_CHECKING(to see if char is signed)
-AC_TRY_RUN([
-#ifdef HAVE_PROTOTYPES
-int is_char_signed (int arg)
-#else
-int is_char_signed (arg)
- int arg;
-#endif
-{
- if (arg == 189) { /* expected result for unsigned char */
- return 0; /* type char is unsigned */
- }
- else if (arg != -67) { /* expected result for signed char */
- printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
- printf("I fear the JPEG software will not work at all.\n\n");
- }
- return 1; /* assume char is signed otherwise */
-}
-char signed_char_check = (char) (-67);
-int main() {
- exit(is_char_signed((int) signed_char_check));
-}], [AC_MSG_RESULT(no)
-AC_DEFINE([CHAR_IS_UNSIGNED],[1],[Characters are unsigned])], AC_MSG_RESULT(yes),
-[echo Assuming that char is signed on target machine.
-echo If it is unsigned, this will be a little bit inefficient.
-])
-dnl
-AC_MSG_CHECKING(to see if right shift is signed)
-AC_TRY_RUN([
-#ifdef HAVE_PROTOTYPES
-int is_shifting_signed (long arg)
-#else
-int is_shifting_signed (arg)
- long arg;
-#endif
-/* See whether right-shift on a long is signed or not. */
-{
- long res = arg >> 4;
+AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
+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
- if (res == -0x7F7E80CL) { /* expected result for signed shift */
- return 1; /* right shift is signed */
- }
- /* see if unsigned-shift hack will fix it. */
- /* we can't just test exact value since it depends on width of long... */
- res |= (~0L) << (32-4);
- if (res == -0x7F7E80CL) { /* expected result now? */
- return 0; /* right shift is unsigned */
- }
- printf("Right shift isn't acting as I expect it to.\n");
- printf("I fear the JPEG software will not work at all.\n\n");
- return 0; /* try it with unsigned anyway */
-}
-int main() {
- exit(is_shifting_signed(-0x7F7E80B1L));
-}], [AC_MSG_RESULT(no)
-AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED],[1],[Broken compiler shifts signed values as an unsigned shift.])], AC_MSG_RESULT(yes),
-AC_MSG_RESULT(Assuming that right shift is signed on target machine.))
-dnl
-AC_MSG_CHECKING(to see if fopen accepts b spec)
-AC_TRY_RUN([
-#include <stdio.h>
-int main() {
- if (fopen("conftestdata", "wb") != NULL)
- exit(0);
- exit(1);
-}], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
-AC_DEFINE([DONT_USE_B_MODE],[1],[Don't open files in binary mode.])],
-AC_MSG_RESULT(Assuming that it does.))
+# Checks for libraries.
-# Configure libtool
-AC_LIBTOOL_WIN32_DLL
-AC_PROG_LIBTOOL
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
+AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
-# Select memory manager depending on user input.
-# If no "-enable-maxmem", use jmemnobs
-MEMORYMGR='jmemnobs'
-MAXMEM="no"
-AC_ARG_ENABLE(maxmem,
-[ --enable-maxmem[=N] enable use of temp files, set max mem usage to N MB],
-MAXMEM="$enableval")
-dnl [# support --with-maxmem for backwards compatibility with IJG V5.]
-dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval")
-if test "x$MAXMEM" = xyes; then
- MAXMEM=1
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_CHAR_UNSIGNED
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_CHECK_TYPES([unsigned char, unsigned short])
+
+AC_MSG_CHECKING([if right shift is signed])
+AC_TRY_RUN(
+ [#include <stdio.h>
+ int is_shifting_signed (long arg) {
+ long res = arg >> 4;
+
+ if (res == -0x7F7E80CL)
+ return 1; /* right shift is signed */
+
+ /* see if unsigned-shift hack will fix it. */
+ /* we can't just test exact value since it depends on width of long... */
+ res |= (~0L) << (32-4);
+ if (res == -0x7F7E80CL)
+ return 0; /* right shift is unsigned */
+
+ printf("Right shift isn't acting as I expect it to.\n");
+ printf("I fear the JPEG software will not work at all.\n\n");
+ return 0; /* try it with unsigned anyway */
+ }
+ int main (void) {
+ exit(is_shifting_signed(-0x7F7E80B1L));
+ }],
+ [AC_MSG_RESULT(no)
+ AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
+
+# test whether global names are unique to at least 15 chars
+AC_MSG_CHECKING([for short external names])
+AC_TRY_LINK(
+ [int possibly_duplicate_function () { return 0; }
+ int possibly_dupli_function () { return 1; }], [ ],
+ [AC_MSG_RESULT(ok)],
+ [AC_MSG_RESULT(short)
+ AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])])
+
+# Checks for library functions.
+AC_CHECK_FUNCS([memset memcpy], [],
+ [AC_DEFINE([NEED_BSD_STRINGS], 1,
+ [Define if you have BSD-like bzero and bcopy])])
+
+# Set flags to indicate platform
+case "$host_os" in
+ cygwin* | mingw* | pw32* | interix*)
+ is_win32=1
+ ;;
+esac
+AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"])
+
++AC_ARG_WITH([jpeg7],
++ AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
++AC_ARG_WITH([jpeg8],
++ AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8b API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
++if test "x${with_jpeg8}" == "xyes"; then
++ JPEG_LIB_VERSION=80
++ AC_DEFINE([JPEG_LIB_VERSION], [80], [Version 8.0])
++ AC_MSG_NOTICE([libjpeg v8b API/ABI emulation enabled])
++else
++ if test "x${with_jpeg7}" == "xyes"; then
++ JPEG_LIB_VERSION=70
++ AC_DEFINE([JPEG_LIB_VERSION], [70], [Version 7.0])
++ AC_MSG_NOTICE([libjpeg v7 API/ABI emulation enabled])
++ else
++ JPEG_LIB_VERSION=62
++ AC_DEFINE([JPEG_LIB_VERSION], [62], [Version 6b])
++ fi
+ fi
-if test "x$MAXMEM" != xno; then
- if test -n "`echo $MAXMEM | sed 's/[[0-9]]//g'`"; then
- AC_MSG_ERROR(non-numeric argument to --enable-maxmem)
++AC_SUBST(JPEG_LIB_VERSION)
++
+# SIMD is optional
+AC_ARG_WITH([simd],
+ AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.]))
+if test "x${with_simd}" != "xno"; then
+ # Check if we're on a supported CPU
+ AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
+ case "$host_cpu" in
+ x86_64 | amd64)
+ AC_MSG_RESULT([yes (x86_64)])
+ AC_PROG_NASM
+ simd_arch=x86_64
+ ;;
+ i*86 | x86 | ia32)
+ AC_MSG_RESULT([yes (i386)])
+ AC_PROG_NASM
+ simd_arch=i386
+ ;;
+ *)
+ AC_MSG_RESULT([no ("$host_cpu")])
+ AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
+ with_simd=no;
+ ;;
+ esac
+
+ if test "x${with_simd}" != "xno"; then
+ AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.])
fi
- DEFAULTMAXMEM=`expr $MAXMEM \* 1048576`
-AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}], [Maximum data space library will allocate.])
-AC_MSG_CHECKING([for 'tmpfile()'])
-AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],
-[AC_MSG_RESULT(yes)
-MEMORYMGR='jmemansi'],
-[AC_MSG_RESULT(no)
-dnl if tmpfile is not present, must use jmemname.
-MEMORYMGR='jmemname'
-
-# Test for the need to remove temporary files using a signal handler (for cjpeg/djpeg)
-AC_DEFINE([NEED_SIGNAL_CATCHER],[1],[Need signal handler to clean up temporary files.])
-AC_MSG_CHECKING([for 'mktemp()'])
-AC_TRY_LINK(, [ char fname[80]; mktemp(fname); ], AC_MSG_RESULT(yes),
-[AC_MSG_RESULT(no)
-AC_DEFINE([NO_MKTEMP],[1],[The mktemp() function is not available.])])])
fi
-AC_SUBST(MEMORYMGR)
-
-# Extract the library version ID from jpeglib.h.
-AC_MSG_CHECKING([libjpeg version number])
-[JPEG_LIB_VERSION=`sed -e '/^#define JPEG_LIB_VERSION/!d' -e 's/^[^0-9]*\([0-9][0-9]*\).*$/\1/' $srcdir/jpeglib.h`]
-[JPEG_LIB_VERSION="`expr $JPEG_LIB_VERSION / 10`:2"]
-AC_MSG_RESULT([$JPEG_LIB_VERSION])
-AC_SUBST([JPEG_LIB_VERSION])
-AC_CONFIG_FILES([Makefile])
+AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"])
+AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
+AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
+AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
+
+case "$host_cpu" in
+ x86_64)
+ RPMARCH=x86_64
+ DEBARCH=amd64
+ ;;
+ i*86 | x86 | ia32)
+ RPMARCH=i386
+ DEBARCH=i386
+ ;;
+esac
+
+AC_SUBST(RPMARCH)
+AC_SUBST(DEBARCH)
+AC_SUBST(BUILD)
+
+# jconfig.h is the file we use, but we have another before that to
+# fool autoheader. the reason is that we include this header in our
+# API headers, which can screw things up for users of the lib.
+# jconfig.h is a minimal version that allows this package to be built
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_HEADERS([jconfig.h])
+AC_CONFIG_FILES([Makefile simd/Makefile])
AC_OUTPUT
cinfo->comp_info = NULL;
- for (i = 0; i < NUM_QUANT_TBLS; i++)
+ for (i = 0; i < NUM_QUANT_TBLS; i++) {
cinfo->quant_tbl_ptrs[i] = NULL;
++#if JPEG_LIB_VERSION >= 70
+ cinfo->q_scale_factor[i] = 100;
++#endif
+ }
for (i = 0; i < NUM_HUFF_TBLS; i++) {
cinfo->dc_huff_tbl_ptrs[i] = NULL;
cinfo->ac_huff_tbl_ptrs[i] = NULL;
}
++#if JPEG_LIB_VERSION >= 80
+ /* Must do it here for emit_dqt in case jpeg_write_tables is used */
+ cinfo->block_size = DCTSIZE;
+ cinfo->natural_order = jpeg_natural_order;
+ cinfo->lim_Se = DCTSIZE2-1;
++#endif
+
cinfo->script_space = NULL;
cinfo->input_gamma = 1.0; /* in case application forgets */
* jcmaster.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2003-2010 by Guido Vollbeding.
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* Support routines that do various essential calculations.
*/
-#ifdef DCT_SCALING_SUPPORTED
-
- /* Compute actual JPEG image dimensions and DCT scaling choices. */
- if (cinfo->scale_num >= cinfo->scale_denom * 8) {
- /* Provide 8/1 scaling */
- cinfo->jpeg_width = cinfo->image_width << 3;
- cinfo->jpeg_height = cinfo->image_height << 3;
- cinfo->min_DCT_h_scaled_size = 1;
- cinfo->min_DCT_v_scaled_size = 1;
- } else if (cinfo->scale_num >= cinfo->scale_denom * 4) {
- /* Provide 4/1 scaling */
- cinfo->jpeg_width = cinfo->image_width << 2;
- cinfo->jpeg_height = cinfo->image_height << 2;
- cinfo->min_DCT_h_scaled_size = 2;
- cinfo->min_DCT_v_scaled_size = 2;
- } else if (cinfo->scale_num * 3 >= cinfo->scale_denom * 8) {
- /* Provide 8/3 scaling */
- cinfo->jpeg_width = (cinfo->image_width << 1) + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 2, 3L);
- cinfo->jpeg_height = (cinfo->image_height << 1) + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 2, 3L);
- cinfo->min_DCT_h_scaled_size = 3;
- cinfo->min_DCT_v_scaled_size = 3;
- } else if (cinfo->scale_num >= cinfo->scale_denom * 2) {
- /* Provide 2/1 scaling */
- cinfo->jpeg_width = cinfo->image_width << 1;
- cinfo->jpeg_height = cinfo->image_height << 1;
- cinfo->min_DCT_h_scaled_size = 4;
- cinfo->min_DCT_v_scaled_size = 4;
- } else if (cinfo->scale_num * 5 >= cinfo->scale_denom * 8) {
- /* Provide 8/5 scaling */
- cinfo->jpeg_width = cinfo->image_width + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 3, 5L);
- cinfo->jpeg_height = cinfo->image_height + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 3, 5L);
- cinfo->min_DCT_h_scaled_size = 5;
- cinfo->min_DCT_v_scaled_size = 5;
- } else if (cinfo->scale_num * 3 >= cinfo->scale_denom * 4) {
- /* Provide 4/3 scaling */
- cinfo->jpeg_width = cinfo->image_width + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width, 3L);
- cinfo->jpeg_height = cinfo->image_height + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height, 3L);
- cinfo->min_DCT_h_scaled_size = 6;
- cinfo->min_DCT_v_scaled_size = 6;
- } else if (cinfo->scale_num * 7 >= cinfo->scale_denom * 8) {
- /* Provide 8/7 scaling */
- cinfo->jpeg_width = cinfo->image_width + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width, 7L);
- cinfo->jpeg_height = cinfo->image_height + (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height, 7L);
- cinfo->min_DCT_h_scaled_size = 7;
- cinfo->min_DCT_v_scaled_size = 7;
- } else if (cinfo->scale_num >= cinfo->scale_denom) {
- /* Provide 1/1 scaling */
- cinfo->jpeg_width = cinfo->image_width;
- cinfo->jpeg_height = cinfo->image_height;
- cinfo->min_DCT_h_scaled_size = 8;
- cinfo->min_DCT_v_scaled_size = 8;
- } else if (cinfo->scale_num * 9 >= cinfo->scale_denom * 8) {
- /* Provide 8/9 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 8, 9L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 8, 9L);
- cinfo->min_DCT_h_scaled_size = 9;
- cinfo->min_DCT_v_scaled_size = 9;
- } else if (cinfo->scale_num * 5 >= cinfo->scale_denom * 4) {
- /* Provide 4/5 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 4, 5L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 4, 5L);
- cinfo->min_DCT_h_scaled_size = 10;
- cinfo->min_DCT_v_scaled_size = 10;
- } else if (cinfo->scale_num * 11 >= cinfo->scale_denom * 8) {
- /* Provide 8/11 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 8, 11L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 8, 11L);
- cinfo->min_DCT_h_scaled_size = 11;
- cinfo->min_DCT_v_scaled_size = 11;
- } else if (cinfo->scale_num * 3 >= cinfo->scale_denom * 2) {
- /* Provide 2/3 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 2, 3L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 2, 3L);
- cinfo->min_DCT_h_scaled_size = 12;
- cinfo->min_DCT_v_scaled_size = 12;
- } else if (cinfo->scale_num * 13 >= cinfo->scale_denom * 8) {
- /* Provide 8/13 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 8, 13L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 8, 13L);
- cinfo->min_DCT_h_scaled_size = 13;
- cinfo->min_DCT_v_scaled_size = 13;
- } else if (cinfo->scale_num * 7 >= cinfo->scale_denom * 4) {
- /* Provide 4/7 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 4, 7L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 4, 7L);
- cinfo->min_DCT_h_scaled_size = 14;
- cinfo->min_DCT_v_scaled_size = 14;
- } else if (cinfo->scale_num * 15 >= cinfo->scale_denom * 8) {
- /* Provide 8/15 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 8, 15L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 8, 15L);
- cinfo->min_DCT_h_scaled_size = 15;
- cinfo->min_DCT_v_scaled_size = 15;
- } else {
- /* Provide 1/2 scaling */
- cinfo->jpeg_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width, 2L);
- cinfo->jpeg_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height, 2L);
- cinfo->min_DCT_h_scaled_size = 16;
- cinfo->min_DCT_v_scaled_size = 16;
- }
-
-#else /* !DCT_SCALING_SUPPORTED */
-
++#if JPEG_LIB_VERSION >= 70
+ /*
+ * Compute JPEG image dimensions and related values.
+ * NOTE: this is exported for possible use by application.
+ * Hence it mustn't do anything that can't be done twice.
+ */
+
+ GLOBAL(void)
+ jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
+ /* Do computations that are needed before master selection phase */
+ {
-
-#endif /* DCT_SCALING_SUPPORTED */
-}
-
-
-LOCAL(void)
-jpeg_calc_trans_dimensions (j_compress_ptr cinfo)
-{
- if (cinfo->min_DCT_h_scaled_size < 1 || cinfo->min_DCT_h_scaled_size > 16
- || cinfo->min_DCT_h_scaled_size != cinfo->min_DCT_v_scaled_size)
- ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
- cinfo->min_DCT_h_scaled_size, cinfo->min_DCT_v_scaled_size);
-
- cinfo->block_size = cinfo->min_DCT_h_scaled_size;
-
- switch (cinfo->block_size) {
- case 2: cinfo->natural_order = jpeg_natural_order2; break;
- case 3: cinfo->natural_order = jpeg_natural_order3; break;
- case 4: cinfo->natural_order = jpeg_natural_order4; break;
- case 5: cinfo->natural_order = jpeg_natural_order5; break;
- case 6: cinfo->natural_order = jpeg_natural_order6; break;
- case 7: cinfo->natural_order = jpeg_natural_order7; break;
- default: cinfo->natural_order = jpeg_natural_order; break;
- }
-
- cinfo->lim_Se = cinfo->block_size < DCTSIZE ?
- cinfo->block_size * cinfo->block_size - 1 : DCTSIZE2-1;
+ /* Hardwire it to "no scaling" */
+ cinfo->jpeg_width = cinfo->image_width;
+ cinfo->jpeg_height = cinfo->image_height;
+ cinfo->min_DCT_h_scaled_size = DCTSIZE;
+ cinfo->min_DCT_v_scaled_size = DCTSIZE;
+ }
++#endif
+
+
LOCAL(void)
-initial_setup (j_compress_ptr cinfo, boolean transcode_only)
+initial_setup (j_compress_ptr cinfo)
/* Do computations that are needed before master selection phase */
{
- int ci, ssize;
+ int ci;
jpeg_component_info *compptr;
long samplesperrow;
JDIMENSION jd_samplesperrow;
- if (transcode_only)
- jpeg_calc_trans_dimensions(cinfo);
- else
- jpeg_calc_jpeg_dimensions(cinfo);
++#if JPEG_LIB_VERSION >= 70
++ jpeg_calc_jpeg_dimensions(cinfo);
++#endif
+
/* Sanity check on image dimensions */
- if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 ||
- cinfo->num_components <= 0 || cinfo->input_components <= 0)
+ if (cinfo->image_height <= 0 || cinfo->image_width <= 0
+ || cinfo->num_components <= 0 || cinfo->input_components <= 0)
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
/* Make sure image isn't bigger than I can handle */
ci++, compptr++) {
/* Fill in the correct component_index value; don't rely on application */
compptr->component_index = ci;
- /* In selecting the actual DCT scaling for each component, we try to
- * scale down the chroma components via DCT scaling rather than downsampling.
- * This saves time if the downsampler gets to use 1:1 scaling.
- * Note this code adapts subsampling ratios which are powers of 2.
- */
- ssize = 1;
-#ifdef DCT_SCALING_SUPPORTED
- while (cinfo->min_DCT_h_scaled_size * ssize <=
- (cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
- (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
- ssize = ssize * 2;
- }
-#endif
- compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
- ssize = 1;
-#ifdef DCT_SCALING_SUPPORTED
- while (cinfo->min_DCT_v_scaled_size * ssize <=
- (cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
- (cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
- ssize = ssize * 2;
- }
+ /* For compression, we never do DCT scaling. */
++#if JPEG_LIB_VERSION >= 70
++ compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
++#else
+ compptr->DCT_scaled_size = DCTSIZE;
+ #endif
- compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
-
- /* We don't support DCT ratios larger than 2. */
- if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2)
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
- else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
- compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
-
/* Size in DCT blocks */
compptr->width_in_blocks = (JDIMENSION)
- jdiv_round_up((long) cinfo->jpeg_width * (long) compptr->h_samp_factor,
- (long) (cinfo->max_h_samp_factor * cinfo->block_size));
+ jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
+ (long) (cinfo->max_h_samp_factor * DCTSIZE));
compptr->height_in_blocks = (JDIMENSION)
- jdiv_round_up((long) cinfo->jpeg_height * (long) compptr->v_samp_factor,
- (long) (cinfo->max_v_samp_factor * cinfo->block_size));
+ jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
+ (long) (cinfo->max_v_samp_factor * DCTSIZE));
/* Size in samples */
compptr->downsampled_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->jpeg_width *
- (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size),
- (long) (cinfo->max_h_samp_factor * cinfo->block_size));
+ jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
+ (long) cinfo->max_h_samp_factor);
compptr->downsampled_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->jpeg_height *
- (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
- (long) (cinfo->max_v_samp_factor * cinfo->block_size));
+ jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
+ (long) cinfo->max_v_samp_factor);
/* Mark component needed (this flag isn't actually used for compression) */
compptr->component_needed = TRUE;
}
--- /dev/null
++/* Version ID for the JPEG library.
++ * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
++ */
++#define JPEG_LIB_VERSION 62 /* Version 6b */
++
+/* Define if your compiler supports prototypes */
+#undef HAVE_PROTOTYPES
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if the system has the type `unsigned char'. */
+#undef HAVE_UNSIGNED_CHAR
+
+/* Define to 1 if the system has the type `unsigned short'. */
+#undef HAVE_UNSIGNED_SHORT
+
+/* Define if you want use complete types */
+#undef INCOMPLETE_TYPES_BROKEN
+
+/* Define if you have BSD-like bzero and bcopy */
+#undef NEED_BSD_STRINGS
+
+/* Define if you need short function names */
+#undef NEED_SHORT_EXTERNAL_NAMES
+
+/* Define if you have sys/types.h */
+#undef NEED_SYS_TYPES_H
+
+/* Define if shift is unsigned */
+#undef RIGHT_SHIFT_IS_UNSIGNED
+
+/* Use accelerated SIMD routines. */
+#undef WITH_SIMD
+
+/* Define to 1 if type `char' is unsigned and you are not using gcc. */
+#ifndef __CHAR_UNSIGNED__
+# undef __CHAR_UNSIGNED__
+#endif
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
* jcparam.c
*
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Copyright (C) 2009, D. R. Commander.
+ * Modified 2003-2008 by Guido Vollbeding.
++ * Copyright (C) 2009-2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
}
+ /* These are the sample quantization tables given in JPEG spec section K.1.
+ * The spec says that the values given produce "good" quality, and
+ * when divided by 2, "very good" quality.
+ */
+ static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
+ 16, 11, 10, 16, 24, 40, 51, 61,
+ 12, 12, 14, 19, 26, 58, 60, 55,
+ 14, 13, 16, 24, 40, 57, 69, 56,
+ 14, 17, 22, 29, 51, 87, 80, 62,
+ 18, 22, 37, 56, 68, 109, 103, 77,
+ 24, 35, 55, 64, 81, 104, 113, 92,
+ 49, 64, 78, 87, 103, 121, 120, 101,
+ 72, 92, 95, 98, 112, 100, 103, 99
+ };
+ static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
+ 17, 18, 24, 47, 99, 99, 99, 99,
+ 18, 21, 26, 66, 99, 99, 99, 99,
+ 24, 26, 56, 99, 99, 99, 99, 99,
+ 47, 66, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99
+ };
+
+
++#if JPEG_LIB_VERSION >= 70
+ GLOBAL(void)
+ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
+ /* Set or change the 'quality' (quantization) setting, using default tables
+ * and straight percentage-scaling quality scales.
+ * This entry point allows different scalings for luminance and chrominance.
+ */
+ {
+ /* Set up two quantization tables using the specified scaling */
+ jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
+ cinfo->q_scale_factor[0], force_baseline);
+ jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
+ cinfo->q_scale_factor[1], force_baseline);
+ }
++#endif
+
+
GLOBAL(void)
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
boolean force_baseline)
/* Initialize everything not dependent on the color space */
++#if JPEG_LIB_VERSION >= 70
+ cinfo->scale_num = 1; /* 1:1 scaling */
+ cinfo->scale_denom = 1;
++#endif
cinfo->data_precision = BITS_IN_JSAMPLE;
/* Set up two quantization tables using default quality of 75 */
jpeg_set_quality(cinfo, 75, TRUE);
/* By default, use the simpler non-cosited sampling alignment */
cinfo->CCIR601_sampling = FALSE;
++#if JPEG_LIB_VERSION >= 70
+ /* By default, apply fancy downsampling */
+ cinfo->do_fancy_downsampling = TRUE;
++#endif
+
/* No input smoothing */
cinfo->smoothing_factor = 0;
dstinfo->image_height = srcinfo->image_height;
dstinfo->input_components = srcinfo->num_components;
dstinfo->in_color_space = srcinfo->jpeg_color_space;
++#if JPEG_LIB_VERSION >= 70
+ dstinfo->jpeg_width = srcinfo->output_width;
+ dstinfo->jpeg_height = srcinfo->output_height;
+ dstinfo->min_DCT_h_scaled_size = srcinfo->min_DCT_h_scaled_size;
+ dstinfo->min_DCT_v_scaled_size = srcinfo->min_DCT_v_scaled_size;
++#endif
/* Initialize all parameters to default values */
jpeg_set_defaults(dstinfo);
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
* jdapistd.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
++#include "jpegcomp.h"
/* Forward declarations */
}
/* Verify that at least one iMCU row can be returned. */
- lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;
- lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size;
++ lines_per_iMCU_row = cinfo->max_v_samp_factor * _min_DCT_scaled_size;
if (max_lines < lines_per_iMCU_row)
ERREXIT(cinfo, JERR_BUFFER_SIZE);
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
++#if JPEG_LIB_VERSION >= 80
+ /* Expanded data destination object for memory output */
+
+ typedef struct {
+ struct jpeg_destination_mgr pub; /* public fields */
+
+ unsigned char ** outbuffer; /* target buffer */
+ unsigned long * outsize;
+ unsigned char * newbuffer; /* newly allocated buffer */
+ JOCTET * buffer; /* start of buffer */
+ size_t bufsize;
+ } my_mem_destination_mgr;
+
+ typedef my_mem_destination_mgr * my_mem_dest_ptr;
++#endif
+
+
/*
* Initialize destination --- called by jpeg_start_compress
* before any data is actually written.
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
}
++#if JPEG_LIB_VERSION >= 80
+ METHODDEF(void)
+ init_mem_destination (j_compress_ptr cinfo)
+ {
+ /* no work necessary here */
+ }
++#endif
+
/*
* Empty the output buffer --- called whenever buffer fills up.
return TRUE;
}
++#if JPEG_LIB_VERSION >= 80
+ METHODDEF(boolean)
+ empty_mem_output_buffer (j_compress_ptr cinfo)
+ {
+ size_t nextsize;
+ JOCTET * nextbuffer;
+ my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
+
+ /* Try to allocate new buffer with double size */
+ nextsize = dest->bufsize * 2;
+ nextbuffer = malloc(nextsize);
+
+ if (nextbuffer == NULL)
+ ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
+
+ MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
+
+ if (dest->newbuffer != NULL)
+ free(dest->newbuffer);
+
+ dest->newbuffer = nextbuffer;
+
+ dest->pub.next_output_byte = nextbuffer + dest->bufsize;
+ dest->pub.free_in_buffer = dest->bufsize;
+
+ dest->buffer = nextbuffer;
+ dest->bufsize = nextsize;
+
+ return TRUE;
+ }
++#endif
+
/*
* Terminate destination --- called by jpeg_finish_compress
ERREXIT(cinfo, JERR_FILE_WRITE);
}
++#if JPEG_LIB_VERSION >= 80
+ METHODDEF(void)
+ term_mem_destination (j_compress_ptr cinfo)
+ {
+ my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
+
+ *dest->outbuffer = dest->buffer;
+ *dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
+ }
++#endif
+
/*
* Prepare for output to a stdio stream.
dest->pub.term_destination = term_destination;
dest->outfile = outfile;
}
+
+
++#if JPEG_LIB_VERSION >= 80
+ /*
+ * Prepare for output to a memory buffer.
+ * The caller may supply an own initial buffer with appropriate size.
+ * Otherwise, or when the actual data output exceeds the given size,
+ * the library adapts the buffer size as necessary.
+ * The standard library functions malloc/free are used for allocating
+ * larger memory, so the buffer is available to the application after
+ * finishing compression, and then the application is responsible for
+ * freeing the requested memory.
+ */
+
+ GLOBAL(void)
+ jpeg_mem_dest (j_compress_ptr cinfo,
+ unsigned char ** outbuffer, unsigned long * outsize)
+ {
+ my_mem_dest_ptr dest;
+
+ if (outbuffer == NULL || outsize == NULL) /* sanity check */
+ ERREXIT(cinfo, JERR_BUFFER_SIZE);
+
+ /* The destination object is made permanent so that multiple JPEG images
+ * can be written to the same buffer without re-executing jpeg_mem_dest.
+ */
+ if (cinfo->dest == NULL) { /* first time for this JPEG object? */
+ cinfo->dest = (struct jpeg_destination_mgr *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
+ SIZEOF(my_mem_destination_mgr));
+ }
+
+ dest = (my_mem_dest_ptr) cinfo->dest;
+ dest->pub.init_destination = init_mem_destination;
+ dest->pub.empty_output_buffer = empty_mem_output_buffer;
+ dest->pub.term_destination = term_mem_destination;
+ dest->outbuffer = outbuffer;
+ dest->outsize = outsize;
+ dest->newbuffer = NULL;
+
+ if (*outbuffer == NULL || *outsize == 0) {
+ /* Allocate initial buffer */
+ dest->newbuffer = *outbuffer = malloc(OUTPUT_BUF_SIZE);
+ if (dest->newbuffer == NULL)
+ ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
+ *outsize = OUTPUT_BUF_SIZE;
+ }
+
+ dest->pub.next_output_byte = dest->buffer = *outbuffer;
+ dest->pub.free_in_buffer = dest->bufsize = *outsize;
+ }
++#endif
src->start_of_file = TRUE;
}
++#if JPEG_LIB_VERSION >= 80
+ METHODDEF(void)
+ init_mem_source (j_decompress_ptr cinfo)
+ {
+ /* no work necessary here */
+ }
++#endif
+
/*
* Fill the input buffer --- called whenever buffer is emptied.
return TRUE;
}
++#if JPEG_LIB_VERSION >= 80
+ METHODDEF(boolean)
+ fill_mem_input_buffer (j_decompress_ptr cinfo)
+ {
+ static JOCTET mybuffer[4];
+
+ /* The whole JPEG data is expected to reside in the supplied memory
+ * buffer, so any request for more data beyond the given buffer size
+ * is treated as an error.
+ */
+ WARNMS(cinfo, JWRN_JPEG_EOF);
+ /* Insert a fake EOI marker */
+ mybuffer[0] = (JOCTET) 0xFF;
+ mybuffer[1] = (JOCTET) JPEG_EOI;
+
+ cinfo->src->next_input_byte = mybuffer;
+ cinfo->src->bytes_in_buffer = 2;
+
+ return TRUE;
+ }
++#endif
+
/*
* Skip data --- used to skip over a potentially large amount of
src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
src->pub.next_input_byte = NULL; /* until buffer loaded */
}
+
+
++#if JPEG_LIB_VERSION >= 80
+ /*
+ * Prepare for input from a supplied memory buffer.
+ * The buffer must contain the whole JPEG data.
+ */
+
+ GLOBAL(void)
+ jpeg_mem_src (j_decompress_ptr cinfo,
+ unsigned char * inbuffer, unsigned long insize)
+ {
+ struct jpeg_source_mgr * src;
+
+ if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */
+ ERREXIT(cinfo, JERR_INPUT_EMPTY);
+
+ /* The source object is made permanent so that a series of JPEG images
+ * can be read from the same buffer by calling jpeg_mem_src only before
+ * the first one.
+ */
+ if (cinfo->src == NULL) { /* first time for this JPEG object? */
+ cinfo->src = (struct jpeg_source_mgr *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
+ SIZEOF(struct jpeg_source_mgr));
+ }
+
+ src = cinfo->src;
+ src->init_source = init_mem_source;
+ src->fill_input_buffer = fill_mem_input_buffer;
+ src->skip_input_data = skip_input_data;
+ src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
+ src->term_source = term_source;
+ src->bytes_in_buffer = (size_t) insize;
+ src->next_input_byte = (JOCTET *) inbuffer;
+ }
++#endif
* jdcoefct.c
*
* Copyright (C) 1994-1997, Thomas G. Lane.
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
++#include "jpegcomp.h"
/* Block smoothing is only applicable for progressive JPEG, so: */
#ifndef D_PROGRESSIVE_SUPPORTED
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
: compptr->last_col_width;
output_ptr = output_buf[compptr->component_index] +
- yoffset * compptr->DCT_scaled_size;
- yoffset * compptr->DCT_v_scaled_size;
++ yoffset * _DCT_scaled_size;
start_col = MCU_col_num * compptr->MCU_sample_width;
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
if (cinfo->input_iMCU_row < last_iMCU_row ||
(*inverse_DCT) (cinfo, compptr,
(JCOEFPTR) coef->MCU_buffer[blkn+xindex],
output_ptr, output_col);
- output_col += compptr->DCT_scaled_size;
- output_col += compptr->DCT_h_scaled_size;
++ output_col += _DCT_scaled_size;
}
}
blkn += compptr->MCU_width;
- output_ptr += compptr->DCT_scaled_size;
- output_ptr += compptr->DCT_v_scaled_size;
++ output_ptr += _DCT_scaled_size;
}
}
}
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
output_ptr, output_col);
buffer_ptr++;
- output_col += compptr->DCT_scaled_size;
- output_col += compptr->DCT_h_scaled_size;
++ output_col += _DCT_scaled_size;
}
- output_ptr += compptr->DCT_scaled_size;
- output_ptr += compptr->DCT_v_scaled_size;
++ output_ptr += _DCT_scaled_size;
}
}
DC4 = DC5; DC5 = DC6;
DC7 = DC8; DC8 = DC9;
buffer_ptr++, prev_block_row++, next_block_row++;
- output_col += compptr->DCT_scaled_size;
- output_col += compptr->DCT_h_scaled_size;
++ output_col += _DCT_scaled_size;
}
- output_ptr += compptr->DCT_scaled_size;
- output_ptr += compptr->DCT_v_scaled_size;
++ output_ptr += _DCT_scaled_size;
}
}
* jddctmgr.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2002-2010 by Guido Vollbeding.
+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#include "jinclude.h"
#include "jpeglib.h"
#include "jdct.h" /* Private declarations for DCT subsystem */
+#include "jsimddct.h"
++#include "jpegcomp.h"
/*
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
/* Select the proper IDCT routine for this component's scaling */
- switch (compptr->DCT_scaled_size) {
- switch ((compptr->DCT_h_scaled_size << 8) + compptr->DCT_v_scaled_size) {
++ switch (_DCT_scaled_size) {
#ifdef IDCT_SCALING_SUPPORTED
- case ((1 << 8) + 1):
+ case 1:
method_ptr = jpeg_idct_1x1;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((2 << 8) + 2):
- method_ptr = jpeg_idct_2x2;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((3 << 8) + 3):
- method_ptr = jpeg_idct_3x3;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((4 << 8) + 4):
- method_ptr = jpeg_idct_4x4;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((5 << 8) + 5):
- method_ptr = jpeg_idct_5x5;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((6 << 8) + 6):
- method_ptr = jpeg_idct_6x6;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((7 << 8) + 7):
- method_ptr = jpeg_idct_7x7;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((9 << 8) + 9):
- method_ptr = jpeg_idct_9x9;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((10 << 8) + 10):
- method_ptr = jpeg_idct_10x10;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((11 << 8) + 11):
- method_ptr = jpeg_idct_11x11;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((12 << 8) + 12):
- method_ptr = jpeg_idct_12x12;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((13 << 8) + 13):
- method_ptr = jpeg_idct_13x13;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((14 << 8) + 14):
- method_ptr = jpeg_idct_14x14;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((15 << 8) + 15):
- method_ptr = jpeg_idct_15x15;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((16 << 8) + 16):
- method_ptr = jpeg_idct_16x16;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((16 << 8) + 8):
- method_ptr = jpeg_idct_16x8;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((14 << 8) + 7):
- method_ptr = jpeg_idct_14x7;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((12 << 8) + 6):
- method_ptr = jpeg_idct_12x6;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((10 << 8) + 5):
- method_ptr = jpeg_idct_10x5;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((8 << 8) + 4):
- method_ptr = jpeg_idct_8x4;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((6 << 8) + 3):
- method_ptr = jpeg_idct_6x3;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((4 << 8) + 2):
- method_ptr = jpeg_idct_4x2;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((2 << 8) + 1):
- method_ptr = jpeg_idct_2x1;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((8 << 8) + 16):
- method_ptr = jpeg_idct_8x16;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((7 << 8) + 14):
- method_ptr = jpeg_idct_7x14;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((6 << 8) + 12):
- method_ptr = jpeg_idct_6x12;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((5 << 8) + 10):
- method_ptr = jpeg_idct_5x10;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((4 << 8) + 8):
- method_ptr = jpeg_idct_4x8;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((3 << 8) + 6):
- method_ptr = jpeg_idct_3x6;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((2 << 8) + 4):
- method_ptr = jpeg_idct_2x4;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
- break;
- case ((1 << 8) + 2):
- method_ptr = jpeg_idct_1x2;
- method = JDCT_ISLOW; /* jidctint uses islow-style table */
+ method = JDCT_ISLOW; /* jidctred uses islow-style table */
+ break;
+ case 2:
+ if (jsimd_can_idct_2x2())
+ method_ptr = jsimd_idct_2x2;
+ else
+ method_ptr = jpeg_idct_2x2;
+ method = JDCT_ISLOW; /* jidctred uses islow-style table */
+ break;
+ case 4:
+ if (jsimd_can_idct_4x4())
+ method_ptr = jsimd_idct_4x4;
+ else
+ method_ptr = jpeg_idct_4x4;
+ method = JDCT_ISLOW; /* jidctred uses islow-style table */
break;
#endif
- case ((DCTSIZE << 8) + DCTSIZE):
+ case DCTSIZE:
switch (cinfo->dct_method) {
#ifdef DCT_ISLOW_SUPPORTED
case JDCT_ISLOW:
}
break;
default:
- ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size);
- ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
- compptr->DCT_h_scaled_size, compptr->DCT_v_scaled_size);
++ ERREXIT1(cinfo, JERR_BAD_DCTSIZE, _DCT_scaled_size);
break;
}
idct->pub.inverse_DCT[ci] = method_ptr;
* jdhuff.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2006-2009 by Guido Vollbeding.
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* storage only upon successful completion of an MCU.
*/
- /* Modifications:
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-
-
-/* Derived data constructed for each Huffman table */
-
-#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */
-
-typedef struct {
- /* Basic tables: (element [0] of each array is unused) */
- INT32 maxcode[18]; /* largest code of length k (-1 if none) */
- /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */
- INT32 valoffset[17]; /* huffval[] offset for codes of length k */
- /* valoffset[k] = huffval[] index of 1st symbol of code length k, less
- * the smallest code of length k; so given a code of length k, the
- * corresponding symbol is huffval[code + valoffset[k]]
- */
-
- /* Link to public Huffman table (needed only in jpeg_huff_decode) */
- JHUFF_TBL *pub;
-
- /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of
- * the input data stream. If the next Huffman code is no more
- * than HUFF_LOOKAHEAD bits long, we can obtain its length and
- * the corresponding symbol directly from these tables.
- */
- int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */
- UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */
-} d_derived_tbl;
-
-
-/*
- * Fetching the next N bits from the input stream is a time-critical operation
- * for the Huffman decoders. We implement it with a combination of inline
- * macros and out-of-line subroutines. Note that N (the number of bits
- * demanded at one time) never exceeds 15 for JPEG use.
++/* Performance enhancements:
+ * Copyright (C)2007 Sun Microsystems, Inc.
+ * Copyright (C)2009-2010 D. R. Commander
*
- * We read source bytes into get_buffer and dole out bits as needed.
- * If get_buffer already contains enough bits, they are fetched in-line
- * by the macros CHECK_BIT_BUFFER and GET_BITS. When there aren't enough
- * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer
- * as full as possible (not just to the number of bits needed; this
- * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer).
- * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension.
- * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains
- * at least the requested number of bits --- dummy zeroes are inserted if
- * necessary.
- */
-
-typedef INT32 bit_buf_type; /* type of bit-extraction buffer */
-#define BIT_BUF_SIZE 32 /* size of buffer in bits */
-
-/* If long is > 32 bits on your machine, and shifting/masking longs is
- * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE
- * appropriately should be a win. Unfortunately we can't define the size
- * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8)
- * because not all machines measure sizeof in 8-bit bytes.
- */
-
-typedef struct { /* Bitreading state saved across MCUs */
- bit_buf_type get_buffer; /* current bit-extraction buffer */
- int bits_left; /* # of unused bits in it */
-} bitread_perm_state;
-
-typedef struct { /* Bitreading working state within an MCU */
- /* Current data source location */
- /* We need a copy, rather than munging the original, in case of suspension */
- const JOCTET * next_input_byte; /* => next byte to read from source */
- size_t bytes_in_buffer; /* # of bytes remaining in source buffer */
- /* Bit input buffer --- note these values are kept in register variables,
- * not in this struct, inside the inner loops.
- */
- bit_buf_type get_buffer; /* current bit-extraction buffer */
- int bits_left; /* # of unused bits in it */
- /* Pointer needed by jpeg_fill_bit_buffer. */
- j_decompress_ptr cinfo; /* back link to decompress master record */
-} bitread_working_state;
-
-/* Macros to declare and load/save bitread local variables. */
-#define BITREAD_STATE_VARS \
- register bit_buf_type get_buffer; \
- register int bits_left; \
- bitread_working_state br_state
-
-#define BITREAD_LOAD_STATE(cinfop,permstate) \
- br_state.cinfo = cinfop; \
- br_state.next_input_byte = cinfop->src->next_input_byte; \
- br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
- get_buffer = permstate.get_buffer; \
- bits_left = permstate.bits_left;
-
-#define BITREAD_SAVE_STATE(cinfop,permstate) \
- cinfop->src->next_input_byte = br_state.next_input_byte; \
- cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
- permstate.get_buffer = get_buffer; \
- permstate.bits_left = bits_left
-
-/*
- * These macros provide the in-line portion of bit fetching.
- * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer
- * before using GET_BITS, PEEK_BITS, or DROP_BITS.
- * The variables get_buffer and bits_left are assumed to be locals,
- * but the state struct might not be (jpeg_huff_decode needs this).
- * CHECK_BIT_BUFFER(state,n,action);
- * Ensure there are N bits in get_buffer; if suspend, take action.
- * val = GET_BITS(n);
- * Fetch next N bits.
- * val = PEEK_BITS(n);
- * Fetch next N bits without removing them from the buffer.
- * DROP_BITS(n);
- * Discard next N bits.
- * The value N should be a simple variable, not an expression, because it
- * is evaluated multiple times.
- */
-
-#define CHECK_BIT_BUFFER(state,nbits,action) \
- { if (bits_left < (nbits)) { \
- if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \
- { action; } \
- get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }
-
-#define GET_BITS(nbits) \
- (((int) (get_buffer >> (bits_left -= (nbits)))) & BIT_MASK(nbits))
-
-#define PEEK_BITS(nbits) \
- (((int) (get_buffer >> (bits_left - (nbits)))) & BIT_MASK(nbits))
-
-#define DROP_BITS(nbits) \
- (bits_left -= (nbits))
-
-
-/*
- * Code for extracting next Huffman-coded symbol from input bit stream.
- * Again, this is time-critical and we make the main paths be macros.
- *
- * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits
- * without looping. Usually, more than 95% of the Huffman codes will be 8
- * or fewer bits long. The few overlength codes are handled with a loop,
- * which need not be inline code.
+ * 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)
+ * any later version. The full license is in the LICENSE.txt file included
+ * with this distribution.
*
- * Notes about the HUFF_DECODE macro:
- * 1. Near the end of the data segment, we may fail to get enough bits
- * for a lookahead. In that case, we do it the hard way.
- * 2. If the lookahead table contains no entry, the next code must be
- * more than HUFF_LOOKAHEAD bits long.
- * 3. jpeg_huff_decode returns -1 if forced to suspend.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * wxWindows Library License for more details.
*/
-#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \
-{ register int nb, look; \
- if (bits_left < HUFF_LOOKAHEAD) { \
- if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
- get_buffer = state.get_buffer; bits_left = state.bits_left; \
- if (bits_left < HUFF_LOOKAHEAD) { \
- nb = 1; goto slowlabel; \
- } \
- } \
- look = PEEK_BITS(HUFF_LOOKAHEAD); \
- if ((nb = htbl->look_nbits[look]) != 0) { \
- DROP_BITS(nb); \
- result = htbl->look_sym[look]; \
- } else { \
- nb = HUFF_LOOKAHEAD+1; \
-slowlabel: \
- if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \
- { failaction; } \
- get_buffer = state.get_buffer; bits_left = state.bits_left; \
- } \
-}
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jdhuff.h" /* Declarations shared with jdphuff.c */
++#include "jpegcomp.h"
/*
typedef huff_entropy_decoder * huff_entropy_ptr;
-static const int jpeg_zigzag_order[8][8] = {
- { 0, 1, 5, 6, 14, 15, 27, 28 },
- { 2, 4, 7, 13, 16, 26, 29, 42 },
- { 3, 8, 12, 17, 25, 30, 41, 43 },
- { 9, 11, 18, 24, 31, 40, 44, 53 },
- { 10, 19, 23, 32, 39, 45, 52, 54 },
- { 20, 22, 33, 38, 46, 51, 55, 60 },
- { 21, 34, 37, 47, 50, 56, 59, 61 },
- { 35, 36, 48, 49, 57, 58, 62, 63 }
-};
-
-static const int jpeg_zigzag_order7[7][7] = {
- { 0, 1, 5, 6, 14, 15, 27 },
- { 2, 4, 7, 13, 16, 26, 28 },
- { 3, 8, 12, 17, 25, 29, 38 },
- { 9, 11, 18, 24, 30, 37, 39 },
- { 10, 19, 23, 31, 36, 40, 45 },
- { 20, 22, 32, 35, 41, 44, 46 },
- { 21, 33, 34, 42, 43, 47, 48 }
-};
-
-static const int jpeg_zigzag_order6[6][6] = {
- { 0, 1, 5, 6, 14, 15 },
- { 2, 4, 7, 13, 16, 25 },
- { 3, 8, 12, 17, 24, 26 },
- { 9, 11, 18, 23, 27, 32 },
- { 10, 19, 22, 28, 31, 33 },
- { 20, 21, 29, 30, 34, 35 }
-};
-
-static const int jpeg_zigzag_order5[5][5] = {
- { 0, 1, 5, 6, 14 },
- { 2, 4, 7, 13, 15 },
- { 3, 8, 12, 16, 21 },
- { 9, 11, 17, 20, 22 },
- { 10, 18, 19, 23, 24 }
-};
-
-static const int jpeg_zigzag_order4[4][4] = {
- { 0, 1, 5, 6 },
- { 2, 4, 7, 12 },
- { 3, 8, 11, 13 },
- { 9, 10, 14, 15 }
-};
-
-static const int jpeg_zigzag_order3[3][3] = {
- { 0, 1, 5 },
- { 2, 4, 6 },
- { 3, 7, 8 }
-};
-
-static const int jpeg_zigzag_order2[2][2] = {
- { 0, 1 },
- { 2, 3 }
-};
+/*
+ * Initialize for a Huffman-compressed scan.
+ */
+
+METHODDEF(void)
+start_pass_huff_decoder (j_decompress_ptr cinfo)
+{
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
+ int ci, blkn, dctbl, actbl;
+ jpeg_component_info * compptr;
+
+ /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
+ * This ought to be an error condition, but we make it a warning because
+ * there are some baseline files out there with all zeroes in these bytes.
+ */
+ if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 ||
+ cinfo->Ah != 0 || cinfo->Al != 0)
+ WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
+
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ dctbl = compptr->dc_tbl_no;
+ actbl = compptr->ac_tbl_no;
+ /* Compute derived values for Huffman tables */
+ /* We may do this more than once for a table, but it's not expensive */
+ jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl,
+ & entropy->dc_derived_tbls[dctbl]);
+ jpeg_make_d_derived_tbl(cinfo, FALSE, actbl,
+ & entropy->ac_derived_tbls[actbl]);
+ /* Initialize DC predictions to 0 */
+ entropy->saved.last_dc_val[ci] = 0;
+ }
+
+ /* Precalculate decoding info for each block in an MCU of this scan */
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
+ ci = cinfo->MCU_membership[blkn];
+ compptr = cinfo->cur_comp_info[ci];
+ /* Precalculate which table to use for each block */
+ entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
+ entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
+ /* Decide whether we really care about the coefficient values */
+ if (compptr->component_needed) {
+ entropy->dc_needed[blkn] = TRUE;
+ /* we don't need the ACs if producing a 1/8th-size image */
- entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1);
++ entropy->ac_needed[blkn] = (_DCT_scaled_size > 1);
+ } else {
+ entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE;
+ }
+ }
+
+ /* Initialize bitread state variables */
+ entropy->bitstate.bits_left = 0;
+ entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
+ entropy->pub.insufficient_data = FALSE;
+
+ /* Initialize restart counter */
+ entropy->restarts_to_go = cinfo->restart_interval;
+}
/*
* jdinput.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2002-2009 by Guido Vollbeding.
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
++#include "jpegcomp.h"
/* Private state */
* Routines to calculate various quantities related to the size of the image.
*/
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 3) {
- /* Provide 3/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 3L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 3L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 3;
- cinfo->min_DCT_v_scaled_size = 3;
+
++#if JPEG_LIB_VERSION >= 80
+ /*
+ * Compute output image dimensions and related values.
+ * NOTE: this is exported for possible use by application.
+ * Hence it mustn't do anything that can't be done twice.
+ */
+
+ GLOBAL(void)
+ jpeg_core_output_dimensions (j_decompress_ptr cinfo)
+ /* Do computations that are needed before master selection phase.
+ * This function is used for transcoding and full decompression.
+ */
+ {
+ #ifdef IDCT_SCALING_SUPPORTED
+ int ci;
+ jpeg_component_info *compptr;
+
+ /* Compute actual output image dimensions and DCT scaling choices. */
+ if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom) {
+ /* Provide 1/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_width, (long) cinfo->block_size);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_height, (long) cinfo->block_size);
+ cinfo->min_DCT_h_scaled_size = 1;
+ cinfo->min_DCT_v_scaled_size = 1;
+ } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 2) {
+ /* Provide 2/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_width * 2L, (long) cinfo->block_size);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_height * 2L, (long) cinfo->block_size);
+ cinfo->min_DCT_h_scaled_size = 2;
+ cinfo->min_DCT_v_scaled_size = 2;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 5) {
- /* Provide 5/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 5L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 5L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 5;
- cinfo->min_DCT_v_scaled_size = 5;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 6) {
- /* Provide 6/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 6L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 6L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 6;
- cinfo->min_DCT_v_scaled_size = 6;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 7) {
- /* Provide 7/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 7L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 7L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 7;
- cinfo->min_DCT_v_scaled_size = 7;
+ } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 4) {
+ /* Provide 4/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_width * 4L, (long) cinfo->block_size);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_height * 4L, (long) cinfo->block_size);
+ cinfo->min_DCT_h_scaled_size = 4;
+ cinfo->min_DCT_v_scaled_size = 4;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 9) {
- /* Provide 9/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 9L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 9L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 9;
- cinfo->min_DCT_v_scaled_size = 9;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 10) {
- /* Provide 10/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 10L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 10L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 10;
- cinfo->min_DCT_v_scaled_size = 10;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 11) {
- /* Provide 11/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 11L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 11L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 11;
- cinfo->min_DCT_v_scaled_size = 11;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 12) {
- /* Provide 12/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 12L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 12L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 12;
- cinfo->min_DCT_v_scaled_size = 12;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 13) {
- /* Provide 13/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 13L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 13L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 13;
- cinfo->min_DCT_v_scaled_size = 13;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 14) {
- /* Provide 14/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 14L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 14L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 14;
- cinfo->min_DCT_v_scaled_size = 14;
- } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 15) {
- /* Provide 15/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 15L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 15L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 15;
- cinfo->min_DCT_v_scaled_size = 15;
- } else {
- /* Provide 16/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width * 16L, (long) cinfo->block_size);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * 16L, (long) cinfo->block_size);
- cinfo->min_DCT_h_scaled_size = 16;
- cinfo->min_DCT_v_scaled_size = 16;
+ } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 8) {
+ /* Provide 8/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_width * 8L, (long) cinfo->block_size);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_height * 8L, (long) cinfo->block_size);
+ cinfo->min_DCT_h_scaled_size = 8;
+ cinfo->min_DCT_v_scaled_size = 8;
-
+ }
+ /* Recompute dimensions of components */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size;
+ compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size;
+ }
+
+ #else /* !IDCT_SCALING_SUPPORTED */
+
+ /* Hardwire it to "no scaling" */
+ cinfo->output_width = cinfo->image_width;
+ cinfo->output_height = cinfo->image_height;
+ /* jdinput.c has already initialized DCT_scaled_size,
+ * and has computed unscaled downsampled_width and downsampled_height.
+ */
+
+ #endif /* IDCT_SCALING_SUPPORTED */
+ }
++#endif
+
+
LOCAL(void)
initial_setup (j_decompress_ptr cinfo)
/* Called once, when first SOS marker is reached */
compptr->v_samp_factor);
}
- /* Derive block_size, natural_order, and lim_Se */
- if (cinfo->is_baseline || (cinfo->progressive_mode &&
- cinfo->comps_in_scan)) { /* no pseudo SOS marker */
++#if JPEG_LIB_VERSION >=80
+ cinfo->block_size = DCTSIZE;
+ cinfo->natural_order = jpeg_natural_order;
+ cinfo->lim_Se = DCTSIZE2-1;
- } else
- switch (cinfo->Se) {
- case (1*1-1):
- cinfo->block_size = 1;
- cinfo->natural_order = jpeg_natural_order; /* not needed */
- cinfo->lim_Se = cinfo->Se;
- break;
- case (2*2-1):
- cinfo->block_size = 2;
- cinfo->natural_order = jpeg_natural_order2;
- cinfo->lim_Se = cinfo->Se;
- break;
- case (3*3-1):
- cinfo->block_size = 3;
- cinfo->natural_order = jpeg_natural_order3;
- cinfo->lim_Se = cinfo->Se;
- break;
- case (4*4-1):
- cinfo->block_size = 4;
- cinfo->natural_order = jpeg_natural_order4;
- cinfo->lim_Se = cinfo->Se;
- break;
- case (5*5-1):
- cinfo->block_size = 5;
- cinfo->natural_order = jpeg_natural_order5;
- cinfo->lim_Se = cinfo->Se;
- break;
- case (6*6-1):
- cinfo->block_size = 6;
- cinfo->natural_order = jpeg_natural_order6;
- cinfo->lim_Se = cinfo->Se;
- break;
- case (7*7-1):
- cinfo->block_size = 7;
- cinfo->natural_order = jpeg_natural_order7;
- cinfo->lim_Se = cinfo->Se;
- break;
- case (8*8-1):
- cinfo->block_size = 8;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (9*9-1):
- cinfo->block_size = 9;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (10*10-1):
- cinfo->block_size = 10;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (11*11-1):
- cinfo->block_size = 11;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (12*12-1):
- cinfo->block_size = 12;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (13*13-1):
- cinfo->block_size = 13;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (14*14-1):
- cinfo->block_size = 14;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (15*15-1):
- cinfo->block_size = 15;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- case (16*16-1):
- cinfo->block_size = 16;
- cinfo->natural_order = jpeg_natural_order;
- cinfo->lim_Se = DCTSIZE2-1;
- break;
- default:
- ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
- cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
- break;
- }
++#endif
+
- /* We initialize DCT_scaled_size and min_DCT_scaled_size to block_size.
- * In the full decompressor,
- * this will be overridden by jpeg_calc_output_dimensions in jdmaster.c;
- * but in the transcoder,
- * jpeg_calc_output_dimensions is not used, so we must do it here.
+ /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
+ * In the full decompressor, this will be overridden by jdmaster.c;
+ * but in the transcoder, jdmaster.c is not used, so we must do it here.
*/
- cinfo->min_DCT_h_scaled_size = cinfo->block_size;
- cinfo->min_DCT_v_scaled_size = cinfo->block_size;
++#if JPEG_LIB_VERSION >= 70
++ cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = DCTSIZE;
++#else
+ cinfo->min_DCT_scaled_size = DCTSIZE;
++#endif
/* Compute dimensions of components */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- compptr->DCT_h_scaled_size = cinfo->block_size;
- compptr->DCT_v_scaled_size = cinfo->block_size;
++#if JPEG_LIB_VERSION >= 70
++ compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
++#else
+ compptr->DCT_scaled_size = DCTSIZE;
++#endif
/* Size in DCT blocks */
compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
compptr->MCU_width = 1;
compptr->MCU_height = 1;
compptr->MCU_blocks = 1;
- compptr->MCU_sample_width = compptr->DCT_scaled_size;
- compptr->MCU_sample_width = compptr->DCT_h_scaled_size;
++ compptr->MCU_sample_width = _DCT_scaled_size;
compptr->last_col_width = 1;
/* For noninterleaved scans, it is convenient to define last_row_height
* as the number of block rows present in the last iMCU row.
compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
- compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size;
- compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_h_scaled_size;
++ compptr->MCU_sample_width = compptr->MCU_width * _DCT_scaled_size;
/* Figure number of non-dummy blocks in last MCU column & row */
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width;
* jdmainct.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
++#include "jpegcomp.h"
/*
{
my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, rgroup;
- int M = cinfo->min_DCT_scaled_size;
- int M = cinfo->min_DCT_v_scaled_size;
++ int M = _min_DCT_scaled_size;
jpeg_component_info *compptr;
JSAMPARRAY xbuf;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
- cinfo->min_DCT_scaled_size; /* height of a row group of component */
- rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
- cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
++ rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
++ _min_DCT_scaled_size; /* height of a row group of component */
/* Get space for pointer lists --- M+4 row groups in each list.
* We alloc both pointer lists with one call to save a few cycles.
*/
{
my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, i, rgroup;
- int M = cinfo->min_DCT_scaled_size;
- int M = cinfo->min_DCT_v_scaled_size;
++ int M = _min_DCT_scaled_size;
jpeg_component_info *compptr;
JSAMPARRAY buf, xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
- cinfo->min_DCT_scaled_size; /* height of a row group of component */
- rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
- cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
++ rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
++ _min_DCT_scaled_size; /* height of a row group of component */
xbuf0 = main->xbuffer[0][ci];
xbuf1 = main->xbuffer[1][ci];
/* First copy the workspace pointers as-is */
{
my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, i, rgroup;
- int M = cinfo->min_DCT_scaled_size;
- int M = cinfo->min_DCT_v_scaled_size;
++ int M = _min_DCT_scaled_size;
jpeg_component_info *compptr;
JSAMPARRAY xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
- cinfo->min_DCT_scaled_size; /* height of a row group of component */
- rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
- cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
++ rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
++ _min_DCT_scaled_size; /* height of a row group of component */
xbuf0 = main->xbuffer[0][ci];
xbuf1 = main->xbuffer[1][ci];
for (i = 0; i < rgroup; i++) {
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
/* Count sample rows in one iMCU row and in one row group */
- iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size;
- rgroup = iMCUheight / cinfo->min_DCT_scaled_size;
- iMCUheight = compptr->v_samp_factor * compptr->DCT_v_scaled_size;
- rgroup = iMCUheight / cinfo->min_DCT_v_scaled_size;
++ iMCUheight = compptr->v_samp_factor * _DCT_scaled_size;
++ rgroup = iMCUheight / _min_DCT_scaled_size;
/* Count nondummy sample rows remaining for this component */
rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
if (rows_left == 0) rows_left = iMCUheight;
}
/* There are always min_DCT_scaled_size row groups in an iMCU row. */
- rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size;
- rowgroups_avail = (JDIMENSION) cinfo->min_DCT_v_scaled_size;
++ rowgroups_avail = (JDIMENSION) _min_DCT_scaled_size;
/* Note: at the bottom of the image, we may pass extra garbage row groups
* to the postprocessor. The postprocessor has to check for bottom
* of image anyway (at row resolution), so no point in us doing it too.
case CTX_PREPARE_FOR_IMCU:
/* Prepare to process first M-1 row groups of this iMCU row */
main->rowgroup_ctr = 0;
- main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1);
- main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1);
++ main->rowgroups_avail = (JDIMENSION) (_min_DCT_scaled_size - 1);
/* Check for bottom of image: if so, tweak pointers to "duplicate"
* the last sample row, and adjust rowgroups_avail to ignore padding rows.
*/
main->buffer_full = FALSE;
/* Still need to process last row group of this iMCU row, */
/* which is saved at index M+1 of the other xbuffer */
- main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1);
- main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2);
- main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1);
- main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2);
++ main->rowgroup_ctr = (JDIMENSION) (_min_DCT_scaled_size + 1);
++ main->rowgroups_avail = (JDIMENSION) (_min_DCT_scaled_size + 2);
main->context_state = CTX_POSTPONED_ROW;
}
}
* ngroups is the number of row groups we need.
*/
if (cinfo->upsample->need_context_rows) {
- if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */
- if (cinfo->min_DCT_v_scaled_size < 2) /* unsupported, see comments above */
++ if (_min_DCT_scaled_size < 2) /* unsupported, see comments above */
ERREXIT(cinfo, JERR_NOTIMPL);
alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
- ngroups = cinfo->min_DCT_scaled_size + 2;
- ngroups = cinfo->min_DCT_v_scaled_size + 2;
++ ngroups = _min_DCT_scaled_size + 2;
} else {
- ngroups = cinfo->min_DCT_scaled_size;
- ngroups = cinfo->min_DCT_v_scaled_size;
++ ngroups = _min_DCT_scaled_size;
}
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
- cinfo->min_DCT_scaled_size; /* height of a row group of component */
- rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
- cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
++ rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
++ _min_DCT_scaled_size; /* height of a row group of component */
main->buffer[ci] = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE,
- compptr->width_in_blocks * compptr->DCT_scaled_size,
- compptr->width_in_blocks * compptr->DCT_h_scaled_size,
++ compptr->width_in_blocks * _DCT_scaled_size,
(JDIMENSION) (rgroup * ngroups));
}
}
* jdmaster.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Copyright (C) 2009, D. R. Commander.
- * Modified 2002-2009 by Guido Vollbeding.
++ * Copyright (C) 2009-2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
++#include "jpegcomp.h"
/* Private state */
cinfo->comp_info[2].v_samp_factor != 1)
return FALSE;
/* furthermore, it doesn't work if we've scaled the IDCTs differently */
- cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
- cinfo->comp_info[0].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
- cinfo->comp_info[1].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
- cinfo->comp_info[2].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size)
++#if JPEG_LIB_VERSION >= 70
+ if (cinfo->comp_info[0].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
+ cinfo->comp_info[1].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
++ cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size)
+ return FALSE;
++#else
+ if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
+ cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
+ cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
+ return FALSE;
++#endif
/* ??? also need to test for upsample-time rescaling, when & if supported */
return TRUE; /* by golly, it'll work... */
#else
if (cinfo->global_state != DSTATE_READY)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
- /* Compute core output image dimensions and DCT scaling choices. */
- jpeg_core_output_dimensions(cinfo);
-
#ifdef IDCT_SCALING_SUPPORTED
+ /* Compute actual output image dimensions and DCT scaling choices. */
+ if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
+ /* Provide 1/8 scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_width, 8L);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_height, 8L);
++#if JPEG_LIB_VERSION >= 70
++ cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 1;
++#else
+ cinfo->min_DCT_scaled_size = 1;
++#endif
+ } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
+ /* Provide 1/4 scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_width, 4L);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_height, 4L);
++#if JPEG_LIB_VERSION >= 70
++ cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 2;
++#else
+ cinfo->min_DCT_scaled_size = 2;
++#endif
+ } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
+ /* Provide 1/2 scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_width, 2L);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long) cinfo->image_height, 2L);
++#if JPEG_LIB_VERSION >= 70
++ cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 4;
++#else
+ cinfo->min_DCT_scaled_size = 4;
++#endif
+ } else {
+ /* Provide 1/1 scaling */
+ cinfo->output_width = cinfo->image_width;
+ cinfo->output_height = cinfo->image_height;
++#if JPEG_LIB_VERSION >= 70
++ cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = DCTSIZE;
++#else
+ cinfo->min_DCT_scaled_size = DCTSIZE;
++#endif
+ }
/* In selecting the actual DCT scaling for each component, we try to
* scale up the chroma components via IDCT scaling rather than upsampling.
* This saves time if the upsampler gets to use 1:1 scaling.
*/
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- int ssize = cinfo->min_DCT_scaled_size;
- int ssize = 1;
- while (cinfo->min_DCT_h_scaled_size * ssize <=
- (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
- (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
- ssize = ssize * 2;
- }
- compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
- ssize = 1;
- while (cinfo->min_DCT_v_scaled_size * ssize <=
- (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
- (cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
++ int ssize = _min_DCT_scaled_size;
+ while (ssize < DCTSIZE &&
+ (compptr->h_samp_factor * ssize * 2 <=
- cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
++ cinfo->max_h_samp_factor * _min_DCT_scaled_size) &&
+ (compptr->v_samp_factor * ssize * 2 <=
- cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
++ cinfo->max_v_samp_factor * _min_DCT_scaled_size)) {
ssize = ssize * 2;
}
- compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
-
- /* We don't support IDCT ratios larger than 2. */
- if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2)
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
- else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
- compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
++#if JPEG_LIB_VERSION >= 70
++ compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
++#else
+ compptr->DCT_scaled_size = ssize;
++#endif
}
/* Recompute downsampled dimensions of components;
/* Size in samples, after IDCT scaling */
compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width *
- (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),
- (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size),
- (long) (cinfo->max_h_samp_factor * cinfo->block_size));
++ (long) (compptr->h_samp_factor * _DCT_scaled_size),
+ (long) (cinfo->max_h_samp_factor * DCTSIZE));
compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height *
- (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),
- (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
- (long) (cinfo->max_v_samp_factor * cinfo->block_size));
++ (long) (compptr->v_samp_factor * _DCT_scaled_size),
+ (long) (cinfo->max_v_samp_factor * DCTSIZE));
}
+#else /* !IDCT_SCALING_SUPPORTED */
+
+ /* Hardwire it to "no scaling" */
+ cinfo->output_width = cinfo->image_width;
+ cinfo->output_height = cinfo->image_height;
+ /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
+ * and has computed unscaled downsampled_width and downsampled_height.
+ */
+
#endif /* IDCT_SCALING_SUPPORTED */
/* Report number of components in selected colorspace. */
* jdsample.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2002-2008 by Guido Vollbeding.
+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
++ * Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsimd.h"
++#include "jpegcomp.h"
/* Pointer to routine to upsample a single component */
if (cinfo->CCIR601_sampling) /* this isn't supported */
ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
- do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1;
+ /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
+ * so don't ask for it.
+ */
++ do_fancy = cinfo->do_fancy_upsampling && _min_DCT_scaled_size > 1;
+
/* Verify we can handle the sampling factors, select per-component methods,
* and create storage as needed.
*/
/* Compute size of an "input group" after IDCT scaling. This many samples
* are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
*/
- h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) /
- cinfo->min_DCT_scaled_size;
- v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
- cinfo->min_DCT_scaled_size;
- h_in_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) /
- cinfo->min_DCT_h_scaled_size;
- v_in_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
- cinfo->min_DCT_v_scaled_size;
++ h_in_group = (compptr->h_samp_factor * _DCT_scaled_size) /
++ _min_DCT_scaled_size;
++ v_in_group = (compptr->v_samp_factor * _DCT_scaled_size) /
++ _min_DCT_scaled_size;
h_out_group = cinfo->max_h_samp_factor;
v_out_group = cinfo->max_v_samp_factor;
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
* jpeglib.h
*
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Copyright (C) 2009, D. R. Commander.
+ * Modified 2002-2009 by Guido Vollbeding.
++ * Copyright (C) 2009-2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
#include "jmorecfg.h" /* seldom changed options */
- /* Version ID for the JPEG library.
- * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
- */
-
- #define JPEG_LIB_VERSION 62 /* Version 6b */
+ #ifdef __cplusplus
+ #ifndef DONT_USE_EXTERN_C
+ extern "C" {
+ #endif
+ #endif
-/* Version ID for the JPEG library.
- * Might be useful for tests like "#if JPEG_LIB_VERSION >= 80".
- */
-
-#define JPEG_LIB_VERSION 80 /* Version 8.0 */
-
/* Various constants determining the sizes of things.
* All of these are specified by the JPEG standard, so don't change them
*/
JDIMENSION width_in_blocks;
JDIMENSION height_in_blocks;
++#if JPEG_LIB_VERSION >= 70
+ /* Size of a DCT block in samples,
+ * reflecting any scaling we choose to apply during the DCT step.
+ * Values from 1 to 16 are supported.
+ * Note that different components may receive different DCT scalings.
+ */
+ int DCT_h_scaled_size;
+ int DCT_v_scaled_size;
+ /* The downsampled dimensions are the component's actual, unpadded number
+ * of samples at the main buffer (preprocessing/compression interface);
+ * DCT scaling is included, so
+ * downsampled_width = ceil(image_width * Hi/Hmax * DCT_h_scaled_size/DCTSIZE)
+ * and similarly for height.
+ */
++#else
+ /* Size of a DCT block in samples. Always DCTSIZE for compression.
+ * For decompression this is the size of the output from one DCT block,
+ * reflecting any scaling we choose to apply during the IDCT step.
+ * Values of 1,2,4,8 are likely to be supported. Note that different
+ * components may receive different IDCT scalings.
+ */
+ int DCT_scaled_size;
+ /* The downsampled dimensions are the component's actual, unpadded number
+ * of samples at the main buffer (preprocessing/compression interface), thus
+ * downsampled_width = ceil(image_width * Hi/Hmax)
+ * and similarly for height. For decompression, IDCT scaling is included, so
+ * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)
+ */
++#endif
JDIMENSION downsampled_width; /* actual width in samples */
JDIMENSION downsampled_height; /* actual height in samples */
/* This flag is used only for decompression. In cases where some of the
int MCU_width; /* number of blocks per MCU, horizontally */
int MCU_height; /* number of blocks per MCU, vertically */
int MCU_blocks; /* MCU_width * MCU_height */
- int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */
- int MCU_sample_width; /* MCU width in samples: MCU_width * DCT_h_scaled_size */
++ int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
int last_col_width; /* # of non-dummy blocks across in last MCU */
int last_row_height; /* # of non-dummy blocks down in last MCU */
* helper routines to simplify changing parameters.
*/
++#if JPEG_LIB_VERSION >= 70
+ unsigned int scale_num, scale_denom; /* fraction by which to scale image */
+
+ JDIMENSION jpeg_width; /* scaled JPEG image width */
+ JDIMENSION jpeg_height; /* scaled JPEG image height */
+ /* Dimensions of actual JPEG image that will be written to file,
+ * derived from input dimensions by scaling factors above.
+ * These fields are computed by jpeg_start_compress().
+ * You can also use jpeg_calc_jpeg_dimensions() to determine these values
+ * in advance of calling jpeg_start_compress().
+ */
++#endif
+
int data_precision; /* bits of precision in image data */
int num_components; /* # of color components in JPEG image */
jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */
-
+
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
- /* ptrs to coefficient quantization tables, or NULL if not defined */
-
++#if JPEG_LIB_VERSION >= 70
+ int q_scale_factor[NUM_QUANT_TBLS];
++#endif
+ /* ptrs to coefficient quantization tables, or NULL if not defined,
+ * and corresponding scale factors (percentage, initialized 100).
+ */
+
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
/* ptrs to Huffman coding tables, or NULL if not defined */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
++#if JPEG_LIB_VERSION >= 70
+ boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
++#endif
int smoothing_factor; /* 1..100, or 0 for no input smoothing */
J_DCT_METHOD dct_method; /* DCT algorithm selector */
int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */
++#if JPEG_LIB_VERSION >= 70
+ int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
+ int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
++#endif
+
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
/* The coefficient controller receives data in units of MCU rows as defined
* for fully interleaved scans (whether the JPEG file is interleaved or not).
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
++#if JPEG_LIB_VERSION >= 80
+ int block_size; /* the basic DCT block size: 1..16 */
+ const int * natural_order; /* natural-order position array */
+ int lim_Se; /* min( Se, DCTSIZE2-1 ) */
++#endif
+
/*
* Links to compression subobjects (methods and private variables of modules)
*/
jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */
++#if JPEG_LIB_VERSION >= 80
+ boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
++#endif
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */
++#if JPEG_LIB_VERSION >= 70
+ int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
+ int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
++#else
+ int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
++#endif
JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
/* The coefficient controller's input and output progress is measured in
* in fully interleaved JPEG scans, but are used whether the scan is
* interleaved or not. We define an iMCU row as v_samp_factor DCT block
* rows of each component. Therefore, the IDCT output contains
- * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.
- * v_samp_factor*DCT_v_scaled_size sample rows of a component per iMCU row.
++ * v_samp_factor*DCT_[v_]scaled_size sample rows of a component per iMCU row.
*/
JSAMPLE * sample_range_limit; /* table for fast range-limiting */
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
++#if JPEG_LIB_VERSION >= 80
+ /* These fields are derived from Se of first SOS marker.
+ */
+ int block_size; /* the basic DCT block size: 1..16 */
+ const int * natural_order; /* natural-order position array for entropy decode */
+ int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
++#endif
+
/* This field is shared between entropy decoder and marker parser.
* It is either zero or the code of a JPEG marker that has been
* read from the data source, but has not yet been processed.
#define jpeg_destroy_decompress jDestDecompress
#define jpeg_stdio_dest jStdDest
#define jpeg_stdio_src jStdSrc
++#if JPEG_LIB_VERSION >= 80
+ #define jpeg_mem_dest jMemDest
+ #define jpeg_mem_src jMemSrc
++#endif
#define jpeg_set_defaults jSetDefaults
#define jpeg_set_colorspace jSetColorspace
#define jpeg_default_colorspace jDefColorspace
#define jpeg_set_quality jSetQuality
#define jpeg_set_linear_quality jSetLQuality
++#if JPEG_LIB_VERSION >= 70
+ #define jpeg_default_qtables jDefQTables
++#endif
#define jpeg_add_quant_table jAddQuantTable
#define jpeg_quality_scaling jQualityScaling
#define jpeg_simple_progression jSimProgress
#define jpeg_start_compress jStrtCompress
#define jpeg_write_scanlines jWrtScanlines
#define jpeg_finish_compress jFinCompress
++#if JPEG_LIB_VERSION >= 70
+ #define jpeg_calc_jpeg_dimensions jCjpegDimensions
++#endif
#define jpeg_write_raw_data jWrtRawData
#define jpeg_write_marker jWrtMarker
#define jpeg_write_m_header jWrtMHeader
#define jpeg_input_complete jInComplete
#define jpeg_new_colormap jNewCMap
#define jpeg_consume_input jConsumeInput
++#if JPEG_LIB_VERSION >= 80
+ #define jpeg_core_output_dimensions jCoreDimensions
++#endif
#define jpeg_calc_output_dimensions jCalcDimensions
#define jpeg_save_markers jSaveMarkers
#define jpeg_set_marker_processor jSetMarker
EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
++#if JPEG_LIB_VERSION >= 80
+ /* Data source and destination managers: memory buffers. */
+ EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
+ unsigned char ** outbuffer,
+ unsigned long * outsize));
+ EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
+ unsigned char * inbuffer,
+ unsigned long insize));
++#endif
+
/* Default parameter setup for compression */
EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
/* Compression parameter setup aids */
EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
int scale_factor,
boolean force_baseline));
++#if JPEG_LIB_VERSION >= 70
+ EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo,
+ boolean force_baseline));
++#endif
EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
int scale_factor,
JDIMENSION num_lines));
EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo));
++#if JPEG_LIB_VERSION >= 70
+ /* Precalculate JPEG dimensions for current compression parameters. */
+ EXTERN(void) jpeg_calc_jpeg_dimensions JPP((j_compress_ptr cinfo));
++#endif
+
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo,
JSAMPIMAGE data,
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
/* Precalculate output dimensions for current decompression parameters. */
++#if JPEG_LIB_VERSION >= 80
+ EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo));
++#endif
EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
/* Control saving of COM and APPn markers into marker_list. */
int tblno, i, j, ci, itemp;
jpeg_component_info *compptr;
JQUANT_TBL *qtblptr;
- JDIMENSION jtemp;
+ JDIMENSION dtemp;
UINT16 qtemp;
- /* Transpose image dimensions */
- jtemp = dstinfo->image_width;
+ /* Transpose basic image dimensions */
+ dtemp = dstinfo->image_width;
dstinfo->image_width = dstinfo->image_height;
- dstinfo->image_height = jtemp;
+ dstinfo->image_height = dtemp;
++#if JPEG_LIB_VERSION >= 70
+ itemp = dstinfo->min_DCT_h_scaled_size;
+ dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size;
+ dstinfo->min_DCT_v_scaled_size = itemp;
++#endif
/* Transpose sampling factors */
for (ci = 0; ci < dstinfo->num_components; ci++) {