-## 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-info ${JPEG_LIB_VERSION} -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
++ ./jpegtran -crop 100x100+10+10 -transpose -perfect -outfile testoutcrop.jpg $(srcdir)/testorig.jpg
++ cmp $(srcdir)/testimgcrop.jpg testoutcrop.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
++ ./jpegtran -crop 100x100+10+10 -transpose -perfect -outfile testoutcrop.jpg $(srcdir)/testorig.jpg
++ cmp $(srcdir)/testimgcrop.jpg testoutcrop.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}
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
++#include "jpegcomp.h"
/* Private state */
LOCAL(void)
- initial_setup (j_compress_ptr cinfo)
+ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
/* 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
+#if JPEG_LIB_VERSION >= 70
- jpeg_calc_jpeg_dimensions(cinfo);
++ if (!transcode_only)
+ jpeg_calc_jpeg_dimensions(cinfo);
+#endif
/* Sanity check on image dimensions */
- if (cinfo->image_height <= 0 || cinfo->image_width <= 0
- if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 ||
- cinfo->num_components <= 0 || cinfo->input_components <= 0)
++ if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_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 */
- if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
- (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
- if ((long) cinfo->jpeg_height > (long) JPEG_MAX_DIMENSION ||
- (long) cinfo->jpeg_width > (long) JPEG_MAX_DIMENSION)
++ if ((long) cinfo->_jpeg_height > (long) JPEG_MAX_DIMENSION ||
++ (long) cinfo->_jpeg_width > (long) JPEG_MAX_DIMENSION)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
/* Width of an input scanline must be representable as JDIMENSION. */
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->image_width * (long) compptr->h_samp_factor,
- 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->_jpeg_width * (long) compptr->h_samp_factor,
+ (long) (cinfo->max_h_samp_factor * DCTSIZE));
compptr->height_in_blocks = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
- 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->_jpeg_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->image_width * (long) compptr->h_samp_factor,
- 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->_jpeg_width * (long) compptr->h_samp_factor,
+ (long) cinfo->max_h_samp_factor);
compptr->downsampled_height = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
- 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->_jpeg_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;
}
* main controller will call coefficient controller).
*/
cinfo->total_iMCU_rows = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height,
- jdiv_round_up((long) cinfo->jpeg_height,
- (long) (cinfo->max_v_samp_factor * cinfo->block_size));
++ jdiv_round_up((long) cinfo->_jpeg_height,
+ (long) (cinfo->max_v_samp_factor*DCTSIZE));
}
/* Overall image size in MCUs */
cinfo->MCUs_per_row = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_width,
- jdiv_round_up((long) cinfo->jpeg_width,
- (long) (cinfo->max_h_samp_factor * cinfo->block_size));
++ jdiv_round_up((long) cinfo->_jpeg_width,
+ (long) (cinfo->max_h_samp_factor*DCTSIZE));
cinfo->MCU_rows_in_scan = (JDIMENSION)
- jdiv_round_up((long) cinfo->image_height,
- jdiv_round_up((long) cinfo->jpeg_height,
- (long) (cinfo->max_v_samp_factor * cinfo->block_size));
++ jdiv_round_up((long) cinfo->_jpeg_height,
+ (long) (cinfo->max_v_samp_factor*DCTSIZE));
cinfo->blocks_in_MCU = 0;
* transupp.c
*
* Copyright (C) 1997-2009, Thomas G. Lane, 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.
*
#include "jinclude.h"
#include "jpeglib.h"
#include "transupp.h" /* My own external interface */
++#include "jpegcomp.h"
+ #include <ctype.h> /* to declare isdigit() */
+
+
++#if JPEG_LIB_VERSION >= 70
++#define dstinfo_min_DCT_h_scaled_size dstinfo->min_DCT_h_scaled_size
++#define dstinfo_min_DCT_v_scaled_size dstinfo->min_DCT_v_scaled_size
++#else
++#define dstinfo_min_DCT_h_scaled_size DCTSIZE
++#define dstinfo_min_DCT_v_scaled_size DCTSIZE
++#endif
+
+
#if TRANSFORMS_SUPPORTED
/*
* mirroring by changing the signs of odd-numbered columns.
* Partial iMCUs at the right edge are left untouched.
*/
- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
+ MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
*ptr2++ = -temp1;
}
}
- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
+ if (x_crop_blocks > 0) {
+ /* Now left-justify the portion of the data to be kept.
+ * We can't use a single jcopy_block_row() call because that routine
+ * depends on memcpy(), whose behavior is unspecified for overlapping
+ * source and destination areas. Sigh.
+ */
+ for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) {
+ jcopy_block_row(buffer[offset_y] + blk_x + x_crop_blocks,
+ buffer[offset_y] + blk_x,
+ (JDIMENSION) 1);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ LOCAL(void)
+ do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
+ jvirt_barray_ptr *src_coef_arrays,
+ jvirt_barray_ptr *dst_coef_arrays)
+ /* Horizontal flip in general cropping case */
+ {
+ JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y;
+ JDIMENSION x_crop_blocks, y_crop_blocks;
+ int ci, k, offset_y;
+ JBLOCKARRAY src_buffer, dst_buffer;
+ JBLOCKROW src_row_ptr, dst_row_ptr;
+ JCOEFPTR src_ptr, dst_ptr;
+ jpeg_component_info *compptr;
+
+ /* Here we must output into a separate array because we can't touch
+ * different rows of a single virtual array simultaneously. Otherwise,
+ * this is essentially the same as the routine above.
+ */
+ MCU_cols = srcinfo->output_width /
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+ comp_width = MCU_cols * compptr->h_samp_factor;
+ x_crop_blocks = x_crop_offset * compptr->h_samp_factor;
+ y_crop_blocks = y_crop_offset * compptr->v_samp_factor;
+ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
+ dst_blk_y += compptr->v_samp_factor) {
+ dst_buffer = (*srcinfo->mem->access_virt_barray)
+ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y,
+ (JDIMENSION) compptr->v_samp_factor, TRUE);
+ src_buffer = (*srcinfo->mem->access_virt_barray)
+ ((j_common_ptr) srcinfo, src_coef_arrays[ci],
+ dst_blk_y + y_crop_blocks,
+ (JDIMENSION) compptr->v_samp_factor, FALSE);
+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
+ dst_row_ptr = dst_buffer[offset_y];
+ src_row_ptr = src_buffer[offset_y];
+ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) {
+ if (x_crop_blocks + dst_blk_x < comp_width) {
+ /* Do the mirrorable blocks */
+ dst_ptr = dst_row_ptr[dst_blk_x];
+ src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1];
+ /* this unrolled loop doesn't need to know which row it's on... */
+ for (k = 0; k < DCTSIZE2; k += 2) {
+ *dst_ptr++ = *src_ptr++; /* copy even column */
+ *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */
+ }
+ } else {
+ /* Copy last partial block(s) verbatim */
+ jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks,
+ dst_row_ptr + dst_blk_x,
+ (JDIMENSION) 1);
+ }
+ }
}
}
}
* of odd-numbered rows.
* Partial iMCUs at the bottom edge are copied verbatim.
*/
- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
+ MCU_rows = srcinfo->output_height /
- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
* at the (output) right edge properly. They just get transposed and
* not mirrored.
*/
- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
+ MCU_cols = srcinfo->output_height /
- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
* at the (output) bottom edge properly. They just get transposed and
* not mirrored.
*/
- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
+ MCU_rows = srcinfo->output_width /
- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
+ MCU_cols = srcinfo->output_width /
- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+ MCU_rows = srcinfo->output_height /
- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
- MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
- MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
+ MCU_cols = srcinfo->output_height /
- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+ MCU_rows = srcinfo->output_width /
- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
jtransform_request_workspace (j_decompress_ptr srcinfo,
jpeg_transform_info *info)
{
- jvirt_barray_ptr *coef_arrays = NULL;
+ jvirt_barray_ptr *coef_arrays;
+ boolean need_workspace, transpose_it;
jpeg_component_info *compptr;
- int ci;
+ JDIMENSION xoffset, yoffset;
+ JDIMENSION width_in_iMCUs, height_in_iMCUs;
+ JDIMENSION width_in_blocks, height_in_blocks;
+ int ci, h_samp_factor, v_samp_factor;
+ /* Determine number of components in output image */
if (info->force_grayscale &&
srcinfo->jpeg_color_space == JCS_YCbCr &&
- srcinfo->num_components == 3) {
+ srcinfo->num_components == 3)
/* We'll only process the first component */
info->num_components = 1;
- } else {
+ else
/* Process all the components */
info->num_components = srcinfo->num_components;
- srcinfo->min_DCT_h_scaled_size,
- srcinfo->min_DCT_v_scaled_size,
+
+ /* Compute output image dimensions and related values. */
++#if JPEG_LIB_VERSION >= 80
+ jpeg_core_output_dimensions(srcinfo);
++#else
++ srcinfo->output_width = srcinfo->image_width;
++ srcinfo->output_height = srcinfo->image_height;
++#endif
+
+ /* Return right away if -perfect is given and transformation is not perfect.
+ */
+ if (info->perfect) {
+ if (info->num_components == 1) {
+ if (!jtransform_perfect_transform(srcinfo->output_width,
+ srcinfo->output_height,
- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size,
- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size,
++ srcinfo->_min_DCT_h_scaled_size,
++ srcinfo->_min_DCT_v_scaled_size,
+ info->transform))
+ return FALSE;
+ } else {
+ if (!jtransform_perfect_transform(srcinfo->output_width,
+ srcinfo->output_height,
++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size,
++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size,
+ info->transform))
+ return FALSE;
+ }
}
- info->iMCU_sample_width = srcinfo->min_DCT_v_scaled_size;
- info->iMCU_sample_height = srcinfo->min_DCT_h_scaled_size;
+ /* If there is only one output component, force the iMCU size to be 1;
+ * else use the source iMCU size. (This allows us to do the right thing
+ * when reducing color to grayscale, and also provides a handy way of
+ * cleaning up "funny" grayscale images whose sampling factors are not 1x1.)
+ */
+ switch (info->transform) {
+ case JXFORM_TRANSPOSE:
+ case JXFORM_TRANSVERSE:
+ case JXFORM_ROT_90:
+ case JXFORM_ROT_270:
+ info->output_width = srcinfo->output_height;
+ info->output_height = srcinfo->output_width;
+ if (info->num_components == 1) {
- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size;
++ info->iMCU_sample_width = srcinfo->_min_DCT_v_scaled_size;
++ info->iMCU_sample_height = srcinfo->_min_DCT_h_scaled_size;
+ } else {
+ info->iMCU_sample_width =
- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size;
++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
+ info->iMCU_sample_height =
- info->iMCU_sample_width = srcinfo->min_DCT_h_scaled_size;
- info->iMCU_sample_height = srcinfo->min_DCT_v_scaled_size;
++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
+ }
+ break;
+ default:
+ info->output_width = srcinfo->output_width;
+ info->output_height = srcinfo->output_height;
+ if (info->num_components == 1) {
- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size;
++ info->iMCU_sample_width = srcinfo->_min_DCT_h_scaled_size;
++ info->iMCU_sample_height = srcinfo->_min_DCT_v_scaled_size;
+ } else {
+ info->iMCU_sample_width =
- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size;
++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
+ info->iMCU_sample_height =
++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
+ }
+ break;
+ }
+
+ /* If cropping has been requested, compute the crop area's position and
+ * dimensions, ensuring that its upper left corner falls at an iMCU boundary.
+ */
+ if (info->crop) {
+ /* Insert default values for unset crop parameters */
+ if (info->crop_xoffset_set == JCROP_UNSET)
+ info->crop_xoffset = 0; /* default to +0 */
+ if (info->crop_yoffset_set == JCROP_UNSET)
+ info->crop_yoffset = 0; /* default to +0 */
+ if (info->crop_xoffset >= info->output_width ||
+ info->crop_yoffset >= info->output_height)
+ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
+ if (info->crop_width_set == JCROP_UNSET)
+ info->crop_width = info->output_width - info->crop_xoffset;
+ if (info->crop_height_set == JCROP_UNSET)
+ info->crop_height = info->output_height - info->crop_yoffset;
+ /* Ensure parameters are valid */
+ if (info->crop_width <= 0 || info->crop_width > info->output_width ||
+ info->crop_height <= 0 || info->crop_height > info->output_height ||
+ info->crop_xoffset > info->output_width - info->crop_width ||
+ info->crop_yoffset > info->output_height - info->crop_height)
+ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC);
+ /* Convert negative crop offsets into regular offsets */
+ if (info->crop_xoffset_set == JCROP_NEG)
+ xoffset = info->output_width - info->crop_width - info->crop_xoffset;
+ else
+ xoffset = info->crop_xoffset;
+ if (info->crop_yoffset_set == JCROP_NEG)
+ yoffset = info->output_height - info->crop_height - info->crop_yoffset;
+ else
+ yoffset = info->crop_yoffset;
+ /* Now adjust so that upper left corner falls at an iMCU boundary */
+ info->output_width =
+ info->crop_width + (xoffset % info->iMCU_sample_width);
+ info->output_height =
+ info->crop_height + (yoffset % info->iMCU_sample_height);
+ /* Save x/y offsets measured in iMCUs */
+ info->x_crop_offset = xoffset / info->iMCU_sample_width;
+ info->y_crop_offset = yoffset / info->iMCU_sample_height;
+ } else {
+ info->x_crop_offset = 0;
+ info->y_crop_offset = 0;
+ }
+
+ /* Figure out whether we need workspace arrays,
+ * and if so whether they are transposed relative to the source.
+ */
+ need_workspace = FALSE;
+ transpose_it = FALSE;
switch (info->transform) {
case JXFORM_NONE:
+ if (info->x_crop_offset != 0 || info->y_crop_offset != 0)
+ need_workspace = TRUE;
+ /* No workspace needed if neither cropping nor transforming */
+ break;
case JXFORM_FLIP_H:
- /* Don't need a workspace array */
+ if (info->trim)
+ trim_right_edge(info, srcinfo->output_width);
+ if (info->y_crop_offset != 0)
+ need_workspace = TRUE;
+ /* do_flip_h_no_crop doesn't need a workspace array */
break;
case JXFORM_FLIP_V:
- case JXFORM_ROT_180:
- /* Need workspace arrays having same dimensions as source image.
- * Note that we allocate arrays padded out to the next iMCU boundary,
- * so that transform routines need not worry about missing edge blocks.
- */
- coef_arrays = (jvirt_barray_ptr *)
- (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE,
- SIZEOF(jvirt_barray_ptr) * info->num_components);
- for (ci = 0; ci < info->num_components; ci++) {
- compptr = srcinfo->comp_info + ci;
- coef_arrays[ci] = (*srcinfo->mem->request_virt_barray)
- ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE,
- (JDIMENSION) jround_up((long) compptr->width_in_blocks,
- (long) compptr->h_samp_factor),
- (JDIMENSION) jround_up((long) compptr->height_in_blocks,
- (long) compptr->v_samp_factor),
- (JDIMENSION) compptr->v_samp_factor);
- }
+ if (info->trim)
+ trim_bottom_edge(info, srcinfo->output_height);
+ /* Need workspace arrays having same dimensions as source image. */
+ need_workspace = TRUE;
break;
case JXFORM_TRANSPOSE:
+ /* transpose does NOT have to trim anything */
+ /* Need workspace arrays having transposed dimensions. */
+ need_workspace = TRUE;
+ transpose_it = TRUE;
+ break;
case JXFORM_TRANSVERSE:
+ if (info->trim) {
+ trim_right_edge(info, srcinfo->output_height);
+ trim_bottom_edge(info, srcinfo->output_width);
+ }
+ /* Need workspace arrays having transposed dimensions. */
+ need_workspace = TRUE;
+ transpose_it = TRUE;
+ break;
case JXFORM_ROT_90:
+ if (info->trim)
+ trim_right_edge(info, srcinfo->output_height);
+ /* Need workspace arrays having transposed dimensions. */
+ need_workspace = TRUE;
+ transpose_it = TRUE;
+ break;
+ case JXFORM_ROT_180:
+ if (info->trim) {
+ trim_right_edge(info, srcinfo->output_width);
+ trim_bottom_edge(info, srcinfo->output_height);
+ }
+ /* Need workspace arrays having same dimensions as source image. */
+ need_workspace = TRUE;
+ break;
case JXFORM_ROT_270:
- /* Need workspace arrays having transposed dimensions.
- * Note that we allocate arrays padded out to the next iMCU boundary,
- * so that transform routines need not worry about missing edge blocks.
- */
+ if (info->trim)
+ trim_bottom_edge(info, srcinfo->output_width);
+ /* Need workspace arrays having transposed dimensions. */
+ need_workspace = TRUE;
+ transpose_it = TRUE;
+ break;
+ }
+
+ /* Allocate workspace if needed.
+ * Note that we allocate arrays padded out to the next iMCU boundary,
+ * so that transform routines need not worry about missing edge blocks.
+ */
+ if (need_workspace) {
coef_arrays = (jvirt_barray_ptr *)
(*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE,
- SIZEOF(jvirt_barray_ptr) * info->num_components);
+ SIZEOF(jvirt_barray_ptr) * info->num_components);
+ width_in_iMCUs = (JDIMENSION)
+ jdiv_round_up((long) info->output_width,
+ (long) info->iMCU_sample_width);
+ height_in_iMCUs = (JDIMENSION)
+ jdiv_round_up((long) info->output_height,
+ (long) info->iMCU_sample_height);
for (ci = 0; ci < info->num_components; ci++) {
compptr = srcinfo->comp_info + ci;
+ if (info->num_components == 1) {
+ /* we're going to force samp factors to 1x1 in this case */
+ h_samp_factor = v_samp_factor = 1;
+ } else if (transpose_it) {
+ h_samp_factor = compptr->v_samp_factor;
+ v_samp_factor = compptr->h_samp_factor;
+ } else {
+ h_samp_factor = compptr->h_samp_factor;
+ v_samp_factor = compptr->v_samp_factor;
+ }
+ width_in_blocks = width_in_iMCUs * h_samp_factor;
+ height_in_blocks = height_in_iMCUs * v_samp_factor;
coef_arrays[ci] = (*srcinfo->mem->request_virt_barray)
((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE,
- (JDIMENSION) jround_up((long) compptr->height_in_blocks,
- (long) compptr->v_samp_factor),
- (JDIMENSION) jround_up((long) compptr->width_in_blocks,
- (long) compptr->h_samp_factor),
- (JDIMENSION) compptr->h_samp_factor);
+ width_in_blocks, height_in_blocks, (JDIMENSION) v_samp_factor);
}
- break;
- }
- info->workspace_coef_arrays = coef_arrays;
+ info->workspace_coef_arrays = coef_arrays;
+ } else
+ info->workspace_coef_arrays = NULL;
+
+ return TRUE;
}
int tblno, i, j, ci, itemp;
jpeg_component_info *compptr;
JQUANT_TBL *qtblptr;
- JDIMENSION dtemp;
+ JDIMENSION jtemp;
UINT16 qtemp;
- /* Transpose basic image dimensions */
- dtemp = dstinfo->image_width;
+ /* Transpose image dimensions */
+ jtemp = dstinfo->image_width;
dstinfo->image_width = dstinfo->image_height;
- dstinfo->image_height = dtemp;
+ dstinfo->image_height = jtemp;
+#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;
/* Sorry, can't do it */
ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL);
}
+ } else if (info->num_components == 1) {
+ /* For a single-component source, we force the destination sampling factors
+ * to 1x1, with or without force_grayscale. This is useful because some
+ * decoders choke on grayscale images with other sampling factors.
+ */
+ dstinfo->comp_info[0].h_samp_factor = 1;
+ dstinfo->comp_info[0].v_samp_factor = 1;
}
- /* Correct the destination's image dimensions etc if necessary */
+ /* Correct the destination's image dimensions as necessary
+ * for rotate/flip, resize, and crop operations.
+ */
++#if JPEG_LIB_VERSION >= 70
+ dstinfo->jpeg_width = info->output_width;
+ dstinfo->jpeg_height = info->output_height;
++#else
++ dstinfo->image_width = info->output_width;
++ dstinfo->image_height = info->output_height;
++#endif
+
+ /* Transpose destination image parameters */
switch (info->transform) {
- case JXFORM_NONE:
- /* Nothing to do */
- break;
- case JXFORM_FLIP_H:
- if (info->trim)
- trim_right_edge(dstinfo);
- break;
- case JXFORM_FLIP_V:
- if (info->trim)
- trim_bottom_edge(dstinfo);
- break;
case JXFORM_TRANSPOSE:
- transpose_critical_parameters(dstinfo);
- /* transpose does NOT have to trim anything */
- break;
case JXFORM_TRANSVERSE:
- transpose_critical_parameters(dstinfo);
- if (info->trim) {
- trim_right_edge(dstinfo);
- trim_bottom_edge(dstinfo);
- }
- break;
case JXFORM_ROT_90:
- transpose_critical_parameters(dstinfo);
- if (info->trim)
- trim_right_edge(dstinfo);
- break;
- case JXFORM_ROT_180:
- if (info->trim) {
- trim_right_edge(dstinfo);
- trim_bottom_edge(dstinfo);
- }
- break;
case JXFORM_ROT_270:
transpose_critical_parameters(dstinfo);
- if (info->trim)
- trim_bottom_edge(dstinfo);
break;
+ default:
+ break;
+ }
+
+ /* Adjust Exif properties */
+ if (srcinfo->marker_list != NULL &&
+ srcinfo->marker_list->marker == JPEG_APP0+1 &&
+ srcinfo->marker_list->data_length >= 6 &&
+ GETJOCTET(srcinfo->marker_list->data[0]) == 0x45 &&
+ GETJOCTET(srcinfo->marker_list->data[1]) == 0x78 &&
+ GETJOCTET(srcinfo->marker_list->data[2]) == 0x69 &&
+ GETJOCTET(srcinfo->marker_list->data[3]) == 0x66 &&
+ GETJOCTET(srcinfo->marker_list->data[4]) == 0 &&
+ GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
+ /* Suppress output of JFIF marker */
+ dstinfo->write_JFIF_header = FALSE;
++#if JPEG_LIB_VERSION >= 70
+ /* Adjust Exif image parameters */
+ if (dstinfo->jpeg_width != srcinfo->image_width ||
+ dstinfo->jpeg_height != srcinfo->image_height)
+ /* Align data segment to start of TIFF structure for parsing */
+ adjust_exif_parameters(srcinfo->marker_list->data + 6,
+ srcinfo->marker_list->data_length - 6,
+ dstinfo->jpeg_width, dstinfo->jpeg_height);
++#endif
}
/* Return the appropriate output data set */