Compare commits

..

29 Commits

Author SHA1 Message Date
DRC
bf6c774305 Fix whitespace errors 2017-12-13 21:48:54 -06:00
DRC
c308d43416 jpeg_crop_scanlines: Handle gray images w/ samp!=1
Since the sampling factor has no meaning for single-component images,
the decompressor ignores it, and jpeg_crop_scanlines() should as well.

Fixes #195
2017-12-06 11:59:04 -06:00
DRC
773040f9d9 Fix lib state when skipping to end of 1-scan image
If jpeg_skip_scanlines() is used to skip to the end of a single-scan
image, then we need to change the library state such that subsequent
calls to jpeg_consume_input() will return JPEG_REACHED_EOI rather than
JPEG_SUSPENDED.  (NOTE: not necessary for multi-scan images, since the
scans are processed prior to any call to jpeg_skip_scanlines().)

Unless I miss my guess, using jpeg_skip_scanlines() in this manner
will prevent any markers at the end of the JPEG image from being
read, but I don't think there is any way around that without actually
reading the data, which would defeat the purpose of
jpeg_skip_scanlines().

Fixes #194
2017-12-05 16:08:01 -06:00
DRC
a831b5a986 Travis: Work around xcode7.3 image bug
Refer to travis-ci/travis-ci#8552.  This was supposed to be fixed on
November 15, then on November 28.  Travis blew through both deadlines,
so I have no confidence that the issue will be fixed as promised in a
timely manner.  Adding 'brew update' to .travis.yml slows the OS X
build, but there is no choice at the moment.
2017-11-29 14:23:31 -06:00
DRC
19b393b624 TJExample: Fix array index OOB w/ 4:1:1 JPEG input 2017-11-17 18:45:08 -06:00
DRC
9d9d8fe658 Code formatting tweaks 2017-11-17 18:39:53 -06:00
DRC
78e97e38cb Uniquify tjbenchtest log file names based on args
+ clean up log files when 'make testclean' is invoked
+ fix 'tjbenchtest -yuv -alloc'
+ fix tjexampletest so that it creates images under /tmp
+ clean up tjexampletest
2017-11-17 18:39:53 -06:00
DRC
468f2fed27 TJExample.java: Don't ignore mistyped args 2017-11-17 18:39:48 -06:00
DRC
5abf2536f6 Doc tweak: TJFLAG_ACCURATEDCT is the first flag 2017-11-14 16:12:13 -06:00
DRC
5fce2e9421 tjbench.exe: Fix decompression access violation
The program crashed when a JPEG image was passed on the command line,
because we were mixing our metaphors vis-a-vis malloc()/free() and
tjAlloc()/tjFree() (malloc()/free() uses the tjbench.exe heap,
whereas tjAlloc()/tjFree() uses the turbojpeg.dll heap.)
2017-11-14 15:41:30 -06:00
DRC
907dd683a4 ChangeLog.md: buglet 2017-11-13 21:46:07 -06:00
DRC
f008876cc1 Build: Fix make dist
Broken by previous commit
2017-11-13 21:24:05 -06:00
DRC
5bc43c7821 Further partial image decompression fixes
- Referring to 073b0e88a1 and #185, the
  reason why BMP and RLE didn't (and won't) work with partial image
  decompression is that the output engines for both formats maintain a
  whole-image buffer, which is used to reverse the order of scanlines.
  However, it was straightforward to add -crop support for GIF and
  Targa, which is useful for testing partial image decompression along
  with color quantization.
- Such testing reproduced a bug reported by Mozilla (refer to PR #182)
  whereby jpeg_skip_scanlines() would segfault if color quantization was
  enabled.  To fix this issue, read_and_discard_scanlines() now sets up
  a dummy quantize function in the same manner that it sets up a dummy
  color conversion function.

Closes #182
2017-11-13 21:01:53 -06:00
DRC
f3ad13e3d8 TJBench/TJUnitTest: Don't ignore mistyped args 2017-11-13 16:00:35 -06:00
DRC
94e152b186 TurboJPEG C: Code formatting tweaks 2017-11-13 15:14:12 -06:00
DRC
073b0e88a1 djpeg -crop: Exit gracefully with non-PPM formats
... and document that only PPM/PGM output images are supported with the
-crop option for the moment.

I investigated the possibility of supporting -crop with -bmp, but even
after resetting the buffer dimensions, I still kept getting virtual
array access errors.  It seems that doing this the "right way" would
require creating a re-initialization function for each image format's
destination manager.  I'm disinclined to do that right now, given that
this feature was Google's baby (developed as a prerequisite for
including libjpeg-turbo in Android), and the -crop option in djpeg is
intended only as an example of how to use the partial image
decompression API.  Real-world applications would need to handle this
in their own destination managers.

It would probably be possible to make this work with Targa by employing
a similar hack to the one we used with PPM, but Targa isn't popular
enough to bother.

Fixes #185
2017-11-08 21:30:19 -06:00
DRC
1b385f37f3 Prevent "unmappable character" error in Java build
This was causing the build to fail when rebuilding libjpeg-turbo from
a source RPM.
2017-09-20 17:05:15 +00:00
DRC
fd778bba46 Fix PowerPC 32-bit RPM build 2017-09-20 16:43:27 +00:00
DRC
8d403aeb6a Fix 32-bit RPM build w/ newer RHEL/Fedora releases
The version of RPM on RHEL 5 and older platforms defines _libdir
as %{_exec_prefix}/%{_lib}, so defining _lib in the spec file redefined
_libdir.  However, newer versions of RPM (probably >= 4.6, since that
was the version that introduced the ISA macros) define _libdir as either
%{_prefix}/lib or %{_prefix}/lib64.  Thus, we need to explicitly
override _libdir in our spec file.
2017-09-19 23:15:46 +00:00
DRC
01b74c101e Packaging: Use parallel make when rebuilding SRPM 2017-09-11 10:06:22 -05:00
DRC
db0dec3c5a Travis: Limit parallel make jobs to # of CPU cores
This tends to be faster than 'make -j', since it is making more wise
use of the available resources.
2017-09-11 09:48:33 -05:00
nyg
ba6e9d8a11 wrjpgcom: Fix comment typo
Comment was copied/pasted from skip_variable() without making the
necessary modifications.
2017-09-05 11:23:56 -05:00
DRC
5426a4cb16 TJUnitTest: Usage formatting tweaks 2017-09-02 04:08:06 +00:00
DRC
d0bac69a8a Java: Fix TJUnitTest on big endian platforms
It is necessary for the C code to be aware of the machine's endianness,
which is why the TurboJPEG Java wrapper sets a different pixel format
for integer BufferedImages depending on ByteOrder.nativeOrder().
However, it isn't necessary to handle endianness in pure Java code such
as TJUnitTest (d'oh!)  This was a product of porting the C version of
TJUnitTest too literally, and of insufficient testing (historically,
the big endian systems I had available for testing didn't have Java.)
2017-09-02 03:47:56 +00:00
DRC
59322e0973 Build: Change ppc64le DEB arch to ppc64el
This is the convention among Debian-based distros.
2017-09-01 21:57:48 +00:00
DRC
4ded4dfac6 Build: Fix AltiVec detection on OS X Leopard
The ability to directly access elements of an AltiVec vector is
apparently a more recent thing.
2017-09-01 09:01:00 -05:00
DRC
02fa8f244e Fix build on PowerPC SPE systems
SPE systems don't support AltiVec instructions.

Fixes #172
2017-08-31 20:32:48 -05:00
DRC
32120054c2 Java: Fix NullPointerException in YUVImage
planes == null is a valid argument to setBuf() if alloc == true, so we
need to make sure that planes is non-null before validating its length.
We also need to allocate one dimension of the planes array if it's null.

Fixes #168
2017-08-14 11:46:26 -05:00
DRC
1478361204 Bump version to 1.5.3 to prepare for new commits 2017-08-14 11:20:19 -05:00
100 changed files with 1422 additions and 6506 deletions

View File

@@ -1,7 +0,0 @@
dcommander = DRC <dcommander@users.sourceforge.net>
astrand = Peter Åstrand <astrand@cendio.se>
ossman_ = Pierre Ossman <ossman@cendio.se>
const_k = Constantin Kaplinsky <const@tightvnc.com>
atkac = Adam Tkac <atkac@redhat.com>

58
.gitignore vendored
View File

@@ -1,48 +1,14 @@
.DS_Store
Makefile.in
Makefile
/CMakeFiles
/autom4te.cache
/aclocal.m4
/compile
/configure
/depcomp
/install-sh
/libtool
/missing
/stamp-h*
/java/classnoinst.stamp
/pkgscripts/
/jconfig.h
/jconfigint.h
/config.guess
/config.h
/config.h.in
/config.log
/config.status
/config.sub
/ltmain.sh
/ar-lib
/libjpeg.map
/.libs/
/simd/.libs/
/simd/jsimdcfg.inc
*.o
*.lo
*.la
/cjpeg
/djpeg
/jcstest
/jpegtran
/jpegyuv
/md5/md5cmp
/rdjpgcom
/test_enc_*
/tjbench
/tjbenchtest
/tjunittest
/wrjpgcom
/yuvjpeg
test_yuv*.jpg
CMakeCache.txt
CTestTestfile.cmake
aclocal.m4
ar-lib
autom4te.cache
compile
config.guess
config.h.in
config.sub
configure
depcomp
install-sh
ltmain.sh
missing

131
.travis.yml Normal file
View File

@@ -0,0 +1,131 @@
language: c
matrix:
include:
- os: linux
env: BUILD_OFFICIAL=1
sudo: required
services:
- docker
- os: osx
env: BUILD_OFFICIAL=1
osx_image: xcode7.3
- os: linux
compiler: clang
env:
CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer"
CONFIGURE_FLAGS="--disable-shared"
ASAN_OPTIONS="detect_leaks=1 symbolize=1"
addons:
apt:
packages:
- nasm
- os: linux
compiler: gcc
env: CONFIGURE_FLAGS="--with-12bit"
- os: linux
compiler: gcc
env: CONFIGURE_FLAGS="--with-jpeg7"
addons:
apt:
packages:
- nasm
- os: linux
compiler: gcc
env: CONFIGURE_FLAGS="--with-jpeg8"
addons:
apt:
packages:
- nasm
- os: linux
compiler: gcc
env: CONFIGURE_FLAGS="--without-simd"
before_install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew update &&
brew install nasm homebrew/versions/gcc5 md5sha1sum Caskroom/versions/java6 &&
ln -fs /usr/local/bin/gpg1 /usr/local/bin/gpg &&
git clone --depth=1 https://github.com/libjpeg-turbo/gas-preprocessor.git ~/src/gas-preprocessor &&
ln -fs /Applications/Xcode.app /Applications/Xcode72.app;
fi
- if [ "${BUILD_OFFICIAL:-}" != "" ]; then
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
docker pull dcommander/buildljt;
fi &&
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git -b $TRAVIS_BRANCH ~/src/buildscripts &&
openssl aes-256-cbc -K $encrypted_f92e8533f6f1_key -iv $encrypted_f92e8533f6f1_iv -in ci/keys.enc -out ci/keys -d &&
tar xf ci/keys &&
rm ci/keys &&
mv ci/gpgsign ~/src/buildscripts &&
gpg --import ci/sign_ljt &&
rm ci/sign_ljt;
fi
script:
- if [ "${BUILD_OFFICIAL:-}" != "" ]; then
mkdir -p ~/src/ljt.nightly &&
if [ -f .git/shallow ]; then
mv .git/shallow .git/shallow.bak;
fi &&
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
docker run -v $HOME/src/ljt.nightly:/root/src/ljt.nightly -v $HOME/src/buildscripts:/root/src/buildscripts -v $TRAVIS_BUILD_DIR:/root/src/libjpeg-turbo -v $HOME/.gnupg:/root/.gnupg -t dcommander/buildljt:latest bash -c "rpm --import http://pgp.mit.edu/pks/lookup?op=get\&search=0x0575F26BD5B3FDB1 && ~/src/buildscripts/buildljt -r file:///root/src/libjpeg-turbo $TRAVIS_BRANCH -v" &&
sudo chown -R travis:travis ~/src/ljt.nightly &&
mv ~/src/ljt.nightly/latest/log-$TRAVIS_OS_NAME.txt ~/src/ljt.nightly/latest/files/;
else
PATH=$PATH:~/src/gas-preprocessor ~/src/buildscripts/buildljt -r file://$TRAVIS_BUILD_DIR $TRAVIS_BRANCH -v &&
mv ~/src/ljt.nightly/latest/log-$TRAVIS_OS_NAME.txt ~/src/ljt.nightly/latest/files/;
fi &&
if [ -f .git/shallow.bak ]; then
mv .git/shallow.bak .git/shallow;
fi
fi
- if [ "${BUILD_OFFICIAL:-}" == "" ]; then
autoreconf -fiv &&
mkdir build &&
pushd build &&
../configure ${CONFIGURE_FLAGS} &&
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo` &&
make -j$NUMCPUS --load-average=$NUMCPUS &&
if [[ "${CONFIGURE_FLAGS}" =~ "with-12bit" ||
"${CONFIGURE_FLAGS}" =~ "without-simd" ]]; then
make test FLOATTEST=32bit;
else
make test FLOATTEST=sse &&
JSIMD_FORCENONE=1 make test FLOATTEST=32bit;
fi &&
popd;
fi
after_failure:
- if [ "${BUILD_OFFICIAL:-}" == "" ]; then
if [ -f $TRAVIS_BUILD_DIR/build/config.log ]; then
cat $TRAVIS_BUILD_DIR/build/config.log;
fi
fi
deploy:
- provider: s3
bucket: libjpeg-turbo-pr
access_key_id:
secure: bmFEt4H90/oR/LiN9XI+G26Pd6hiyrTw3+Vg3lS4ynwAYk33weApaVM8CyzQTgIhGSPzFStqVm9fTrb3RmrYP/PnNS+/surOeWLkH2DMRxvc0qmetBuNx1+vAN7FUkY8MO/u5uE9WXHAdp4e64pXcLXEbKmh+wgDm72b35WmMxErtHsGbpqy+j47rQkY4BJGi7XQzjjafaamfm4PzitsjkYYsgX8KLI16jyJEIirvyDHCPTn9wKR/jSjelDl+xTlgZGuCqmLCBW8f6JgycIspWjcYfO4WpWvkbnnI2sl3rCMPvOYc4wHe8SwzG0l4tM1PblZZDRcU7vjE15PmNf1Xfq9Vx3RpgBJv+UBNL/Vn0rKdpUCeEcfC12hxrske8DWpV6waBiDivjQJreE+YRXqa5YBhV/EdkoKYCqafnJvRASlOko9evje8F9KXTNsIGTT1HPmU9QM9WoJwLs/Xa3t09EmA2IjhcuAvvUmwCTuBBQVAlDjExiTT3Zhc9IYZDD92JgpAYLgridtzR87ElOxKhTkR4PowdI6UiLYArPjMFTjoz5Rivb9qNpbLaQC8HCYgLWxpWtUTzlW/9rM8izHpF8ySFHjO6E2aA9OJFc0tcbEGwAs2jLGD01OduU+DbBfsIkW0EgfXCPbD3FVgHsn3tkuzgO/bg20SM7uuCEYKQ=
secret_access_key:
secure: mrkOpEtqd2dEmi/qNJyX9vkME+6xgVBnXaRETKF7jT+flcQCQ0ayQkRkMV7lzGqq44XFg+n6Cpfn6oW0gH9RNdcC8YQvFP+kgzPx6nw6V/M31Vz6ySapJf59HBzVevf0NJkr0/1JoWsp1iq4IoN10WPzsCXZB55Io3Cf7DgpR+yiyBlWOctDfNdjJ97Juw3ENE80MHDf0fVqdUOIknQka1p68yAGkjar9kc2Oe7o94RzzmoqEn8tuFumiBQjIcuVRALsKqz+eIxBNgkL3BF9shVyRjOWLAeBhMPVFxZs5Dgd4ECbvU0i33gfmje3d6qqcw78N2lZaLefoVvWol3pOzVO133ewOSY9/lmpqEiRUU2ohEe8T4aSoS7posBW42itUTO4Y5w+eVOnHsm4sRQaI+/AXWTe7GPel+P8Qbe8Ya10A5gnpoag7o3raRDcHx+/qaZw1Af/u4XiAOYz3be3U90Qc+YMc/kS5i8BH0GXBbSfaWQ00CwRFlZQ3n1xUqmjC2CmjZTki3W/p7mEt0DjhcH9ZIXscK603sCC+mF6pEd9019k5fG/8fr2Y4Ptai9kd3BxZJCX9/jSoMfWOBbgkA5bRgHU0xrAj+p49qD6Ej9Xr8GE3+uebz3sEuhSFRnCKwKoOHOemfgevfO2y/jQXP677WPf3xQX7bVDfTFSHU=
acl: public_read
local-dir: $HOME/src/ljt.nightly/latest/files
upload-dir: $TRAVIS_BRANCH/$TRAVIS_OS_NAME
on:
branch: master
condition: -n "$BUILD_OFFICIAL"
- provider: s3
bucket: libjpeg-turbo-pr
access_key_id:
secure: bmFEt4H90/oR/LiN9XI+G26Pd6hiyrTw3+Vg3lS4ynwAYk33weApaVM8CyzQTgIhGSPzFStqVm9fTrb3RmrYP/PnNS+/surOeWLkH2DMRxvc0qmetBuNx1+vAN7FUkY8MO/u5uE9WXHAdp4e64pXcLXEbKmh+wgDm72b35WmMxErtHsGbpqy+j47rQkY4BJGi7XQzjjafaamfm4PzitsjkYYsgX8KLI16jyJEIirvyDHCPTn9wKR/jSjelDl+xTlgZGuCqmLCBW8f6JgycIspWjcYfO4WpWvkbnnI2sl3rCMPvOYc4wHe8SwzG0l4tM1PblZZDRcU7vjE15PmNf1Xfq9Vx3RpgBJv+UBNL/Vn0rKdpUCeEcfC12hxrske8DWpV6waBiDivjQJreE+YRXqa5YBhV/EdkoKYCqafnJvRASlOko9evje8F9KXTNsIGTT1HPmU9QM9WoJwLs/Xa3t09EmA2IjhcuAvvUmwCTuBBQVAlDjExiTT3Zhc9IYZDD92JgpAYLgridtzR87ElOxKhTkR4PowdI6UiLYArPjMFTjoz5Rivb9qNpbLaQC8HCYgLWxpWtUTzlW/9rM8izHpF8ySFHjO6E2aA9OJFc0tcbEGwAs2jLGD01OduU+DbBfsIkW0EgfXCPbD3FVgHsn3tkuzgO/bg20SM7uuCEYKQ=
secret_access_key:
secure: mrkOpEtqd2dEmi/qNJyX9vkME+6xgVBnXaRETKF7jT+flcQCQ0ayQkRkMV7lzGqq44XFg+n6Cpfn6oW0gH9RNdcC8YQvFP+kgzPx6nw6V/M31Vz6ySapJf59HBzVevf0NJkr0/1JoWsp1iq4IoN10WPzsCXZB55Io3Cf7DgpR+yiyBlWOctDfNdjJ97Juw3ENE80MHDf0fVqdUOIknQka1p68yAGkjar9kc2Oe7o94RzzmoqEn8tuFumiBQjIcuVRALsKqz+eIxBNgkL3BF9shVyRjOWLAeBhMPVFxZs5Dgd4ECbvU0i33gfmje3d6qqcw78N2lZaLefoVvWol3pOzVO133ewOSY9/lmpqEiRUU2ohEe8T4aSoS7posBW42itUTO4Y5w+eVOnHsm4sRQaI+/AXWTe7GPel+P8Qbe8Ya10A5gnpoag7o3raRDcHx+/qaZw1Af/u4XiAOYz3be3U90Qc+YMc/kS5i8BH0GXBbSfaWQ00CwRFlZQ3n1xUqmjC2CmjZTki3W/p7mEt0DjhcH9ZIXscK603sCC+mF6pEd9019k5fG/8fr2Y4Ptai9kd3BxZJCX9/jSoMfWOBbgkA5bRgHU0xrAj+p49qD6Ej9Xr8GE3+uebz3sEuhSFRnCKwKoOHOemfgevfO2y/jQXP677WPf3xQX7bVDfTFSHU=
acl: public_read
local-dir: $HOME/src/ljt.nightly/latest/files
upload-dir: $TRAVIS_BRANCH/$TRAVIS_OS_NAME
on:
branch: dev
condition: -n "$BUILD_OFFICIAL"

View File

@@ -1,902 +0,0 @@
*******************************************************************************
** Building on Un*x Platforms (including Cygwin and OS X)
*******************************************************************************
==================
Build Requirements
==================
-- pkg-config
-- autoconf 2.56 or later
-- automake 1.7 or later
-- libtool 1.4 or later
* If using Xcode 4.3 or later on OS X, autoconf and automake are no longer
provided. The easiest way to obtain them is from MacPorts
(http://www.macports.org/).
-- NASM or YASM (if building x86 or x86-64 SIMD extensions)
* NASM 0.98, or 2.01 or later is required for an x86 build (0.99 and 2.00 do
not work properly with libjpeg-turbo's x86 SIMD code.)
* NASM 2.00 or later is required for an x86-64 build.
* NASM 2.07, or 2.11.09 or later is required for an x86-64 Mac build
(2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code when
building macho64 objects.) NASM or YASM can be obtained from MacPorts
(http://www.macports.org/).
The binary RPMs released by the NASM project do not work on older Linux
systems, such as Red Hat Enterprise Linux 4. On such systems, you can
easily build and install NASM from a source RPM by downloading one of the
SRPMs from
http://www.nasm.us/pub/nasm/releasebuilds
and executing the following as root:
ARCH=`uname -m`
rpmbuild --rebuild nasm-{version}.src.rpm
rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
NOTE: the NASM build will fail if texinfo is not installed.
-- GCC v4.1 or later recommended for best performance
* Beginning with Xcode 4, Apple stopped distributing GCC and switched to
the LLVM compiler. Xcode v4.0 through v4.6 provides a GCC front end
called LLVM-GCC. Unfortunately, as of this writing, neither LLVM-GCC nor
the LLVM (clang) compiler produces optimal performance with libjpeg-turbo.
Building mozjpeg with LLVM-GCC v4.2 results in a 10% performance
degradation when compressing using 64-bit code, relative to building
libjpeg-turbo with GCC v4.2. Building libjpeg-turbo with LLVM (clang)
results in a 20% performance degradation when compressing using 64-bit
code, relative to building libjpeg-turbo with GCC v4.2. If you are
running Snow Leopard or earlier, it is suggested that you continue to use
Xcode v3.2.6, which provides GCC v4.2. If you are using Lion or later, it
is suggested that you install Apple GCC v4.2 or GCC v5 through MacPorts.
-- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
required. Some systems, such as Solaris 10 and later and Red Hat Enterprise
Linux 5 and later, have this pre-installed. On OS X 10.5 and later, it will
be necessary to install the Java Developer Package, which can be downloaded
from http://developer.apple.com/downloads (Apple ID required.) For systems
that do not have a JDK installed, you can obtain the Oracle Java Development
Kit from http://www.java.com.
==================
Out-of-Tree Builds
==================
Binary objects, libraries, and executables are generated in the same directory
from which configure was executed (the "binary directory"), and this directory
need not necessarily be the same as the mozjpeg source directory. You
can create multiple independent binary directories, in which different versions
of mozjpeg can be built from the same source tree using different
compilers or settings. In the sections below, {build_directory} refers to the
binary directory, whereas {source_directory} refers to the mozjpeg source
directory. For in-tree builds, these directories are the same.
================
Building mozjpeg
================
The following procedure will build mozjpeg on Linux, FreeBSD, Cygwin, and
Solaris/x86 systems (on Solaris, this generates a 32-bit library. See below
for 64-bit build instructions.)
Simple Release tar.gz Source Build
----------------------------------
cd {source_directory}
./configure [additional configure flags]
make
Non-Release Source Build (e.g. GitHub clone)
--------------------------------------------
cd {source_directory}
autoreconf -fiv
cd {build_directory}
sh {source_directory}/configure [additional configure flags]
make
NOTE: Running autoreconf in the source directory is not necessary if building
mozjpeg from one of the official release tarballs.
This will generate the following files under .libs/
libjpeg.a
Static link library for the libjpeg API
libjpeg.so.{version} (Linux, Unix)
libjpeg.{version}.dylib (OS X)
cygjpeg-{version}.dll (Cygwin)
Shared library for the libjpeg API
By default, {version} is 62.2.0, 7.2.0, or 8.1.2, depending on whether
libjpeg v6b (default), v7, or v8 emulation is enabled. If using Cygwin,
{version} is 62, 7, or 8.
libjpeg.so (Linux, Unix)
libjpeg.dylib (OS X)
Development symlink for the libjpeg API
libjpeg.dll.a (Cygwin)
Import library for the libjpeg API
libturbojpeg.a
Static link library for the TurboJPEG API
libturbojpeg.so.0.1.0 (Linux, Unix)
libturbojpeg.0.1.0.dylib (OS X)
cygturbojpeg-0.dll (Cygwin)
Shared library for the TurboJPEG API
libturbojpeg.so (Linux, Unix)
libturbojpeg.dylib (OS X)
Development symlink for the TurboJPEG API
libturbojpeg.dll.a (Cygwin)
Import library for the TurboJPEG API
libjpeg v7 or v8 API/ABI Emulation
----------------------------------
Add --with-jpeg7 to the configure command line to build a version of
mozjpeg that is API/ABI-compatible with libjpeg v7. Add --with-jpeg8 to
the configure command to build a version of mozjpeg that is
API/ABI-compatible with libjpeg v8. See README-turbo.txt for more information
on libjpeg v7 and v8 emulation.
In-Memory Source/Destination Managers
-------------------------------------
When using libjpeg v6b or v7 API/ABI emulation, add --without-mem-srcdst to the
configure command line to build a version of mozjpeg that lacks the
jpeg_mem_src() and jpeg_mem_dest() functions. These functions were not part of
the original libjpeg v6b and v7 APIs, so removing them ensures strict
conformance with those APIs. See README-turbo.txt for more information.
Arithmetic Coding Support
-------------------------
Since the patent on arithmetic coding has expired, this functionality has been
included in this release of mozjpeg. mozjpeg's implementation is
based on the implementation in libjpeg v8, but it works when emulating libjpeg
v7 or v6b as well. The default is to enable both arithmetic encoding and
decoding, but those who have philosophical objections to arithmetic coding can
add --without-arith-enc or --without-arith-dec to the configure command line to
disable encoding or decoding (respectively.)
TurboJPEG Java Wrapper
----------------------
Add --with-java to the configure command line to incorporate an optional Java
Native Interface wrapper into the TurboJPEG shared library and build the Java
front-end classes to support it. This allows the TurboJPEG shared library to
be used directly from Java applications. See java/README for more details.
You can set the JAVAC, JAR, and JAVA configure variables to specify
alternate commands for javac, jar, and java (respectively.) You can also
set the JAVACFLAGS configure variable to specify arguments that should be
passed to the Java compiler when building the front-end classes, and JNI_CFLAGS
to specify arguments that should be passed to the C compiler when building the
JNI wrapper. Run 'configure --help' for more details.
==================
Installing mozjpeg
==================
If you intend to install these libraries and the associated header files, then
replace 'make' in the instructions above with
make install prefix={base dir} libdir={library directory}
For example,
make install prefix=/usr/local libdir=/usr/local/lib64
will install the header files in /usr/local/include and the library files in
/usr/local/lib64. If 'prefix' and 'libdir' are not specified, then the default
is to install the header files in /opt/mozjpeg/include and the library
files in /opt/mozjpeg/lib32 (32-bit) or /opt/mozjpeg/lib64
(64-bit.)
NOTE: You can specify a prefix of /usr and a libdir of, for instance,
/usr/lib64 to overwrite the system's version of libjpeg. If you do this,
however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before
overwriting it. It is recommended that you instead install mozjpeg into
a non-system directory and manipulate the LD_LIBRARY_PATH or create symlinks
to force applications to use mozjpeg instead of libjpeg. See
README-turbo.txt for more information.
=============
Build Recipes
=============
32-bit Build on 64-bit Linux
----------------------------
Add
--host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
to the configure command line.
64-bit Build on 64-bit OS X
---------------------------
Add
--host x86_64-apple-darwin NASM=/opt/local/bin/nasm
to the configure command line. NASM 2.07 or later from MacPorts must be
installed.
32-bit Build on 64-bit OS X
---------------------------
Add
--host i686-apple-darwin CFLAGS='-O3 -m32' LDFLAGS=-m32
to the configure command line.
64-bit Backward-Compatible Build on 64-bit OS X
-----------------------------------------------
Add
--host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
-mmacosx-version-min=10.5 -O3' \
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
-mmacosx-version-min=10.5'
to the configure command line. The OS X 10.5 SDK, and NASM 2.07 or later from
MacPorts, must be installed.
32-bit Backward-Compatible Build on OS X
----------------------------------------
Add
--host i686-apple-darwin \
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
-mmacosx-version-min=10.5 -O3 -m32' \
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
-mmacosx-version-min=10.5 -m32'
to the configure command line. The OS X 10.5 SDK must be installed.
64-bit Library Build on 64-bit Solaris
--------------------------------------
Add
--host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
to the configure command line.
32-bit Build on 64-bit FreeBSD
------------------------------
Add
--host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
LDFLAGS='-B/usr/lib32'
to the configure command line. NASM 2.07 or later from FreeBSD ports must be
installed.
Oracle Solaris Studio
---------------------
Add
CC=cc
to the configure command line. mozjpeg will automatically be built with
the maximum optimization level (-xO5) unless you override CFLAGS.
To build a 64-bit version of mozjpeg using Oracle Solaris Studio, add
--host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
to the configure command line.
MinGW Build on Cygwin
---------------------
Use CMake (see recipes below)
===========
ARM Support
===========
This release of mozjpeg can use ARM NEON SIMD instructions to accelerate
JPEG compression/decompression by approximately 2-4x on ARMv7 and later
platforms. If mozjpeg is configured on an ARM Linux platform, then the
build system will automatically include the NEON SIMD routines, if they are
supported. Build instructions for other ARM-based platforms follow.
Building mozjpeg for iOS
------------------------
iOS platforms, such as the iPhone and iPad, use ARM processors, some of which
support NEON instructions. Additional steps are required in order to build
mozjpeg for these platforms.
Additional build requirements:
gas-preprocessor.pl
(https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl)
should be installed in your PATH.
ARM 32-bit Build (Xcode 4.6.x and earlier, LLVM-GCC):
Set the following shell variables for simplicity:
Xcode 4.2 and earlier:
IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform
Xcode 4.3 and later:
IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
ARMv6 (code will run on all iOS devices, not SIMD-accelerated):
[NOTE: Requires Xcode 4.4.x or earlier]
IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer):
IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon"
ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer):
[NOTE: Requires Xcode 4.5 or later]
IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon"
Follow the procedure under "Building mozjpeg" above, adding
--host arm-apple-darwin10 \
CC="$IOS_GCC" LD="$IOS_GCC" \
CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS"
to the configure command line.
ARM 32-bit Build (Xcode 5.0.x and later, Clang):
Set the following shell variables for simplicity:
IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer):
IOS_CFLAGS="-arch armv7"
ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer):
IOS_CFLAGS="-arch armv7s"
Follow the procedure under "Building libjpeg-turbo" above, adding
--host arm-apple-darwin10 \
CC="$IOS_GCC" LD="$IOS_GCC" \
CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" \
CCASFLAGS="-no-integrated-as $IOS_CFLAGS"
to the configure command line.
ARMv8 64-bit Build (Xcode 5.0.x and later, Clang):
Code will run on iPhone 5S/iPad Mini 2/iPad Air and newer.
Set the following shell variables for simplicity:
IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
IOS_CFLAGS="-arch arm64"
Follow the procedure under "Building libjpeg-turbo" above, adding
--host aarch64-apple-darwin \
CC="$IOS_GCC" LD="$IOS_GCC" \
CFLAGS="-isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
LDFLAGS="-isysroot $IOS_SYSROOT $IOS_CFLAGS"
to the configure command line.
NOTE: You can also add -miphoneos-version-min={version} to $IOS_CFLAGS above
in order to support older versions of iOS than the default version supported by
the SDK.
Once built, lipo can be used to combine the ARMv6, v7, v7s, and/or v8 variants
into a universal library.
Building libjpeg-turbo for Android
----------------------------------
Building libjpeg-turbo for Android platforms requires the Android NDK
(https://developer.android.com/tools/sdk/ndk) and autotools. The following is
a general recipe script that can be modified for your specific needs.
# Set these variables to suit your needs
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/ndk}
BUILD_PLATFORM={the platform name for the NDK package you installed--
for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
toolchain directory under ${NDK_PATH}/toolchains/.}
ANDROID_VERSION={The minimum version of Android to support-- for example,
"16", "19", etc. "21" or later is required for a 64-bit build.}
# 32-bit ARMv7 build
HOST=arm-linux-androideabi
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
ANDROID_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
--sysroot=${SYSROOT}"
# 64-bit ARMv8 build
HOST=aarch64-linux-android
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm64
ANDROID_CFLAGS="--sysroot=${SYSROOT}"
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include"
export CPP=${TOOLCHAIN}/bin/${HOST}-cpp
export AR=${TOOLCHAIN}/bin/${HOST}-ar
export AS=${TOOLCHAIN}/bin/${HOST}-as
export NM=${TOOLCHAIN}/bin/${HOST}-nm
export CC=${TOOLCHAIN}/bin/${HOST}-gcc
export LD=${TOOLCHAIN}/bin/${HOST}-ld
export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib
export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump
export STRIP=${TOOLCHAIN}/bin/${HOST}-strip
cd {build_directory}
sh {source_directory}/configure --host=${HOST} \
CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3 -fPIE" \
CPPFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS}" \
LDFLAGS="${ANDROID_CFLAGS} -pie" --with-simd ${1+"$@"}
make
If building for Android 4.0.x (API level < 16) or earlier, remove -fPIE from
CFLAGS and -pie from LDFLAGS.
*******************************************************************************
** Building on Windows (Visual C++ or MinGW)
*******************************************************************************
==================
Build Requirements
==================
-- CMake (http://www.cmake.org) v2.8.8 or later
-- Microsoft Visual C++ 2005 or later
If you don't already have Visual C++, then the easiest way to get it is by
installing the Windows SDK:
http://msdn.microsoft.com/en-us/windows/bb980924.aspx
The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
everything necessary to build mozjpeg.
* You can also use Microsoft Visual Studio Express Edition, which is a free
download. (NOTE: versions prior to 2012 can only be used to build 32-bit
code.)
* If you intend to build mozjpeg from the command line, then add the
appropriate compiler and SDK directories to the INCLUDE, LIB, and PATH
environment variables. This is generally accomplished by executing
vcvars32.bat or vcvars64.bat and SetEnv.cmd. vcvars32.bat and
vcvars64.bat are part of Visual C++ and are located in the same directory
as the compiler. SetEnv.cmd is part of the Windows SDK. You can pass
optional arguments to SetEnv.cmd to specify a 32-bit or 64-bit build
environment.
... OR ...
-- MinGW
MinGW-builds (http://sourceforge.net/projects/mingwbuilds/) or
tdm-gcc (http://tdm-gcc.tdragon.net/) recommended if building on a Windows
machine. Both distributions install a Start Menu link that can be used to
launch a command prompt with the appropriate compiler paths automatically
set.
-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
a 64-bit build)
-- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
can be downloaded from http://www.java.com.
==================
Out-of-Tree Builds
==================
Binary objects, libraries, and executables are generated in the same directory
from which cmake was executed (the "binary directory"), and this directory need
not necessarily be the same as the mozjpeg source directory. You can
create multiple independent binary directories, in which different versions of
mozjpeg can be built from the same source tree using different compilers
or settings. In the sections below, {build_directory} refers to the binary
directory, whereas {source_directory} refers to the mozjpeg source
directory. For in-tree builds, these directories are the same.
================
Building mozjpeg
================
Visual C++ (Command Line)
-------------------------
cd {build_directory}
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory}
nmake
This will build either a 32-bit or a 64-bit version of mozjpeg, depending
on which version of cl.exe is in the PATH.
The following files will be generated under {build_directory}:
jpeg-static.lib
Static link library for the libjpeg API
sharedlib/jpeg{version}.dll
DLL for the libjpeg API
sharedlib/jpeg.lib
Import library for the libjpeg API
turbojpeg-static.lib
Static link library for the TurboJPEG API
turbojpeg.dll
DLL for the TurboJPEG API
turbojpeg.lib
Import library for the TurboJPEG API
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
v8 emulation is enabled.
Visual C++ (IDE)
----------------
Choose the appropriate CMake generator option for your version of Visual Studio
(run "cmake" with no arguments for a list of available generators.) For
instance:
cd {build_directory}
cmake -G "Visual Studio 10" {source_directory}
NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10
Win64") to build a 64-bit version of libjpeg-turbo. Recent versions of CMake
no longer document that. A separate build directory must be used for 32-bit
and 64-bit builds.
You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
configurations in that project ("Debug", "Release", etc.) to generate a full
build of mozjpeg.
This will generate the following files under {build_directory}:
{configuration}/jpeg-static.lib
Static link library for the libjpeg API
sharedlib/{configuration}/jpeg{version}.dll
DLL for the libjpeg API
sharedlib/{configuration}/jpeg.lib
Import library for the libjpeg API
{configuration}/turbojpeg-static.lib
Static link library for the TurboJPEG API
{configuration}/turbojpeg.dll
DLL for the TurboJPEG API
{configuration}/turbojpeg.lib
Import library for the TurboJPEG API
{configuration} is Debug, Release, RelWithDebInfo, or MinSizeRel, depending on
the configuration you built in the IDE, and {version} is 62, 7, or 8,
depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
MinGW
-----
NOTE: This assumes that you are building on a Windows machine. If you are
cross-compiling on a Linux/Unix machine, then see "Build Recipes" below.
cd {build_directory}
cmake -G "MinGW Makefiles" {source_directory}
mingw32-make
This will generate the following files under {build_directory}
libjpeg.a
Static link library for the libjpeg API
sharedlib/libjpeg-{version}.dll
DLL for the libjpeg API
sharedlib/libjpeg.dll.a
Import library for the libjpeg API
libturbojpeg.a
Static link library for the TurboJPEG API
libturbojpeg.dll
DLL for the TurboJPEG API
libturbojpeg.dll.a
Import library for the TurboJPEG API
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
v8 emulation is enabled.
Debug Build
-----------
Add "-DCMAKE_BUILD_TYPE=Debug" to the cmake command line. Or, if building with
NMake, remove "-DCMAKE_BUILD_TYPE=Release" (Debug builds are the default with
NMake.)
libjpeg v7 or v8 API/ABI Emulation
-----------------------------------
Add "-DWITH_JPEG7=1" to the cmake command line to build a version of
mozjpeg that is API/ABI-compatible with libjpeg v7. Add "-DWITH_JPEG8=1"
to the cmake command to build a version of mozjpeg that is
API/ABI-compatible with libjpeg v8. See README-turbo.txt for more information
on libjpeg v7 and v8 emulation.
In-Memory Source/Destination Managers
-------------------------------------
When using libjpeg v6b or v7 API/ABI emulation, add -DWITH_MEM_SRCDST=0 to the
CMake command line to build a version of mozjpeg that lacks the
jpeg_mem_src() and jpeg_mem_dest() functions. These functions were not part of
the original libjpeg v6b and v7 APIs, so removing them ensures strict
conformance with those APIs. See README-turbo.txt for more information.
Arithmetic Coding Support
-------------------------
Since the patent on arithmetic coding has expired, this functionality has been
included in this release of mozjpeg. mozjpeg's implementation is
based on the implementation in libjpeg v8, but it works when emulating libjpeg
v7 or v6b as well. The default is to enable both arithmetic encoding and
decoding, but those who have philosophical objections to arithmetic coding can
add "-DWITH_ARITH_ENC=0" or "-DWITH_ARITH_DEC=0" to the cmake command line to
disable encoding or decoding (respectively.)
TurboJPEG Java Wrapper
----------------------
Add "-DWITH_JAVA=1" to the cmake command line to incorporate an optional Java
Native Interface wrapper into the TurboJPEG shared library and build the Java
front-end classes to support it. This allows the TurboJPEG shared library to
be used directly from Java applications. See java/README for more details.
If you are using CMake 2.8, you can set the Java_JAVAC_EXECUTABLE,
Java_JAVA_EXECUTABLE, and Java_JAR_EXECUTABLE CMake variables to specify
alternate commands or locations for javac, jar, and java (respectively.) If
you are using CMake 2.6, set JAVA_COMPILE, JAVA_RUNTIME, and JAVA_ARCHIVE
instead. You can also set the JAVACFLAGS CMake variable to specify arguments
that should be passed to the Java compiler when building the front-end classes.
==================
Installing mozjpeg
==================
You can use the build system to install mozjpeg into a directory of your
choosing (as opposed to creating an installer.) To do this, add:
-DCMAKE_INSTALL_PREFIX={install_directory}
to the cmake command line.
For example,
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=c:\mozjpeg {source_directory}
nmake install
will install the header files in c:\mozjpeg\include, the library files
in c:\mozjpeg\lib, the DLL's in c:\mozjpeg\bin, and the
documentation in c:\mozjpeg\doc.
=============
Build Recipes
=============
64-bit MinGW Build on Cygwin
----------------------------
cd {build_directory}
CC=/usr/bin/x86_64-w64-mingw32-gcc \
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe \
{source_directory}
make
This produces a 64-bit build of mozjpeg that does not depend on
cygwin1.dll or other Cygwin DLL's. The mingw64-x86_64-gcc-core and
mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
32-bit MinGW Build on Cygwin
----------------------------
cd {build_directory}
CC=/usr/bin/i686-w64-mingw32-gcc \
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_RC_COMPILER=/usr/bin/i686-w64-mingw32-windres.exe \
{source_directory}
make
This produces a 32-bit build of mozjpeg that does not depend on
cygwin1.dll or other Cygwin DLL's. The mingw64-i686-gcc-core and
mingw64-i686-gcc-g++ packages (and their dependencies) must be installed.
MinGW Build on Linux
--------------------
cd {build_directory}
CC={mingw_binary_path}/i386-mingw32-gcc \
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
-DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
{source_directory}
make
*******************************************************************************
** Creating Release Packages
*******************************************************************************
The following commands can be used to create various types of release packages:
Unix/Linux
----------
make rpm
Create Red Hat-style binary RPM package. Requires RPM v4 or later.
make srpm
This runs 'make dist' to create a pristine source tarball, then creates a
Red Hat-style source RPM package from the tarball. Requires RPM v4 or later.
make deb
Create Debian-style binary package. Requires dpkg.
make dmg
Create Macintosh package/disk image. This requires pkgbuild and
productbuild, which are installed by default on OS X 10.7 and later and which
can be obtained by installing Xcode 3.2.6 (with the "Unix Development"
option) on OS X 10.6. Packages built in this manner can be installed on OS X
10.5 and later, but they must be built on OS X 10.6 or later.
make udmg [BUILDDIR32={32-bit build directory}]
On 64-bit OS X systems, this creates a Macintosh package and disk image that
contains universal i386/x86-64 binaries. You should first configure a 32-bit
out-of-tree build of mozjpeg, then configure a 64-bit out-of-tree
build, then run 'make udmg' from the 64-bit build directory. The build
system will look for the 32-bit build under {source_directory}/osxx86 by
default, but you can override this by setting the BUILDDIR32 variable on the
make command line as shown above.
make iosdmg [BUILDDIR32={32-bit build directory}] \
[BUILDDIRARMV6={ARMv6 build directory}] \
[BUILDDIRARMV7={ARMv7 build directory}] \
[BUILDDIRARMV7S={ARMv7s build directory}] \
[BUILDDIRARMV8={ARMv8 build directory}]
On OS X systems, this creates a Macintosh package and disk image in which the
mozjpeg static libraries contain ARM architectures necessary to build
iOS applications. If building on an x86-64 system, the binaries will also
contain the i386 architecture, as with 'make udmg' above. You should first
configure ARMv6, ARMv7, ARMv7s, and/or ARMv8 out-of-tree builds of
mozjpeg (see "Building mozjpeg for iOS" above.) If you are
building an x86-64 version of mozjpeg, you should configure a 32-bit
out-of-tree build as well. Next, build mozjpeg as you would normally,
using an out-of-tree build. When it is built, run 'make iosdmg' from the
build directory. The build system will look for the ARMv6 build under
{source_directory}/iosarmv6 by default, the ARMv7 build under
{source_directory}/iosarmv7 by default, the ARMv7s build under
{source_directory}/iosarmv7s by default, the ARMv8 build under
{source_directory}/iosarmv8 by default, and (if applicable) the 32-bit build
under {source_directory}/osxx86 by default, but you can override this by
setting the BUILDDIR32, BUILDDIRARMV6, BUILDDIRARMV7, BUILDDIRARMV7S, and/or
BUILDDIRARMV8 variables on the make command line as shown above.
NOTE: If including an ARMv8 build in the package, then you may need to use
Xcode's version of lipo instead of the operating system's. To do this, pass
an argument of LIPO="xcrun lipo" on the make command line.
make cygwinpkg
Build a Cygwin binary package.
Windows
-------
If using NMake:
cd {build_directory}
nmake installer
If using MinGW:
cd {build_directory}
make installer
If using the Visual Studio IDE, build the "installer" project.
The installer package (mozjpeg[-gcc][64].exe) will be located under
{build_directory}. If building using the Visual Studio IDE, then the installer
package will be located in a subdirectory with the same name as the
configuration you built (such as {build_directory}\Debug\ or
{build_directory}\Release\).
Building a Windows installer requires the Nullsoft Install System
(http://nsis.sourceforge.net/.) makensis.exe should be in your PATH.
*******************************************************************************
** Regression testing
*******************************************************************************
The most common way to test mozjpeg is by invoking 'make test' on
Unix/Linux platforms or 'ctest' on Windows platforms, once the build has
completed. This runs a series of tests to ensure that mathematical
compatibility has been maintained. This also invokes the TurboJPEG unit tests,
which ensure that the colorspace extensions, YUV encoding, decompression
scaling, and other features of the TurboJPEG C and Java APIs are working
properly (and, by extension, that the equivalent features of the underlying
libjpeg API are also working.)
Invoking 'make testclean' or 'nmake testclean' (if using NMake) or building
the 'testclean' target (if using the Visual Studio IDE) will clean up the
output images generated by 'make test'.
On Unix/Linux platforms, more extensive tests of the TurboJPEG C and Java
wrappers can be run by invoking 'make tjtest'. These extended TurboJPEG tests
essentially iterate through all of the available features of the TurboJPEG APIs
that are not covered by the TurboJPEG unit tests (this includes the lossless
transform options) and compare the images generated by each feature to images
generated using the equivalent feature in the libjpeg API. The extended
TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
not in the underlying libjpeg API library.

View File

@@ -8,8 +8,26 @@ if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif()
project(mozjpeg C)
set(VERSION 3.3.1)
project(libjpeg-turbo C)
set(VERSION 1.5.3)
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
list(GET VERSION_TRIPLET 2 VERSION_REVISION)
function(pad_number NUMBER OUTPUT_LEN)
string(LENGTH "${${NUMBER}}" INPUT_LEN)
if(INPUT_LEN LESS OUTPUT_LEN)
math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1")
set(NUM ${${NUMBER}})
foreach(C RANGE ${ZEROES})
set(NUM "0${NUM}")
endforeach()
set(${NUMBER} ${NUM} PARENT_SCOPE)
endif()
endfunction()
pad_number(VERSION_MINOR 3)
pad_number(VERSION_REVISION 3)
set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION})
if(NOT WIN32)
message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
@@ -34,10 +52,10 @@ endif()
message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
option(WITH_SIMD "Include SIMD extensions" TRUE)
option(WITH_ARITH_ENC "Include arithmetic encoding support" TRUE)
option(WITH_ARITH_DEC "Include arithmetic decoding support" TRUE)
option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes mozjpeg backward incompatible with libjpeg v6b)" FALSE)
option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes mozjpeg backward incompatible with libjpeg v6b)" FALSE)
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE)
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE)
option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE)
option(WITH_TURBOJPEG "Include the TurboJPEG wrapper library and associated test programs" TRUE)
option(WITH_JAVA "Build Java wrapper for the TurboJPEG library" FALSE)
@@ -159,7 +177,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX_DEFAULT ${CMAKE_INSTALL_PREFIX_DEFAULT}64)
endif()
set(CMAKE_INSTALL_PREFIX "c:/${CMAKE_INSTALL_PREFIX_DEFAULT}" CACHE PATH
"Directory into which to install mozjpeg (default: c:/${CMAKE_INSTALL_PREFIX_DEFAULT})"
"Directory into which to install libjpeg-turbo (default: c:/${CMAKE_INSTALL_PREFIX_DEFAULT})"
FORCE)
endif()
@@ -168,7 +186,7 @@ message(STATUS "Install directory = ${CMAKE_INSTALL_PREFIX}")
configure_file(win/jconfig.h.in jconfig.h)
configure_file(win/jconfigint.h.in jconfigint.h)
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
@@ -191,13 +209,13 @@ endif()
# Targets
#
set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jcext.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)
set(JPEG_SOURCES 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)
if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
@@ -301,7 +319,7 @@ else()
endif()
if(ENABLE_STATIC)
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdjpeg.c rdswitch.c
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
${CJPEG_BMP_SOURCES})
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
target_link_libraries(cjpeg-static jpeg-static)
@@ -351,8 +369,8 @@ if(WITH_12BIT)
set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
if(64BIT)
# Windows/x64 uses SSE for floating point
set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8)
set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956)
set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8)
set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956)
else()
# Windows/x86 uses the 387 FPU for floating point
if(MSVC)
@@ -405,8 +423,8 @@ else()
set(MD5_PPM_3x2_FLOAT 1a75f36e5904d6fc3a85a43da9ad89bb)
else()
if(64BIT)
set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
else()
if(MSVC)
set(MD5_JPEG_3x2_FLOAT_PROG 7999ce9cd0ee9b6c7043b7351ab7639d)
@@ -414,7 +432,7 @@ else()
else()
set(MD5_JPEG_3x2_FLOAT_PROG 1657664a410e0822c924b54f6f65e6e9)
set(MD5_PPM_3x2_FLOAT cb0a1f027f3d2917c902b5640214e025)
endif()
endif()
endif()
endif()
set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
@@ -511,7 +529,7 @@ foreach(libtype ${TEST_LIBTYPES})
# CC: null SAMP: fullsize FDCT: islow ENT: huff
add_test(cjpeg${suffix}-rgb-islow
${dir}cjpeg${suffix} -revert -rgb -dct int
${dir}cjpeg${suffix} -rgb -dct int
-outfile testout_rgb_islow.jpg ${TESTIMAGES}/testorig.ppm)
add_test(cjpeg${suffix}-rgb-islow-cmp
${MD5CMP} ${MD5_JPEG_RGB_ISLOW} testout_rgb_islow.jpg)
@@ -541,7 +559,7 @@ foreach(libtype ${TEST_LIBTYPES})
# CC: RGB->YCC SAMP: fullsize/h2v1 FDCT: ifast ENT: 2-pass huff
add_test(cjpeg${suffix}-422-ifast-opt
${dir}cjpeg${suffix} -revert -sample 2x1 -dct fast -opt
${dir}cjpeg${suffix} -sample 2x1 -dct fast -opt
-outfile testout_422_ifast_opt.jpg ${TESTIMAGES}/testorig.ppm)
add_test(cjpeg${suffix}-422-ifast-opt-cmp
${MD5CMP} ${MD5_JPEG_422_IFAST_OPT} testout_422_ifast_opt.jpg)
@@ -578,7 +596,7 @@ foreach(libtype ${TEST_LIBTYPES})
# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
add_test(cjpeg${suffix}-420-q100-ifast-prog
${dir}cjpeg${suffix} -revert -sample 2x2 -quality 100 -dct fast -prog
${dir}cjpeg${suffix} -sample 2x2 -quality 100 -dct fast -prog
-outfile testout_420_q100_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm)
add_test(cjpeg${suffix}-420-q100-ifast-prog-cmp
${MD5CMP} ${MD5_JPEG_420_IFAST_Q100_PROG} testout_420_q100_ifast_prog.jpg)
@@ -599,7 +617,7 @@ foreach(libtype ${TEST_LIBTYPES})
# CC: RGB->Gray SAMP: fullsize FDCT: islow ENT: huff
add_test(cjpeg${suffix}-gray-islow
${dir}cjpeg${suffix} -revert -gray -dct int
${dir}cjpeg${suffix} -gray -dct int
-outfile testout_gray_islow.jpg ${TESTIMAGES}/testorig.ppm)
add_test(cjpeg${suffix}-gray-islow-cmp
${MD5CMP} ${MD5_JPEG_GRAY_ISLOW} testout_gray_islow.jpg)
@@ -644,7 +662,7 @@ foreach(libtype ${TEST_LIBTYPES})
# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
add_test(cjpeg${suffix}-3x2-float-prog
${dir}cjpeg${suffix} -revert -sample 3x2 -dct float -prog
${dir}cjpeg${suffix} -sample 3x2 -dct float -prog
-outfile testout_3x2_float_prog.jpg ${TESTIMAGES}/testorig.ppm)
add_test(cjpeg${suffix}-3x2-float-prog-cmp
${MD5CMP} ${MD5_JPEG_3x2_FLOAT_PROG} testout_3x2_float_prog.jpg)
@@ -659,20 +677,20 @@ foreach(libtype ${TEST_LIBTYPES})
if(WITH_ARITH_ENC)
# CC: YCC->RGB SAMP: fullsize/h2v2 FDCT: islow ENT: arith
add_test(cjpeg${suffix}-420-islow-ari
${dir}cjpeg${suffix} -revert -dct int -arithmetic
${dir}cjpeg${suffix} -dct int -arithmetic
-outfile testout_420_islow_ari.jpg ${TESTIMAGES}/testorig.ppm)
add_test(cjpeg${suffix}-420-islow-ari-cmp
${MD5CMP} ${MD5_JPEG_420_ISLOW_ARI} testout_420_islow_ari.jpg)
add_test(jpegtran${suffix}-420-islow-ari
${dir}jpegtran${suffix} -revert -arithmetic
${dir}jpegtran${suffix} -arithmetic
-outfile testout_420_islow_ari.jpg ${TESTIMAGES}/testimgint.jpg)
add_test(jpegtran${suffix}-420-islow-ari-cmp
${MD5CMP} ${MD5_JPEG_420_ISLOW_ARI} testout_420_islow_ari.jpg)
# CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith
add_test(cjpeg${suffix}-444-islow-progari
${dir}cjpeg${suffix} -revert -sample 1x1 -dct int -prog -arithmetic
${dir}cjpeg${suffix} -sample 1x1 -dct int -prog -arithmetic
-outfile testout_444_islow_progari.jpg ${TESTIMAGES}/testorig.ppm)
add_test(cjpeg${suffix}-444-islow-progari-cmp
${MD5CMP} ${MD5_JPEG_444_ISLOW_PROGARI} testout_444_islow_progari.jpg)
@@ -687,7 +705,7 @@ foreach(libtype ${TEST_LIBTYPES})
${MD5CMP} ${MD5_PPM_420M_IFAST_ARI} testout_420m_ifast_ari.ppm)
add_test(jpegtran${suffix}-420-islow
${dir}jpegtran${suffix} -revert
${dir}jpegtran${suffix}
-outfile testout_420_islow.jpg ${TESTIMAGES}/testimgari.jpg)
add_test(jpegtran${suffix}-420-islow-cmp
${MD5CMP} ${MD5_JPEG_420_ISLOW} testout_420_islow.jpg)
@@ -841,7 +859,7 @@ foreach(libtype ${TEST_LIBTYPES})
endif()
add_test(jpegtran${suffix}-crop
${dir}jpegtran${suffix} -revert -crop 120x90+20+50 -transpose -perfect
${dir}jpegtran${suffix} -crop 120x90+20+50 -transpose -perfect
-outfile testout_crop.jpg ${TESTIMAGES}/${TESTORIG})
add_test(jpegtran${suffix}-crop-cmp
${MD5CMP} ${MD5_JPEG_CROP} testout_crop.jpg)
@@ -870,7 +888,7 @@ endif()
if(64BIT)
set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
set(INST_NAME ${INST_NAME}64)
set(INST_REG_NAME "${INST_DIR}64")
set(INST_REG_NAME ${INST_DIR}64)
set(INST_DEFS ${INST_DEFS} -DWIN64)
endif()
@@ -884,18 +902,18 @@ else()
set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
endif()
STRING(REGEX REPLACE "/" "\\\\" INST_DIR "${CMAKE_INSTALL_PREFIX}")
STRING(REGEX REPLACE "/" "\\\\" INST_DIR ${CMAKE_INSTALL_PREFIX})
configure_file(release/mozjpeg.nsi.in mozjpeg.nsi @ONLY)
configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
if(WITH_JAVA)
set(JAVA_DEPEND java)
endif()
add_custom_target(installer
makensis -nocd ${INST_DEFS} mozjpeg.nsi
makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
cjpeg djpeg jpegtran tjbench ${JAVA_DEPEND}
SOURCES mozjpeg.nsi)
SOURCES libjpeg-turbo.nsi)
if(WITH_TURBOJPEG)
if(ENABLE_SHARED)
@@ -928,7 +946,7 @@ endif()
install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION bin)
install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README-mozilla.txt
install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README.md
${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt
${CMAKE_SOURCE_DIR}/structure.txt ${CMAKE_SOURCE_DIR}/usage.txt
${CMAKE_SOURCE_DIR}/wizard.txt

View File

@@ -1,3 +1,47 @@
1.5.3
=====
### Significant changes relative to 1.5.2:
1. Fixed a NullPointerException in the TurboJPEG Java wrapper that occurred
when using the YUVImage constructor that creates an instance backed by separate
image planes and allocates memory for the image planes.
2. Fixed an issue whereby the Java version of TJUnitTest would fail when
testing BufferedImage encoding/decoding on big endian systems.
3. Fixed a segfault in djpeg that would occur if an output format other than
PPM/PGM was selected along with the `-crop` option. The `-crop` option now
works with the GIF and Targa formats as well (unfortunately, it cannot be made
to work with the BMP and RLE formats due to the fact that those output engines
write scanlines in bottom-up order.) djpeg will now exit gracefully if an
output format other than PPM/PGM, GIF, or Targa is selected along with the
`-crop` option.
4. Fixed an issue whereby `jpeg_skip_scanlines()` would segfault if color
quantization was enabled.
5. TJBench (both C and Java versions) will now display usage information if any
command-line argument is unrecognized. This prevents the program from silently
ignoring typos.
6. Fixed an access violation in tjbench.exe (Windows) that occurred when the
program was used to decompress an existing JPEG image.
7. Fixed an ArrayIndexOutOfBoundsException in the TJExample Java program that
occurred when attempting to decompress a JPEG image that had been compressed
with 4:1:1 chrominance subsampling.
8. Fixed an issue whereby, when using `jpeg_skip_scanlines()` to skip to the
end of a single-scan (non-progressive) image, subsequent calls to
`jpeg_consume_input()` would return `JPEG_SUSPENDED` rather than
`JPEG_REACHED_EOI`.
9. `jpeg_crop_scanlines()` now works correctly when decompressing grayscale
JPEG images that were compressed with a sampling factor other than 1 (for
instance, with `cjpeg -grayscale -sample 2x2`).
1.5.2
=====

View File

@@ -16,18 +16,18 @@ if WITH_TURBOJPEG
pkgconfig_DATA += pkgscripts/libturbojpeg.pc
endif
HDRS = jchuff.h jcmaster.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h \
jmorecfg.h jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h jpegcomp.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 jpegcomp.h \
jpeg_nbits_table.h
libjpeg_la_SOURCES = $(HDRS) jcapimin.c jcapistd.c jccoefct.c jccolor.c \
jcdctmgr.c jcext.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
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
if WITH_ARITH
libjpeg_la_SOURCES += jaricom.c
@@ -90,7 +90,7 @@ endif
bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom
noinst_PROGRAMS = jcstest jpegyuv yuvjpeg
noinst_PROGRAMS = jcstest
if WITH_TURBOJPEG
@@ -113,7 +113,7 @@ tjunittest_LDADD = libturbojpeg.la
endif
cjpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c cjpeg.c rdgif.c rdppm.c rdswitch.c rdjpeg.c
cjpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c cjpeg.c rdgif.c rdppm.c rdswitch.c
if WITH_12BIT
else
cjpeg_SOURCES += rdbmp.c rdtarga.c
@@ -127,12 +127,6 @@ else
cjpeg_CFLAGS += -DBMP_SUPPORTED -DTARGA_SUPPORTED
endif
if HAVE_LIBPNG
cjpeg_CFLAGS += -DPNG_SUPPORTED $(libpng_CFLAGS)
cjpeg_LDADD += $(libpng_LIBS)
cjpeg_SOURCES += rdpng.c
endif
djpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c djpeg.c rdcolmap.c rdswitch.c \
wrgif.c wrppm.c
if WITH_12BIT
@@ -164,14 +158,6 @@ jcstest_SOURCES = jcstest.c
jcstest_LDADD = libjpeg.la
jpegyuv_SOURCES = jpegyuv.c
jpegyuv_LDADD = libjpeg.la
yuvjpeg_SOURCES = yuvjpeg.c
yuvjpeg_LDADD = libjpeg.la
dist_man1_MANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1
DOCS= coderules.txt jconfig.txt change.log rdrle.c wrrle.c BUILDING.md \
@@ -187,7 +173,7 @@ dist_example_DATA = example.c
EXTRA_DIST = win release $(DOCS) testimages CMakeLists.txt \
sharedlib/CMakeLists.txt cmakescripts libjpeg.map.in doc doxygen.config \
doxygen-extra.css jccolext.c jdcolext.c jdcol565.c jdmrgext.c jdmrg565.c \
jstdhuff.c jdcoefct.h jdmainct.h jdmaster.h jdsample.h wrppm.h \
jstdhuff.c jdcoefct.h jdmainct.h jdmaster.h jdsample.h \
md5/CMakeLists.txt
dist-hook:
@@ -355,7 +341,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3
# Test compressing from/decompressing to an arbitrary subregion of a larger
# image buffer
cp $(srcdir)/testimages/testorig.ppm testout_tile.ppm
TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
for i in 8 16 32 64 128; do \
md5/md5cmp $(MD5_PPM_GRAY_TILE) testout_tile_GRAY_Q95_$$i\x$$i.ppm; \
done
@@ -374,7 +360,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3
done
rm -f testout_tile_GRAY_* testout_tile_420_* testout_tile_422_* testout_tile_444_*
TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
md5/md5cmp $(MD5_PPM_420M_8x8_TILE) testout_tile_420_Q95_8x8.ppm
for i in 16 32 64 128; do \
md5/md5cmp $(MD5_PPM_420M_TILE) testout_tile_420_Q95_$$i\x$$i.ppm; \
@@ -399,7 +385,7 @@ endif
# ones.)
# CC: null SAMP: fullsize FDCT: islow ENT: huff
./cjpeg -revert -rgb -dct int -outfile testout_rgb_islow.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -rgb -dct int -outfile testout_rgb_islow.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_RGB_ISLOW) testout_rgb_islow.jpg
# CC: null SAMP: fullsize IDCT: islow ENT: huff
./djpeg -dct int -ppm -outfile testout_rgb_islow.ppm testout_rgb_islow.jpg
@@ -419,7 +405,7 @@ else
endif
# CC: RGB->YCC SAMP: fullsize/h2v1 FDCT: ifast ENT: 2-pass huff
./cjpeg -revert -sample 2x1 -dct fast -opt -outfile testout_422_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -sample 2x1 -dct fast -opt -outfile testout_422_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_422_IFAST_OPT) testout_422_ifast_opt.jpg
# CC: YCC->RGB SAMP: fullsize/h2v1 fancy IDCT: ifast ENT: huff
./djpeg -dct fast -outfile testout_422_ifast.ppm testout_422_ifast_opt.jpg
@@ -443,7 +429,7 @@ else
endif
# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
./cjpeg -revert -sample 2x2 -quality 100 -dct fast -prog -outfile testout_420_q100_ifast_prog.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -sample 2x2 -quality 100 -dct fast -prog -outfile testout_420_q100_ifast_prog.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_420_IFAST_Q100_PROG) testout_420_q100_ifast_prog.jpg
# CC: YCC->RGB SAMP: fullsize/h2v2 fancy IDCT: ifast ENT: prog huff
./djpeg -dct fast -outfile testout_420_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
@@ -455,7 +441,7 @@ endif
rm -f testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
# CC: RGB->Gray SAMP: fullsize FDCT: islow ENT: huff
./cjpeg -revert -gray -dct int -outfile testout_gray_islow.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -gray -dct int -outfile testout_gray_islow.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_GRAY_ISLOW) testout_gray_islow.jpg
# CC: Gray->Gray SAMP: fullsize IDCT: islow ENT: huff
./djpeg -dct int -outfile testout_gray_islow.ppm testout_gray_islow.jpg
@@ -480,7 +466,7 @@ endif
# CC: RGB->YCC SAMP: fullsize smooth/h2v2 smooth FDCT: islow
# ENT: 2-pass huff
./cjpeg -revert -sample 2x2 -smooth 1 -dct int -opt -outfile testout_420s_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -sample 2x2 -smooth 1 -dct int -opt -outfile testout_420s_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_420S_IFAST_OPT) testout_420s_ifast_opt.jpg
rm -f testout_420s_ifast_opt.jpg
@@ -504,7 +490,7 @@ endif
# generally the default with x86 compilers)
# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
./cjpeg -revert -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm
if [ "${FLOATTEST}" = "sse" ]; then \
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_SSE) testout_3x2_float_prog.jpg; \
elif [ "${FLOATTEST}" = "32bit" -o "${FLOATTEST}" = "64bit" ]; then \
@@ -526,7 +512,7 @@ endif
rm -f testout_3x2_float.ppm testout_3x2_float_prog.jpg
# CC: RGB->YCC SAMP: fullsize/int FDCT: ifast ENT: prog huff
./cjpeg -revert -sample 3x2 -dct fast -prog -outfile testout_3x2_ifast_prog.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -sample 3x2 -dct fast -prog -outfile testout_3x2_ifast_prog.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_3x2_IFAST_PROG) testout_3x2_ifast_prog.jpg
# CC: YCC->RGB SAMP: fullsize/int IDCT: ifast ENT: prog huff
./djpeg -dct fast -outfile testout_3x2_ifast.ppm testout_3x2_ifast_prog.jpg
@@ -535,14 +521,14 @@ endif
if WITH_ARITH_ENC
# CC: YCC->RGB SAMP: fullsize/h2v2 FDCT: islow ENT: arith
./cjpeg -revert -dct int -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -dct int -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_420_ISLOW_ARI) testout_420_islow_ari.jpg
rm -f testout_420_islow_ari.jpg
./jpegtran -revert -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testimgint.jpg
./jpegtran -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testimgint.jpg
md5/md5cmp $(MD5_JPEG_420_ISLOW_ARI) testout_420_islow_ari.jpg
rm -f testout_420_islow_ari.jpg
# CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith
./cjpeg -revert -sample 1x1 -dct int -prog -arithmetic -outfile testout_444_islow_progari.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -sample 1x1 -dct int -prog -arithmetic -outfile testout_444_islow_progari.jpg $(srcdir)/testimages/testorig.ppm
md5/md5cmp $(MD5_JPEG_444_ISLOW_PROGARI) testout_444_islow_progari.jpg
rm -f testout_444_islow_progari.jpg
endif
@@ -551,7 +537,7 @@ if WITH_ARITH_DEC
./djpeg -fast -ppm -outfile testout_420m_ifast_ari.ppm $(srcdir)/testimages/testimgari.jpg
md5/md5cmp $(MD5_PPM_420M_IFAST_ARI) testout_420m_ifast_ari.ppm
rm -f testout_420m_ifast_ari.ppm
./jpegtran -revert -outfile testout_420_islow.jpg $(srcdir)/testimages/testimgari.jpg
./jpegtran -outfile testout_420_islow.jpg $(srcdir)/testimages/testimgari.jpg
md5/md5cmp $(MD5_JPEG_420_ISLOW) testout_420_islow.jpg
rm -f testout_420_islow.jpg
endif
@@ -642,7 +628,7 @@ if WITH_ARITH_DEC
rm -f testout_420_islow_ari_skip16,139.ppm
endif
# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff
./cjpeg -revert -dct int -prog -outfile testout_420_islow_prog.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -dct int -prog -outfile testout_420_islow_prog.jpg $(srcdir)/testimages/testorig.ppm
./djpeg -dct int -crop 62x62+71+71 -ppm -outfile testout_420_islow_prog_crop62x62,71,71.ppm testout_420_islow_prog.jpg
md5/md5cmp $(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71) testout_420_islow_prog_crop62x62,71,71.ppm
rm -f testout_420_islow_prog_crop62x62,71,71.ppm testout_420_islow_prog.jpg
@@ -653,18 +639,18 @@ if WITH_ARITH_DEC
rm -f testout_420_islow_ari_crop53x53,4,4.ppm
endif
# Context rows: No Intra-iMCU row: Yes ENT: huff
./cjpeg -revert -dct int -sample 1x1 -outfile testout_444_islow.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -dct int -sample 1x1 -outfile testout_444_islow.jpg $(srcdir)/testimages/testorig.ppm
./djpeg -dct int -skip 1,6 -ppm -outfile testout_444_islow_skip1,6.ppm testout_444_islow.jpg
md5/md5cmp $(MD5_PPM_444_ISLOW_SKIP1_6) testout_444_islow_skip1,6.ppm
rm -f testout_444_islow_skip1,6.ppm testout_444_islow.jpg
# Context rows: No Intra-iMCU row: No ENT: prog huff
./cjpeg -revert -dct int -prog -sample 1x1 -outfile testout_444_islow_prog.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -dct int -prog -sample 1x1 -outfile testout_444_islow_prog.jpg $(srcdir)/testimages/testorig.ppm
./djpeg -dct int -crop 98x98+13+13 -ppm -outfile testout_444_islow_prog_crop98x98,13,13.ppm testout_444_islow_prog.jpg
md5/md5cmp $(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13) testout_444_islow_prog_crop98x98,13,13.ppm
rm -f testout_444_islow_prog_crop98x98,13,13.ppm testout_444_islow_prog.jpg
# Context rows: No Intra-iMCU row: No ENT: arith
if WITH_ARITH_ENC
./cjpeg -revert -dct int -arithmetic -sample 1x1 -outfile testout_444_islow_ari.jpg $(srcdir)/testimages/testorig.ppm
./cjpeg -dct int -arithmetic -sample 1x1 -outfile testout_444_islow_ari.jpg $(srcdir)/testimages/testorig.ppm
if WITH_ARITH_DEC
./djpeg -dct int -crop 37x37+0+0 -ppm -outfile testout_444_islow_ari_crop37x37,0,0.ppm testout_444_islow_ari.jpg
md5/md5cmp $(MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0) testout_444_islow_ari_crop37x37,0,0.ppm
@@ -673,7 +659,7 @@ endif
rm -f testout_444_islow_ari.jpg
endif
./jpegtran -revert -crop 120x90+20+50 -transpose -perfect -outfile testout_crop.jpg $(srcdir)/testimages/$(TESTORIG)
./jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testout_crop.jpg $(srcdir)/testimages/$(TESTORIG)
md5/md5cmp $(MD5_JPEG_CROP) testout_crop.jpg
rm -f testout_crop.jpg
echo GREAT SUCCESS!
@@ -711,6 +697,8 @@ testclean:
rm -f *_411_*.ppm
rm -f *_411_*.jpg
rm -f *_411.yuv
rm -f tjbenchtest*.log
rm -f tjexampletest*.log
tjtest:
@@ -724,26 +712,26 @@ if WITH_JAVA
endif
pkgscripts/mozjpeg.spec: pkgscripts/mozjpeg.spec.tmpl
cat pkgscripts/mozjpeg.spec.tmpl | sed s@%{__prefix}@$(prefix)@g | \
pkgscripts/libjpeg-turbo.spec: pkgscripts/libjpeg-turbo.spec.tmpl
cat pkgscripts/libjpeg-turbo.spec.tmpl | sed s@%{__prefix}@$(prefix)@g | \
sed s@%{__bindir}@$(bindir)@g | sed s@%{__datadir}@$(datadir)@g | \
sed s@%{__docdir}@$(docdir)@g | sed s@%{__includedir}@$(includedir)@g | \
sed s@%{__libdir}@$(libdir)@g | sed s@%{__mandir}@$(mandir)@g \
> pkgscripts/mozjpeg.spec
> pkgscripts/libjpeg-turbo.spec
rpm: all pkgscripts/mozjpeg.spec
rpm: all pkgscripts/libjpeg-turbo.spec
TMPDIR=`mktemp -d /tmp/${PACKAGE_NAME}-build.XXXXXX`; \
mkdir -p $$TMPDIR/RPMS; \
ln -fs `pwd` $$TMPDIR/BUILD; \
rm -f ${PKGNAME}-${VERSION}.${RPMARCH}.rpm; \
rpmbuild -bb --define "_blddir $$TMPDIR/buildroot" \
--define "_topdir $$TMPDIR" \
--target ${RPMARCH} pkgscripts/mozjpeg.spec; \
--target ${RPMARCH} pkgscripts/libjpeg-turbo.spec; \
cp $$TMPDIR/RPMS/${RPMARCH}/${PKGNAME}-${VERSION}-${BUILD}.${RPMARCH}.rpm \
${PKGNAME}-${VERSION}.${RPMARCH}.rpm; \
rm -rf $$TMPDIR
srpm: dist-gzip pkgscripts/mozjpeg.spec
srpm: dist-gzip pkgscripts/libjpeg-turbo.spec
TMPDIR=`mktemp -d /tmp/${PACKAGE_NAME}-build.XXXXXX`; \
mkdir -p $$TMPDIR/RPMS; \
mkdir -p $$TMPDIR/SRPMS; \
@@ -752,10 +740,10 @@ srpm: dist-gzip pkgscripts/mozjpeg.spec
mkdir -p $$TMPDIR/SPECS; \
rm -f ${PKGNAME}-${VERSION}.src.rpm; \
cp ${PACKAGE_NAME}-${VERSION}.tar.gz $$TMPDIR/SOURCES; \
cat pkgscripts/mozjpeg.spec | sed s/%{_blddir}/%{_tmppath}/g \
cat pkgscripts/libjpeg-turbo.spec | sed s/%{_blddir}/%{_tmppath}/g \
| sed s/#--\>//g \
> $$TMPDIR/SPECS/mozjpeg.spec; \
rpmbuild -bs --define "_topdir $$TMPDIR" $$TMPDIR/SPECS/mozjpeg.spec; \
> $$TMPDIR/SPECS/libjpeg-turbo.spec; \
rpmbuild -bs --define "_topdir $$TMPDIR" $$TMPDIR/SPECS/libjpeg-turbo.spec; \
cp $$TMPDIR/SRPMS/${PKGNAME}-${VERSION}-${BUILD}.src.rpm \
${PKGNAME}-${VERSION}.src.rpm; \
rm -rf $$TMPDIR

View File

@@ -1,194 +0,0 @@
Mozilla JPEG Encoder Project
============================
mozjpeg is a fork of libjpeg-turbo that aims to speed up load times of web
pages by reducing the size (and, by extension, the transmission time) of JPEG
files. It accomplishes this by enabling optimized Huffman trees and
progressive entropy coding by default in the JPEG compressor, as well as
splitting the spectrum of DCT coefficients into separate scans and using
Trellis quantisation.
Although it is based on libjpeg-turbo, mozjpeg is not intended to be a
general-purpose or high-performance JPEG library. Its performance is highly
"asymmetric". That is, the JPEG files it generates require much more time to
compress than to decompress. When the default settings are used, mozjpeg is
considerably slower than libjpeg-turbo or even libjpeg at compressing images.
Thus, it is not generally suitable for real-time compression. It is best used
as part of a web encoding workflow.
libjpeg API Extensibility Framework
===================================
mozjpeg's implementation of the libjpeg API includes an extensibility framework
that allows new features to be added without modifying the transparent libjpeg
compress/decompress structures (which would break backward ABI compatibility.)
Extension parameters are placed into the opaque jpeg_comp_master structure, and
a set of accessor functions and globally unique tokens allows for
getting/setting those parameters without directly accessing the structure.
Currently, only the accessor functions necessary to support the mozjpeg
extensions are implemented, but the framework can be easily extended in the
future to accommodate additional simple parameter types, complex or
multi-valued parameters, or decompressor extensions.
The currently-implemented accessor functions are as follows:
boolean jpeg_c_bool_param_supported (j_compress_ptr cinfo,
J_BOOLEAN_PARAM param)
Returns TRUE if the given boolean extension parameter is supported by
this implementation of the libjpeg API, or FALSE otherwise.
void jpeg_c_set_bool_param (j_compress_ptr cinfo,
J_BOOLEAN_PARAM param, boolean value);
Set the given boolean extension parameter to the given value (TRUE or
FALSE.)
boolean jpeg_c_get_bool_param (j_compress_ptr cinfo, J_BOOLEAN_PARAM param)
Get the value of the given boolean extension parameter (TRUE or FALSE.)
boolean jpeg_c_float_param_supported (j_compress_ptr cinfo,
J_FLOAT_PARAM param)
Returns TRUE if the given floating point extension parameter is
supported by this implementation of the libjpeg API, or FALSE
otherwise.
void jpeg_c_set_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param,
float value)
Set the given floating point extension parameter to the given value.
float jpeg_c_get_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param);
Get the value of the given floating point extension parameter.
boolean jpeg_c_int_param_supported (j_compress_ptr cinfo,
J_INT_PARAM param)
Returns TRUE if the given integer extension parameter is supported by
this implementation of the libjpeg API, or FALSE otherwise.
void jpeg_c_set_int_param (j_compress_ptr cinfo, J_INT_PARAM param,
int value)
Set the given integer extension parameter to the given value.
int jpeg_c_get_int_param (j_compress_ptr cinfo, J_INT_PARAM param)
Get the value of the given integer extension parameter.
Boolean Extension Parameters Supported by mozjpeg
-------------------------------------------------
* JBOOLEAN_OPTIMIZE_SCANS (default: TRUE)
Specifies whether scan parameters should be optimized. Parameter
optimization is done as in jpgcrush. jpeg_simple_progression() should be called
after setting JBOOLEAN_OPTIMIZE_SCANS.
When disabling JBOOLEAN_OPTIMIZE_SCANS, cinfo.scan_info should additionally be
set to NULL to disable use of the progressive coding mode, if so desired.
* JBOOLEAN_TRELLIS_QUANT (default: TRUE)
Specifies whether to apply trellis quantization. For each 8x8 block, trellis
quantization determines the best tradeoff between rate and distortion.
* JBOOLEAN_TRELLIS_QUANT_DC (default: TRUE)
Specifies whether to apply trellis quantization to DC coefficients.
* JBOOLEAN_TRELLIS_EOB_OPT (default: FALSE)
Specifies whether to optimize runs of zero blocks in trellis quantization.
This is applicable only when JBOOLEAN_USE_SCANS_IN_TRELLIS is enabled.
* JBOOLEAN_USE_LAMBDA_WEIGHT_TBL currently has no effect.
* JBOOLEAN_USE_SCANS_IN_TRELLIS (default: FALSE)
Specifies whether multiple scans should be considered during trellis
quantization.
* JBOOLEAN_TRELLIS_Q_OPT (default: FALSE)
Specifies whether to optimize the quantization table after trellis
quantization. If enabled, then a revised quantization table is derived so
as to minimize the reconstruction error of the quantized coefficients.
* JBOOLEAN_OVERSHOOT_DERINGING (default: TRUE)
Specifies whether overshooting is applied to samples with extreme values
(for example, 0 and 255 for 8-bit samples). Overshooting may reduce ringing
artifacts from compression, in particular in areas where black text appears
on a white background.
Floating Point Extension Parameters Supported by mozjpeg
--------------------------------------------------------
* JFLOAT_LAMBDA_LOG_SCALE1 (default: 14.75)
JFLOAT_LAMBDA_LOG_SCALE2 (default: 16.5)
These parameters specify the lambda value used in trellis quantization. The
lambda value (Lagrange multiplier) in the
R + lambda * D
equation is derived from
lambda = 2^s1 / ((2^s2 + n) * q^2),
where s1 and s2 are the values of JFLOAT_LAMBDA_LOG_SCALE1 and
JFLOAT_LAMBDA_LOG_SCALE2, n is the average of the squared unquantized AC
coefficients within the current 8x8 block, and q is the quantization table
entry associated with the current coefficient frequency. If
JFLOAT_LAMBDA_LOG_SCALE2 is 0, then an alternate form is used that does not
rely on n:
lambda = 2^(s1-12) / q^2.
* JFLOAT_TRELLIS_DELTA_DC_WEIGHT (default: 0.0)
This parameter controls how distortion is calculated in DC trellis quantization
(enabled with JBOOLEAN_TRELLIS_QUANT_DC). It defines weighting between distortion
of the DC coefficient and distortion of the vertical gradient of DC coefficients.
The value of the parameter corresponds to the weight applied to the distortion
of the vertical gradient.
Integer Extension Parameters Supported by mozjpeg
-------------------------------------------------
* JINT_COMPRESS_PROFILE (default: JCP_MAX_COMPRESSION)
Select a compression profile, which is a set of default parameters that will
achieve a desired compression goal. This parameter controls the behavior of
the jpeg_set_defaults() function. Thus, setting JINT_COMPRESS_PROFILE does
not cause any other parameters to be modified until jpeg_set_defaults() is
called. The following compression profiles are supported:
- JCP_MAX_COMPRESSION (default)
Increase the compression ratio as much as possible, at the expense of
increased encoding time. This enables progressive entropy coding and all
mozjpeg extensions.
- JCP_FASTEST
Use the libjpeg[-turbo] defaults (baseline entropy coding, no mozjpeg
extensions enabled.)
* JINT_TRELLIS_FREQ_SPLIT (default: 8)
Specifies the position within the zigzag scan at which the split between
scans is positioned in the context of trellis quantization.
JBOOLEAN_USE_SCANS_IN_TRELLIS must be enabled for this parameter to have any
effect.
* JINT_TRELLIS_NUM_LOOPS (default: 1)
Specifies the number of trellis quantization passes. Huffman tables are
updated between passes.
* JINT_BASE_QUANT_TBL_IDX (default: 3)
Specifies which quantization table set to use. The following options are
available:
0 = Tables from JPEG Annex K
1 = Flat table
2 = Table tuned for MSSIM on Kodak image set
3 = Table from http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
4 = Table tuned for PSNR-HVS-M on Kodak image set
5 = Table from: Relevance of Human Vision to JPEG-DCT Compression
(1992) Klein, Silverstein and Carney
6 = Table from: DCTune Perceptual Optimization of Compressed Dental X-Rays
(1997) Watson, Taylor, Borthwick
7 = Table from: A Visual Detection Model for DCT Coefficient Quantization
(12/9/93) Ahumada, Watson, Peterson
8 = Table from: An Improved Detection Model for DCT Coefficient Quantization
(1993) Peterson, Ahumada and Watson
* JINT_DC_SCAN_OPT_MODE (default: 1)
Specifies the DC scan optimization mode. The following options are
available:
0 = One scan for all components
1 = One scan per component
2 = Optimize between one scan for all components and one scan for the first
component plus one scan for the remaining components

View File

@@ -1,342 +0,0 @@
Background
==========
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
NEON, AltiVec) to accelerate baseline JPEG compression and decompression on
x86, x86-64, ARM, and PowerPC systems. On such systems, libjpeg-turbo is
generally 2-6x as fast as libjpeg, all else being equal. On other types of
systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by
virtue of its highly-optimized Huffman coding routines. In many cases, the
performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs.
libjpeg-turbo implements both the traditional libjpeg API as well as the less
powerful but more straightforward TurboJPEG API. libjpeg-turbo also features
colorspace extensions that allow it to compress from/decompress to 32-bit and
big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java
interface.
libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated
derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
broader range of users and developers.
License
=======
libjpeg-turbo is covered by three compatible BSD-style open source licenses.
Refer to [LICENSE.md](LICENSE.md) for a roll-up of license terms.
Building libjpeg-turbo
======================
Refer to [BUILDING.md](BUILDING.md) for complete instructions.
Using libjpeg-turbo
===================
libjpeg-turbo includes two APIs that can be used to compress and decompress
JPEG images:
- **TurboJPEG API**
This API provides an easy-to-use interface for compressing and decompressing
JPEG images in memory. It also provides some functionality that would not be
straightforward to achieve using the underlying libjpeg API, such as
generating planar YUV images and performing multiple simultaneous lossless
transforms on an image. The Java interface for libjpeg-turbo is written on
top of the TurboJPEG API.
- **libjpeg API**
This is the de facto industry-standard API for compressing and decompressing
JPEG images. It is more difficult to use than the TurboJPEG API but also
more powerful. The libjpeg API implementation in libjpeg-turbo is both
API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
(see below.)
There is no significant performance advantage to either API when both are used
to perform similar operations.
Colorspace Extensions
---------------------
libjpeg-turbo includes extensions that allow JPEG images to be compressed
directly from (and decompressed directly to) buffers that use BGR, BGRX,
RGBX, XBGR, and XRGB pixel ordering. This is implemented with ten new
colorspace constants:
JCS_EXT_RGB /* red/green/blue */
JCS_EXT_RGBX /* red/green/blue/x */
JCS_EXT_BGR /* blue/green/red */
JCS_EXT_BGRX /* blue/green/red/x */
JCS_EXT_XBGR /* x/blue/green/red */
JCS_EXT_XRGB /* x/red/green/blue */
JCS_EXT_RGBA /* red/green/blue/alpha */
JCS_EXT_BGRA /* blue/green/red/alpha */
JCS_EXT_ABGR /* alpha/blue/green/red */
JCS_EXT_ARGB /* alpha/red/green/blue */
Setting `cinfo.in_color_space` (compression) or `cinfo.out_color_space`
(decompression) to one of these values will cause libjpeg-turbo to read the
red, green, and blue values from (or write them to) the appropriate position in
the pixel when compressing from/decompressing to an RGB buffer.
Your application can check for the existence of these extensions at compile
time with:
#ifdef JCS_EXTENSIONS
At run time, attempting to use these extensions with a libjpeg implementation
that does not support them will result in a "Bogus input colorspace" error.
Applications can trap this error in order to test whether run-time support is
available for the colorspace extensions.
When using the RGBX, BGRX, XBGR, and XRGB colorspaces during decompression, the
X byte is undefined, and in order to ensure the best performance, libjpeg-turbo
can set that byte to whatever value it wishes. If an application expects the X
byte to be used as an alpha channel, then it should specify `JCS_EXT_RGBA`,
`JCS_EXT_BGRA`, `JCS_EXT_ABGR`, or `JCS_EXT_ARGB`. When these colorspace
constants are used, the X byte is guaranteed to be 0xFF, which is interpreted
as opaque.
Your application can check for the existence of the alpha channel colorspace
extensions at compile time with:
#ifdef JCS_ALPHA_EXTENSIONS
[jcstest.c](jcstest.c), located in the libjpeg-turbo source tree, demonstrates
how to check for the existence of the colorspace extensions at compile time and
run time.
libjpeg v7 and v8 API/ABI Emulation
-----------------------------------
With libjpeg v7 and v8, new features were added that necessitated extending the
compression and decompression structures. Unfortunately, due to the exposed
nature of those structures, extending them also necessitated breaking backward
ABI compatibility with previous libjpeg releases. Thus, programs that were
built to use libjpeg v7 or v8 did not work with libjpeg-turbo, since it is
based on the libjpeg v6b code base. Although libjpeg v7 and v8 are not
as widely used as v6b, enough programs (including a few Linux distros) made
the switch that there was a demand to emulate the libjpeg v7 and v8 ABIs
in libjpeg-turbo. It should be noted, however, that this feature was added
primarily so that applications that had already been compiled to use libjpeg
v7+ could take advantage of accelerated baseline JPEG encoding/decoding
without recompiling. libjpeg-turbo does not claim to support all of the
libjpeg v7+ features, nor to produce identical output to libjpeg v7+ in all
cases (see below.)
By passing an argument of `--with-jpeg7` or `--with-jpeg8` to `configure`, or
an argument of `-DWITH_JPEG7=1` or `-DWITH_JPEG8=1` to `cmake`, you can build a
version of libjpeg-turbo that emulates the libjpeg v7 or v8 ABI, so that
programs that are built against libjpeg v7 or v8 can be run with libjpeg-turbo.
The following section describes which libjpeg v7+ features are supported and
which aren't.
### Support for libjpeg v7 and v8 Features
#### Fully supported
- **libjpeg: IDCT scaling extensions in decompressor**
libjpeg-turbo supports IDCT scaling with scaling factors of 1/8, 1/4, 3/8,
1/2, 5/8, 3/4, 7/8, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8, and 2/1 (only 1/4
and 1/2 are SIMD-accelerated.)
- **libjpeg: Arithmetic coding**
- **libjpeg: In-memory source and destination managers**
See notes below.
- **cjpeg: Separate quality settings for luminance and chrominance**
Note that the libpjeg v7+ API was extended to accommodate this feature only
for convenience purposes. It has always been possible to implement this
feature with libjpeg v6b (see rdswitch.c for an example.)
- **cjpeg: 32-bit BMP support**
- **cjpeg: `-rgb` option**
- **jpegtran: Lossless cropping**
- **jpegtran: `-perfect` option**
- **jpegtran: Forcing width/height when performing lossless crop**
- **rdjpgcom: `-raw` option**
- **rdjpgcom: Locale awareness**
#### Not supported
NOTE: As of this writing, extensive research has been conducted into the
usefulness of DCT scaling as a means of data reduction and SmartScale as a
means of quality improvement. The reader is invited to peruse the research at
<http://www.libjpeg-turbo.org/About/SmartScale> and draw his/her own conclusions,
but it is the general belief of our project that these features have not
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
- **libjpeg: DCT scaling in compressor**
`cinfo.scale_num` and `cinfo.scale_denom` are silently ignored.
There is no technical reason why DCT scaling could not be supported when
emulating the libjpeg v7+ API/ABI, but without the SmartScale extension (see
below), only scaling factors of 1/2, 8/15, 4/7, 8/13, 2/3, 8/11, 4/5, and
8/9 would be available, which is of limited usefulness.
- **libjpeg: SmartScale**
`cinfo.block_size` is silently ignored.
SmartScale is an extension to the JPEG format that allows for DCT block
sizes other than 8x8. Providing support for this new format would be
feasible (particularly without full acceleration.) However, until/unless
the format becomes either an official industry standard or, at minimum, an
accepted solution in the community, we are hesitant to implement it, as
there is no sense of whether or how it might change in the future. It is
our belief that SmartScale has not demonstrated sufficient usefulness as a
lossless format nor as a means of quality enhancement, and thus our primary
interest in providing this feature would be as a means of supporting
additional DCT scaling factors.
- **libjpeg: Fancy downsampling in compressor**
`cinfo.do_fancy_downsampling` is silently ignored.
This requires the DCT scaling feature, which is not supported.
- **jpegtran: Scaling**
This requires both the DCT scaling and SmartScale features, which are not
supported.
- **Lossless RGB JPEG files**
This requires the SmartScale feature, which is not supported.
### What About libjpeg v9?
libjpeg v9 introduced yet another field to the JPEG compression structure
(`color_transform`), thus making the ABI backward incompatible with that of
libjpeg v8. This new field was introduced solely for the purpose of supporting
lossless SmartScale encoding. Furthermore, there was actually no reason to
extend the API in this manner, as the color transform could have just as easily
been activated by way of a new JPEG colorspace constant, thus preserving
backward ABI compatibility.
Our research (see link above) has shown that lossless SmartScale does not
generally accomplish anything that can't already be accomplished better with
existing, standard lossless formats. Therefore, at this time it is our belief
that there is not sufficient technical justification for software projects to
upgrade from libjpeg v8 to libjpeg v9, and thus there is not sufficient
echnical justification for us to emulate the libjpeg v9 ABI.
In-Memory Source/Destination Managers
-------------------------------------
By default, libjpeg-turbo 1.3 and later includes the `jpeg_mem_src()` and
`jpeg_mem_dest()` functions, even when not emulating the libjpeg v8 API/ABI.
Previously, it was necessary to build libjpeg-turbo from source with libjpeg v8
API/ABI emulation in order to use the in-memory source/destination managers,
but several projects requested that those functions be included when emulating
the libjpeg v6b API/ABI as well. This allows the use of those functions by
programs that need them, without breaking ABI compatibility for programs that
don't, and it allows those functions to be provided in the "official"
libjpeg-turbo binaries.
Those who are concerned about maintaining strict conformance with the libjpeg
v6b or v7 API can pass an argument of `--without-mem-srcdst` to `configure` or
an argument of `-DWITH_MEM_SRCDST=0` to `cmake` prior to building
libjpeg-turbo. This will restore the pre-1.3 behavior, in which
`jpeg_mem_src()` and `jpeg_mem_dest()` are only included when emulating the
libjpeg v8 API/ABI.
On Un*x systems, including the in-memory source/destination managers changes
the dynamic library version from 62.0.0 to 62.1.0 if using libjpeg v6b API/ABI
emulation and from 7.0.0 to 7.1.0 if using libjpeg v7 API/ABI emulation.
Note that, on most Un*x systems, the dynamic linker will not look for a
function in a library until that function is actually used. Thus, if a program
is built against libjpeg-turbo 1.3+ and uses `jpeg_mem_src()` or
`jpeg_mem_dest()`, that program will not fail if run against an older version
of libjpeg-turbo or against libjpeg v7- until the program actually tries to
call `jpeg_mem_src()` or `jpeg_mem_dest()`. Such is not the case on Windows.
If a program is built against the libjpeg-turbo 1.3+ DLL and uses
`jpeg_mem_src()` or `jpeg_mem_dest()`, then it must use the libjpeg-turbo 1.3+
DLL at run time.
Both cjpeg and djpeg have been extended to allow testing the in-memory
source/destination manager functions. See their respective man pages for more
details.
Mathematical Compatibility
==========================
For the most part, libjpeg-turbo should produce identical output to libjpeg
v6b. The one exception to this is when using the floating point DCT/IDCT, in
which case the outputs of libjpeg v6b and libjpeg-turbo can differ for the
following reasons:
- The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever so
slightly more accurate than the implementation in libjpeg v6b, but not by
any amount perceptible to human vision (generally in the range of 0.01 to
0.08 dB gain in PNSR.)
- When not using the SIMD extensions, libjpeg-turbo uses the more accurate
(and slightly faster) floating point IDCT algorithm introduced in libjpeg
v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
however, that this algorithm basically brings the accuracy of the floating
point IDCT in line with the accuracy of the slow integer IDCT. The floating
point DCT/IDCT algorithms are mainly a legacy feature, and they do not
produce significantly more accuracy than the slow integer algorithms (to put
numbers on this, the typical difference in PNSR between the two algorithms
is less than 0.10 dB, whereas changing the quality level by 1 in the upper
range of the quality scale is typically more like a 1.0 dB difference.)
- If the floating point algorithms in libjpeg-turbo are not implemented using
SIMD instructions on a particular platform, then the accuracy of the
floating point DCT/IDCT can depend on the compiler settings.
While libjpeg-turbo does emulate the libjpeg v8 API/ABI, under the hood it is
still using the same algorithms as libjpeg v6b, so there are several specific
cases in which libjpeg-turbo cannot be expected to produce the same output as
libjpeg v8:
- When decompressing using scaling factors of 1/2 and 1/4, because libjpeg v8
implements those scaling algorithms differently than libjpeg v6b does, and
libjpeg-turbo's SIMD extensions are based on the libjpeg v6b behavior.
- When using chrominance subsampling, because libjpeg v8 implements this
with its DCT/IDCT scaling algorithms rather than with a separate
downsampling/upsampling algorithm. In our testing, the subsampled/upsampled
output of libjpeg v8 is less accurate than that of libjpeg v6b for this
reason.
- When decompressing using a scaling factor > 1 and merged (AKA "non-fancy" or
"non-smooth") chrominance upsampling, because libjpeg v8 does not support
merged upsampling with scaling factors > 1.
Performance Pitfalls
====================
Restart Markers
---------------
The optimized Huffman decoder in libjpeg-turbo does not handle restart markers
in a way that makes the rest of the libjpeg infrastructure happy, so it is
necessary to use the slow Huffman decoder when decompressing a JPEG image that
has restart markers. This can cause the decompression performance to drop by
as much as 20%, but the performance will still be much greater than that of
libjpeg. Many consumer packages, such as PhotoShop, use restart markers when
generating JPEG images, so images generated by those programs will experience
this issue.
Fast Integer Forward DCT at High Quality Levels
-----------------------------------------------
The algorithm used by the SIMD-accelerated quantization function cannot produce
correct results whenever the fast integer forward DCT is used along with a JPEG
quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
function in those cases. This causes performance to drop by as much as 40%.
It is therefore strongly advised that you use the slow integer forward DCT
whenever encoding images with a JPEG quality of 98 or higher.

350
README.md Normal file → Executable file
View File

@@ -1,23 +1,341 @@
Mozilla JPEG Encoder Project
============================
Background
==========
MozJPEG reduces file sizes of JPEG images while retaining quality and compatibility with the vast majority of the world's deployed decoders.
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
NEON, AltiVec) to accelerate baseline JPEG compression and decompression on
x86, x86-64, ARM, and PowerPC systems. On such systems, libjpeg-turbo is
generally 2-6x as fast as libjpeg, all else being equal. On other types of
systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by
virtue of its highly-optimized Huffman coding routines. In many cases, the
performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs.
MozJPEG is based on [libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo). It's compatible with libjpeg API and ABI, and can be used as a drop-in replacement for libjpeg. MozJPEG makes tradeoffs that are intended to benefit Web use cases and focuses solely on improving encoding, so it's best used as part of a Web encoding workflow.
libjpeg-turbo implements both the traditional libjpeg API as well as the less
powerful but more straightforward TurboJPEG API. libjpeg-turbo also features
colorspace extensions that allow it to compress from/decompress to 32-bit and
big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java
interface.
MozJPEG is meant to be used as a library in graphics programs and image processing tools. We include a demo `cjpeg` tool, but it's not intended for serious use. We encourage authors of graphics programs to use MozJPEG's [C API](libjpeg.txt) instead.
libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated
derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
broader range of users and developers.
## Features
* Progressive encoding with "jpegrescan" optimization. It can be applied to any JPEG file (with `jpegtran`) to losslessly reduce file size.
* Trellis quantization. When converting other formats to JPEG it maximizes quality/filesize ratio.
* Comes with new quantization table presets, e.g. tuned for high-resolution displays.
* Fully compatible with all web browsers.
* Can be seamlessly integrated into any program using libjpeg.
License
=======
## Releases
libjpeg-turbo is covered by three compatible BSD-style open source licenses.
Refer to [LICENSE.md](LICENSE.md) for a roll-up of license terms.
* [Latest release](https://github.com/mozilla/mozjpeg/releases/latest)
* [Version 3.0 Announcement](https://boomswaggerboom.wordpress.com/2014/12/30/mozjpeg-3-0-released/) ([overview of 3.0 features](https://calendar.perfplanet.com/2014/mozjpeg-3-0/))
* [Version 2.0 Announcement](https://blog.mozilla.org/research/2014/07/15/mozilla-advances-jpeg-encoding-with-mozjpeg-2-0/)
* [Version 1.0 Announcement](https://blog.mozilla.org/research/2014/03/05/introducing-the-mozjpeg-project/)
Building libjpeg-turbo
======================
Refer to [BUILDING.md](BUILDING.md) for complete instructions.
Using libjpeg-turbo
===================
libjpeg-turbo includes two APIs that can be used to compress and decompress
JPEG images:
- **TurboJPEG API**<br>
This API provides an easy-to-use interface for compressing and decompressing
JPEG images in memory. It also provides some functionality that would not be
straightforward to achieve using the underlying libjpeg API, such as
generating planar YUV images and performing multiple simultaneous lossless
transforms on an image. The Java interface for libjpeg-turbo is written on
top of the TurboJPEG API.
- **libjpeg API**<br>
This is the de facto industry-standard API for compressing and decompressing
JPEG images. It is more difficult to use than the TurboJPEG API but also
more powerful. The libjpeg API implementation in libjpeg-turbo is both
API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
(see below.)
There is no significant performance advantage to either API when both are used
to perform similar operations.
Colorspace Extensions
---------------------
libjpeg-turbo includes extensions that allow JPEG images to be compressed
directly from (and decompressed directly to) buffers that use BGR, BGRX,
RGBX, XBGR, and XRGB pixel ordering. This is implemented with ten new
colorspace constants:
JCS_EXT_RGB /* red/green/blue */
JCS_EXT_RGBX /* red/green/blue/x */
JCS_EXT_BGR /* blue/green/red */
JCS_EXT_BGRX /* blue/green/red/x */
JCS_EXT_XBGR /* x/blue/green/red */
JCS_EXT_XRGB /* x/red/green/blue */
JCS_EXT_RGBA /* red/green/blue/alpha */
JCS_EXT_BGRA /* blue/green/red/alpha */
JCS_EXT_ABGR /* alpha/blue/green/red */
JCS_EXT_ARGB /* alpha/red/green/blue */
Setting `cinfo.in_color_space` (compression) or `cinfo.out_color_space`
(decompression) to one of these values will cause libjpeg-turbo to read the
red, green, and blue values from (or write them to) the appropriate position in
the pixel when compressing from/decompressing to an RGB buffer.
Your application can check for the existence of these extensions at compile
time with:
#ifdef JCS_EXTENSIONS
At run time, attempting to use these extensions with a libjpeg implementation
that does not support them will result in a "Bogus input colorspace" error.
Applications can trap this error in order to test whether run-time support is
available for the colorspace extensions.
When using the RGBX, BGRX, XBGR, and XRGB colorspaces during decompression, the
X byte is undefined, and in order to ensure the best performance, libjpeg-turbo
can set that byte to whatever value it wishes. If an application expects the X
byte to be used as an alpha channel, then it should specify `JCS_EXT_RGBA`,
`JCS_EXT_BGRA`, `JCS_EXT_ABGR`, or `JCS_EXT_ARGB`. When these colorspace
constants are used, the X byte is guaranteed to be 0xFF, which is interpreted
as opaque.
Your application can check for the existence of the alpha channel colorspace
extensions at compile time with:
#ifdef JCS_ALPHA_EXTENSIONS
[jcstest.c](jcstest.c), located in the libjpeg-turbo source tree, demonstrates
how to check for the existence of the colorspace extensions at compile time and
run time.
libjpeg v7 and v8 API/ABI Emulation
-----------------------------------
With libjpeg v7 and v8, new features were added that necessitated extending the
compression and decompression structures. Unfortunately, due to the exposed
nature of those structures, extending them also necessitated breaking backward
ABI compatibility with previous libjpeg releases. Thus, programs that were
built to use libjpeg v7 or v8 did not work with libjpeg-turbo, since it is
based on the libjpeg v6b code base. Although libjpeg v7 and v8 are not
as widely used as v6b, enough programs (including a few Linux distros) made
the switch that there was a demand to emulate the libjpeg v7 and v8 ABIs
in libjpeg-turbo. It should be noted, however, that this feature was added
primarily so that applications that had already been compiled to use libjpeg
v7+ could take advantage of accelerated baseline JPEG encoding/decoding
without recompiling. libjpeg-turbo does not claim to support all of the
libjpeg v7+ features, nor to produce identical output to libjpeg v7+ in all
cases (see below.)
By passing an argument of `--with-jpeg7` or `--with-jpeg8` to `configure`, or
an argument of `-DWITH_JPEG7=1` or `-DWITH_JPEG8=1` to `cmake`, you can build a
version of libjpeg-turbo that emulates the libjpeg v7 or v8 ABI, so that
programs that are built against libjpeg v7 or v8 can be run with libjpeg-turbo.
The following section describes which libjpeg v7+ features are supported and
which aren't.
### Support for libjpeg v7 and v8 Features
#### Fully supported
- **libjpeg: IDCT scaling extensions in decompressor**<br>
libjpeg-turbo supports IDCT scaling with scaling factors of 1/8, 1/4, 3/8,
1/2, 5/8, 3/4, 7/8, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8, and 2/1 (only 1/4
and 1/2 are SIMD-accelerated.)
- **libjpeg: Arithmetic coding**
- **libjpeg: In-memory source and destination managers**<br>
See notes below.
- **cjpeg: Separate quality settings for luminance and chrominance**<br>
Note that the libpjeg v7+ API was extended to accommodate this feature only
for convenience purposes. It has always been possible to implement this
feature with libjpeg v6b (see rdswitch.c for an example.)
- **cjpeg: 32-bit BMP support**
- **cjpeg: `-rgb` option**
- **jpegtran: Lossless cropping**
- **jpegtran: `-perfect` option**
- **jpegtran: Forcing width/height when performing lossless crop**
- **rdjpgcom: `-raw` option**
- **rdjpgcom: Locale awareness**
#### Not supported
NOTE: As of this writing, extensive research has been conducted into the
usefulness of DCT scaling as a means of data reduction and SmartScale as a
means of quality improvement. The reader is invited to peruse the research at
<http://www.libjpeg-turbo.org/About/SmartScale> and draw his/her own conclusions,
but it is the general belief of our project that these features have not
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
- **libjpeg: DCT scaling in compressor**<br>
`cinfo.scale_num` and `cinfo.scale_denom` are silently ignored.
There is no technical reason why DCT scaling could not be supported when
emulating the libjpeg v7+ API/ABI, but without the SmartScale extension (see
below), only scaling factors of 1/2, 8/15, 4/7, 8/13, 2/3, 8/11, 4/5, and
8/9 would be available, which is of limited usefulness.
- **libjpeg: SmartScale**<br>
`cinfo.block_size` is silently ignored.
SmartScale is an extension to the JPEG format that allows for DCT block
sizes other than 8x8. Providing support for this new format would be
feasible (particularly without full acceleration.) However, until/unless
the format becomes either an official industry standard or, at minimum, an
accepted solution in the community, we are hesitant to implement it, as
there is no sense of whether or how it might change in the future. It is
our belief that SmartScale has not demonstrated sufficient usefulness as a
lossless format nor as a means of quality enhancement, and thus our primary
interest in providing this feature would be as a means of supporting
additional DCT scaling factors.
- **libjpeg: Fancy downsampling in compressor**<br>
`cinfo.do_fancy_downsampling` is silently ignored.
This requires the DCT scaling feature, which is not supported.
- **jpegtran: Scaling**<br>
This requires both the DCT scaling and SmartScale features, which are not
supported.
- **Lossless RGB JPEG files**<br>
This requires the SmartScale feature, which is not supported.
### What About libjpeg v9?
libjpeg v9 introduced yet another field to the JPEG compression structure
(`color_transform`), thus making the ABI backward incompatible with that of
libjpeg v8. This new field was introduced solely for the purpose of supporting
lossless SmartScale encoding. Furthermore, there was actually no reason to
extend the API in this manner, as the color transform could have just as easily
been activated by way of a new JPEG colorspace constant, thus preserving
backward ABI compatibility.
Our research (see link above) has shown that lossless SmartScale does not
generally accomplish anything that can't already be accomplished better with
existing, standard lossless formats. Therefore, at this time it is our belief
that there is not sufficient technical justification for software projects to
upgrade from libjpeg v8 to libjpeg v9, and thus there is not sufficient
technical justification for us to emulate the libjpeg v9 ABI.
In-Memory Source/Destination Managers
-------------------------------------
By default, libjpeg-turbo 1.3 and later includes the `jpeg_mem_src()` and
`jpeg_mem_dest()` functions, even when not emulating the libjpeg v8 API/ABI.
Previously, it was necessary to build libjpeg-turbo from source with libjpeg v8
API/ABI emulation in order to use the in-memory source/destination managers,
but several projects requested that those functions be included when emulating
the libjpeg v6b API/ABI as well. This allows the use of those functions by
programs that need them, without breaking ABI compatibility for programs that
don't, and it allows those functions to be provided in the "official"
libjpeg-turbo binaries.
Those who are concerned about maintaining strict conformance with the libjpeg
v6b or v7 API can pass an argument of `--without-mem-srcdst` to `configure` or
an argument of `-DWITH_MEM_SRCDST=0` to `cmake` prior to building
libjpeg-turbo. This will restore the pre-1.3 behavior, in which
`jpeg_mem_src()` and `jpeg_mem_dest()` are only included when emulating the
libjpeg v8 API/ABI.
On Un*x systems, including the in-memory source/destination managers changes
the dynamic library version from 62.1.0 to 62.2.0 if using libjpeg v6b API/ABI
emulation and from 7.1.0 to 7.2.0 if using libjpeg v7 API/ABI emulation.
Note that, on most Un*x systems, the dynamic linker will not look for a
function in a library until that function is actually used. Thus, if a program
is built against libjpeg-turbo 1.3+ and uses `jpeg_mem_src()` or
`jpeg_mem_dest()`, that program will not fail if run against an older version
of libjpeg-turbo or against libjpeg v7- until the program actually tries to
call `jpeg_mem_src()` or `jpeg_mem_dest()`. Such is not the case on Windows.
If a program is built against the libjpeg-turbo 1.3+ DLL and uses
`jpeg_mem_src()` or `jpeg_mem_dest()`, then it must use the libjpeg-turbo 1.3+
DLL at run time.
Both cjpeg and djpeg have been extended to allow testing the in-memory
source/destination manager functions. See their respective man pages for more
details.
Mathematical Compatibility
==========================
For the most part, libjpeg-turbo should produce identical output to libjpeg
v6b. The one exception to this is when using the floating point DCT/IDCT, in
which case the outputs of libjpeg v6b and libjpeg-turbo can differ for the
following reasons:
- The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever so
slightly more accurate than the implementation in libjpeg v6b, but not by
any amount perceptible to human vision (generally in the range of 0.01 to
0.08 dB gain in PNSR.)
- When not using the SIMD extensions, libjpeg-turbo uses the more accurate
(and slightly faster) floating point IDCT algorithm introduced in libjpeg
v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
however, that this algorithm basically brings the accuracy of the floating
point IDCT in line with the accuracy of the slow integer IDCT. The floating
point DCT/IDCT algorithms are mainly a legacy feature, and they do not
produce significantly more accuracy than the slow integer algorithms (to put
numbers on this, the typical difference in PNSR between the two algorithms
is less than 0.10 dB, whereas changing the quality level by 1 in the upper
range of the quality scale is typically more like a 1.0 dB difference.)
- If the floating point algorithms in libjpeg-turbo are not implemented using
SIMD instructions on a particular platform, then the accuracy of the
floating point DCT/IDCT can depend on the compiler settings.
While libjpeg-turbo does emulate the libjpeg v8 API/ABI, under the hood it is
still using the same algorithms as libjpeg v6b, so there are several specific
cases in which libjpeg-turbo cannot be expected to produce the same output as
libjpeg v8:
- When decompressing using scaling factors of 1/2 and 1/4, because libjpeg v8
implements those scaling algorithms differently than libjpeg v6b does, and
libjpeg-turbo's SIMD extensions are based on the libjpeg v6b behavior.
- When using chrominance subsampling, because libjpeg v8 implements this
with its DCT/IDCT scaling algorithms rather than with a separate
downsampling/upsampling algorithm. In our testing, the subsampled/upsampled
output of libjpeg v8 is less accurate than that of libjpeg v6b for this
reason.
- When decompressing using a scaling factor > 1 and merged (AKA "non-fancy" or
"non-smooth") chrominance upsampling, because libjpeg v8 does not support
merged upsampling with scaling factors > 1.
Performance Pitfalls
====================
Restart Markers
---------------
The optimized Huffman decoder in libjpeg-turbo does not handle restart markers
in a way that makes the rest of the libjpeg infrastructure happy, so it is
necessary to use the slow Huffman decoder when decompressing a JPEG image that
has restart markers. This can cause the decompression performance to drop by
as much as 20%, but the performance will still be much greater than that of
libjpeg. Many consumer packages, such as PhotoShop, use restart markers when
generating JPEG images, so images generated by those programs will experience
this issue.
Fast Integer Forward DCT at High Quality Levels
-----------------------------------------------
The algorithm used by the SIMD-accelerated quantization function cannot produce
correct results whenever the fast integer forward DCT is used along with a JPEG
quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
function in those cases. This causes performance to drop by as much as 40%.
It is therefore strongly advised that you use the slow integer forward DCT
whenever encoding images with a JPEG quality of 98 or higher.

View File

@@ -252,3 +252,36 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE],[
$2
fi
])
# AC_CHECK_ALTIVEC
# ----------------
# Test whether AltiVec intrinsics are supported
AC_DEFUN([AC_CHECK_ALTIVEC],[
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -maltivec"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <altivec.h>
int main(void) {
__vector int vi = { 0, 0, 0, 0 };
int i[4];
vec_st(vi, 0, i);
return i[0];
}]])], ac_has_altivec=yes)
CFLAGS="$ac_save_CFLAGS"
if test "x$ac_has_altivec" = "xyes" ; then
$1
else
$2
fi
])
AC_DEFUN([AC_NO_SIMD],[
AC_MSG_RESULT([no ("$1")])
with_simd=no;
if test "x${require_simd}" = "xyes"; then
AC_MSG_ERROR([SIMD support not available for this CPU.])
else
AC_MSG_WARN([SIMD support not available for this CPU. Performance will\
suffer.])
fi
])

57
appveyor.yml Normal file
View File

@@ -0,0 +1,57 @@
install:
- cmd: >-
mkdir c:\installers
mkdir c:\temp
curl -fSL -o c:\installers\nasm-2.10.01-win32.zip http://www.nasm.us/pub/nasm/releasebuilds/2.10.01/win32/nasm-2.10.01-win32.zip
7z x c:\installers\nasm-2.10.01-win32.zip -oc:\ > c:\installers\nasm.install.log
set INCLUDE=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\include
set LIB=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\lib\x64
set PATH=c:\nasm-2.10.01;c:\Program Files (x86)\NSIS;c:\msys64\mingw32\bin;c:\msys64\usr\bin;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin\x64;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin;%PATH%
set MSYSTEM=MINGW32
bash -c "pacman --noconfirm -S autoconf automake libtool zip"
mklink /d "%ProgramData%\Oracle\Java32" "c:\Program Files (x86)\Java\jdk1.6.0"
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git c:/buildscripts
build_script:
- cmd: >-
for /f %%i in ('"cygpath %CD%"') do set MINGWPATH=%%i
bash c:/buildscripts/buildljt -r file://%MINGWPATH% -b /c/ljt.nightly %APPVEYOR_REPO_BRANCH% -v
move c:\ljt.nightly\files\*.tar.gz .
move c:\ljt.nightly\files\*.exe .
move c:\ljt.nightly\files\*.zip .
move c:\ljt.nightly\log-windows.txt .
artifacts:
- path: '*.tar.gz'
name: Source tarball
- path: '*-gcc*.exe'
name: SDK for MinGW
- path: '*-vc*.exe'
name: SDK for Visual C++
- path: '*.zip'
name: Windows JNI JARs
- path: 'log-windows.txt'
name: Build log
test: off
deploy: off

View File

@@ -124,11 +124,6 @@ JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format")
#endif
JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")
#ifdef PNG_SUPPORTED
JMESSAGE(JERR_PNG_ERROR, "Unable to read PNG file: %s")
JMESSAGE(JERR_PNG_PROFILETOOLARGE, "Embedded profile was too large for this tool - dropped.")
#endif
#ifdef JMAKE_ENUM_LIST
JMSG_LASTADDONCODE

View File

@@ -3,11 +3,10 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1997, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README.ijg file.
* libjpeg-turbo Modifications:
* Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains common declarations for the sample applications
* cjpeg and djpeg. It is NOT used by the core JPEG library.
@@ -20,7 +19,6 @@
#include "jerror.h" /* get library error codes too */
#include "cderror.h" /* get application-specific error codes */
#define JPEG_RAW_READER 0
/*
* Object interface for cjpeg's source file decoding modules
@@ -37,13 +35,6 @@ struct cjpeg_source_struct {
JSAMPARRAY buffer;
JDIMENSION buffer_height;
#if JPEG_RAW_READER
// For reading JPEG
JSAMPARRAY plane_pointer[4];
#endif
jpeg_saved_marker_ptr marker_list;
};
@@ -63,6 +54,14 @@ struct djpeg_dest_struct {
JDIMENSION rows_supplied);
/* Finish up at the end of the image. */
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
/* Re-calculate buffer dimensions based on output dimensions (for use with
partial image decompression.) If this is NULL, then the output format
does not support partial image decompression (BMP and RLE, in particular,
cannot support partial decompression because they use an inversion buffer
to write the image in bottom-up order.) */
void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
djpeg_dest_ptr dinfo);
/* Target file spec; filled in by djpeg.c after object is created. */
FILE *output_file;
@@ -102,9 +101,7 @@ EXTERN(djpeg_dest_ptr) jinit_write_bmp (j_decompress_ptr cinfo,
boolean is_os2);
EXTERN(cjpeg_source_ptr) jinit_read_gif (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_gif (j_decompress_ptr cinfo);
EXTERN(cjpeg_source_ptr) jinit_read_jpeg (j_compress_ptr cinfo);
EXTERN(cjpeg_source_ptr) jinit_read_ppm (j_compress_ptr cinfo);
EXTERN(cjpeg_source_ptr) jinit_read_png (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_ppm (j_decompress_ptr cinfo);
EXTERN(cjpeg_source_ptr) jinit_read_rle (j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_rle (j_decompress_ptr cinfo);

BIN
ci/keys.enc Normal file

Binary file not shown.

221
cjpeg.c
View File

@@ -6,9 +6,8 @@
* Modified 2003-2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2013-2014, 2017, D. R. Commander.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains a command-line user interface for the JPEG compressor.
* It should work on any system with Unix- or MS-DOS-style command lines.
@@ -80,8 +79,7 @@ static const char * const cdjpeg_message_table[] = {
*/
static boolean is_targa; /* records user -targa switch */
static boolean is_jpeg;
static boolean copy_markers;
LOCAL(cjpeg_source_ptr)
select_file_type (j_compress_ptr cinfo, FILE *infile)
@@ -114,11 +112,6 @@ select_file_type (j_compress_ptr cinfo, FILE *infile)
case 'P':
return jinit_read_ppm(cinfo);
#endif
#ifdef PNG_SUPPORTED
case 0x89:
copy_markers = TRUE;
return jinit_read_png(cinfo);
#endif
#ifdef RLE_SUPPORTED
case 'R':
return jinit_read_rle(cinfo);
@@ -127,10 +120,6 @@ select_file_type (j_compress_ptr cinfo, FILE *infile)
case 0x00:
return jinit_read_targa(cinfo);
#endif
case 0xff:
is_jpeg = TRUE;
copy_markers = TRUE;
return jinit_read_jpeg(cinfo);
default:
ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
break;
@@ -171,31 +160,15 @@ usage (void)
fprintf(stderr, " -grayscale Create monochrome JPEG file\n");
fprintf(stderr, " -rgb Create RGB JPEG file\n");
#ifdef ENTROPY_OPT_SUPPORTED
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression, enabled by default)\n");
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
#endif
#ifdef C_PROGRESSIVE_SUPPORTED
fprintf(stderr, " -progressive Create progressive JPEG file (enabled by default)\n");
fprintf(stderr, " -progressive Create progressive JPEG file\n");
#endif
fprintf(stderr, " -baseline Create baseline JPEG file (disable progressive coding)\n");
#ifdef TARGA_SUPPORTED
fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n");
#endif
fprintf(stderr, " -revert Revert to standard defaults (instead of mozjpeg defaults)\n");
fprintf(stderr, " -fastcrush Disable progressive scan optimization\n");
fprintf(stderr, " -dc-scan-opt DC scan optimization mode\n");
fprintf(stderr, " - 0 One scan for all components\n");
fprintf(stderr, " - 1 One scan per component (default)\n");
fprintf(stderr, " - 2 Optimize between one scan for all components and one scan for 1st component\n");
fprintf(stderr, " plus one scan for remaining components\n");
fprintf(stderr, " -notrellis Disable trellis optimization\n");
fprintf(stderr, " -trellis-dc Enable trellis optimization of DC coefficients (default)\n");
fprintf(stderr, " -notrellis-dc Disable trellis optimization of DC coefficients\n");
fprintf(stderr, " -tune-psnr Tune trellis optimization for PSNR\n");
fprintf(stderr, " -tune-hvs-psnr Tune trellis optimization for PSNR-HVS (default)\n");
fprintf(stderr, " -tune-ssim Tune trellis optimization for SSIM\n");
fprintf(stderr, " -tune-ms-ssim Tune trellis optimization for MS-SSIM\n");
fprintf(stderr, "Switches for advanced users:\n");
fprintf(stderr, " -noovershoot Disable black-on-white deringing via overshoot\n");
#ifdef C_ARITH_CODING_SUPPORTED
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
#endif
@@ -211,14 +184,6 @@ usage (void)
fprintf(stderr, " -dct float Use floating-point DCT method%s\n",
(JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
#endif
fprintf(stderr, " -quant-baseline Use 8-bit quantization table entries for baseline JPEG compatibility\n");
fprintf(stderr, " -quant-table N Use predefined quantization table N:\n");
fprintf(stderr, " - 0 JPEG Annex K\n");
fprintf(stderr, " - 1 Flat\n");
fprintf(stderr, " - 2 Custom, tuned for MS-SSIM\n");
fprintf(stderr, " - 3 ImageMagick table by N. Robidoux\n");
fprintf(stderr, " - 4 Custom, tuned for PSNR-HVS\n");
fprintf(stderr, " - 5 Table from paper by Klein, Silverstein and Carney\n");
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
#ifdef INPUT_SMOOTHING_SUPPORTED
fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n");
@@ -231,6 +196,7 @@ usage (void)
fprintf(stderr, " -verbose or -debug Emit debug output\n");
fprintf(stderr, " -version Print version information and exit\n");
fprintf(stderr, "Switches for wizards:\n");
fprintf(stderr, " -baseline Force baseline quantization tables\n");
fprintf(stderr, " -qtables FILE Use quantization tables given in FILE\n");
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
@@ -266,11 +232,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* Set up default JPEG parameters. */
force_baseline = FALSE; /* by default, allow 16-bit quantizers */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = cinfo->num_scans == 0 ? FALSE : TRUE;
#else
simple_progressive = FALSE;
#endif
is_targa = FALSE;
outfilename = NULL;
memdst = FALSE;
@@ -294,9 +256,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* Use arithmetic coding. */
#ifdef C_ARITH_CODING_SUPPORTED
cinfo->arith_code = TRUE;
/* No table optimization required for AC */
cinfo->optimize_coding = FALSE;
#else
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
progname);
@@ -306,27 +265,19 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "baseline", 1)) {
/* Force baseline-compatible output (8-bit quantizer values). */
force_baseline = TRUE;
/* Disable multiple scans */
simple_progressive = FALSE;
cinfo->num_scans = 0;
cinfo->scan_info = NULL;
} else if (keymatch(arg, "dct", 2)) {
/* Select DCT algorithm. */
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for dct\n", progname);
if (++argn >= argc) /* advance to next argument */
usage();
}
if (keymatch(argv[argn], "int", 1)) {
cinfo->dct_method = JDCT_ISLOW;
} else if (keymatch(argv[argn], "fast", 2)) {
cinfo->dct_method = JDCT_IFAST;
} else if (keymatch(argv[argn], "float", 2)) {
cinfo->dct_method = JDCT_FLOAT;
} else {
fprintf(stderr, "%s: invalid argument for dct\n", progname);
} else
usage();
}
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
/* Enable debug printouts. */
@@ -348,9 +299,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
PACKAGE_NAME, VERSION, BUILD);
exit(EXIT_SUCCESS);
} else if (keymatch(arg, "fastcrush", 4)) {
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OPTIMIZE_SCANS, FALSE);
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
/* Force a monochrome JPEG file to be generated. */
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
@@ -359,18 +307,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* Force an RGB JPEG file to be generated. */
jpeg_set_colorspace(cinfo, JCS_RGB);
} else if (keymatch(arg, "lambda1", 7)) {
if (++argn >= argc) /* advance to next argument */
usage();
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1,
atof(argv[argn]));
} else if (keymatch(arg, "lambda2", 7)) {
if (++argn >= argc) /* advance to next argument */
usage();
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2,
atof(argv[argn]));
} else if (keymatch(arg, "maxmemory", 3)) {
/* Maximum memory in Kb (or Mb with 'm'). */
long lval;
@@ -384,13 +320,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
lval *= 1000L;
cinfo->mem->max_memory_to_use = lval * 1000L;
} else if (keymatch(arg, "dc-scan-opt", 3)) {
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for dc-scan-opt\n", progname);
usage();
}
jpeg_c_set_int_param(cinfo, JINT_DC_SCAN_OPT_MODE, atoi(argv[argn]));
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
/* Enable entropy parm optimization. */
#ifdef ENTROPY_OPT_SUPPORTED
@@ -403,10 +332,8 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "outfile", 4)) {
/* Set output file name. */
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for outfile\n", progname);
if (++argn >= argc) /* advance to next argument */
usage();
}
outfilename = argv[argn]; /* save it away for later use */
} else if (keymatch(arg, "progressive", 1)) {
@@ -432,10 +359,8 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "quality", 1)) {
/* Quality ratings (quantization table scaling factors). */
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for quality\n", progname);
if (++argn >= argc) /* advance to next argument */
usage();
}
qualityarg = argv[argn];
} else if (keymatch(arg, "qslots", 2)) {
@@ -455,22 +380,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
qtablefile = argv[argn];
/* We postpone actually reading the file in case -quality comes later. */
} else if (keymatch(arg, "quant-table", 7)) {
int val;
if (++argn >= argc) /* advance to next argument */
usage();
val = atoi(argv[argn]);
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, val);
if (jpeg_c_get_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX) != val) {
fprintf(stderr, "%s: %d is invalid argument for quant-table\n", progname, val);
usage();
}
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "quant-baseline", 7)) {
/* Force quantization table to meet baseline requirements */
force_baseline = TRUE;
} else if (keymatch(arg, "restart", 1)) {
/* Restart interval in MCU rows (or in MCUs with 'b'). */
long lval;
@@ -490,11 +399,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* restart_interval will be computed during startup */
}
} else if (keymatch(arg, "revert", 3)) {
/* revert to old JPEG default */
jpeg_c_set_int_param(cinfo, JINT_COMPRESS_PROFILE, JCP_FASTEST);
jpeg_set_defaults(cinfo);
} else if (keymatch(arg, "sample", 2)) {
/* Set sampling factors. */
if (++argn >= argc) /* advance to next argument */
@@ -534,57 +438,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* Input file is Targa format. */
is_targa = TRUE;
} else if (keymatch(arg, "notrellis-dc", 11)) {
/* disable trellis quantization */
jpeg_c_set_bool_param(cinfo, JBOOLEAN_TRELLIS_QUANT_DC, FALSE);
} else if (keymatch(arg, "notrellis", 1)) {
/* disable trellis quantization */
jpeg_c_set_bool_param(cinfo, JBOOLEAN_TRELLIS_QUANT, FALSE);
} else if (keymatch(arg, "trellis-dc-ver-weight", 12)) {
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for trellis-dc-ver-weight\n", progname);
usage();
}
jpeg_c_set_float_param(cinfo, JFLOAT_TRELLIS_DELTA_DC_WEIGHT, atof(argv[argn]));
} else if (keymatch(arg, "trellis-dc", 9)) {
/* enable DC trellis quantization */
jpeg_c_set_bool_param(cinfo, JBOOLEAN_TRELLIS_QUANT_DC, TRUE);
} else if (keymatch(arg, "tune-psnr", 6)) {
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 1);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 9.0);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 0.0);
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, FALSE);
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "tune-ssim", 6)) {
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 1);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 11.5);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 12.75);
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, FALSE);
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "tune-ms-ssim", 6)) {
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 3);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 12.0);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 13.0);
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, TRUE);
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "tune-hvs-psnr", 6)) {
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 3);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 14.75);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 16.5);
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, TRUE);
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "noovershoot", 11)) {
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OVERSHOOT_DERINGING, FALSE);
} else {
fprintf(stderr, "%s: unknown option '%s'\n", progname, arg);
usage(); /* bogus switch */
}
}
@@ -596,28 +450,20 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* Set quantization tables for selected quality. */
/* Some or all may be overridden if -qtables is present. */
if (qualityarg != NULL) /* process -quality if it was present */
if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) {
fprintf(stderr, "%s: can't set quality ratings\n", progname);
if (! set_quality_ratings(cinfo, qualityarg, force_baseline))
usage();
}
if (qtablefile != NULL) /* process -qtables if it was present */
if (! read_quant_tables(cinfo, qtablefile, force_baseline)) {
fprintf(stderr, "%s: can't read qtable file\n", progname);
if (! read_quant_tables(cinfo, qtablefile, force_baseline))
usage();
}
if (qslotsarg != NULL) /* process -qslots if it was present */
if (! set_quant_slots(cinfo, qslotsarg))
usage();
/* set_quality_ratings sets default subsampling, so the explicit
subsampling must be set after it */
if (samplearg != NULL) /* process -sample if it was present */
if (! set_sample_factors(cinfo, samplearg)) {
fprintf(stderr, "%s: can't set sample factors\n", progname);
if (! set_sample_factors(cinfo, samplearg))
usage();
}
#ifdef C_PROGRESSIVE_SUPPORTED
if (simple_progressive) /* process -progressive; -scans can override */
@@ -749,9 +595,6 @@ main (int argc, char **argv)
(*src_mgr->start_input) (&cinfo, src_mgr);
/* Now that we know input colorspace, fix colorspace-dependent defaults */
#if JPEG_RAW_READER
if (!is_jpeg)
#endif
jpeg_default_colorspace(&cinfo);
/* Adjust default compression parameters by re-parsing the options */
@@ -768,47 +611,9 @@ main (int argc, char **argv)
/* Start compressor */
jpeg_start_compress(&cinfo, TRUE);
/* Copy metadata */
if (copy_markers) {
jpeg_saved_marker_ptr marker;
/* In the current implementation, we don't actually need to examine the
* option flag here; we just copy everything that got saved.
* But to avoid confusion, we do not output JFIF and Adobe APP14 markers
* if the encoder library already wrote one.
*/
for (marker = src_mgr->marker_list; marker != NULL; marker = marker->next) {
if (cinfo.write_JFIF_header &&
marker->marker == JPEG_APP0 &&
marker->data_length >= 5 &&
GETJOCTET(marker->data[0]) == 0x4A &&
GETJOCTET(marker->data[1]) == 0x46 &&
GETJOCTET(marker->data[2]) == 0x49 &&
GETJOCTET(marker->data[3]) == 0x46 &&
GETJOCTET(marker->data[4]) == 0)
continue; /* reject duplicate JFIF */
if (cinfo.write_Adobe_marker &&
marker->marker == JPEG_APP0+14 &&
marker->data_length >= 5 &&
GETJOCTET(marker->data[0]) == 0x41 &&
GETJOCTET(marker->data[1]) == 0x64 &&
GETJOCTET(marker->data[2]) == 0x6F &&
GETJOCTET(marker->data[3]) == 0x62 &&
GETJOCTET(marker->data[4]) == 0x65)
continue; /* reject duplicate Adobe */
jpeg_write_marker(&cinfo, marker->marker, marker->data,
marker->data_length);
}
}
/* Process data */
while (cinfo.next_scanline < cinfo.image_height) {
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
#if JPEG_RAW_READER
if (is_jpeg)
(void) jpeg_write_raw_data(&cinfo, src_mgr->plane_pointer, num_scanlines);
else
#endif
(void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
}

View File

@@ -2,11 +2,10 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.56])
AC_INIT([mozjpeg], [3.3.1])
BUILD=`date +%Y%m%d`
AC_INIT([libjpeg-turbo], [1.5.3])
AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
AC_PREFIX_DEFAULT(/opt/mozjpeg)
AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -19,7 +18,6 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AM_PROG_AS
AM_PROG_CC_C_O
AC_PROG_INSTALL
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LIBTOOL
AC_PROG_LN_S
@@ -62,7 +60,7 @@ AC_CHECK_SIZEOF(size_t)
if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then
LIBDIR=`eval echo ${libdir}`
LIBDIR=`eval echo $LIBDIR`
if test "$LIBDIR" = "/opt/mozjpeg/lib"; then
if test "$LIBDIR" = "/opt/libjpeg-turbo/lib"; then
case $host_os in
darwin*)
;;
@@ -104,12 +102,6 @@ if test "x${SUNCC}" = "xyes"; then
fi
# Checks for libraries.
AC_CHECK_LIB([m],[pow])
PKG_CHECK_MODULES([libpng], [libpng], [HAVE_LIBPNG=1], [
PKG_CHECK_MODULES([libpng], [libpng12], [HAVE_LIBPNG=1], [HAVE_LIBPNG=0])
])
AM_CONDITIONAL([HAVE_LIBPNG], [test "$HAVE_LIBPNG" -eq 1])
# Checks for header files.
AC_HEADER_STDC
@@ -162,10 +154,10 @@ AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
if test "x$JPEG_LIB_VERSION" = "x"; then
AC_ARG_WITH([jpeg7],
AC_HELP_STRING([--with-jpeg7],
[Emulate libjpeg v7 API/ABI (this makes mozjpeg backward incompatible with libjpeg v6b.)]))
[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 v8 API/ABI (this makes mozjpeg backward incompatible with libjpeg v6b.)]))
[Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
if test "x${with_jpeg8}" = "xyes"; then
JPEG_LIB_VERSION=80
else
@@ -183,9 +175,9 @@ AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
[libjpeg API version])
AC_ARG_VAR(SO_MAJOR_VERSION,
[Major version of the mozjpeg shared library (default is determined by the API version)])
[Major version of the libjpeg-turbo shared library (default is determined by the API version)])
AC_ARG_VAR(SO_MINOR_VERSION,
[Minor version of the mozjpeg shared library (default is determined by the API version)])
[Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
if test "x$SO_MAJOR_VERSION" = "x"; then
case "$JPEG_LIB_VERSION" in
62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
@@ -230,7 +222,7 @@ AC_SUBST(SO_MINOR_VERSION)
AC_SUBST(SO_AGE)
AC_SUBST(MEM_SRCDST_FUNCTIONS)
AC_DEFINE_UNQUOTED(MOZJPEG_VERSION, [$VERSION], [mozjpeg version])
AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
m4_define(version_major,m4_car(m4_shiftn(1,[],version_triplet)))
@@ -245,7 +237,7 @@ AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION_NUMBER, [$LIBJPEG_TURBO_VERSION_NUMBER]
VERSION_SCRIPT=yes
AC_ARG_ENABLE([ld-version-script],
AS_HELP_STRING([--disable-ld-version-script],
[Disable linker version script for mozjpeg (default is to use linker version script if the linker supports it)]),
[Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
[VERSION_SCRIPT=$enableval], [])
AC_MSG_CHECKING([whether the linker supports version scripts])
@@ -256,13 +248,13 @@ VERS_1 {
global: *;
};
EOF
AC_LINK_IFELSE([AC_LANG_SOURCE([AC_LANG_PROGRAM([], [])])],
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[VERSION_SCRIPT_FLAG=-Wl,--version-script,;
AC_MSG_RESULT([yes (GNU style)])],
[])
if test "x$VERSION_SCRIPT_FLAG" = "x"; then
LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
AC_LINK_IFELSE([AC_LANG_SOURCE([AC_LANG_PROGRAM([], [])])],
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[VERSION_SCRIPT_FLAG=-Wl,-M,;
AC_MSG_RESULT([yes (Sun style)])],
[])
@@ -273,7 +265,7 @@ if test "x$VERSION_SCRIPT_FLAG" = "x"; then
fi
LDFLAGS="$SAVED_LDFLAGS"
AC_MSG_CHECKING([whether to use version script when building mozjpeg])
AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
AC_MSG_RESULT($VERSION_SCRIPT)
AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
@@ -369,6 +361,7 @@ if test "x$JAVAC" = "x"; then
fi
AC_SUBST(JAVAC)
AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
JAVACFLAGS="$JAVACFLAGS -J-Dfile.encoding=UTF8"
AC_SUBST(JAVACFLAGS)
AC_ARG_VAR(JAR, [Java archive command (default: jar)])
if test "x$JAR" = "x"; then
@@ -525,17 +518,13 @@ if test "x${with_simd}" != "xno"; then
fi
;;
powerpc*)
AC_MSG_RESULT([yes (powerpc)])
simd_arch=powerpc
AC_CHECK_ALTIVEC(
[AC_MSG_RESULT([yes (powerpc)])
simd_arch=powerpc],
[AC_NO_SIMD(PowerPC SPE)])
;;
*)
AC_MSG_RESULT([no ("$host_cpu")])
with_simd=no;
if test "x${require_simd}" = "xyes"; then
AC_MSG_ERROR([SIMD support not available for this CPU.])
else
AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
fi
AC_NO_SIMD($host_cpu)
;;
esac
@@ -558,7 +547,7 @@ AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd6
AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = "xyes"])
AC_ARG_VAR(PKGNAME, [distribution package name (default: mozjpeg)])
AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
if test "x$PKGNAME" = "x"; then
PKGNAME=$PACKAGE_NAME
fi
@@ -573,6 +562,14 @@ case "$host_cpu" in
RPMARCH=i386
DEBARCH=i386
;;
powerpc64le)
RPMARCH=`uname -m`
DEBARCH=ppc64el
;;
powerpc)
RPMARCH=ppc
DEBARCH=ppc
;;
*)
RPMARCH=`uname -m`
DEBARCH=$RPMARCH
@@ -598,7 +595,7 @@ AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [libjpeg-turbo build number])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([jconfig.h])
AC_CONFIG_HEADERS([jconfigint.h])
AC_CONFIG_FILES([pkgscripts/mozjpeg.spec.tmpl:release/mozjpeg.spec.in])
AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
AC_CONFIG_FILES([pkgscripts/makemacpkg.tmpl:release/makemacpkg.in])

View File

@@ -1,4 +1,4 @@
.TH DJPEG 1 "18 March 2017"
.TH DJPEG 1 "13 November 2017"
.SH NAME
djpeg \- decompress a JPEG file to an image file
.SH SYNOPSIS
@@ -204,7 +204,8 @@ Decompress only a rectangular subregion of the image, starting at point X,Y
with width W and height H. If necessary, X will be shifted left to the nearest
iMCU boundary, and the width will be increased accordingly. Note that if
decompression scaling is being used, then X, Y, W, and H are relative to the
scaled image dimensions.
scaled image dimensions. Currently this option only works with the
PBMPLUS (PPM/PGM), GIF, and Targa output formats.
.TP
.B \-verbose
Enable debug printout. More

11
djpeg.c
View File

@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2013 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2010-2011, 2013-2016, D. R. Commander.
* Copyright (C) 2010-2011, 2013-2017, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -31,7 +31,6 @@
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "jversion.h" /* for version message */
#include "jconfigint.h"
#include "wrppm.h"
#include <ctype.h> /* to declare isprint() */
@@ -173,6 +172,7 @@ usage (void)
fprintf(stderr, " -skip Y0,Y1 Decompress all rows except those between Y0 and Y1 (inclusive)\n");
fprintf(stderr, " -crop WxH+X+Y Decompress only a rectangular subregion of the image\n");
fprintf(stderr, " [requires PBMPLUS (PPM/PGM), GIF, or Targa output format]\n");
fprintf(stderr, " -verbose or -debug Emit debug output\n");
fprintf(stderr, " -version Print version information and exit\n");
exit(EXIT_FAILURE);
@@ -713,9 +713,10 @@ main (int argc, char **argv)
}
jpeg_crop_scanline(&cinfo, &crop_x, &crop_width);
((ppm_dest_ptr) dest_mgr)->buffer_width = cinfo.output_width *
cinfo.out_color_components *
sizeof(JSAMPLE);
if (dest_mgr->calc_buffer_dimensions)
(*dest_mgr->calc_buffer_dimensions) (&cinfo, dest_mgr);
else
ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
/* Write output file header. This is a hack to ensure that the destination
* manager creates an output image of the proper size.

View File

@@ -1014,7 +1014,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
<tr><td class="paramname">jpegSubsamp</td><td>the level of chrominance subsampling to be used when generating the JPEG image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1111,7 +1111,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1208,7 +1208,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1301,7 +1301,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
<tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr>
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1394,7 +1394,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
<tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr>
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1479,7 +1479,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this is <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the decompressed image is unpadded, else <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the decompressed image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. (NOTE: <code>scaledWidth</code> can be determined by calling <a class="el" href="group___turbo_j_p_e_g.html#ga84878bb65404204743aa18cac02781df" title="Compute the scaled value of dimension using the given scaling factor.">TJSCALED()</a> with the JPEG image width and one of the scaling factors returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8" title="Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of Tur...">tjGetScalingFactors()</a>.) You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
<tr><td class="paramname">height</td><td>desired height (in pixels) of the destination image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size.</td></tr>
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1629,7 +1629,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr>
<tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1708,7 +1708,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the scaled plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective scaled plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to decompress the JPEG image into a subregion of a larger YUV planar image.</td></tr>
<tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1826,7 +1826,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> to determine the appropriate size for this buffer based on the image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.)</td></tr>
<tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr>
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -1919,7 +1919,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">dstPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if generating a grayscale image) that will receive the encoded image. These planes can be contiguous or non-contiguous in memory. Use <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> to determine the appropriate size for each plane based on the image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details.</td></tr>
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to encode an RGB or grayscale image into a subregion of a larger YUV planar image.</td></tr>
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>
@@ -2275,7 +2275,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
If you choose option 1, <code>dstSizes[i]</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>dstBufs[i]</code> upon return from this function, as it may have changed.</td></tr>
<tr><td class="paramname">dstSizes</td><td>pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If <code>dstBufs[i]</code> points to a pre-allocated buffer, then <code>dstSizes[i]</code> should be set to the size of the buffer. Upon return, <code>dstSizes[i]</code> will contain the size of the JPEG image (in bytes.)</td></tr>
<tr><td class="paramname">transforms</td><td>pointer to an array of n <a class="el" href="structtjtransform.html" title="Lossless transform.">tjtransform</a> structures, each of which specifies the transform parameters and/or cropping region for the corresponding transformed output image.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table>
</dd>
</dl>

View File

@@ -1,3 +1,3 @@
code {
color: #4665A2;
color: #4665A2;
}

View File

@@ -1,26 +0,0 @@
#!/bin/sh
set -e
# Make a local, clean libjpeg-turbo branch that tracks the remote libjpeg-turbo.
# This will allow pushing of imported libjpeg-turbo commits to the mozjpeg repository.
# The libjpeg-turbo branch must only contain imported SVN commits (with git-svn-id: in the message).
git branch -f -t libjpeg-turbo origin/libjpeg-turbo
# Configure git-svn. "git svn fetch" will rebuild remaining git-svn metadata.
git config svn-remote.svn.url svn://svn.code.sf.net/p/libjpeg-turbo/code
git config svn-remote.svn.fetch trunk:refs/heads/libjpeg-turbo
# Enable mapping of SVN usernames to git authors.
git config svn.authorsfile .gitauthors
# Mark which libjpeg-turbo commit has been used to start mozjpeg.
# Required for accurate merging and blame.
echo > .git/info/grafts "72b66f9c77b3e4ae363b21e48145f635cec0b193 540789427ccae8e9e778151cbc16ab8ee88ac6a8"
# To get changes from SVN:
# git svn fetch
# git push origin libjpeg-turbo
#
# To merge SVN changes with mozjpeg:
# git checkout master
# git merge libjpeg-turbo

View File

@@ -1,5 +1,5 @@
set(JAR_FILE turbojpeg.jar)
set(MANIFEST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.MF")
set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.MF)
set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ
org/libjpegturbo/turbojpeg/TJCompressor
@@ -17,7 +17,7 @@ set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ
if(MSVC_IDE)
set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
else()
set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}")
set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
set(TURBOJPEG_DLL_NAME "turbojpeg")
@@ -25,34 +25,33 @@ if(MINGW)
set(TURBOJPEG_DLL_NAME "libturbojpeg")
endif()
configure_file(org/libjpegturbo/turbojpeg/TJLoader.java.in
"${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java")
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
set(JAVA_SOURCES "")
set(JAVA_CLASSES "")
set(JAVA_CLASSES_FULL "")
foreach(class ${JAVA_CLASSNAMES})
list(APPEND JAVA_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${class}.java")
list(APPEND JAVA_CLASSES "${class}.class")
list(APPEND JAVA_CLASSES_FULL "${OBJDIR}/${class}.class")
set(JAVA_SOURCES ${JAVA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${class}.java)
set(JAVA_CLASSES ${JAVA_CLASSES} ${class}.class)
set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL} ${OBJDIR}/${class}.class)
endforeach()
list(APPEND JAVA_SOURCES
"${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java")
list(APPEND JAVA_CLASSES org/libjpegturbo/turbojpeg/TJLoader.class)
list(APPEND JAVA_CLASSES_FULL
"${OBJDIR}/org/libjpegturbo/turbojpeg/TJLoader.class")
set(JAVA_SOURCES ${JAVA_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
set(JAVA_CLASSES ${JAVA_CLASSES}
org/libjpegturbo/turbojpeg/TJLoader.class)
set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL}
${OBJDIR}/org/libjpegturbo/turbojpeg/TJLoader.class)
string(REGEX REPLACE " " ";" JAVACFLAGS "${JAVACFLAGS}")
add_custom_command(OUTPUT ${JAVA_CLASSES_FULL} DEPENDS ${JAVA_SOURCES}
COMMAND "${JAVA_COMPILE}" ARGS ${JAVACFLAGS} -d "${OBJDIR}" ${JAVA_SOURCES}
VERBATIM)
COMMAND ${JAVA_COMPILE} ARGS ${JAVACFLAGS} -d ${OBJDIR} ${JAVA_SOURCES})
add_custom_command(OUTPUT "${JAR_FILE}" DEPENDS ${JAVA_CLASSES_FULL}
"${MANIFEST_FILE}"
COMMAND "${JAVA_ARCHIVE}" cfm "${JAR_FILE}" "${MANIFEST_FILE}" ${JAVA_CLASSES}
WORKING_DIRECTORY "${OBJDIR}"
VERBATIM)
add_custom_command(OUTPUT ${JAR_FILE} DEPENDS ${JAVA_CLASSES_FULL}
${MANIFEST_FILE}
COMMAND ${JAVA_ARCHIVE} cfm ${JAR_FILE} ${MANIFEST_FILE} ${JAVA_CLASSES}
WORKING_DIRECTORY ${OBJDIR})
add_custom_target(java ALL DEPENDS "${JAR_FILE}")
add_custom_target(java ALL DEPENDS ${JAR_FILE})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${JAR_FILE}" DESTINATION classes)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${JAR_FILE} DESTINATION classes)

View File

@@ -721,37 +721,37 @@ class TJBench {
if (argv[i].equalsIgnoreCase("-tile")) {
doTile = true; xformOpt |= TJTransform.OPT_CROP;
}
if (argv[i].equalsIgnoreCase("-fastupsample")) {
else if (argv[i].equalsIgnoreCase("-fastupsample")) {
System.out.println("Using fast upsampling code\n");
flags |= TJ.FLAG_FASTUPSAMPLE;
}
if (argv[i].equalsIgnoreCase("-fastdct")) {
else if (argv[i].equalsIgnoreCase("-fastdct")) {
System.out.println("Using fastest DCT/IDCT algorithm\n");
flags |= TJ.FLAG_FASTDCT;
}
if (argv[i].equalsIgnoreCase("-accuratedct")) {
else if (argv[i].equalsIgnoreCase("-accuratedct")) {
System.out.println("Using most accurate DCT/IDCT algorithm\n");
flags |= TJ.FLAG_ACCURATEDCT;
}
if (argv[i].equalsIgnoreCase("-rgb"))
else if (argv[i].equalsIgnoreCase("-rgb"))
pf = TJ.PF_RGB;
if (argv[i].equalsIgnoreCase("-rgbx"))
else if (argv[i].equalsIgnoreCase("-rgbx"))
pf = TJ.PF_RGBX;
if (argv[i].equalsIgnoreCase("-bgr"))
else if (argv[i].equalsIgnoreCase("-bgr"))
pf = TJ.PF_BGR;
if (argv[i].equalsIgnoreCase("-bgrx"))
else if (argv[i].equalsIgnoreCase("-bgrx"))
pf = TJ.PF_BGRX;
if (argv[i].equalsIgnoreCase("-xbgr"))
else if (argv[i].equalsIgnoreCase("-xbgr"))
pf = TJ.PF_XBGR;
if (argv[i].equalsIgnoreCase("-xrgb"))
else if (argv[i].equalsIgnoreCase("-xrgb"))
pf = TJ.PF_XRGB;
if (argv[i].equalsIgnoreCase("-bottomup"))
else if (argv[i].equalsIgnoreCase("-bottomup"))
flags |= TJ.FLAG_BOTTOMUP;
if (argv[i].equalsIgnoreCase("-quiet"))
else if (argv[i].equalsIgnoreCase("-quiet"))
quiet = 1;
if (argv[i].equalsIgnoreCase("-qq"))
else if (argv[i].equalsIgnoreCase("-qq"))
quiet = 2;
if (argv[i].equalsIgnoreCase("-scale") && i < argv.length - 1) {
else if (argv[i].equalsIgnoreCase("-scale") && i < argv.length - 1) {
int temp1 = 0, temp2 = 0;
boolean match = false, scanned = true;
Scanner scanner = new Scanner(argv[++i]).useDelimiter("/");
@@ -774,25 +774,25 @@ class TJBench {
} else
usage();
}
if (argv[i].equalsIgnoreCase("-hflip"))
else if (argv[i].equalsIgnoreCase("-hflip"))
xformOp = TJTransform.OP_HFLIP;
if (argv[i].equalsIgnoreCase("-vflip"))
else if (argv[i].equalsIgnoreCase("-vflip"))
xformOp = TJTransform.OP_VFLIP;
if (argv[i].equalsIgnoreCase("-transpose"))
else if (argv[i].equalsIgnoreCase("-transpose"))
xformOp = TJTransform.OP_TRANSPOSE;
if (argv[i].equalsIgnoreCase("-transverse"))
else if (argv[i].equalsIgnoreCase("-transverse"))
xformOp = TJTransform.OP_TRANSVERSE;
if (argv[i].equalsIgnoreCase("-rot90"))
else if (argv[i].equalsIgnoreCase("-rot90"))
xformOp = TJTransform.OP_ROT90;
if (argv[i].equalsIgnoreCase("-rot180"))
else if (argv[i].equalsIgnoreCase("-rot180"))
xformOp = TJTransform.OP_ROT180;
if (argv[i].equalsIgnoreCase("-rot270"))
else if (argv[i].equalsIgnoreCase("-rot270"))
xformOp = TJTransform.OP_ROT270;
if (argv[i].equalsIgnoreCase("-grayscale"))
else if (argv[i].equalsIgnoreCase("-grayscale"))
xformOpt |= TJTransform.OPT_GRAY;
if (argv[i].equalsIgnoreCase("-nooutput"))
else if (argv[i].equalsIgnoreCase("-nooutput"))
xformOpt |= TJTransform.OPT_NOOUTPUT;
if (argv[i].equalsIgnoreCase("-benchtime") && i < argv.length - 1) {
else if (argv[i].equalsIgnoreCase("-benchtime") && i < argv.length - 1) {
double temp = -1;
try {
temp = Double.parseDouble(argv[++i]);
@@ -802,11 +802,11 @@ class TJBench {
else
usage();
}
if (argv[i].equalsIgnoreCase("-yuv")) {
else if (argv[i].equalsIgnoreCase("-yuv")) {
System.out.println("Testing YUV planar encoding/decoding\n");
doYUV = true;
}
if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) {
else if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) {
int temp = 0;
try {
temp = Integer.parseInt(argv[++i]);
@@ -814,7 +814,7 @@ class TJBench {
if (temp >= 1)
yuvpad = temp;
}
if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) {
else if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) {
i++;
if (argv[i].toUpperCase().startsWith("G"))
subsamp = TJ.SAMP_GRAY;
@@ -829,11 +829,11 @@ class TJBench {
else if (argv[i].equals("411"))
subsamp = TJ.SAMP_411;
}
if (argv[i].equalsIgnoreCase("-componly"))
else if (argv[i].equalsIgnoreCase("-componly"))
compOnly = true;
if (argv[i].equalsIgnoreCase("-nowrite"))
else if (argv[i].equalsIgnoreCase("-nowrite"))
write = false;
if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
else if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
double temp = -1;
try {
temp = Double.parseDouble(argv[++i]);
@@ -844,8 +844,7 @@ class TJBench {
} else
usage();
}
if (argv[i].equalsIgnoreCase("-?"))
usage();
else usage();
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C)2011-2012, 2014-2015 D. R. Commander. All Rights Reserved.
* Copyright (C)2011-2012, 2014-2015, 2017 D. R. Commander.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -94,7 +95,7 @@ public class TJExample implements TJCustomFilter {
}
private static final String[] sampName = {
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0"
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0", "4:1:1"
};
public static void main(String[] argv) {
@@ -117,114 +118,114 @@ public class TJExample implements TJCustomFilter {
int outSubsamp = -1, outQual = 95;
boolean display = false;
if (argv.length > 1) {
for (int i = 1; i < argv.length; i++) {
if (argv[i].length() < 2)
continue;
if (argv[i].length() > 2 &&
argv[i].substring(0, 3).equalsIgnoreCase("-sc")) {
int match = 0;
if (i < argv.length - 1) {
String[] scaleArg = argv[++i].split("/");
if (scaleArg.length == 2) {
TJScalingFactor tempsf =
new TJScalingFactor(Integer.parseInt(scaleArg[0]),
Integer.parseInt(scaleArg[1]));
for (int j = 0; j < sf.length; j++) {
if (tempsf.equals(sf[j])) {
scaleFactor = sf[j];
match = 1;
break;
}
if (argv[1].substring(0, 2).equalsIgnoreCase("-d"))
display = true;
for (int i = 2; i < argv.length; i++) {
if (argv[i].length() < 2)
continue;
else if (argv[i].length() > 2 &&
argv[i].substring(0, 3).equalsIgnoreCase("-sc")) {
int match = 0;
if (i < argv.length - 1) {
String[] scaleArg = argv[++i].split("/");
if (scaleArg.length == 2) {
TJScalingFactor tempsf =
new TJScalingFactor(Integer.parseInt(scaleArg[0]),
Integer.parseInt(scaleArg[1]));
for (int j = 0; j < sf.length; j++) {
if (tempsf.equals(sf[j])) {
scaleFactor = sf[j];
match = 1;
break;
}
}
}
if (match != 1) usage();
}
if (argv[i].equalsIgnoreCase("-h") || argv[i].equalsIgnoreCase("-?"))
usage();
if (argv[i].length() > 2 &&
argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
if (i < argv.length - 1) {
i++;
if (argv[i].substring(0, 1).equalsIgnoreCase("g"))
outSubsamp = TJ.SAMP_GRAY;
else if (argv[i].equals("444"))
outSubsamp = TJ.SAMP_444;
else if (argv[i].equals("422"))
outSubsamp = TJ.SAMP_422;
else if (argv[i].equals("420"))
outSubsamp = TJ.SAMP_420;
else
usage();
} else
usage();
}
if (argv[i].substring(0, 2).equalsIgnoreCase("-q")) {
if (i < argv.length - 1) {
int qual = Integer.parseInt(argv[++i]);
if (qual >= 1 && qual <= 100)
outQual = qual;
else
usage();
} else
usage();
}
if (argv[i].substring(0, 2).equalsIgnoreCase("-g"))
xform.options |= TJTransform.OPT_GRAY;
if (argv[i].equalsIgnoreCase("-hflip"))
xform.op = TJTransform.OP_HFLIP;
if (argv[i].equalsIgnoreCase("-vflip"))
xform.op = TJTransform.OP_VFLIP;
if (argv[i].equalsIgnoreCase("-transpose"))
xform.op = TJTransform.OP_TRANSPOSE;
if (argv[i].equalsIgnoreCase("-transverse"))
xform.op = TJTransform.OP_TRANSVERSE;
if (argv[i].equalsIgnoreCase("-rot90"))
xform.op = TJTransform.OP_ROT90;
if (argv[i].equalsIgnoreCase("-rot180"))
xform.op = TJTransform.OP_ROT180;
if (argv[i].equalsIgnoreCase("-rot270"))
xform.op = TJTransform.OP_ROT270;
if (argv[i].equalsIgnoreCase("-custom"))
xform.cf = new TJExample();
else if (argv[i].length() > 2 &&
argv[i].substring(0, 2).equalsIgnoreCase("-c")) {
if (i >= argv.length - 1)
usage();
String[] cropArg = argv[++i].split(",");
if (cropArg.length != 3)
usage();
String[] dimArg = cropArg[2].split("[xX]");
if (dimArg.length != 2)
usage();
int tempx = Integer.parseInt(cropArg[0]);
int tempy = Integer.parseInt(cropArg[1]);
int tempw = Integer.parseInt(dimArg[0]);
int temph = Integer.parseInt(dimArg[1]);
if (tempx < 0 || tempy < 0 || tempw < 0 || temph < 0)
usage();
xform.x = tempx;
xform.y = tempy;
xform.width = tempw;
xform.height = temph;
xform.options |= TJTransform.OPT_CROP;
}
if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
display = true;
if (argv[i].equalsIgnoreCase("-fastupsample")) {
System.out.println("Using fast upsampling code");
flags |= TJ.FLAG_FASTUPSAMPLE;
}
if (argv[i].equalsIgnoreCase("-fastdct")) {
System.out.println("Using fastest DCT/IDCT algorithm");
flags |= TJ.FLAG_FASTDCT;
}
if (argv[i].equalsIgnoreCase("-accuratedct")) {
System.out.println("Using most accurate DCT/IDCT algorithm");
flags |= TJ.FLAG_ACCURATEDCT;
}
if (match != 1) usage();
}
else if (argv[i].length() > 2 &&
argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
if (i < argv.length - 1) {
i++;
if (argv[i].substring(0, 1).equalsIgnoreCase("g"))
outSubsamp = TJ.SAMP_GRAY;
else if (argv[i].equals("444"))
outSubsamp = TJ.SAMP_444;
else if (argv[i].equals("422"))
outSubsamp = TJ.SAMP_422;
else if (argv[i].equals("420"))
outSubsamp = TJ.SAMP_420;
else
usage();
} else
usage();
}
else if (argv[i].substring(0, 2).equalsIgnoreCase("-q")) {
if (i < argv.length - 1) {
int qual = Integer.parseInt(argv[++i]);
if (qual >= 1 && qual <= 100)
outQual = qual;
else
usage();
} else
usage();
}
else if (argv[i].substring(0, 2).equalsIgnoreCase("-g"))
xform.options |= TJTransform.OPT_GRAY;
else if (argv[i].equalsIgnoreCase("-hflip"))
xform.op = TJTransform.OP_HFLIP;
else if (argv[i].equalsIgnoreCase("-vflip"))
xform.op = TJTransform.OP_VFLIP;
else if (argv[i].equalsIgnoreCase("-transpose"))
xform.op = TJTransform.OP_TRANSPOSE;
else if (argv[i].equalsIgnoreCase("-transverse"))
xform.op = TJTransform.OP_TRANSVERSE;
else if (argv[i].equalsIgnoreCase("-rot90"))
xform.op = TJTransform.OP_ROT90;
else if (argv[i].equalsIgnoreCase("-rot180"))
xform.op = TJTransform.OP_ROT180;
else if (argv[i].equalsIgnoreCase("-rot270"))
xform.op = TJTransform.OP_ROT270;
else if (argv[i].equalsIgnoreCase("-custom"))
xform.cf = new TJExample();
else if (argv[i].length() > 2 &&
argv[i].substring(0, 2).equalsIgnoreCase("-c")) {
if (i >= argv.length - 1)
usage();
String[] cropArg = argv[++i].split(",");
if (cropArg.length != 3)
usage();
String[] dimArg = cropArg[2].split("[xX]");
if (dimArg.length != 2)
usage();
int tempx = Integer.parseInt(cropArg[0]);
int tempy = Integer.parseInt(cropArg[1]);
int tempw = Integer.parseInt(dimArg[0]);
int temph = Integer.parseInt(dimArg[1]);
if (tempx < 0 || tempy < 0 || tempw < 0 || temph < 0)
usage();
xform.x = tempx;
xform.y = tempy;
xform.width = tempw;
xform.height = temph;
xform.options |= TJTransform.OPT_CROP;
}
else if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
display = true;
else if (argv[i].equalsIgnoreCase("-fastupsample")) {
System.out.println("Using fast upsampling code");
flags |= TJ.FLAG_FASTUPSAMPLE;
}
else if (argv[i].equalsIgnoreCase("-fastdct")) {
System.out.println("Using fastest DCT/IDCT algorithm");
flags |= TJ.FLAG_FASTDCT;
}
else if (argv[i].equalsIgnoreCase("-accuratedct")) {
System.out.println("Using most accurate DCT/IDCT algorithm");
flags |= TJ.FLAG_ACCURATEDCT;
}
else usage();
}
String[] inFileTokens = argv[0].split("\\.");
if (inFileTokens.length > 1)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2011-2016 D. R. Commander. All Rights Reserved.
* Copyright (C)2011-2017 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -44,10 +44,10 @@ public class TJUnitTest {
private static void usage() {
System.out.println("\nUSAGE: java " + classname + " [options]\n");
System.out.println("Options:\n");
System.out.println("-yuv = test YUV encoding/decoding support\n");
System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
System.out.println(" 4-byte boundary\n");
System.out.println("Options:");
System.out.println("-yuv = test YUV encoding/decoding support");
System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest");
System.out.println(" 4-byte boundary");
System.out.println("-bi = test BufferedImage support\n");
System.exit(1);
}
@@ -109,21 +109,12 @@ public class TJUnitTest {
case BufferedImage.TYPE_BYTE_GRAY:
return TJ.PF_GRAY;
case BufferedImage.TYPE_INT_BGR:
if (byteOrder == ByteOrder.BIG_ENDIAN)
return TJ.PF_XBGR;
else
return TJ.PF_RGBX;
return TJ.PF_RGBX;
case BufferedImage.TYPE_INT_RGB:
if (byteOrder == ByteOrder.BIG_ENDIAN)
return TJ.PF_XRGB;
else
return TJ.PF_BGRX;
return TJ.PF_BGRX;
case BufferedImage.TYPE_INT_ARGB:
case BufferedImage.TYPE_INT_ARGB_PRE:
if (byteOrder == ByteOrder.BIG_ENDIAN)
return TJ.PF_ARGB;
else
return TJ.PF_BGRA;
return TJ.PF_BGRA;
}
return 0;
}
@@ -911,15 +902,13 @@ public class TJUnitTest {
for (int i = 0; i < argv.length; i++) {
if (argv[i].equalsIgnoreCase("-yuv"))
doYUV = true;
if (argv[i].equalsIgnoreCase("-noyuvpad"))
else if (argv[i].equalsIgnoreCase("-noyuvpad"))
pad = 1;
if (argv[i].substring(0, 1).equalsIgnoreCase("-h") ||
argv[i].equalsIgnoreCase("-?"))
usage();
if (argv[i].equalsIgnoreCase("-bi")) {
else if (argv[i].equalsIgnoreCase("-bi")) {
bi = true;
testName = "javabitest";
}
} else
usage();
}
if (doYUV)
_4byteFormats[4] = -1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2014 D. R. Commander. All Rights Reserved.
* Copyright (C)2014, 2017 D. R. Commander. All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -220,10 +220,13 @@ public class YUVImage {
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
int nc = (subsamp == TJ.SAMP_GRAY ? 1 : 3);
if (planes.length != nc || (offsets != null && offsets.length != nc) ||
if ((planes != null && planes.length != nc) ||
(offsets != null && offsets.length != nc) ||
(strides != null && strides.length != nc))
throw new IllegalArgumentException("YUVImage::setBuf(): planes, offsets, or strides array is the wrong size");
if (planes == null)
planes = new byte[nc][];
if (offsets == null)
offsets = new int[nc];
if (strides == null)

View File

@@ -4,9 +4,10 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2014, D. R. Commander.
* For conditions of distribution and use, see the accompanying README file.
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains application interface code for the compression half
* of the JPEG library. These are the "minimum" API routines that may be
@@ -22,8 +23,6 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jmemsys.h"
#include "jcmaster.h"
/*
@@ -93,16 +92,6 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
/* OK, I'm ready */
cinfo->global_state = CSTATE_START;
/* The master struct is used to store extension parameters, so we allocate it
* here. It is later reallocated by jinit_c_master_control().
*/
cinfo->master = (struct jpeg_comp_master *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
sizeof(my_comp_master));
MEMZERO(cinfo->master, sizeof(my_comp_master));
cinfo->master->compress_profile = JCP_MAX_COMPRESSION;
}

View File

@@ -3,9 +3,8 @@
*
* Copyright (C) 1994-1996, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains application interface code for the compression half
* of the JPEG library. These are the "standard" API routines that are
@@ -45,11 +44,6 @@ jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
if (write_all_tables)
jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
/* setting up scan optimisation pattern failed, disable scan optimisation */
if (cinfo->master->num_scans_luma == 0 || cinfo->scan_info == NULL ||
cinfo->num_scans == 0)
cinfo->master->optimize_scans = FALSE;
/* (Re)initialize error mgr and destination modules */
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
(*cinfo->dest->init_destination) (cinfo);

View File

@@ -3,9 +3,10 @@
*
* This file was part of the Independent JPEG Group's software:
* Developed 1997-2009 by Guido Vollbeding.
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file.
* libjpeg-turbo Modifications:
* Copyright (C) 2015, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains portable arithmetic entropy encoding routines for JPEG
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
@@ -18,7 +19,7 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include <math.h>
/* Expanded entropy encoder object for arithmetic encoding. */
@@ -120,10 +121,6 @@ emit_byte (int val, j_compress_ptr cinfo)
{
struct jpeg_destination_mgr *dest = cinfo->dest;
/* Do not emit bytes during trellis passes */
if (cinfo->master->trellis_passes)
return;
*dest->next_output_byte++ = (JOCTET) val;
if (--dest->free_in_buffer == 0)
if (! (*dest->empty_output_buffer) (cinfo))
@@ -830,7 +827,6 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci, tbl;
jpeg_component_info *compptr;
boolean progressive_mode;
if (gather_statistics)
/* Make sure to avoid that in the master control logic!
@@ -841,12 +837,8 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
/* We assume jcmaster.c already validated the progressive scan parameters. */
/* Trellis optimization does DC and AC in same pass and without refinement
* so consider progressive mode to be off in such case */
progressive_mode = (cinfo->master->trellis_passes) ? FALSE : cinfo->progressive_mode;
/* Select execution routines */
if (progressive_mode) {
if (cinfo->progressive_mode) {
if (cinfo->Ah == 0) {
if (cinfo->Ss == 0)
entropy->pub.encode_mcu = encode_mcu_DC_first;
@@ -865,7 +857,7 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
/* DC needs no table for refinement scan */
if (progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
tbl = compptr->dc_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
@@ -878,7 +870,7 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
entropy->dc_context[ci] = 0;
}
/* AC needs no table when not present */
if (progressive_mode == 0 || cinfo->Se) {
if (cinfo->progressive_mode == 0 || cinfo->Se) {
tbl = compptr->ac_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
@@ -887,7 +879,7 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
#ifdef CALCULATE_SPECTRAL_CONDITIONING
if (progressive_mode)
if (cinfo->progressive_mode)
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
cinfo->arith_ac_K[tbl] = cinfo->Ss + ((8 + cinfo->Se - cinfo->Ss) >> 4);
#endif
@@ -934,34 +926,3 @@ jinit_arith_encoder (j_compress_ptr cinfo)
/* Initialize index for fixed probability estimation */
entropy->fixed_bin[0] = 113;
}
GLOBAL(void)
jget_arith_rates (j_compress_ptr cinfo, int dc_tbl_no, int ac_tbl_no, arith_rates *r)
{
int i;
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
r->arith_dc_L = cinfo->arith_dc_L[dc_tbl_no];
r->arith_dc_U = cinfo->arith_dc_U[dc_tbl_no];
r->arith_ac_K = cinfo->arith_ac_K[ac_tbl_no];
for (i = 0; i < DC_STAT_BINS; i++) {
int state = entropy->dc_stats[dc_tbl_no][i];
int mps_val = state >> 7;
float prob_lps = (jpeg_aritab[state & 0x7f] >> 16) / 46340.95; /* 32768*sqrt(2) */
float prob_0 = (mps_val) ? prob_lps : 1.0 - prob_lps;
float prob_1 = 1.0 - prob_0;
r->rate_dc[i][0] = -log(prob_0) / log(2.0);
r->rate_dc[i][1] = -log(prob_1) / log(2.0);
}
for (i = 0; i < AC_STAT_BINS; i++) {
int state = entropy->ac_stats[ac_tbl_no][i];
int mps_val = state >> 7;
float prob_lps = (jpeg_aritab[state & 0x7f] >> 16) / 46340.95;
float prob_0 = (mps_val) ? prob_lps : 1.0 - prob_lps;
float prob_1 = 1.0 - prob_0;
r->rate_ac[i][0] = -log(prob_0) / log(2.0);
r->rate_ac[i][1] = -log(prob_1) / log(2.0);
}
}

View File

@@ -5,9 +5,8 @@
* Copyright (C) 1994-1997, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code and
* information relevant to libjpeg-turbo.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains the coefficient buffer controller for compression.
* This controller is the top level of the JPEG compressor proper.
@@ -17,7 +16,7 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jchuff.h"
/* We use a full-image coefficient buffer when doing Huffman optimization,
* and also for writing multiple-scan JPEG files. In all cases, the DCT
@@ -53,10 +52,6 @@ typedef struct {
/* In multi-pass modes, we need a virtual block array for each component. */
jvirt_barray_ptr whole_image[MAX_COMPONENTS];
/* when using trellis quantization, need to keep a copy of all unquantized coefficients */
jvirt_barray_ptr whole_image_uq[MAX_COMPONENTS];
} my_coef_controller;
typedef my_coef_controller *my_coef_ptr;
@@ -71,8 +66,6 @@ METHODDEF(boolean) compress_first_pass
METHODDEF(boolean) compress_output
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
#endif
METHODDEF(boolean) compress_trellis_pass
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
LOCAL(void)
@@ -129,12 +122,6 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
coef->pub.compress_data = compress_output;
break;
#endif
case JBUF_REQUANT:
if (coef->whole_image[0] == NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
coef->pub.compress_data = compress_trellis_pass;
break;
default:
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
break;
@@ -190,8 +177,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
input_buf[compptr->component_index],
coef->MCU_buffer[blkn],
ypos, xpos, (JDIMENSION) blockcnt,
NULL);
ypos, xpos, (JDIMENSION) blockcnt);
if (blockcnt < compptr->MCU_width) {
/* Create some dummy blocks at the right edge of the image. */
jzero_far((void *) coef->MCU_buffer[blkn + blockcnt],
@@ -266,7 +252,6 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
jpeg_component_info *compptr;
JBLOCKARRAY buffer;
JBLOCKROW thisblockrow, lastblockrow;
JBLOCKARRAY buffer_dst;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
@@ -275,12 +260,6 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
((j_common_ptr) cinfo, coef->whole_image[ci],
coef->iMCU_row_num * compptr->v_samp_factor,
(JDIMENSION) compptr->v_samp_factor, TRUE);
buffer_dst = (*cinfo->mem->access_virt_barray)
((j_common_ptr) cinfo, coef->whole_image_uq[ci],
coef->iMCU_row_num * compptr->v_samp_factor,
(JDIMENSION) compptr->v_samp_factor, TRUE);
/* Count non-dummy DCT block rows in this iMCU row. */
if (coef->iMCU_row_num < last_iMCU_row)
block_rows = compptr->v_samp_factor;
@@ -303,8 +282,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
input_buf[ci], thisblockrow,
(JDIMENSION) (block_row * DCTSIZE),
(JDIMENSION) 0, blocks_across,
buffer_dst[block_row]);
(JDIMENSION) 0, blocks_across);
if (ndummy > 0) {
/* Create dummy blocks at the right edge of the image. */
thisblockrow += blocks_across; /* => first dummy block */
@@ -348,136 +326,6 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
return compress_output(cinfo, input_buf);
}
METHODDEF(boolean)
compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
{
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
JDIMENSION blocks_across, MCUs_across, MCUindex;
int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
JCOEF lastDC;
jpeg_component_info *compptr;
JBLOCKARRAY buffer;
JBLOCKROW thisblockrow, lastblockrow;
JBLOCKARRAY buffer_dst;
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
c_derived_tbl dctbl_data;
c_derived_tbl *dctbl = &dctbl_data;
c_derived_tbl actbl_data;
c_derived_tbl *actbl = &actbl_data;
#ifdef C_ARITH_CODING_SUPPORTED
arith_rates arith_r_data;
arith_rates *arith_r = &arith_r_data;
#endif
compptr = cinfo->cur_comp_info[ci];
#ifdef C_ARITH_CODING_SUPPORTED
if (cinfo->arith_code)
jget_arith_rates(cinfo, compptr->dc_tbl_no, compptr->ac_tbl_no, arith_r);
else
#endif
{
jpeg_make_c_derived_tbl(cinfo, TRUE, compptr->dc_tbl_no, &dctbl);
jpeg_make_c_derived_tbl(cinfo, FALSE, compptr->ac_tbl_no, &actbl);
}
/* Align the virtual buffer for this component. */
buffer = (*cinfo->mem->access_virt_barray)
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
coef->iMCU_row_num * compptr->v_samp_factor,
(JDIMENSION) compptr->v_samp_factor, TRUE);
buffer_dst = (*cinfo->mem->access_virt_barray)
((j_common_ptr) cinfo, coef->whole_image_uq[compptr->component_index],
coef->iMCU_row_num * compptr->v_samp_factor,
(JDIMENSION) compptr->v_samp_factor, TRUE);
/* Count non-dummy DCT block rows in this iMCU row. */
if (coef->iMCU_row_num < last_iMCU_row)
block_rows = compptr->v_samp_factor;
else {
/* NB: can't use last_row_height here, since may not be set! */
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
if (block_rows == 0) block_rows = compptr->v_samp_factor;
}
blocks_across = compptr->width_in_blocks;
h_samp_factor = compptr->h_samp_factor;
/* Count number of dummy blocks to be added at the right margin. */
ndummy = (int) (blocks_across % h_samp_factor);
if (ndummy > 0)
ndummy = h_samp_factor - ndummy;
lastDC = 0;
/* Perform DCT for all non-dummy blocks in this iMCU row. Each call
* on forward_DCT processes a complete horizontal row of DCT blocks.
*/
for (block_row = 0; block_row < block_rows; block_row++) {
thisblockrow = buffer[block_row];
lastblockrow = (block_row > 0) ? buffer[block_row-1] : NULL;
#ifdef C_ARITH_CODING_SUPPORTED
if (cinfo->arith_code)
quantize_trellis_arith(cinfo, arith_r, thisblockrow,
buffer_dst[block_row], blocks_across,
cinfo->quant_tbl_ptrs[compptr->quant_tbl_no],
cinfo->master->norm_src[compptr->quant_tbl_no],
cinfo->master->norm_coef[compptr->quant_tbl_no],
&lastDC, lastblockrow, buffer_dst[block_row-1]);
else
#endif
quantize_trellis(cinfo, dctbl, actbl, thisblockrow,
buffer_dst[block_row], blocks_across,
cinfo->quant_tbl_ptrs[compptr->quant_tbl_no],
cinfo->master->norm_src[compptr->quant_tbl_no],
cinfo->master->norm_coef[compptr->quant_tbl_no],
&lastDC, lastblockrow, buffer_dst[block_row-1]);
if (ndummy > 0) {
/* Create dummy blocks at the right edge of the image. */
thisblockrow += blocks_across; /* => first dummy block */
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
lastDC = thisblockrow[-1][0];
for (bi = 0; bi < ndummy; bi++) {
thisblockrow[bi][0] = lastDC;
}
}
}
/* If at end of image, create dummy block rows as needed.
* The tricky part here is that within each MCU, we want the DC values
* of the dummy blocks to match the last real block's DC value.
* This squeezes a few more bytes out of the resulting file...
*/
if (coef->iMCU_row_num == last_iMCU_row) {
blocks_across += ndummy; /* include lower right corner */
MCUs_across = blocks_across / h_samp_factor;
for (block_row = block_rows; block_row < compptr->v_samp_factor;
block_row++) {
thisblockrow = buffer[block_row];
lastblockrow = buffer[block_row-1];
jzero_far((void *) thisblockrow,
(size_t) (blocks_across * sizeof(JBLOCK)));
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
lastDC = lastblockrow[h_samp_factor-1][0];
for (bi = 0; bi < h_samp_factor; bi++) {
thisblockrow[bi][0] = lastDC;
}
thisblockrow += h_samp_factor; /* advance to next MCU in row */
lastblockrow += h_samp_factor;
}
}
}
}
/* NB: compress_output will increment iMCU_row_num if successful.
* A suspension return will result in redoing all the work above next time.
*/
/* Emit data to the entropy encoder, sharing code with subsequent passes */
return compress_output(cinfo, input_buf);
}
/*
* Process some data in subsequent passes of a multi-pass case.
@@ -581,14 +429,6 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
(long) compptr->v_samp_factor),
(JDIMENSION) compptr->v_samp_factor);
coef->whole_image_uq[ci] = (*cinfo->mem->request_virt_barray)
((j_common_ptr) cinfo, 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);
}
#else
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);

1067
jcdctmgr.c

File diff suppressed because it is too large Load Diff

219
jcext.c
View File

@@ -1,219 +0,0 @@
/*
* jcext.c
*
* Copyright (C) 2014, D. R. Commander.
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains accessor functions for extension parameters. These
* allow for extending the functionality of the libjpeg API without breaking
* backward ABI compatibility.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
GLOBAL(boolean)
jpeg_c_bool_param_supported (const j_compress_ptr cinfo, J_BOOLEAN_PARAM param)
{
switch (param) {
case JBOOLEAN_OPTIMIZE_SCANS:
case JBOOLEAN_TRELLIS_QUANT:
case JBOOLEAN_TRELLIS_QUANT_DC:
case JBOOLEAN_TRELLIS_EOB_OPT:
case JBOOLEAN_USE_LAMBDA_WEIGHT_TBL:
case JBOOLEAN_USE_SCANS_IN_TRELLIS:
case JBOOLEAN_TRELLIS_Q_OPT:
case JBOOLEAN_OVERSHOOT_DERINGING:
return TRUE;
}
return FALSE;
}
GLOBAL(void)
jpeg_c_set_bool_param (j_compress_ptr cinfo, J_BOOLEAN_PARAM param,
boolean value)
{
switch(param) {
case JBOOLEAN_OPTIMIZE_SCANS:
cinfo->master->optimize_scans = value;
break;
case JBOOLEAN_TRELLIS_QUANT:
cinfo->master->trellis_quant = value;
break;
case JBOOLEAN_TRELLIS_QUANT_DC:
cinfo->master->trellis_quant_dc = value;
break;
case JBOOLEAN_TRELLIS_EOB_OPT:
cinfo->master->trellis_eob_opt = value;
break;
case JBOOLEAN_USE_LAMBDA_WEIGHT_TBL:
cinfo->master->use_lambda_weight_tbl = value;
break;
case JBOOLEAN_USE_SCANS_IN_TRELLIS:
cinfo->master->use_scans_in_trellis = value;
break;
case JBOOLEAN_TRELLIS_Q_OPT:
cinfo->master->trellis_q_opt = value;
break;
case JBOOLEAN_OVERSHOOT_DERINGING:
cinfo->master->overshoot_deringing = value;
break;
default:
ERREXIT(cinfo, JERR_BAD_PARAM);
}
}
GLOBAL(boolean)
jpeg_c_get_bool_param (const j_compress_ptr cinfo, J_BOOLEAN_PARAM param)
{
switch(param) {
case JBOOLEAN_OPTIMIZE_SCANS:
return cinfo->master->optimize_scans;
case JBOOLEAN_TRELLIS_QUANT:
return cinfo->master->trellis_quant;
case JBOOLEAN_TRELLIS_QUANT_DC:
return cinfo->master->trellis_quant_dc;
case JBOOLEAN_TRELLIS_EOB_OPT:
return cinfo->master->trellis_eob_opt;
case JBOOLEAN_USE_LAMBDA_WEIGHT_TBL:
return cinfo->master->use_lambda_weight_tbl;
case JBOOLEAN_USE_SCANS_IN_TRELLIS:
return cinfo->master->use_scans_in_trellis;
case JBOOLEAN_TRELLIS_Q_OPT:
return cinfo->master->trellis_q_opt;
case JBOOLEAN_OVERSHOOT_DERINGING:
return cinfo->master->overshoot_deringing;
default:
ERREXIT(cinfo, JERR_BAD_PARAM);
}
return FALSE;
}
GLOBAL(boolean)
jpeg_c_float_param_supported (const j_compress_ptr cinfo, J_FLOAT_PARAM param)
{
switch (param) {
case JFLOAT_LAMBDA_LOG_SCALE1:
case JFLOAT_LAMBDA_LOG_SCALE2:
case JFLOAT_TRELLIS_DELTA_DC_WEIGHT:
return TRUE;
}
return FALSE;
}
GLOBAL(void)
jpeg_c_set_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param, float value)
{
switch (param) {
case JFLOAT_LAMBDA_LOG_SCALE1:
cinfo->master->lambda_log_scale1 = value;
break;
case JFLOAT_LAMBDA_LOG_SCALE2:
cinfo->master->lambda_log_scale2 = value;
break;
case JFLOAT_TRELLIS_DELTA_DC_WEIGHT:
cinfo->master->trellis_delta_dc_weight = value;
break;
default:
ERREXIT(cinfo, JERR_BAD_PARAM);
}
}
GLOBAL(float)
jpeg_c_get_float_param (const j_compress_ptr cinfo, J_FLOAT_PARAM param)
{
switch (param) {
case JFLOAT_LAMBDA_LOG_SCALE1:
return cinfo->master->lambda_log_scale1;
case JFLOAT_LAMBDA_LOG_SCALE2:
return cinfo->master->lambda_log_scale2;
case JFLOAT_TRELLIS_DELTA_DC_WEIGHT:
return cinfo->master->trellis_delta_dc_weight;
default:
ERREXIT(cinfo, JERR_BAD_PARAM);
}
return -1;
}
GLOBAL(boolean)
jpeg_c_int_param_supported (const j_compress_ptr cinfo, J_INT_PARAM param)
{
switch (param) {
case JINT_COMPRESS_PROFILE:
case JINT_TRELLIS_FREQ_SPLIT:
case JINT_TRELLIS_NUM_LOOPS:
case JINT_BASE_QUANT_TBL_IDX:
case JINT_DC_SCAN_OPT_MODE:
return TRUE;
}
return FALSE;
}
GLOBAL(void)
jpeg_c_set_int_param (j_compress_ptr cinfo, J_INT_PARAM param, int value)
{
switch (param) {
case JINT_COMPRESS_PROFILE:
switch (value) {
case JCP_MAX_COMPRESSION:
case JCP_FASTEST:
cinfo->master->compress_profile = value;
break;
default:
ERREXIT(cinfo, JERR_BAD_PARAM_VALUE);
}
break;
case JINT_TRELLIS_FREQ_SPLIT:
cinfo->master->trellis_freq_split = value;
break;
case JINT_TRELLIS_NUM_LOOPS:
cinfo->master->trellis_num_loops = value;
break;
case JINT_BASE_QUANT_TBL_IDX:
if (value >= 0 && value <= 8)
cinfo->master->quant_tbl_master_idx = value;
break;
case JINT_DC_SCAN_OPT_MODE:
cinfo->master->dc_scan_opt_mode = value;
break;
default:
ERREXIT(cinfo, JERR_BAD_PARAM);
}
}
GLOBAL(int)
jpeg_c_get_int_param (const j_compress_ptr cinfo, J_INT_PARAM param)
{
switch (param) {
case JINT_COMPRESS_PROFILE:
return cinfo->master->compress_profile;
case JINT_TRELLIS_FREQ_SPLIT:
return cinfo->master->trellis_freq_split;
case JINT_TRELLIS_NUM_LOOPS:
return cinfo->master->trellis_num_loops;
case JINT_BASE_QUANT_TBL_IDX:
return cinfo->master->quant_tbl_master_idx;
case JINT_DC_SCAN_OPT_MODE:
return cinfo->master->dc_scan_opt_mode;
default:
ERREXIT(cinfo, JERR_BAD_PARAM);
}
return -1;
}

View File

@@ -5,9 +5,8 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains declarations for Huffman entropy encoding routines
* that are shared between the sequential encoder (jchuff.c) and the
@@ -42,8 +41,3 @@ EXTERN(void) jpeg_make_c_derived_tbl
/* Generate an optimal table definition given the specified counts */
EXTERN(void) jpeg_gen_optimal_table
(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[]);
EXTERN(void) quantize_trellis
(j_compress_ptr cinfo, c_derived_tbl *dctbl, c_derived_tbl *actbl, JBLOCKROW coef_blocks, JBLOCKROW src, JDIMENSION num_blocks,
JQUANT_TBL * qtbl, double *norm_src, double *norm_coef, JCOEF *last_dc_val,
JBLOCKROW coef_blocks_above, JBLOCKROW src_above);

View File

@@ -3,9 +3,8 @@
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains initialization logic for the JPEG compressor.
* This routine is in charge of selecting the modules to be executed and
@@ -62,8 +61,7 @@ jinit_compress_master (j_compress_ptr cinfo)
/* Need a full-image coefficient buffer in any multi-pass mode. */
jinit_c_coef_controller(cinfo,
(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding ||
cinfo->master->optimize_scans || cinfo->master->trellis_quant));
(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
jinit_marker_writer(cinfo);

View File

@@ -184,72 +184,6 @@ emit_dqt (j_compress_ptr cinfo, int index)
return prec;
}
LOCAL(int)
emit_multi_dqt (j_compress_ptr cinfo)
/* Emits a DQT marker containing all quantization tables */
/* Returns number of emitted 16-bit tables, or -1 for failed for baseline checking. */
{
int prec[MAX_COMPONENTS];
int seen[MAX_COMPONENTS] = { 0 };
int fin_prec = 0;
int ci;
int size = 0;
if (cinfo->master->compress_profile == JCP_FASTEST)
return -1;
for (ci = 0; ci < cinfo->num_components; ci++) {
int tbl_num = cinfo->comp_info[ci].quant_tbl_no;
int i;
JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[tbl_num];
if (qtbl == NULL || qtbl->sent_table == TRUE)
return -1;
prec[ci] = 0;
for (i = 0; i < DCTSIZE2; i++)
prec[ci] = !!(prec[ci] + (qtbl->quantval[i] > 255));
fin_prec += prec[ci];
}
emit_marker(cinfo, M_DQT);
for (ci = 0; ci < cinfo->num_components; ci++) {
int tbl_num = cinfo->comp_info[ci].quant_tbl_no;
if (!seen[tbl_num]) {
size += DCTSIZE2 * (prec[ci] + 1) + 1;
seen[tbl_num] = 1;
}
}
size += 2;
emit_2bytes(cinfo, size);
for (ci = 0; ci < cinfo->num_components; ci++) {
int tbl_num = cinfo->comp_info[ci].quant_tbl_no;
int i;
JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[tbl_num];
if (qtbl->sent_table == TRUE)
continue;
emit_byte(cinfo, tbl_num + (prec[ci] << 4));
for (i = 0; i < DCTSIZE2; i++) {
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
if (prec[ci])
emit_byte(cinfo, (int) (qval >> 8));
emit_byte(cinfo, (int) (qval & 0xFF));
}
qtbl->sent_table = TRUE;
}
return fin_prec;
}
LOCAL(void)
emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
@@ -288,115 +222,6 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
}
}
LOCAL(boolean)
emit_multi_dht (j_compress_ptr cinfo)
/* Emit all DHT markers */
/* Returns FALSE on failure, TRUE otherwise. */
{
int i, j;
int length = 2;
int dclens[NUM_HUFF_TBLS] = { 0 };
int aclens[NUM_HUFF_TBLS] = { 0 };
JHUFF_TBL *dcseen[NUM_HUFF_TBLS] = { NULL };
JHUFF_TBL *acseen[NUM_HUFF_TBLS] = { NULL };
if (cinfo->master->compress_profile == JCP_FASTEST)
return 0;
/* Calclate the total length. */
for (i = 0; i < cinfo->comps_in_scan; i++) {
jpeg_component_info *compptr = cinfo->cur_comp_info[i];
int dcidx = compptr->dc_tbl_no;
int acidx = compptr->ac_tbl_no;
JHUFF_TBL *dctbl = cinfo->dc_huff_tbl_ptrs[dcidx];
JHUFF_TBL *actbl = cinfo->ac_huff_tbl_ptrs[acidx];
int seen = 0;
/* Handle DC table lenghts */
if (cinfo->Ss == 0 && cinfo->Ah == 0) {
if (dctbl == NULL)
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dcidx);
if (dctbl->sent_table)
continue;
for (j = 0; j < NUM_HUFF_TBLS; j++)
seen += (dctbl == dcseen[j]);
if (seen)
continue;
dcseen[i] = dctbl;
for (j = 1; j <= 16; j++)
dclens[i] += dctbl->bits[j];
length += dclens[i] + 16 + 1;
}
/* Handle AC table lengths */
if (cinfo->Se) {
if (actbl == NULL)
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, acidx + 0x10);
if (actbl->sent_table)
continue;
seen = 0;
for (j = 0; j < NUM_HUFF_TBLS; j++)
seen += (actbl == acseen[j]);
if (seen)
continue;
acseen[i] = actbl;
for (j = 1; j <= 16; j++)
aclens[i] += actbl->bits[j];
length += aclens[i] + 16 + 1;
}
}
/* Make sure we can fit it all into one DHT marker */
if (length > (1 << 16) - 1)
return FALSE;
emit_marker(cinfo, M_DHT);
emit_2bytes(cinfo, length);
for (i = 0; i < cinfo->comps_in_scan; i++) {
jpeg_component_info *compptr = cinfo->cur_comp_info[i];
int dcidx = compptr->dc_tbl_no;
int acidx = compptr->ac_tbl_no;
JHUFF_TBL *dctbl = cinfo->dc_huff_tbl_ptrs[dcidx];
JHUFF_TBL *actbl = cinfo->ac_huff_tbl_ptrs[acidx];
acidx += 0x10;
/* DC */
if (cinfo->Ss == 0 && cinfo->Ah == 0 && !dctbl->sent_table) {
emit_byte(cinfo, dcidx);
for (j = 1; j <= 16; j++)
emit_byte(cinfo, dctbl->bits[j]);
for (j = 0; j < dclens[i]; j++)
emit_byte(cinfo, dctbl->huffval[j]);
dctbl->sent_table = TRUE;
}
if (cinfo->Se && !actbl->sent_table) {
emit_byte(cinfo, acidx);
for (j = 1; j <= 16; j++)
emit_byte(cinfo, actbl->bits[j]);
for (j = 0; j < aclens[i]; j++)
emit_byte(cinfo, actbl->huffval[j]);
actbl->sent_table = TRUE;
}
}
return TRUE;
}
LOCAL(void)
emit_dac (j_compress_ptr cinfo)
@@ -680,14 +505,11 @@ write_frame_header (j_compress_ptr cinfo)
/* Emit DQT for each quantization table.
* Note that emit_dqt() suppresses any duplicate tables.
*/
prec = emit_multi_dqt(cinfo);
if (prec == -1) {
prec = 0;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
prec += emit_dqt(cinfo, compptr->quant_tbl_no);
}
}
/* now prec is nonzero iff there are any 16-bit quant tables. */
/* Check for a non-baseline specification.
@@ -750,7 +572,6 @@ write_scan_header (j_compress_ptr cinfo)
/* Emit Huffman tables.
* Note that emit_dht() suppresses any duplicate tables.
*/
if (!emit_multi_dht(cinfo)) {
for (i = 0; i < cinfo->comps_in_scan; i++) {
compptr = cinfo->cur_comp_info[i];
/* DC needs no table for refinement scan */
@@ -761,7 +582,6 @@ write_scan_header (j_compress_ptr cinfo)
emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
}
}
}
/* Emit DRI if required --- note that DRI value could change for each scan.
* We avoid wasting space with unnecessary DRIs, however.

View File

@@ -6,9 +6,8 @@
* Modified 2003-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2016, D. R. Commander.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains master control logic for the JPEG compressor.
* These routines are concerned with parameter validation, initial setup,
@@ -21,11 +20,41 @@
#include "jpeglib.h"
#include "jpegcomp.h"
#include "jconfigint.h"
#include "jmemsys.h"
#include "jcmaster.h"
/* Private state */
typedef enum {
main_pass, /* input data, also do first output step */
huff_opt_pass, /* Huffman code optimization pass */
output_pass /* data output pass */
} c_pass_type;
typedef struct {
struct jpeg_comp_master pub; /* public fields */
c_pass_type pass_type; /* the type of the current pass */
int pass_number; /* # of passes completed */
int total_passes; /* total # of passes needed */
int scan_number; /* current index in scan_info[] */
/*
* This is here so we can add libjpeg-turbo version/build information to the
* global string table without introducing a new global symbol. Adding this
* information to the global string table allows one to examine a binary
* object and determine which version of libjpeg-turbo it was built from or
* linked against.
*/
const char *jpeg_version;
} my_comp_master;
typedef my_comp_master *my_master_ptr;
/*
* Support routines that do various essential calculations.
*/
@@ -160,14 +189,6 @@ validate_script (j_compress_ptr cinfo)
/* -1 until that coefficient has been seen; then last Al for it */
#endif
if (cinfo->master->optimize_scans) {
cinfo->progressive_mode = TRUE;
/* When we optimize scans, there is redundancy in the scan list
* and this function will fail. Therefore skip all this checking
*/
return;
}
if (cinfo->num_scans <= 0)
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);
@@ -296,27 +317,9 @@ select_scan_parameters (j_compress_ptr cinfo)
int ci;
#ifdef C_MULTISCAN_FILES_SUPPORTED
my_master_ptr master = (my_master_ptr) cinfo->master;
if (master->pass_number < master->pass_number_scan_opt_base) {
cinfo->comps_in_scan = 1;
if (cinfo->master->use_scans_in_trellis) {
cinfo->cur_comp_info[0] =
&cinfo->comp_info[master->pass_number /
(4 * cinfo->master->trellis_num_loops)];
cinfo->Ss = (master->pass_number % 4 < 2) ?
1 : cinfo->master->trellis_freq_split + 1;
cinfo->Se = (master->pass_number % 4 < 2) ?
cinfo->master->trellis_freq_split : DCTSIZE2 - 1;
} else {
cinfo->cur_comp_info[0] =
&cinfo->comp_info[master->pass_number /
(2 * cinfo->master->trellis_num_loops)];
cinfo->Ss = 1;
cinfo->Se = DCTSIZE2-1;
}
}
else if (cinfo->scan_info != NULL) {
if (cinfo->scan_info != NULL) {
/* Prepare for current scan --- the script is already validated */
my_master_ptr master = (my_master_ptr) cinfo->master;
const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
cinfo->comps_in_scan = scanptr->comps_in_scan;
@@ -328,21 +331,6 @@ select_scan_parameters (j_compress_ptr cinfo)
cinfo->Se = scanptr->Se;
cinfo->Ah = scanptr->Ah;
cinfo->Al = scanptr->Al;
if (cinfo->master->optimize_scans) {
/* luma frequency split passes */
if (master->scan_number >= cinfo->master->num_scans_luma_dc +
3 * cinfo->master->Al_max_luma + 2 &&
master->scan_number < cinfo->master->num_scans_luma)
cinfo->Al = master->best_Al_luma;
/* chroma frequency split passes */
if (master->scan_number >= cinfo->master->num_scans_luma +
cinfo->master->num_scans_chroma_dc +
(6 * cinfo->master->Al_max_chroma + 4) &&
master->scan_number < cinfo->num_scans)
cinfo->Al = master->best_Al_chroma;
}
/* save value for later retrieval during printout of scans */
master->actual_Al[master->scan_number] = cinfo->Al;
}
else
#endif
@@ -460,8 +448,6 @@ METHODDEF(void)
prepare_for_pass (j_compress_ptr cinfo)
{
my_master_ptr master = (my_master_ptr) cinfo->master;
cinfo->master->trellis_passes =
master->pass_number < master->pass_number_scan_opt_base;
switch (master->pass_type) {
case main_pass:
@@ -476,12 +462,12 @@ prepare_for_pass (j_compress_ptr cinfo)
(*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
}
(*cinfo->fdct->start_pass) (cinfo);
(*cinfo->entropy->start_pass) (cinfo, (cinfo->optimize_coding || cinfo->master->trellis_quant) && !cinfo->arith_code);
(*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
(*cinfo->coef->start_pass) (cinfo,
(master->total_passes > 1 ?
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
(*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
if (cinfo->optimize_coding || cinfo->master->trellis_quant) {
if (cinfo->optimize_coding) {
/* No immediate data output; postpone writing frame/scan headers */
master->pub.call_pass_startup = FALSE;
} else {
@@ -514,13 +500,6 @@ prepare_for_pass (j_compress_ptr cinfo)
select_scan_parameters(cinfo);
per_scan_setup(cinfo);
}
if (cinfo->master->optimize_scans) {
master->saved_dest = cinfo->dest;
cinfo->dest = NULL;
master->scan_size[master->scan_number] = 0;
jpeg_mem_dest_internal(cinfo, &master->scan_buffer[master->scan_number], &master->scan_size[master->scan_number], JPOOL_IMAGE);
(*cinfo->dest->init_destination)(cinfo);
}
(*cinfo->entropy->start_pass) (cinfo, FALSE);
(*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
/* We emit frame/scan headers now */
@@ -529,24 +508,6 @@ prepare_for_pass (j_compress_ptr cinfo)
(*cinfo->marker->write_scan_header) (cinfo);
master->pub.call_pass_startup = FALSE;
break;
case trellis_pass:
if (master->pass_number %
(cinfo->num_components * (cinfo->master->use_scans_in_trellis ? 4 : 2)) == 1 &&
cinfo->master->trellis_q_opt) {
int i, j;
for (i = 0; i < NUM_QUANT_TBLS; i++) {
for (j = 1; j < DCTSIZE2; j++) {
cinfo->master->norm_src[i][j] = 0.0;
cinfo->master->norm_coef[i][j] = 0.0;
}
}
}
(*cinfo->entropy->start_pass) (cinfo, !cinfo->arith_code);
(*cinfo->coef->start_pass) (cinfo, JBUF_REQUANT);
master->pub.call_pass_startup = FALSE;
break;
default:
ERREXIT(cinfo, JERR_NOT_COMPILED);
}
@@ -581,232 +542,6 @@ pass_startup (j_compress_ptr cinfo)
}
LOCAL(void)
copy_buffer (j_compress_ptr cinfo, int scan_idx)
{
my_master_ptr master = (my_master_ptr) cinfo->master;
unsigned long size = master->scan_size[scan_idx];
unsigned char * src = master->scan_buffer[scan_idx];
int i;
if (cinfo->err->trace_level > 0) {
fprintf(stderr, "SCAN ");
for (i = 0; i < cinfo->scan_info[scan_idx].comps_in_scan; i++)
fprintf(stderr, "%s%d", (i==0)?"":",", cinfo->scan_info[scan_idx].component_index[i]);
fprintf(stderr, ": %d %d", cinfo->scan_info[scan_idx].Ss, cinfo->scan_info[scan_idx].Se);
fprintf(stderr, " %d %d", cinfo->scan_info[scan_idx].Ah, master->actual_Al[scan_idx]);
fprintf(stderr, "\n");
}
while (size >= cinfo->dest->free_in_buffer)
{
MEMCOPY(cinfo->dest->next_output_byte, src, cinfo->dest->free_in_buffer);
src += cinfo->dest->free_in_buffer;
size -= cinfo->dest->free_in_buffer;
cinfo->dest->next_output_byte += cinfo->dest->free_in_buffer;
cinfo->dest->free_in_buffer = 0;
if (!(*cinfo->dest->empty_output_buffer)(cinfo))
ERREXIT(cinfo, JERR_UNSUPPORTED_SUSPEND);
}
MEMCOPY(cinfo->dest->next_output_byte, src, size);
cinfo->dest->next_output_byte += size;
cinfo->dest->free_in_buffer -= size;
}
LOCAL(void)
select_scans (j_compress_ptr cinfo, int next_scan_number)
{
my_master_ptr master = (my_master_ptr) cinfo->master;
int base_scan_idx = 0;
int luma_freq_split_scan_start = cinfo->master->num_scans_luma_dc +
3 * cinfo->master->Al_max_luma + 2;
int chroma_freq_split_scan_start = cinfo->master->num_scans_luma +
cinfo->master->num_scans_chroma_dc +
(6 * cinfo->master->Al_max_chroma + 4);
int passes_per_scan = cinfo->optimize_coding ? 2 : 1;
if (next_scan_number > 1 && next_scan_number <= luma_freq_split_scan_start) {
if ((next_scan_number - 1) % 3 == 2) {
int Al = (next_scan_number - 1) / 3;
int i;
unsigned long cost = 0;
cost += master->scan_size[next_scan_number-2];
cost += master->scan_size[next_scan_number-1];
for (i = 0; i < Al; i++)
cost += master->scan_size[3 + 3*i];
if (Al == 0 || cost < master->best_cost) {
master->best_cost = cost;
master->best_Al_luma = Al;
} else {
master->scan_number = luma_freq_split_scan_start - 1;
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
}
}
} else if (next_scan_number > luma_freq_split_scan_start &&
next_scan_number <= cinfo->master->num_scans_luma) {
if (next_scan_number == luma_freq_split_scan_start + 1) {
master->best_freq_split_idx_luma = 0;
master->best_cost = master->scan_size[next_scan_number-1];
} else if ((next_scan_number - luma_freq_split_scan_start) % 2 == 1) {
int idx = (next_scan_number - luma_freq_split_scan_start) >> 1;
unsigned long cost = 0;
cost += master->scan_size[next_scan_number-2];
cost += master->scan_size[next_scan_number-1];
if (cost < master->best_cost) {
master->best_cost = cost;
master->best_freq_split_idx_luma = idx;
}
/* if after testing first 3, no split is the best, don't search further */
if ((idx == 2 && master->best_freq_split_idx_luma == 0) ||
(idx == 3 && master->best_freq_split_idx_luma != 2) ||
(idx == 4 && master->best_freq_split_idx_luma != 4)) {
master->scan_number = cinfo->master->num_scans_luma - 1;
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
}
}
} else if (cinfo->num_scans > cinfo->master->num_scans_luma) {
if (next_scan_number == cinfo->master->num_scans_luma +
cinfo->master->num_scans_chroma_dc) {
base_scan_idx = cinfo->master->num_scans_luma;
master->interleave_chroma_dc = master->scan_size[base_scan_idx] <= master->scan_size[base_scan_idx+1] + master->scan_size[base_scan_idx+2];
} else if (next_scan_number > cinfo->master->num_scans_luma +
cinfo->master->num_scans_chroma_dc &&
next_scan_number <= chroma_freq_split_scan_start) {
base_scan_idx = cinfo->master->num_scans_luma +
cinfo->master->num_scans_chroma_dc;
if ((next_scan_number - base_scan_idx) % 6 == 4) {
int Al = (next_scan_number - base_scan_idx) / 6;
int i;
unsigned long cost = 0;
cost += master->scan_size[next_scan_number-4];
cost += master->scan_size[next_scan_number-3];
cost += master->scan_size[next_scan_number-2];
cost += master->scan_size[next_scan_number-1];
for (i = 0; i < Al; i++) {
cost += master->scan_size[base_scan_idx + 4 + 6*i];
cost += master->scan_size[base_scan_idx + 5 + 6*i];
}
if (Al == 0 || cost < master->best_cost) {
master->best_cost = cost;
master->best_Al_chroma = Al;
} else {
master->scan_number = chroma_freq_split_scan_start - 1;
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
}
}
} else if (next_scan_number > chroma_freq_split_scan_start && next_scan_number <= cinfo->num_scans) {
if (next_scan_number == chroma_freq_split_scan_start + 2) {
master->best_freq_split_idx_chroma = 0;
master->best_cost = master->scan_size[next_scan_number-2];
master->best_cost += master->scan_size[next_scan_number-1];
} else if ((next_scan_number - chroma_freq_split_scan_start) % 4 == 2) {
int idx = (next_scan_number - chroma_freq_split_scan_start) >> 2;
unsigned long cost = 0;
cost += master->scan_size[next_scan_number-4];
cost += master->scan_size[next_scan_number-3];
cost += master->scan_size[next_scan_number-2];
cost += master->scan_size[next_scan_number-1];
if (cost < master->best_cost) {
master->best_cost = cost;
master->best_freq_split_idx_chroma = idx;
}
/* if after testing first 3, no split is the best, don't search further */
if ((idx == 2 && master->best_freq_split_idx_chroma == 0) ||
(idx == 3 && master->best_freq_split_idx_chroma != 2) ||
(idx == 4 && master->best_freq_split_idx_chroma != 4)) {
master->scan_number = cinfo->num_scans - 1;
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
}
}
}
}
if (master->scan_number == cinfo->num_scans - 1) {
int i, Al;
int min_Al = MIN(master->best_Al_luma, master->best_Al_chroma);
copy_buffer(cinfo, 0);
if (cinfo->num_scans > cinfo->master->num_scans_luma &&
cinfo->master->dc_scan_opt_mode != 0) {
base_scan_idx = cinfo->master->num_scans_luma;
if (master->interleave_chroma_dc && cinfo->master->dc_scan_opt_mode != 1)
copy_buffer(cinfo, base_scan_idx);
else {
copy_buffer(cinfo, base_scan_idx+1);
copy_buffer(cinfo, base_scan_idx+2);
}
}
if (master->best_freq_split_idx_luma == 0)
copy_buffer(cinfo, luma_freq_split_scan_start);
else {
copy_buffer(cinfo, luma_freq_split_scan_start+2*(master->best_freq_split_idx_luma-1)+1);
copy_buffer(cinfo, luma_freq_split_scan_start+2*(master->best_freq_split_idx_luma-1)+2);
}
/* copy the LSB refinements as well */
for (Al = master->best_Al_luma-1; Al >= min_Al; Al--)
copy_buffer(cinfo, 3 + 3*Al);
if (cinfo->num_scans > cinfo->master->num_scans_luma) {
if (master->best_freq_split_idx_chroma == 0) {
copy_buffer(cinfo, chroma_freq_split_scan_start);
copy_buffer(cinfo, chroma_freq_split_scan_start+1);
}
else {
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+2);
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+3);
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+4);
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+5);
}
base_scan_idx = cinfo->master->num_scans_luma +
cinfo->master->num_scans_chroma_dc;
for (Al = master->best_Al_chroma-1; Al >= min_Al; Al--) {
copy_buffer(cinfo, base_scan_idx + 6*Al + 4);
copy_buffer(cinfo, base_scan_idx + 6*Al + 5);
}
}
for (Al = min_Al-1; Al >= 0; Al--) {
copy_buffer(cinfo, 3 + 3*Al);
if (cinfo->num_scans > cinfo->master->num_scans_luma) {
copy_buffer(cinfo, base_scan_idx + 6*Al + 4);
copy_buffer(cinfo, base_scan_idx + 6*Al + 5);
}
}
/* free the memory allocated for buffers */
for (i = 0; i < cinfo->num_scans; i++)
if (master->scan_buffer[i])
free(master->scan_buffer[i]);
}
}
/*
* Finish up at end of pass.
*/
@@ -827,54 +562,20 @@ finish_pass_master (j_compress_ptr cinfo)
/* next pass is either output of scan 0 (after optimization)
* or output of scan 1 (if no optimization).
*/
if (cinfo->master->trellis_quant)
master->pass_type = trellis_pass;
else {
master->pass_type = output_pass;
if (! cinfo->optimize_coding)
master->scan_number++;
}
break;
case huff_opt_pass:
/* next pass is always output of current scan */
master->pass_type = (master->pass_number < master->pass_number_scan_opt_base-1) ? trellis_pass : output_pass;
master->pass_type = output_pass;
break;
case output_pass:
/* next pass is either optimization or output of next scan */
if (cinfo->optimize_coding)
master->pass_type = huff_opt_pass;
if (cinfo->master->optimize_scans) {
(*cinfo->dest->term_destination)(cinfo);
cinfo->dest = master->saved_dest;
select_scans(cinfo, master->scan_number + 1);
}
master->scan_number++;
break;
case trellis_pass:
if (cinfo->optimize_coding)
master->pass_type = huff_opt_pass;
else
master->pass_type = (master->pass_number < master->pass_number_scan_opt_base-1) ? trellis_pass : output_pass;
if ((master->pass_number + 1) %
(cinfo->num_components * (cinfo->master->use_scans_in_trellis ? 4 : 2)) == 0 &&
cinfo->master->trellis_q_opt) {
int i, j;
for (i = 0; i < NUM_QUANT_TBLS; i++) {
for (j = 1; j < DCTSIZE2; j++) {
if (cinfo->master->norm_coef[i][j] != 0.0) {
int q = (int)(cinfo->master->norm_src[i][j] /
cinfo->master->norm_coef[i][j] + 0.5);
if (q > 254) q = 254;
if (q < 1) q = 1;
cinfo->quant_tbl_ptrs[i]->quantval[j] = q;
}
}
}
}
break;
}
master->pass_number++;
@@ -888,13 +589,16 @@ finish_pass_master (j_compress_ptr cinfo)
GLOBAL(void)
jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
{
my_master_ptr master = (my_master_ptr) cinfo->master;
my_master_ptr master;
master = (my_master_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
sizeof(my_comp_master));
cinfo->master = (struct jpeg_comp_master *) master;
master->pub.prepare_for_pass = prepare_for_pass;
master->pub.pass_startup = pass_startup;
master->pub.finish_pass = finish_pass_master;
master->pub.is_last_pass = FALSE;
master->pub.call_pass_startup = FALSE;
/* Validate parameters, determine derived values */
initial_setup(cinfo, transcode_only);
@@ -932,25 +636,4 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
master->total_passes = cinfo->num_scans;
master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
master->pass_number_scan_opt_base = 0;
if (cinfo->master->trellis_quant) {
if (cinfo->optimize_coding)
master->pass_number_scan_opt_base =
((cinfo->master->use_scans_in_trellis) ? 4 : 2) * cinfo->num_components *
cinfo->master->trellis_num_loops;
else
master->pass_number_scan_opt_base =
((cinfo->master->use_scans_in_trellis) ? 2 : 1) * cinfo->num_components *
cinfo->master->trellis_num_loops + 1;
master->total_passes += master->pass_number_scan_opt_base;
}
if (cinfo->master->optimize_scans) {
int i;
master->best_Al_chroma = 0;
for (i = 0; i < cinfo->num_scans; i++)
master->scan_buffer[i] = NULL;
}
}

View File

@@ -1,56 +0,0 @@
/*
* jcmaster.h
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains the master control structures for the JPEG compressor.
*/
/* Private state */
typedef enum {
main_pass, /* input data, also do first output step */
huff_opt_pass, /* Huffman code optimization pass */
output_pass, /* data output pass */
trellis_pass /* trellis quantization pass */
} c_pass_type;
typedef struct {
struct jpeg_comp_master pub; /* public fields */
c_pass_type pass_type; /* the type of the current pass */
int pass_number; /* # of passes completed */
int total_passes; /* total # of passes needed */
int scan_number; /* current index in scan_info[] */
/* fields for scan optimisation */
int pass_number_scan_opt_base; /* pass number where scan optimization begins */
unsigned char * scan_buffer[64]; /* buffer for a given scan */
unsigned long scan_size[64]; /* size for a given scan */
int actual_Al[64]; /* actual value of Al used for a scan */
unsigned long best_cost; /* bit count for best frequency split */
int best_freq_split_idx_luma; /* index for best frequency split (luma) */
int best_freq_split_idx_chroma; /* index for best frequency split (chroma) */
int best_Al_luma; /* best value for Al found in scan search (luma) */
int best_Al_chroma; /* best value for Al found in scan search (luma) */
boolean interleave_chroma_dc; /* indicate whether to interleave chroma DC scans */
struct jpeg_destination_mgr * saved_dest; /* saved value of cinfo->dest */
/*
* This is here so we can add libjpeg-turbo version/build information to the
* global string table without introducing a new global symbol. Adding this
* information to the global string table allows one to examine a binary
* object and determine which version of libjpeg-turbo it was built from or
* linked against.
*/
const char *jpeg_version;
} my_comp_master;
typedef my_comp_master * my_master_ptr;

View File

@@ -71,6 +71,3 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T

View File

@@ -115,7 +115,6 @@ typedef unsigned char boolean;
/* These defines indicate which image (non-JPEG) file formats are allowed. */
#define PNG_SUPPORTED /* PNG image file format */
#define BMP_SUPPORTED /* BMP image file format */
#define GIF_SUPPORTED /* GIF image file format */
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */

483
jcparam.c
View File

@@ -6,9 +6,8 @@
* Modified 2003-2008 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2009-2011, D. R. Commander.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains optional default-setting code for the JPEG compressor.
* Applications do not have to use this file, but those that don't use it
@@ -70,10 +69,7 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
* 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[9][DCTSIZE2] = {
{
/* JPEG Annex K
*/
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,
@@ -82,105 +78,8 @@ static const unsigned int std_luminance_quant_tbl[9][DCTSIZE2] = {
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
},
{
/* flat
*/
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16
},
{
12, 17, 20, 21, 30, 34, 56, 63,
18, 20, 20, 26, 28, 51, 61, 55,
19, 20, 21, 26, 33, 58, 69, 55,
26, 26, 26, 30, 46, 87, 86, 66,
31, 33, 36, 40, 46, 96, 100, 73,
40, 35, 46, 62, 81, 100, 111, 91,
46, 66, 76, 86, 102, 121, 120, 101,
68, 90, 90, 96, 113, 102, 105, 103
},
{
/* From http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
*/
16, 16, 16, 18, 25, 37, 56, 85,
16, 17, 20, 27, 34, 40, 53, 75,
16, 20, 24, 31, 43, 62, 91, 135,
18, 27, 31, 40, 53, 74, 106, 156,
25, 34, 43, 53, 69, 94, 131, 189,
37, 40, 62, 74, 94, 124, 169, 238,
56, 53, 91, 106, 131, 169, 226, 311,
85, 75, 135, 156, 189, 238, 311, 418
},
{
9, 10, 12, 14, 27, 32, 51, 62,
11, 12, 14, 19, 27, 44, 59, 73,
12, 14, 18, 25, 42, 59, 79, 78,
17, 18, 25, 42, 61, 92, 87, 92,
23, 28, 42, 75, 79, 112, 112, 99,
40, 42, 59, 84, 88, 124, 132, 111,
42, 64, 78, 95, 105, 126, 125, 99,
70, 75, 100, 102, 116, 100, 107, 98
},
{
/* Relevance of human vision to JPEG-DCT compression (1992) Klein, Silverstein and Carney.
*/
10, 12, 14, 19, 26, 38, 57, 86,
12, 18, 21, 28, 35, 41, 54, 76,
14, 21, 25, 32, 44, 63, 92, 136,
19, 28, 32, 41, 54, 75, 107, 157,
26, 35, 44, 54, 70, 95, 132, 190,
38, 41, 63, 75, 95, 125, 170, 239,
57, 54, 92, 107, 132, 170, 227, 312,
86, 76, 136, 157, 190, 239, 312, 419
},
{
/* DCTune perceptual optimization of compressed dental X-Rays (1997) Watson, Taylor, Borthwick
*/
7, 8, 10, 14, 23, 44, 95, 241,
8, 8, 11, 15, 25, 47, 102, 255,
10, 11, 13, 19, 31, 58, 127, 255,
14, 15, 19, 27, 44, 83, 181, 255,
23, 25, 31, 44, 72, 136, 255, 255,
44, 47, 58, 83, 136, 255, 255, 255,
95, 102, 127, 181, 255, 255, 255, 255,
241, 255, 255, 255, 255, 255, 255, 255
},
{
/* A visual detection model for DCT coefficient quantization (12/9/93) Ahumada, Watson, Peterson
*/
15, 11, 11, 12, 15, 19, 25, 32,
11, 13, 10, 10, 12, 15, 19, 24,
11, 10, 14, 14, 16, 18, 22, 27,
12, 10, 14, 18, 21, 24, 28, 33,
15, 12, 16, 21, 26, 31, 36, 42,
19, 15, 18, 24, 31, 38, 45, 53,
25, 19, 22, 28, 36, 45, 55, 65,
32, 24, 27, 33, 42, 53, 65, 77
},
{
/* An improved detection model for DCT coefficient quantization (1993) Peterson, Ahumada and Watson
*/
14, 10, 11, 14, 19, 25, 34, 45,
10, 11, 11, 12, 15, 20, 26, 33,
11, 11, 15, 18, 21, 25, 31, 38,
14, 12, 18, 24, 28, 33, 39, 47,
19, 15, 21, 28, 36, 43, 51, 59,
25, 20, 25, 33, 43, 54, 64, 74,
34, 26, 31, 39, 51, 64, 77, 91,
45, 33, 38, 47, 59, 74, 91, 108
}
};
static const unsigned int std_chrominance_quant_tbl[9][DCTSIZE2] = {
{
/* JPEG Annex K
*/
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,
@@ -189,105 +88,9 @@ static const unsigned int std_chrominance_quant_tbl[9][DCTSIZE2] = {
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
},
{
/* flat
*/
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16
},
{
8, 12, 15, 15, 86, 96, 96, 98,
13, 13, 15, 26, 90, 96, 99, 98,
12, 15, 18, 96, 99, 99, 99, 99,
17, 16, 90, 96, 99, 99, 99, 99,
96, 96, 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
},
{
/* From http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
*/
16, 16, 16, 18, 25, 37, 56, 85,
16, 17, 20, 27, 34, 40, 53, 75,
16, 20, 24, 31, 43, 62, 91, 135,
18, 27, 31, 40, 53, 74, 106, 156,
25, 34, 43, 53, 69, 94, 131, 189,
37, 40, 62, 74, 94, 124, 169, 238,
56, 53, 91, 106, 131, 169, 226, 311,
85, 75, 135, 156, 189, 238, 311, 418
},
{
9, 10, 17, 19, 62, 89, 91, 97,
12, 13, 18, 29, 84, 91, 88, 98,
14, 19, 29, 93, 95, 95, 98, 97,
20, 26, 84, 88, 95, 95, 98, 94,
26, 86, 91, 93, 97, 99, 98, 99,
99, 100, 98, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
97, 97, 99, 99, 99, 99, 97, 99
},
{
/* Relevance of human vision to JPEG-DCT compression (1992) Klein, Silverstein and Carney.
* Copied from luma
*/
10, 12, 14, 19, 26, 38, 57, 86,
12, 18, 21, 28, 35, 41, 54, 76,
14, 21, 25, 32, 44, 63, 92, 136,
19, 28, 32, 41, 54, 75, 107, 157,
26, 35, 44, 54, 70, 95, 132, 190,
38, 41, 63, 75, 95, 125, 170, 239,
57, 54, 92, 107, 132, 170, 227, 312,
86, 76, 136, 157, 190, 239, 312, 419
},
{
/* DCTune perceptual optimization of compressed dental X-Rays (1997) Watson, Taylor, Borthwick
* Copied from luma
*/
7, 8, 10, 14, 23, 44, 95, 241,
8, 8, 11, 15, 25, 47, 102, 255,
10, 11, 13, 19, 31, 58, 127, 255,
14, 15, 19, 27, 44, 83, 181, 255,
23, 25, 31, 44, 72, 136, 255, 255,
44, 47, 58, 83, 136, 255, 255, 255,
95, 102, 127, 181, 255, 255, 255, 255,
241, 255, 255, 255, 255, 255, 255, 255
},
{
/* A visual detection model for DCT coefficient quantization (12/9/93) Ahumada, Watson, Peterson
* Copied from luma
*/
15, 11, 11, 12, 15, 19, 25, 32,
11, 13, 10, 10, 12, 15, 19, 24,
11, 10, 14, 14, 16, 18, 22, 27,
12, 10, 14, 18, 21, 24, 28, 33,
15, 12, 16, 21, 26, 31, 36, 42,
19, 15, 18, 24, 31, 38, 45, 53,
25, 19, 22, 28, 36, 45, 55, 65,
32, 24, 27, 33, 42, 53, 65, 77
},
{
/* An improved detection model for DCT coefficient quantization (1993) Peterson, Ahumada and Watson
* Copied from luma
*/
14, 10, 11, 14, 19, 25, 34, 45,
10, 11, 11, 12, 15, 20, 26, 33,
11, 11, 15, 18, 21, 25, 31, 38,
14, 12, 18, 24, 28, 33, 39, 47,
19, 15, 21, 28, 36, 43, 51, 59,
25, 20, 25, 33, 43, 54, 64, 74,
34, 26, 31, 39, 51, 64, 77, 91,
45, 33, 38, 47, 59, 74, 91, 108
}
};
#if JPEG_LIB_VERSION >= 70
GLOBAL(void)
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
@@ -297,9 +100,9 @@ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
*/
{
/* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl[cinfo->master->quant_tbl_master_idx],
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->master->quant_tbl_master_idx],
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
cinfo->q_scale_factor[1], force_baseline);
}
#endif
@@ -315,29 +118,23 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
*/
{
/* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl[cinfo->master->quant_tbl_master_idx],
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
scale_factor, force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl[cinfo->master->quant_tbl_master_idx],
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
scale_factor, force_baseline);
}
GLOBAL(int)
jpeg_quality_scaling (int quality)
{
return jpeg_float_quality_scaling(quality);
}
GLOBAL(float)
jpeg_float_quality_scaling(float quality)
/* Convert a user-specified quality rating to a percentage scaling factor
* for an underlying quantization table, using our recommended scaling curve.
* The input 'quality' factor should be 0 (terrible) to 100 (very good).
*/
{
/* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */
if (quality <= 0.f) quality = 1.f;
if (quality > 100.f) quality = 100.f;
if (quality <= 0) quality = 1;
if (quality > 100) quality = 100;
/* The basic table is used as-is (scaling 100) for a quality of 50.
* Qualities 50..100 are converted to scaling percentage 200 - 2*Q;
@@ -345,10 +142,10 @@ jpeg_float_quality_scaling(float quality)
* to make all the table entries 1 (hence, minimum quantization loss).
* Qualities 1..50 are converted to scaling percentage 5000/Q.
*/
if (quality < 50.f)
quality = 5000.f / quality;
if (quality < 50)
quality = 5000 / quality;
else
quality = 200.f - quality*2.f;
quality = 200 - quality*2;
return quality;
}
@@ -427,18 +224,8 @@ jpeg_set_defaults (j_compress_ptr cinfo)
/* Use Huffman coding, not arithmetic coding, by default */
cinfo->arith_code = FALSE;
#ifdef ENTROPY_OPT_SUPPORTED
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION)
/* By default, do extra passes to optimize entropy coding */
cinfo->optimize_coding = TRUE;
else
/* By default, don't do extra passes to optimize entropy coding */
cinfo->optimize_coding = FALSE;
#else
/* By default, don't do extra passes to optimize entropy coding */
cinfo->optimize_coding = FALSE;
#endif
/* The standard Huffman tables are only valid for 8-bit data precision.
* If the precision is higher, force optimization on so that usable
* tables will be computed. This test can be removed if default tables
@@ -455,9 +242,6 @@ jpeg_set_defaults (j_compress_ptr cinfo)
cinfo->do_fancy_downsampling = TRUE;
#endif
cinfo->master->overshoot_deringing =
cinfo->master->compress_profile == JCP_MAX_COMPRESSION;
/* No input smoothing */
cinfo->smoothing_factor = 0;
@@ -486,31 +270,6 @@ jpeg_set_defaults (j_compress_ptr cinfo)
/* Choose JPEG colorspace based on input space, set defaults accordingly */
jpeg_default_colorspace(cinfo);
cinfo->master->dc_scan_opt_mode = 1;
#ifdef C_PROGRESSIVE_SUPPORTED
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
cinfo->master->optimize_scans = TRUE;
jpeg_simple_progression(cinfo);
} else
cinfo->master->optimize_scans = FALSE;
#endif
cinfo->master->trellis_quant =
cinfo->master->compress_profile == JCP_MAX_COMPRESSION;
cinfo->master->lambda_log_scale1 = 14.75;
cinfo->master->lambda_log_scale2 = 16.5;
cinfo->master->quant_tbl_master_idx =
cinfo->master->compress_profile == JCP_MAX_COMPRESSION ? 3 : 0;
cinfo->master->use_lambda_weight_tbl = TRUE;
cinfo->master->use_scans_in_trellis = FALSE;
cinfo->master->trellis_freq_split = 8;
cinfo->master->trellis_num_loops = 1;
cinfo->master->trellis_q_opt = FALSE;
cinfo->master->trellis_quant_dc = TRUE;
cinfo->master->trellis_delta_dc_weight = 0.0;
}
@@ -659,22 +418,6 @@ fill_a_scan (jpeg_scan_info *scanptr, int ci,
return scanptr;
}
LOCAL(jpeg_scan_info *)
fill_a_scan_pair (jpeg_scan_info * scanptr, int ci,
int Ss, int Se, int Ah, int Al)
/* Support routine: generate one scan for pair of components */
{
scanptr->comps_in_scan = 2;
scanptr->component_index[0] = ci;
scanptr->component_index[1] = ci + 1;
scanptr->Ss = Ss;
scanptr->Se = Se;
scanptr->Ah = Ah;
scanptr->Al = Al;
scanptr++;
return scanptr;
}
LOCAL(jpeg_scan_info *)
fill_scans (jpeg_scan_info *scanptr, int ncomps,
int Ss, int Se, int Ah, int Al)
@@ -717,132 +460,6 @@ fill_dc_scans (jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
}
/*
* List of scans to be tested
* cinfo->num_components and cinfo->jpeg_color_space must be correct.
*/
LOCAL(boolean)
jpeg_search_progression (j_compress_ptr cinfo)
{
int ncomps = cinfo->num_components;
int nscans;
jpeg_scan_info * scanptr;
int Al;
int frequency_split[] = { 2, 8, 5, 12, 18 };
int i;
/* Safety check to ensure start_compress not called yet. */
if (cinfo->global_state != CSTATE_START)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Figure space needed for script. Calculation must match code below! */
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
/* Custom script for YCbCr color images. */
nscans = 64;
} else if (ncomps == 1) {
nscans = 23;
} else {
cinfo->master->num_scans_luma = 0;
return FALSE;
}
/* Allocate space for script.
* We need to put it in the permanent pool in case the application performs
* multiple compressions without changing the settings. To avoid a memory
* leak if jpeg_simple_progression is called repeatedly for the same JPEG
* object, we try to re-use previously allocated space, and we allocate
* enough space to handle YCbCr even if initially asked for grayscale.
*/
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
cinfo->script_space_size = MAX(nscans, 64);
cinfo->script_space = (jpeg_scan_info *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
cinfo->script_space_size * sizeof(jpeg_scan_info));
}
scanptr = cinfo->script_space;
cinfo->scan_info = scanptr;
cinfo->num_scans = nscans;
cinfo->master->Al_max_luma = 3;
cinfo->master->num_scans_luma_dc = 1;
cinfo->master->num_frequency_splits = 5;
cinfo->master->num_scans_luma =
cinfo->master->num_scans_luma_dc + (3 * cinfo->master->Al_max_luma + 2) +
(2 * cinfo->master->num_frequency_splits + 1);
/* 23 scans for luma */
/* 1 scan for DC */
/* 11 scans to determine successive approximation */
/* 11 scans to determine frequency approximation */
/* after 12 scans need to update following 11 */
/* after 23 scans need to determine which to keep */
/* last 4 done conditionally */
/* luma DC by itself */
if (cinfo->master->dc_scan_opt_mode == 0)
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
else
scanptr = fill_dc_scans(scanptr, 1, 0, 0);
scanptr = fill_a_scan(scanptr, 0, 1, 8, 0, 0);
scanptr = fill_a_scan(scanptr, 0, 9, 63, 0, 0);
for (Al = 0; Al < cinfo->master->Al_max_luma; Al++) {
scanptr = fill_a_scan(scanptr, 0, 1, 63, Al+1, Al);
scanptr = fill_a_scan(scanptr, 0, 1, 8, 0, Al+1);
scanptr = fill_a_scan(scanptr, 0, 9, 63, 0, Al+1);
}
scanptr = fill_a_scan(scanptr, 0, 1, 63, 0, 0);
for (i = 0; i < cinfo->master->num_frequency_splits; i++) {
scanptr = fill_a_scan(scanptr, 0, 1, frequency_split[i], 0, 0);
scanptr = fill_a_scan(scanptr, 0, frequency_split[i]+1, 63, 0, 0);
}
if (ncomps == 1) {
cinfo->master->Al_max_chroma = 0;
cinfo->master->num_scans_chroma_dc = 0;
} else {
cinfo->master->Al_max_chroma = 2;
cinfo->master->num_scans_chroma_dc = 3;
/* 41 scans for chroma */
/* chroma DC combined */
scanptr = fill_a_scan_pair(scanptr, 1, 0, 0, 0, 0);
/* chroma DC separate */
scanptr = fill_a_scan(scanptr, 1, 0, 0, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 0, 0, 0, 0);
scanptr = fill_a_scan(scanptr, 1, 1, 8, 0, 0);
scanptr = fill_a_scan(scanptr, 1, 9, 63, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 1, 8, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, 0);
for (Al = 0; Al < cinfo->master->Al_max_chroma; Al++) {
scanptr = fill_a_scan(scanptr, 1, 1, 63, Al+1, Al);
scanptr = fill_a_scan(scanptr, 2, 1, 63, Al+1, Al);
scanptr = fill_a_scan(scanptr, 1, 1, 8, 0, Al+1);
scanptr = fill_a_scan(scanptr, 1, 9, 63, 0, Al+1);
scanptr = fill_a_scan(scanptr, 2, 1, 8, 0, Al+1);
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, Al+1);
}
scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 0);
for (i = 0; i < cinfo->master->num_frequency_splits; i++) {
scanptr = fill_a_scan(scanptr, 1, 1, frequency_split[i], 0, 0);
scanptr = fill_a_scan(scanptr, 1, frequency_split[i]+1, 63, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 1, frequency_split[i], 0, 0);
scanptr = fill_a_scan(scanptr, 2, frequency_split[i]+1, 63, 0, 0);
}
}
return TRUE;
}
/*
* Create a recommended progressive-JPEG script.
* cinfo->num_components and cinfo->jpeg_color_space must be correct.
@@ -851,48 +468,25 @@ jpeg_search_progression (j_compress_ptr cinfo)
GLOBAL(void)
jpeg_simple_progression (j_compress_ptr cinfo)
{
int ncomps;
int ncomps = cinfo->num_components;
int nscans;
jpeg_scan_info *scanptr;
if (cinfo->master->optimize_scans) {
if (jpeg_search_progression(cinfo) == TRUE)
return;
}
/* Safety check to ensure start_compress not called yet. */
if (cinfo->global_state != CSTATE_START)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Figure space needed for script. Calculation must match code below! */
ncomps = cinfo->num_components;
/* Figure space needed for script. Calculation must match code below! */
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
/* Custom script for YCbCr color images. */
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
if (cinfo->master->dc_scan_opt_mode == 0) {
nscans = 9; /* 1 DC scan for all components */
} else if (cinfo->master->dc_scan_opt_mode == 1) {
nscans = 11; /* 1 DC scan for each component */
} else {
nscans = 10; /* 1 DC scan for luminance and 1 DC scan for chroma */
}
} else {
nscans = 10; /* 2 DC scans and 8 AC scans */
}
nscans = 10;
} else {
/* All-purpose script for other color spaces. */
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
if (ncomps > MAX_COMPS_IN_SCAN)
nscans = 5 * ncomps; /* 2 DC + 4 AC scans per component */
else
nscans = 1 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
} else {
if (ncomps > MAX_COMPS_IN_SCAN)
nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */
else
nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
}
}
/* Allocate space for script.
* We need to put it in the permanent pool in case the application performs
@@ -913,36 +507,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
/* Custom script for YCbCr color images. */
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
/* scan defined in jpeg_scan_rgb.txt in jpgcrush */
/* Initial DC scan */
if (cinfo->master->dc_scan_opt_mode == 0) {
/* 1 DC scan for all components */
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
} else if (cinfo->master->dc_scan_opt_mode == 1) {
/* 1 DC scan for each component */
scanptr = fill_a_scan(scanptr, 0, 0, 0, 0, 0);
scanptr = fill_a_scan(scanptr, 1, 0, 0, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 0, 0, 0, 0);
} else {
/* 1 DC scan for luminance and 1 DC scan for chroma */
scanptr = fill_dc_scans(scanptr, 1, 0, 0);
scanptr = fill_a_scan_pair(scanptr, 1, 0, 0, 0, 0);
}
/* Low frequency AC scans */
scanptr = fill_a_scan(scanptr, 0, 1, 8, 0, 2);
scanptr = fill_a_scan(scanptr, 1, 1, 8, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 1, 8, 0, 0);
/* Complete spectral selection for luma AC */
scanptr = fill_a_scan(scanptr, 0, 9, 63, 0, 2);
/* Finish luma AC successive approximation */
scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
/* Complete spectral selection for chroma AC */
scanptr = fill_a_scan(scanptr, 1, 9, 63, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, 0);
} else {
/* Initial DC scan */
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
/* Initial AC scan: get some luma data out in a hurry */
scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2);
@@ -960,22 +525,9 @@ jpeg_simple_progression (j_compress_ptr cinfo)
scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
/* Luma bottom bit comes last since it's usually largest scan */
scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
}
} else {
/* All-purpose script for other color spaces. */
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
/* scan defined in jpeg_scan_bw.txt in jpgcrush */
/* DC component, no successive approximation */
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
/* Successive approximation first pass */
scanptr = fill_scans(scanptr, ncomps, 1, 8, 0, 2);
scanptr = fill_scans(scanptr, ncomps, 9, 63, 0, 2);
/* Successive approximation second pass */
scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
/* Successive approximation final pass */
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
} else {
/* Successive approximation first pass */
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
@@ -986,6 +538,5 @@ jpeg_simple_progression (j_compress_ptr cinfo)
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
}
}
}
#endif /* C_PROGRESSIVE_SUPPORTED */

View File

@@ -3,11 +3,10 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-1997, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* libjpeg-turbo Modifications:
* Copyright (C) 2015, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains Huffman entropy encoding routines for progressive JPEG.
*
@@ -171,14 +170,6 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257 * sizeof(long));
MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
if (cinfo->master->trellis_passes) {
/* When generating tables for trellis passes, make sure that all */
/* codewords have an assigned length */
int i, j;
for (i = 0; i < 16; i++)
for (j = 0; j < 12; j++)
entropy->count_ptrs[tbl][16 * i + j] = 1;
}
} else {
/* Compute derived values for Huffman table */
/* We may do this more than once for a table, but it's not expensive */
@@ -480,8 +471,6 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
int Se = cinfo->Se;
int Al = cinfo->Al;
JBLOCKROW block;
int deadzone = (1 << Al) - 1;
int sign;
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
@@ -499,24 +488,29 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
r = 0; /* r = run length of zeros */
for (k = cinfo->Ss; k <= Se; k++) {
temp = (*block)[jpeg_natural_order[k]];
if ((unsigned)(temp + deadzone) <= 2*deadzone) {
if ((temp = (*block)[jpeg_natural_order[k]]) == 0) {
r++;
continue;
}
/* We must apply the point transform by Al. For AC coefficients this
* is an integer division with rounding towards 0. The code is
* is an integer division with rounding towards 0. To do this portably
* in C, we shift after obtaining the absolute value; so the code is
* interwoven with finding the abs value (temp) and output bits (temp2).
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
sign = (temp < 0) ? ~0 : 0;
#else
sign = temp >> (8*sizeof(temp)-1);
#endif
temp += sign;
temp = (temp ^ sign) >> Al;
temp2 = temp ^ sign;
if (temp < 0) {
temp = -temp; /* temp is abs value of input */
temp >>= Al; /* apply the point transform */
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */
temp2 = ~temp;
} else {
temp >>= Al; /* apply the point transform */
temp2 = temp;
}
/* Watch out for case that nonzero coef is zero after point transform */
if (temp == 0) {
r++;
continue;
}
/* Emit any pending EOBRUN */
if (entropy->EOBRUN > 0)

View File

@@ -77,7 +77,7 @@ int main(void)
jerr.pub.error_exit = my_error_exit;
jerr.pub.output_message = my_output_message;
if(setjmp(jerr.jb)) {
if (setjmp(jerr.jb)) {
/* this will execute if libjpeg has an error */
jcs_valid = 0;
goto done;
@@ -104,7 +104,7 @@ int main(void)
printf(" Not present at compile time\n");
#endif
if(setjmp(jerr.jb)) {
if (setjmp(jerr.jb)) {
/* this will execute if libjpeg has an error */
jcs_alpha_valid = 0;
goto done2;

View File

@@ -6,9 +6,8 @@
* Modified 2000-2009 by Guido Vollbeding.
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains library routines for transcoding compression,
* that is, writing raw DCT coefficient arrays to an output JPEG file.
@@ -42,10 +41,6 @@ LOCAL(void) transencode_coef_controller
GLOBAL(void)
jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
{
/* setting up scan optimisation pattern failed, disable scan optimisation */
if (cinfo->master->num_scans_luma == 0)
cinfo->master->optimize_scans = FALSE;
if (cinfo->global_state != CSTATE_START)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Mark all tables to be written */
@@ -69,7 +64,7 @@ jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
*/
GLOBAL(void)
jpeg_copy_critical_parameters (const j_decompress_ptr srcinfo,
jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
j_compress_ptr dstinfo)
{
JQUANT_TBL **qtblptr;
@@ -93,8 +88,6 @@ jpeg_copy_critical_parameters (const j_decompress_ptr srcinfo,
#endif
/* Initialize all parameters to default values */
jpeg_set_defaults(dstinfo);
dstinfo->master->trellis_quant = FALSE;
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
* Fix it to get the right header markers for the image colorspace.
*/

View File

@@ -343,7 +343,7 @@ jpeg_consume_input (j_decompress_ptr cinfo)
*/
GLOBAL(boolean)
jpeg_input_complete (const j_decompress_ptr cinfo)
jpeg_input_complete (j_decompress_ptr cinfo)
{
/* Check for valid jpeg object */
if (cinfo->global_state < DSTATE_START ||
@@ -358,7 +358,7 @@ jpeg_input_complete (const j_decompress_ptr cinfo)
*/
GLOBAL(boolean)
jpeg_has_multiple_scans (const j_decompress_ptr cinfo)
jpeg_has_multiple_scans (j_decompress_ptr cinfo)
{
/* Only valid after jpeg_read_header completes */
if (cinfo->global_state < DSTATE_READY ||

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2015-2016, D. R. Commander.
* Copyright (C) 2010, 2015-2017, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -190,7 +190,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
* single-pass decompression case, allowing us to use the same MCU column
* width for all of the components.
*/
align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor;
if (cinfo->comps_in_scan == 1 && cinfo->num_components == 1)
align = cinfo->_min_DCT_scaled_size;
else
align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor;
/* Adjust xoffset to the nearest iMCU boundary <= the requested value */
input_xoffset = *xoffset;
@@ -215,6 +218,9 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
int hsf = (cinfo->comps_in_scan == 1 && cinfo->num_components == 1) ?
1 : compptr->h_samp_factor;
/* Set downsampled_width to the new output width. */
orig_downsampled_width = compptr->downsampled_width;
compptr->downsampled_width =
@@ -228,11 +234,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
* values will be used in multi-scan decompressions.
*/
cinfo->master->first_MCU_col[ci] =
(JDIMENSION) (long) (*xoffset * compptr->h_samp_factor) /
(long) align;
(JDIMENSION) (long) (*xoffset * hsf) / (long) align;
cinfo->master->last_MCU_col[ci] =
(JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) *
compptr->h_samp_factor),
hsf),
(long) align) - 1;
}
@@ -293,6 +298,14 @@ noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
}
/* Dummy quantize function used by jpeg_skip_scanlines() */
LOCAL(void)
noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows)
{
}
/*
* In some cases, it is best to call jpeg_read_scanlines() and discard the
* output, rather than skipping the scanlines, because this allows us to
@@ -308,14 +321,22 @@ read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION input_row, JSAMPARRAY output_buf,
int num_rows);
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows) = NULL;
color_convert = cinfo->cconvert->color_convert;
cinfo->cconvert->color_convert = noop_convert;
if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
color_quantize = cinfo->cquantize->color_quantize;
cinfo->cquantize->color_quantize = noop_quantize;
}
for (n = 0; n < num_lines; n++)
jpeg_read_scanlines(cinfo, NULL, 1);
cinfo->cconvert->color_convert = color_convert;
if (color_quantize)
cinfo->cquantize->color_quantize = color_quantize;
}
@@ -370,6 +391,8 @@ jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
/* Do not skip past the bottom of the image. */
if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
cinfo->output_scanline = cinfo->output_height;
(*cinfo->inputctl->finish_input_pass) (cinfo);
cinfo->inputctl->eoi_reached = TRUE;
return cinfo->output_height - cinfo->output_scanline;
}

View File

@@ -130,7 +130,7 @@ term_mem_destination (j_compress_ptr cinfo)
{
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
if(dest->alloc) *dest->outbuffer = dest->buffer;
if (dest->alloc) *dest->outbuffer = dest->buffer;
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
}

View File

@@ -208,9 +208,9 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
{
my_dest_ptr dest;
/* The destination object is made permanent so that multiple JPEG images
* can be written to the same file without re-executing jpeg_stdio_dest.
*/
/* The destination object is made permanent so that multiple JPEG images
* can be written to the same file without re-executing jpeg_stdio_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,
@@ -249,8 +249,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
*/
GLOBAL(void)
jpeg_mem_dest_internal (j_compress_ptr cinfo,
unsigned char **outbuffer, unsigned long *outsize, int pool_id)
jpeg_mem_dest (j_compress_ptr cinfo,
unsigned char **outbuffer, unsigned long *outsize)
{
my_mem_dest_ptr dest;
@@ -262,7 +262,7 @@ jpeg_mem_dest_internal (j_compress_ptr cinfo,
*/
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, pool_id,
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
sizeof(my_mem_destination_mgr));
} else if (cinfo->dest->init_destination != init_mem_destination) {
/* It is unsafe to reuse the existing destination manager unless it was
@@ -290,15 +290,4 @@ jpeg_mem_dest_internal (j_compress_ptr cinfo,
dest->pub.next_output_byte = dest->buffer = *outbuffer;
dest->pub.free_in_buffer = dest->bufsize = *outsize;
}
GLOBAL(void)
jpeg_mem_dest (j_compress_ptr cinfo,
unsigned char **outbuffer, unsigned long *outsize)
{
/* The destination object is made permanent so that multiple JPEG images
* can be written to the same file without re-executing jpeg_stdio_dest.
*/
jpeg_mem_dest_internal(cinfo, outbuffer, outsize, JPOOL_PERMANENT);
}
#endif

View File

@@ -616,7 +616,7 @@ static const JLONG dither_matrix[4] = {
static INLINE boolean is_big_endian(void)
{
int test_value = 1;
if(*(char *)&test_value != 1)
if (*(char *)&test_value != 1)
return TRUE;
return FALSE;
}

View File

@@ -503,7 +503,7 @@ static const JLONG dither_matrix[4] = {
static INLINE boolean is_big_endian(void)
{
int test_value = 1;
if(*(char *)&test_value != 1)
if (*(char *)&test_value != 1)
return TRUE;
return FALSE;
}

View File

@@ -208,10 +208,6 @@ JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
#endif
#endif
JMESSAGE(JERR_BAD_PARAM, "Bogus parameter")
JMESSAGE(JERR_BAD_PARAM_VALUE, "Bogus parameter value")
JMESSAGE(JERR_UNSUPPORTED_SUSPEND, "I/O suspension not supported in scan optimization")
#ifdef JMAKE_ENUM_LIST

View File

@@ -7,8 +7,6 @@
* libjpeg-turbo Modifications:
* Copyright (C) 2015-2016, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -25,8 +23,7 @@ typedef enum { /* Operating modes for buffer controllers */
/* Remaining modes require a full-image buffer to have been created */
JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
JBUF_SAVE_AND_PASS, /* Run both subobjects, save output */
JBUF_REQUANT /* Requantize */
JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
} J_BUF_MODE;
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
@@ -70,67 +67,8 @@ struct jpeg_comp_master {
/* State variables made visible to other modules */
boolean call_pass_startup; /* True if pass_startup must be called */
boolean is_last_pass; /* True during last pass */
/* Extension parameters */
boolean optimize_scans; /* TRUE=optimize progressive coding scans */
boolean trellis_quant; /* TRUE=use trellis quantization */
boolean trellis_quant_dc; /* TRUE=use trellis quant for DC coefficient */
boolean trellis_eob_opt; /* TRUE=optimize for sequences of EOB */
boolean use_lambda_weight_tbl; /* TRUE=use lambda weighting table */
boolean use_scans_in_trellis; /* TRUE=use scans in trellis optimization */
boolean trellis_passes; /* TRUE=currently doing trellis-related passes [not exposed] */
boolean trellis_q_opt; /* TRUE=optimize quant table in trellis loop */
boolean overshoot_deringing; /* TRUE=preprocess input to reduce ringing of edges on white background */
double norm_src[NUM_QUANT_TBLS][DCTSIZE2];
double norm_coef[NUM_QUANT_TBLS][DCTSIZE2];
int compress_profile; /* compression profile */
int dc_scan_opt_mode; /* DC scan optimization mode */
int quant_tbl_master_idx; /* Quantization table master index */
int trellis_freq_split; /* splitting point for frequency in trellis quantization */
int trellis_num_loops; /* number of trellis loops */
int num_scans_luma; /* # of entries in scan_info array pertaining to luma (used when optimize_scans is TRUE */
int num_scans_luma_dc;
int num_scans_chroma_dc;
int num_frequency_splits;
int Al_max_luma; /* maximum value of Al tested when optimizing scans (luma) */
int Al_max_chroma; /* maximum value of Al tested when optimizing scans (chroma) */
float lambda_log_scale1;
float lambda_log_scale2;
float trellis_delta_dc_weight;
};
#ifdef C_ARITH_CODING_SUPPORTED
/* The following two definitions specify the allocation chunk size
* for the statistics area.
* According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
* 49 statistics bins for DC, and 245 statistics bins for AC coding.
*
* We use a compact representation with 1 byte per statistics bin,
* thus the numbers directly represent byte sizes.
* This 1 byte per statistics bin contains the meaning of the MPS
* (more probable symbol) in the highest bit (mask 0x80), and the
* index into the probability estimation state machine table
* in the lower bits (mask 0x7F).
*/
#define DC_STAT_BINS 64
#define AC_STAT_BINS 256
typedef struct {
float rate_dc[DC_STAT_BINS][2];
float rate_ac[AC_STAT_BINS][2];
int arith_dc_L;
int arith_dc_U;
int arith_ac_K;
} arith_rates;
#endif
/* Main buffer control (downsampled-data buffer) */
struct jpeg_c_main_controller {
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
@@ -179,7 +117,7 @@ struct jpeg_forward_dct {
void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks, JBLOCKROW dst);
JDIMENSION num_blocks);
};
/* Entropy encoding */
@@ -402,12 +340,6 @@ EXTERN(void) jinit_merged_upsampler (j_decompress_ptr cinfo);
/* Memory manager initialization */
EXTERN(void) jinit_memory_mgr (j_common_ptr cinfo);
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
EXTERN(void)
jpeg_mem_dest_internal (j_compress_ptr cinfo,
unsigned char **outbuffer, unsigned long *outsize, int pool_id);
#endif
/* Utility routines in jutils.c */
EXTERN(long) jdiv_round_up (long a, long b);
EXTERN(long) jround_up (long a, long b);
@@ -417,16 +349,6 @@ EXTERN(void) jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
EXTERN(void) jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
JDIMENSION num_blocks);
EXTERN(void) jzero_far (void *target, size_t bytestozero);
#ifdef C_ARITH_CODING_SUPPORTED
EXTERN(void) jget_arith_rates (j_compress_ptr cinfo, int dc_tbl_no, int ac_tbl_no, arith_rates *r);
EXTERN(void) quantize_trellis_arith
(j_compress_ptr cinfo, arith_rates *r, JBLOCKROW coef_blocks, JBLOCKROW src, JDIMENSION num_blocks,
JQUANT_TBL * qtbl, double *norm_src, double *norm_coef, JCOEF *last_dc_val,
JBLOCKROW coef_blocks_above, JBLOCKROW src_above);
#endif
/* Constant tables in jutils.c */
#if 0 /* This table is not actually needed in v6a */
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */

View File

@@ -7,8 +7,6 @@
* libjpeg-turbo Modifications:
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -267,52 +265,6 @@ typedef enum {
} J_DITHER_MODE;
/* These 32-bit GUIDs and the corresponding jpeg_*_get_*_param()/
* jpeg_*_set_*_param() functions allow for extending the libjpeg API without
* breaking backward ABI compatibility. The actual parameters are stored in
* the opaque jpeg_comp_master and jpeg_decomp_master structs.
*/
/* Boolean extension parameters */
typedef enum {
JBOOLEAN_OPTIMIZE_SCANS = 0x680C061E, /* TRUE=optimize progressive coding scans */
JBOOLEAN_TRELLIS_QUANT = 0xC5122033, /* TRUE=use trellis quantization */
JBOOLEAN_TRELLIS_QUANT_DC = 0x339D4C0C, /* TRUE=use trellis quant for DC coefficient */
JBOOLEAN_TRELLIS_EOB_OPT = 0xD7F73780, /* TRUE=optimize for sequences of EOB */
JBOOLEAN_USE_LAMBDA_WEIGHT_TBL = 0x339DB65F, /* TRUE=use lambda weighting table */
JBOOLEAN_USE_SCANS_IN_TRELLIS = 0xFD841435, /* TRUE=use scans in trellis optimization */
JBOOLEAN_TRELLIS_Q_OPT = 0xE12AE269, /* TRUE=optimize quant table in trellis loop */
JBOOLEAN_OVERSHOOT_DERINGING = 0x3F4BBBF9 /* TRUE=preprocess input to reduce ringing of edges on white background */
} J_BOOLEAN_PARAM;
/* Floating point parameters */
typedef enum {
JFLOAT_LAMBDA_LOG_SCALE1 = 0x5B61A599,
JFLOAT_LAMBDA_LOG_SCALE2 = 0xB9BBAE03,
JFLOAT_TRELLIS_DELTA_DC_WEIGHT = 0x13775453
} J_FLOAT_PARAM;
/* Integer parameters */
typedef enum {
JINT_COMPRESS_PROFILE = 0xE9918625, /* compression profile */
JINT_TRELLIS_FREQ_SPLIT = 0x6FAFF127, /* splitting point for frequency in trellis quantization */
JINT_TRELLIS_NUM_LOOPS = 0xB63EBF39, /* number of trellis loops */
JINT_BASE_QUANT_TBL_IDX = 0x44492AB1, /* base quantization table index */
JINT_DC_SCAN_OPT_MODE = 0x0BE7AD3C /* DC scan optimization mode */
} J_INT_PARAM;
/* Values for the JINT_COMPRESS_PROFILE parameter (32-bit GUIDs) */
enum {
JCP_MAX_COMPRESSION = 0x5D083AAD, /* best compression ratio (progressive, all mozjpeg extensions) */
JCP_FASTEST = 0x2AEA5CB4 /* libjpeg[-turbo] defaults (baseline, no mozjpeg extensions) */
};
/* Common fields between JPEG compression and decompression master structs. */
#define jpeg_common_fields \
@@ -991,7 +943,6 @@ EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
int scale_factor, boolean force_baseline);
EXTERN(int) jpeg_quality_scaling (int quality);
EXTERN(float) jpeg_float_quality_scaling (float quality);
EXTERN(void) jpeg_simple_progression (j_compress_ptr cinfo);
EXTERN(void) jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress);
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table (j_common_ptr cinfo);
@@ -1053,10 +1004,10 @@ EXTERN(JDIMENSION) jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
JDIMENSION max_lines);
/* Additional entry points for buffered-image mode. */
EXTERN(boolean) jpeg_has_multiple_scans (const j_decompress_ptr cinfo);
EXTERN(boolean) jpeg_has_multiple_scans (j_decompress_ptr cinfo);
EXTERN(boolean) jpeg_start_output (j_decompress_ptr cinfo, int scan_number);
EXTERN(boolean) jpeg_finish_output (j_decompress_ptr cinfo);
EXTERN(boolean) jpeg_input_complete (const j_decompress_ptr cinfo);
EXTERN(boolean) jpeg_input_complete (j_decompress_ptr cinfo);
EXTERN(void) jpeg_new_colormap (j_decompress_ptr cinfo);
EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
/* Return value is one of: */
@@ -1085,7 +1036,7 @@ EXTERN(void) jpeg_set_marker_processor (j_decompress_ptr cinfo,
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients (j_decompress_ptr cinfo);
EXTERN(void) jpeg_write_coefficients (j_compress_ptr cinfo,
jvirt_barray_ptr *coef_arrays);
EXTERN(void) jpeg_copy_critical_parameters (const j_decompress_ptr srcinfo,
EXTERN(void) jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
j_compress_ptr dstinfo);
/* If you choose to abort compression or decompression before completing
@@ -1106,28 +1057,6 @@ EXTERN(void) jpeg_destroy (j_common_ptr cinfo);
/* Default restart-marker-resync procedure for use by data source modules */
EXTERN(boolean) jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired);
/* Accessor functions for extension parameters */
#define JPEG_C_PARAM_SUPPORTED 1
EXTERN(boolean) jpeg_c_bool_param_supported (const j_compress_ptr cinfo,
J_BOOLEAN_PARAM param);
EXTERN(void) jpeg_c_set_bool_param (j_compress_ptr cinfo,
J_BOOLEAN_PARAM param, boolean value);
EXTERN(boolean) jpeg_c_get_bool_param (const j_compress_ptr cinfo,
J_BOOLEAN_PARAM param);
EXTERN(boolean) jpeg_c_float_param_supported (const j_compress_ptr cinfo,
J_FLOAT_PARAM param);
EXTERN(void) jpeg_c_set_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param,
float value);
EXTERN(float) jpeg_c_get_float_param (const j_compress_ptr cinfo,
J_FLOAT_PARAM param);
EXTERN(boolean) jpeg_c_int_param_supported (const j_compress_ptr cinfo,
J_INT_PARAM param);
EXTERN(void) jpeg_c_set_int_param (j_compress_ptr cinfo, J_INT_PARAM param,
int value);
EXTERN(int) jpeg_c_get_int_param (const j_compress_ptr cinfo, J_INT_PARAM param);
/* These marker codes are exported since applications and data source modules
* are likely to want to use them.

View File

@@ -5,9 +5,8 @@
* Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2014, 2017, D. R. Commander.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains a command-line user interface for JPEG transcoding.
* It is very similar to cjpeg.c, and partly to djpeg.c, but provides
@@ -44,8 +43,6 @@ static const char *progname; /* program name for error messages */
static char *outfilename; /* for -outfile switch */
static JCOPY_OPTION copyoption; /* -copy switch */
static jpeg_transform_info transformoption; /* image transformation options */
boolean memsrc = FALSE; /* for -memsrc switch */
#define INPUT_BUF_SIZE 4096
LOCAL(void)
@@ -64,13 +61,11 @@ usage (void)
fprintf(stderr, " -copy comments Copy only comment markers (default)\n");
fprintf(stderr, " -copy all Copy all extra markers\n");
#ifdef ENTROPY_OPT_SUPPORTED
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression, enabled by default)\n");
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
#endif
#ifdef C_PROGRESSIVE_SUPPORTED
fprintf(stderr, " -progressive Create progressive JPEG file (enabled by default)\n");
fprintf(stderr, " -progressive Create progressive JPEG file\n");
#endif
fprintf(stderr, " -revert Revert to standard defaults (instead of mozjpeg defaults)\n");
fprintf(stderr, " -fastcrush Disable progressive scan optimization\n");
fprintf(stderr, "Switches for modifying the image:\n");
#if TRANSFORMS_SUPPORTED
fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n");
@@ -142,11 +137,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
char *scansarg = NULL; /* saves -scans parm if any */
/* Set up default JPEG parameters. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = cinfo->num_scans == 0 ? FALSE : TRUE;
#else
simple_progressive = FALSE;
#endif
outfilename = NULL;
copyoption = JCOPYOPT_DEFAULT;
transformoption.transform = JXFORM_NONE;
@@ -175,9 +166,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* Use arithmetic coding. */
#ifdef C_ARITH_CODING_SUPPORTED
cinfo->arith_code = TRUE;
/* No table optimization required for AC */
cinfo->optimize_coding = FALSE;
#else
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
progname);
@@ -242,9 +230,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
else
usage();
} else if (keymatch(arg, "fastcrush", 4)) {
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OPTIMIZE_SCANS, FALSE);
} else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) {
/* Force to grayscale. */
#if TRANSFORMS_SUPPORTED
@@ -317,10 +302,6 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* restart_interval will be computed during startup */
}
} else if (keymatch(arg, "revert", 3)) {
/* revert to old JPEG default */
jpeg_c_set_int_param(cinfo, JINT_COMPRESS_PROFILE, JCP_FASTEST);
} else if (keymatch(arg, "rotate", 2)) {
/* Rotate 90, 180, or 270 degrees (measured clockwise). */
if (++argn >= argc) /* advance to next argument */
@@ -404,10 +385,6 @@ main (int argc, char **argv)
* single file pointer for sequential input and output operation.
*/
FILE *fp;
unsigned char *inbuffer = NULL;
unsigned long insize = 0;
unsigned char *outbuffer = NULL;
unsigned long outsize = 0;
/* On Mac, fetch a command line. */
#ifdef USE_CCOMMAND
@@ -477,32 +454,6 @@ main (int argc, char **argv)
#endif
/* Specify data source for decompression */
if (jpeg_c_int_param_supported(&dstinfo, JINT_COMPRESS_PROFILE) &&
jpeg_c_get_int_param(&dstinfo, JINT_COMPRESS_PROFILE)
== JCP_MAX_COMPRESSION)
memsrc = TRUE; /* needed to revert to original */
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
if (memsrc) {
size_t nbytes;
do {
inbuffer = (unsigned char *)realloc(inbuffer, insize + INPUT_BUF_SIZE);
if (inbuffer == NULL) {
fprintf(stderr, "%s: memory allocation failure\n", progname);
exit(EXIT_FAILURE);
}
nbytes = JFREAD(fp, &inbuffer[insize], INPUT_BUF_SIZE);
if (nbytes < INPUT_BUF_SIZE && ferror(fp)) {
if (file_index < argc)
fprintf(stderr, "%s: can't read from %s\n", progname,
argv[file_index]);
else
fprintf(stderr, "%s: can't read from stdin\n", progname);
}
insize += (unsigned long)nbytes;
} while (nbytes == INPUT_BUF_SIZE);
jpeg_mem_src(&srcinfo, inbuffer, insize);
} else
#endif
jpeg_stdio_src(&srcinfo, fp);
/* Enable saving of extra markers that we want to copy */
@@ -565,13 +516,6 @@ main (int argc, char **argv)
file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
/* Specify data destination for compression */
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
if (jpeg_c_int_param_supported(&dstinfo, JINT_COMPRESS_PROFILE) &&
jpeg_c_get_int_param(&dstinfo, JINT_COMPRESS_PROFILE)
== JCP_MAX_COMPRESSION)
jpeg_mem_dest(&dstinfo, &outbuffer, &outsize);
else
#endif
jpeg_stdio_dest(&dstinfo, fp);
/* Start compressor (note no image data is actually written here) */
@@ -589,29 +533,6 @@ main (int argc, char **argv)
/* Finish compression and release memory */
jpeg_finish_compress(&dstinfo);
if (jpeg_c_int_param_supported(&dstinfo, JINT_COMPRESS_PROFILE) &&
jpeg_c_get_int_param(&dstinfo, JINT_COMPRESS_PROFILE)
== JCP_MAX_COMPRESSION) {
size_t nbytes;
unsigned char *buffer = outbuffer;
unsigned long size = outsize;
if (insize < size) {
size = insize;
buffer = inbuffer;
}
nbytes = JFWRITE(fp, buffer, size);
if (nbytes < size && ferror(fp)) {
if (file_index < argc)
fprintf(stderr, "%s: can't write to %s\n", progname,
argv[file_index]);
else
fprintf(stderr, "%s: can't write to stdout\n", progname);
}
}
jpeg_destroy_compress(&dstinfo);
(void) jpeg_finish_decompress(&srcinfo);
jpeg_destroy_decompress(&srcinfo);
@@ -624,9 +545,6 @@ main (int argc, char **argv)
end_progress_monitor((j_common_ptr) &dstinfo);
#endif
free(inbuffer);
free(outbuffer);
/* All done. */
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS);
return 0; /* suppress no-return-value warnings */

172
jpegyuv.c
View File

@@ -1,172 +0,0 @@
/*
* Written by Josh Aas and Tim Terriberry
* Copyright (c) 2013, Mozilla Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the Mozilla Corporation nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Input: JPEG YUV 4:2:0 */
/* Output: YUV 4:2:0 */
/* gcc -std=c99 jpegyuv.c -I/opt/local/include/ -L/opt/local/lib/ -ljpeg -o jpegyuv */
#include <stdio.h>
#include <stdlib.h>
#include "jpeglib.h"
int main(int argc, char *argv[]) {
const char *jpg_path;
const char *yuv_path;
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE *jpg_fd;
int luma_width;
int luma_height;
int chroma_width;
int chroma_height;
int frame_width;
int yuv_size;
JSAMPLE *jpg_buffer;
JSAMPROW yrow_pointer[16];
JSAMPROW cbrow_pointer[8];
JSAMPROW crrow_pointer[8];
JSAMPROW *plane_pointer[3];
unsigned char *yuv_buffer;
int x;
int y;
FILE *yuv_fd;
if (argc != 3) {
fprintf(stderr, "Required arguments:\n");
fprintf(stderr, "1. Path to JPG input file\n");
fprintf(stderr, "2. Path to YUV output file\n");
return 1;
}
/* Will check these for validity when opening via 'fopen'. */
jpg_path = argv[1];
yuv_path = argv[2];
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpg_fd = fopen(jpg_path, "rb");
if (!jpg_fd) {
fprintf(stderr, "Invalid path to JPEG file!\n");
return 1;
}
jpeg_stdio_src(&cinfo, jpg_fd);
jpeg_read_header(&cinfo, TRUE);
cinfo.raw_data_out = TRUE;
cinfo.do_fancy_upsampling = FALSE;
jpeg_start_decompress(&cinfo);
luma_width = cinfo.output_width;
luma_height = cinfo.output_height;
chroma_width = (luma_width + 1) >> 1;
chroma_height = (luma_height + 1) >> 1;
yuv_size = luma_width*luma_height + 2*chroma_width*chroma_height;
yuv_buffer = malloc(yuv_size);
if (!yuv_buffer) {
fclose(jpg_fd);
fprintf(stderr, "Memory allocation failure!\n");
return 1;
}
frame_width = (cinfo.output_width + (16 - 1)) & ~(16 - 1);
jpg_buffer = malloc(frame_width*16 + 2*(frame_width/2)*8);
if (!jpg_buffer) {
fclose(jpg_fd);
free(yuv_buffer);
fprintf(stderr, "Memory allocation failure!\n");
return 1;
}
plane_pointer[0] = yrow_pointer;
plane_pointer[1] = cbrow_pointer;
plane_pointer[2] = crrow_pointer;
for (y = 0; y < 16; y++) {
yrow_pointer[y] = &jpg_buffer[frame_width*y];
}
for (y = 0; y < 8; y++) {
cbrow_pointer[y] = &jpg_buffer[frame_width*16 + (frame_width/2)*y];
crrow_pointer[y] = &jpg_buffer[frame_width*16 + (frame_width/2)*(8 + y)];
}
while (cinfo.output_scanline < cinfo.output_height) {
int luma_scanline;
int chroma_scanline;
luma_scanline = cinfo.output_scanline;
chroma_scanline = (luma_scanline + 1) >> 1;
jpeg_read_raw_data(&cinfo, plane_pointer, 16);
for (y = 0; y < 16 && luma_scanline + y < luma_height; y++) {
for (x = 0; x < luma_width; x++) {
yuv_buffer[luma_width*(luma_scanline + y) + x] = yrow_pointer[y][x];
}
}
for (y = 0; y < 8 && chroma_scanline + y < chroma_height; y++) {
for (x = 0; x < chroma_width; x++) {
yuv_buffer[luma_width*luma_height +
chroma_width*(chroma_scanline + y) + x] = cbrow_pointer[y][x];
yuv_buffer[luma_width*luma_height + chroma_width*chroma_height +
chroma_width*(chroma_scanline + y) + x] = crrow_pointer[y][x];
}
}
}
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(jpg_fd);
free(jpg_buffer);
yuv_fd = fopen(yuv_path, "wb");
if (!yuv_fd) {
fprintf(stderr, "Invalid path to YUV file!");
free(yuv_buffer);
return 1;
}
if (fwrite(yuv_buffer, yuv_size, 1, yuv_fd) != 1) {
fprintf(stderr, "Error writing yuv file\n");
}
fclose(yuv_fd);
free(yuv_buffer);
return 0;
}

View File

@@ -5,9 +5,8 @@
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2012-2017, D. R. Commander.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* For conditions of distribution and use, see the accompanying README file.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains software version identification.
*/
@@ -40,7 +39,6 @@
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
"Copyright (C) 2015-2016 Matthieu Darbois\n" \
"Copyright (C) 2015 Google, Inc.\n" \
"Copyright (C) 2014 Mozilla Corporation\n" \
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
"Copyright (C) 2013 Linaro Limited\n" \
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \

View File

@@ -1,15 +0,0 @@
#!/bin/bash
set -e
if [ $# == 0 ]; then
echo "usage: OUTPUT=<label> $0 *.out"
exit 1
fi
TOTAL=total.out
if [ -n "$OUTPUT" ]; then
TOTAL="$OUTPUT.out"
fi
awk '{size[FNR]+=$2;bytes[FNR]+=$3;psnr[FNR]+=$2*$4;psnrhvs[FNR]+=$2*$5;ssim[FNR]+=$2*$6;fastssim[FNR]+=$2*$7;}END{for(i=1;i<=FNR;i++)print i-1,size[i],bytes[i],psnr[i]/size[i],psnrhvs[i]/size[i],ssim[i]/size[i],fastssim[i]/size[i];}' $@ > $TOTAL

View File

@@ -1,106 +0,0 @@
#!/bin/bash
set -e
if [ $# == 0 ]; then
echo "usage: DAALA_ROOT=<daala_root> MOZJPEG_ROOT=<mozjpeg_root> $0 *.y4m"
exit 1
fi
if [ -z $MOZJPEG_ROOT ]; then
MOZJPEG_ROOT=.
fi
if [ -z $DAALA_ROOT ]; then
echo "DAALA_ROOT not set."
exit 1
fi
if [ -z "$PLANE" ]; then
export PLANE=0
fi
if [ $PLANE != 0 ] && [ $PLANE != 1 ] && [ $PLANE != 2 ]; then
echo "Invalid plane $PLANE. Must be 0, 1 or 2."
exit 1
fi
if [ -z "$YUVJPEG" ]; then
export YUVJPEG=$MOZJPEG_ROOT/yuvjpeg
fi
if [ -z "$JPEGYUV" ]; then
export JPEGYUV=$MOZJPEG_ROOT/jpegyuv
fi
if [ ! -x "$YUVJPEG" ]; then
echo "Executable not found YUVJPEG=$YUVJPEG"
echo "Do you have the right MOZJPEG_ROOT=$MOZJPEG_ROOT"
exit 1
fi
if [ ! -x "$JPEGYUV" ]; then
echo "Executable not found JPEGYUV=$JPEGYUV"
echo "Do you have the right MOZJPEG_ROOT=$MOZJPEG_ROOT"
exit 1
fi
# TODO refactor these out of the daala project into a metrics project
if [ -z "$YUV2YUV4MPEG" ]; then
export YUV2YUV4MPEG=$DAALA_ROOT/tools/yuv2yuv4mpeg
fi
if [ -z "$DUMP_PSNR" ]; then
export DUMP_PSNR=$DAALA_ROOT/tools/dump_psnr
fi
if [ -z "$DUMP_PSNRHVS" ]; then
export DUMP_PSNRHVS=$DAALA_ROOT/tools/dump_psnrhvs
fi
if [ -z "$DUMP_SSIM" ]; then
export DUMP_SSIM=$DAALA_ROOT/tools/dump_ssim
fi
if [ -z "$DUMP_FASTSSIM" ]; then
export DUMP_FASTSSIM=$DAALA_ROOT/tools/dump_fastssim
fi
if [ ! -x "$YUV2YUV4MPEG" ]; then
echo "Executable not found YUV2YUV4MPEG=$YUV2YUV4MPEG"
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
exit 1
fi
if [ ! -x "$DUMP_PSNR" ]; then
echo "Executable not found DUMP_PSNR=$DUMP_PSNR"
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
exit 1
fi
if [ ! -x "$DUMP_PSNRHVS" ]; then
echo "Executable not found DUMP_PSNRHVS=$DUMP_PSNRHVS"
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
exit 1
fi
if [ ! -x "$DUMP_SSIM" ]; then
echo "Executable not found DUMP_SSIM=$DUMP_SSIM"
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
exit 1
fi
if [ ! -x "$DUMP_FASTSSIM" ]; then
echo "Executable not found DUMP_FASTSSIM=$DUMP_FASTSSIM"
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
exit 1
fi
RD_COLLECT_SUB=$(dirname "$0")/rd_collect_sub.sh
if [ -z "$CORES" ]; then
CORES=`grep -i processor /proc/cpuinfo | wc -l`
#echo "CORES not set, using $CORES"
fi
find $@ -type f -name "*.y4m" -print0 | xargs -0 -n1 -P$CORES $RD_COLLECT_SUB

View File

@@ -1,28 +0,0 @@
#!/bin/bash
set -e
FILE=$1
BASENAME=$(basename $FILE)
rm $BASENAME.out 2> /dev/null || true
echo $BASENAME
tail -n+3 $FILE > $BASENAME-in.yuv
WIDTH=$(head -1 $FILE | cut -d\ -f 2 | tr -d 'W')
HEIGHT=$(head -1 $FILE | cut -d\ -f 3 | tr -d 'H')
for x in {0..100}; do
$YUVJPEG $x "$WIDTH"x$HEIGHT $BASENAME-in.yuv $BASENAME.jpeg
$JPEGYUV $BASENAME.jpeg $BASENAME.yuv
$YUV2YUV4MPEG $BASENAME -w$WIDTH -h$HEIGHT -an0 -ad0 -c420mpeg2
PIXELS=$(($WIDTH*$HEIGHT))
SIZE=$(wc -c $BASENAME.jpeg | awk '{ print $1 }')
PSNR=$($DUMP_PSNR $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
PSNRHVS=$($DUMP_PSNRHVS $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
SSIM=$($DUMP_SSIM $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
FASTSSIM=$($DUMP_FASTSSIM -c $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
rm $BASENAME.jpeg $BASENAME.yuv $BASENAME.y4m
echo $x $PIXELS $SIZE $PSNR $PSNRHVS $SSIM $FASTSSIM >> $BASENAME.out
#tail -1 $BASENAME.out
done
rm $BASENAME-in.yuv

View File

@@ -1,47 +0,0 @@
#!/bin/bash
set -e
# Use this to average data from multiple runs
#awk '{size[FNR]+=$2;bytes[FNR]+=$3;psnr[FNR]+=$2*$4;psnrhvs[FNR]+=$2*$5;ssim[FNR]+=$2*$6;fastssim[FNR]+=$2*$7;}END{for(i=1;i<=FNR;i++)print i+1,size[i],bytes[i],psnr[i]/size[i],psnrhvs[i]/size[i],ssim[i]/size[i],fastssim[i]/size[i];}' *.out > total.out
if [ -n "$IMAGE" ]; then
IMAGE="$IMAGE-"
fi
if [ $# == 0 ]; then
echo "usage: IMAGE=<prefix> $0 *.out"
exit 1
fi
if [ -z "$GNUPLOT" -a -n "`type -p gnuplot`" ]; then
GNUPLOT=`type -p gnuplot`
fi
if [ ! -x "$GNUPLOT" ]; then
echo "Executable not found GNUPLOT=$GNUPLOT"
echo "Please install it or set GNUPLOT to point to an installed copy"
exit 1
fi
CMDS="$CMDS set term pngcairo dashed size 1024,768;"
CMDS="$CMDS set log x;"
CMDS="$CMDS set xlabel 'Bits/Pixel';"
CMDS="$CMDS set ylabel 'dB';"
CMDS="$CMDS set key bot right;"
for FILE in "$@"; do
BASENAME=$(basename $FILE)
PSNR="$PSNR $PREFIX '$FILE' using (\$3*8/\$2):4 with lines title '${BASENAME%.*} (PSNR)'"
PSNRHVS="$PSNRHVS $PREFIX '$FILE' using (\$3*8/\$2):5 with lines title '${BASENAME%.*} (PSNR-HVS)'"
SSIM="$SSIM $PREFIX '$FILE' using (\$3*8/\$2):6 with lines title '${BASENAME%.*} (SSIM)'"
FASTSSIM="$FASTSSIM $PREFIX '$FILE' using (\$3*8/\$2):7 with lines title '${BASENAME%.*} (FAST SSIM)'"
PREFIX=","
done
SUFFIX="psnr.png"
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $PSNR;" 2> /dev/null
SUFFIX="psnrhvs.png"
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $PSNRHVS;" 2> /dev/null
SUFFIX="ssim.png"
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $SSIM;" 2> /dev/null
SUFFIX="fastssim.png"
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $FASTSSIM;" 2> /dev/null

View File

@@ -383,7 +383,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
return;
}
if (biWidth <= 0 || biHeight <= 0 || biWidth > 0x7fffffffL || biHeight > 0x7fffffffL)
if (biWidth <= 0 || biHeight <= 0)
ERREXIT(cinfo, JERR_BMP_EMPTY);
if (biPlanes != 1)
ERREXIT(cinfo, JERR_BMP_BADPLANES);

160
rdjpeg.c
View File

@@ -1,160 +0,0 @@
/*
* rdjpeg.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#if JPEG_RAW_READER
#define NUM_ROWS 32
#endif
/* Private version of data source object */
typedef struct _jpeg_source_struct * jpeg_source_ptr;
typedef struct _jpeg_source_struct {
struct cjpeg_source_struct pub; /* public fields */
j_compress_ptr cinfo; /* back link saves passing separate parm */
struct jpeg_decompress_struct dinfo;
struct jpeg_error_mgr jerr;
} jpeg_source_struct;
METHODDEF(JDIMENSION)
get_rows (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
jpeg_source_ptr source = (jpeg_source_ptr) sinfo;
#if !JPEG_RAW_READER
return jpeg_read_scanlines(&source->dinfo, source->pub.buffer, source->pub.buffer_height);
#else
jpeg_read_raw_data(&source->dinfo, source->pub.plane_pointer, 8*cinfo->max_v_samp_factor);
return 8*cinfo->max_v_samp_factor;
#endif
}
/*
* Read the file header; return image size and component count.
*/
METHODDEF(void)
start_input_jpeg (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
#if JPEG_RAW_READER
int i;
#endif
int m;
jpeg_source_ptr source = (jpeg_source_ptr) sinfo;
source->dinfo.err = jpeg_std_error(&source->jerr);
jpeg_create_decompress(&source->dinfo);
jpeg_stdio_src(&source->dinfo, source->pub.input_file);
jpeg_save_markers(&source->dinfo, JPEG_COM, 0xFFFF);
for (m = 0; m < 16; m++)
jpeg_save_markers(&source->dinfo, JPEG_APP0 + m, 0xFFFF);
jpeg_read_header(&source->dinfo, TRUE);
source->pub.marker_list = source->dinfo.marker_list;
#if !JPEG_RAW_READER
source->dinfo.raw_data_out = FALSE;
jpeg_start_decompress(&source->dinfo);
cinfo->in_color_space = source->dinfo.out_color_space;
cinfo->input_components = source->dinfo.output_components;
cinfo->data_precision = source->dinfo.data_precision;
cinfo->image_width = source->dinfo.image_width;
cinfo->image_height = source->dinfo.image_height;
cinfo->raw_data_in = FALSE;
source->pub.buffer = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE,
(JDIMENSION) (cinfo->image_width * cinfo->input_components), (JDIMENSION) 1);
source->pub.buffer_height = 1;
#else
source->dinfo.raw_data_out = TRUE;
source->dinfo.do_fancy_upsampling = FALSE;
jpeg_start_decompress(&source->dinfo);
cinfo->in_color_space = source->dinfo.out_color_space;
cinfo->input_components = source->dinfo.output_components;
cinfo->data_precision = source->dinfo.data_precision;
cinfo->image_width = source->dinfo.image_width;
cinfo->image_height = source->dinfo.image_height;
jpeg_set_colorspace(cinfo, source->dinfo.jpeg_color_space);
cinfo->max_v_samp_factor = source->dinfo.max_v_samp_factor;
cinfo->max_h_samp_factor = source->dinfo.max_h_samp_factor;
cinfo->raw_data_in = TRUE;
#if JPEG_LIB_VERSION >= 70
cinfo->do_fancy_upsampling = FALSE;
#endif
for (i = 0; i < cinfo->input_components; i++) {
cinfo->comp_info[i].h_samp_factor = source->dinfo.comp_info[i].h_samp_factor;
cinfo->comp_info[i].v_samp_factor = source->dinfo.comp_info[i].v_samp_factor;
source->pub.plane_pointer[i] = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE,
(JDIMENSION) cinfo->image_width, (JDIMENSION) NUM_ROWS);
}
#endif
source->pub.get_pixel_rows = get_rows;
}
/*
* Finish up at the end of the file.
*/
METHODDEF(void)
finish_input_jpeg (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
jpeg_source_ptr source = (jpeg_source_ptr) sinfo;
jpeg_finish_decompress(&source->dinfo);
jpeg_destroy_decompress(&source->dinfo);
}
/*
* The module selection routine for JPEG format input.
*/
GLOBAL(cjpeg_source_ptr)
jinit_read_jpeg (j_compress_ptr cinfo)
{
jpeg_source_ptr source;
/* Create module interface object */
source = (jpeg_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
sizeof(jpeg_source_struct));
source->cinfo = cinfo; /* make back link for subroutines */
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_jpeg;
source->pub.finish_input = finish_input_jpeg;
return (cjpeg_source_ptr) source;
}

183
rdpng.c
View File

@@ -1,183 +0,0 @@
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#ifdef PNG_SUPPORTED
#include <png.h> /* if this fails, you need to install libpng-devel */
typedef struct png_source_struct {
struct cjpeg_source_struct pub;
png_structp png_ptr;
png_infop info_ptr;
JDIMENSION current_row;
} png_source_struct;
METHODDEF(void)
finish_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
METHODDEF(JDIMENSION)
get_pixel_rows_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
METHODDEF(void)
start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
GLOBAL(cjpeg_source_ptr)
jinit_read_png(j_compress_ptr cinfo)
{
png_source_struct *source = (*cinfo->mem->alloc_small)((j_common_ptr) cinfo, JPOOL_IMAGE, sizeof(png_source_struct));
memset(source, 0, sizeof(*source));
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_png;
source->pub.finish_input = finish_input_png;
return &source->pub;
}
METHODDEF(void) error_input_png(png_structp png_ptr, png_const_charp msg) {
j_compress_ptr cinfo = png_get_error_ptr(png_ptr);
ERREXITS(cinfo, JERR_PNG_ERROR, msg);
}
/* This is a small ICC profile for sRGB */
static unsigned char tiny_srgb[] = {0,0,2,24,108,99,109,115,2,16,0,0,109,110,
116,114,82,71,66,32,88,89,90,32,7,220,0,1,0,25,0,3,0,41,0,57,97,99,115,112,65,
80,80,76,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,214,0,1,0,0,0,
0,211,45,108,99,109,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,100,101,115,99,0,0,0,252,0,0,0,106,
99,112,114,116,0,0,1,104,0,0,0,11,119,116,112,116,0,0,1,116,0,0,0,20,98,107,
112,116,0,0,1,136,0,0,0,20,114,88,89,90,0,0,1,156,0,0,0,20,103,88,89,90,0,0,1,
176,0,0,0,20,98,88,89,90,0,0,1,196,0,0,0,20,114,84,82,67,0,0,1,216,0,0,0,64,98,
84,82,67,0,0,1,216,0,0,0,64,103,84,82,67,0,0,1,216,0,0,0,64,100,101,115,99,0,0,
0,0,0,0,0,13,115,82,71,66,32,77,111,122,74,80,69,71,0,0,0,0,0,0,0,0,1,0,0,0,0,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,101,120,
116,0,0,0,0,80,68,0,0,88,89,90,32,0,0,0,0,0,0,246,214,0,1,0,0,0,0,211,45,88,89,
90,32,0,0,0,0,0,0,3,22,0,0,3,51,0,0,2,164,88,89,90,32,0,0,0,0,0,0,111,162,0,0,
56,245,0,0,3,144,88,89,90,32,0,0,0,0,0,0,98,153,0,0,183,133,0,0,24,218,88,89,
90,32,0,0,0,0,0,0,36,160,0,0,15,132,0,0,182,207,99,117,114,118,0,0,0,0,0,0,0,
26,0,0,0,203,1,201,3,99,5,146,8,107,11,246,16,63,21,81,27,52,33,241,41,144,50,
24,59,146,70,5,81,119,93,237,107,112,122,5,137,177,154,124,172,105,191,125,211,
195,233,48,255,255,};
METHODDEF(void)
start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
png_source_struct *source = (png_source_struct *)sinfo;
source->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, cinfo, error_input_png, NULL);
source->info_ptr = png_create_info_struct(source->png_ptr);
if (!source->png_ptr || !source->info_ptr) {
ERREXITS(cinfo, JERR_PNG_ERROR, "Can't create read/info_struct");
return;
}
png_set_palette_to_rgb(source->png_ptr);
png_set_expand_gray_1_2_4_to_8(source->png_ptr);
png_set_strip_alpha(source->png_ptr);
png_set_interlace_handling(source->png_ptr);
png_init_io(source->png_ptr, source->pub.input_file);
png_read_info(source->png_ptr, source->info_ptr);
png_uint_32 width, height;
int bit_depth, color_type;
png_get_IHDR(source->png_ptr, source->info_ptr, &width, &height,
&bit_depth, &color_type, NULL, NULL, NULL);
if (width > 65535 || height > 65535) {
ERREXITS(cinfo, JERR_PNG_ERROR, "Image too large");
return;
}
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
cinfo->in_color_space = JCS_GRAYSCALE;
cinfo->input_components = 1;
} else {
cinfo->in_color_space = JCS_RGB;
cinfo->input_components = 3;
}
if (bit_depth == 16) {
png_set_strip_16(source->png_ptr);
}
cinfo->data_precision = 8;
cinfo->image_width = width;
cinfo->image_height = height;
int has_srgb_chunk = png_get_valid(source->png_ptr, source->info_ptr, PNG_INFO_sRGB);
double gamma = 0.45455;
if (!has_srgb_chunk) {
png_get_gAMA(source->png_ptr, source->info_ptr, &gamma);
}
cinfo->input_gamma = gamma;
sinfo->get_pixel_rows = get_pixel_rows_png;
source->pub.marker_list = NULL;
png_bytep profile = NULL;
png_charp unused1 = NULL;
int unused2 = 0;
png_uint_32 proflen = 0;
int has_profile = 0;
if (has_srgb_chunk) {
/* PNG can declare use of an sRGB profile without embedding an ICC file, but JPEG doesn't have such feature */
has_profile = 1;
profile = tiny_srgb;
proflen = sizeof(tiny_srgb);
} else {
has_profile = png_get_iCCP(source->png_ptr, source->info_ptr, &unused1, &unused2, &profile, &proflen); /* your libpng is out of date if you get a warning here */
}
if (has_profile && profile && proflen) {
if (proflen < 65535-14) {
size_t datalen = proflen + 14;
JOCTET *dataptr = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, datalen);
memcpy(dataptr, "ICC_PROFILE\0\x01\x01", 14);
memcpy(dataptr + 14, profile, proflen);
struct jpeg_marker_struct *marker = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, sizeof(struct jpeg_marker_struct));
marker->next = NULL;
marker->marker = JPEG_APP0+2;
marker->original_length = 0;
marker->data_length = datalen;
marker->data = dataptr;
source->pub.marker_list = marker;
} else {
WARNMS(cinfo, JERR_PNG_PROFILETOOLARGE);
}
}
png_read_update_info(source->png_ptr, source->info_ptr);
png_size_t rowbytes = png_get_rowbytes(source->png_ptr, source->info_ptr);
source->pub.buffer = (*cinfo->mem->alloc_sarray)((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)rowbytes, 1);
source->pub.buffer_height = 1;
}
METHODDEF(JDIMENSION)
get_pixel_rows_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
png_source_struct *source = (png_source_struct *)sinfo;
png_read_row(source->png_ptr, source->pub.buffer[0], NULL);
return 1;
}
METHODDEF(void)
finish_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
png_source_struct *source = (png_source_struct *)sinfo;
png_read_end(source->png_ptr, source->info_ptr);
png_destroy_read_struct(&source->png_ptr, &source->info_ptr, NULL);
}
#endif

View File

@@ -267,9 +267,6 @@ bogus:
MEMCOPY(scanptr, scans, scanno * sizeof(jpeg_scan_info));
cinfo->scan_info = scanptr;
cinfo->num_scans = scanno;
/* Disable scan optimization if using custom scan */
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OPTIMIZE_SCANS, FALSE);
}
fclose(fp);
@@ -284,10 +281,7 @@ bogus:
* 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[9][DCTSIZE2] = {
{
/* JPEG Annex K
*/
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,
@@ -296,105 +290,8 @@ static const unsigned int std_luminance_quant_tbl[9][DCTSIZE2] = {
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
},
{
/* flat
*/
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16
},
{
12, 17, 20, 21, 30, 34, 56, 63,
18, 20, 20, 26, 28, 51, 61, 55,
19, 20, 21, 26, 33, 58, 69, 55,
26, 26, 26, 30, 46, 87, 86, 66,
31, 33, 36, 40, 46, 96, 100, 73,
40, 35, 46, 62, 81, 100, 111, 91,
46, 66, 76, 86, 102, 121, 120, 101,
68, 90, 90, 96, 113, 102, 105, 103
},
{
/* From http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
*/
16, 16, 16, 18, 25, 37, 56, 85,
16, 17, 20, 27, 34, 40, 53, 75,
16, 20, 24, 31, 43, 62, 91, 135,
18, 27, 31, 40, 53, 74, 106, 156,
25, 34, 43, 53, 69, 94, 131, 189,
37, 40, 62, 74, 94, 124, 169, 238,
56, 53, 91, 106, 131, 169, 226, 311,
85, 75, 135, 156, 189, 238, 311, 418
},
{
9, 10, 12, 14, 27, 32, 51, 62,
11, 12, 14, 19, 27, 44, 59, 73,
12, 14, 18, 25, 42, 59, 79, 78,
17, 18, 25, 42, 61, 92, 87, 92,
23, 28, 42, 75, 79, 112, 112, 99,
40, 42, 59, 84, 88, 124, 132, 111,
42, 64, 78, 95, 105, 126, 125, 99,
70, 75, 100, 102, 116, 100, 107, 98
},
{
/* Relevance of human vision to JPEG-DCT compression (1992) Klein, Silverstein and Carney.
*/
10, 12, 14, 19, 26, 38, 57, 86,
12, 18, 21, 28, 35, 41, 54, 76,
14, 21, 25, 32, 44, 63, 92, 136,
19, 28, 32, 41, 54, 75, 107, 157,
26, 35, 44, 54, 70, 95, 132, 190,
38, 41, 63, 75, 95, 125, 170, 239,
57, 54, 92, 107, 132, 170, 227, 312,
86, 76, 136, 157, 190, 239, 312, 419
},
{
/* DCTune perceptual optimization of compressed dental X-Rays (1997) Watson, Taylor, Borthwick
*/
7, 8, 10, 14, 23, 44, 95, 241,
8, 8, 11, 15, 25, 47, 102, 255,
10, 11, 13, 19, 31, 58, 127, 255,
14, 15, 19, 27, 44, 83, 181, 255,
23, 25, 31, 44, 72, 136, 255, 255,
44, 47, 58, 83, 136, 255, 255, 255,
95, 102, 127, 181, 255, 255, 255, 255,
241, 255, 255, 255, 255, 255, 255, 255
},
{
/* A visual detection model for DCT coefficient quantization (12/9/93) Ahumada, Watson, Peterson
*/
15, 11, 11, 12, 15, 19, 25, 32,
11, 13, 10, 10, 12, 15, 19, 24,
11, 10, 14, 14, 16, 18, 22, 27,
12, 10, 14, 18, 21, 24, 28, 33,
15, 12, 16, 21, 26, 31, 36, 42,
19, 15, 18, 24, 31, 38, 45, 53,
25, 19, 22, 28, 36, 45, 55, 65,
32, 24, 27, 33, 42, 53, 65, 77
},
{
/* An improved detection model for DCT coefficient quantization (1993) Peterson, Ahumada and Watson
*/
14, 10, 11, 14, 19, 25, 34, 45,
10, 11, 11, 12, 15, 20, 26, 33,
11, 11, 15, 18, 21, 25, 31, 38,
14, 12, 18, 24, 28, 33, 39, 47,
19, 15, 21, 28, 36, 43, 51, 59,
25, 20, 25, 33, 43, 54, 64, 74,
34, 26, 31, 39, 51, 64, 77, 91,
45, 33, 38, 47, 59, 74, 91, 108
}
};
static const unsigned int std_chrominance_quant_tbl[9][DCTSIZE2] = {
{
/* JPEG Annex K
*/
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,
@@ -403,115 +300,15 @@ static const unsigned int std_chrominance_quant_tbl[9][DCTSIZE2] = {
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
},
{
/* flat
*/
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16
},
{
8, 12, 15, 15, 86, 96, 96, 98,
13, 13, 15, 26, 90, 96, 99, 98,
12, 15, 18, 96, 99, 99, 99, 99,
17, 16, 90, 96, 99, 99, 99, 99,
96, 96, 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
},
{
/* From http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
*/
16, 16, 16, 18, 25, 37, 56, 85,
16, 17, 20, 27, 34, 40, 53, 75,
16, 20, 24, 31, 43, 62, 91, 135,
18, 27, 31, 40, 53, 74, 106, 156,
25, 34, 43, 53, 69, 94, 131, 189,
37, 40, 62, 74, 94, 124, 169, 238,
56, 53, 91, 106, 131, 169, 226, 311,
85, 75, 135, 156, 189, 238, 311, 418
},
{
9, 10, 17, 19, 62, 89, 91, 97,
12, 13, 18, 29, 84, 91, 88, 98,
14, 19, 29, 93, 95, 95, 98, 97,
20, 26, 84, 88, 95, 95, 98, 94,
26, 86, 91, 93, 97, 99, 98, 99,
99, 100, 98, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
97, 97, 99, 99, 99, 99, 97, 99
},
{
/* Relevance of human vision to JPEG-DCT compression (1992) Klein, Silverstein and Carney.
* Copied from luma
*/
10, 12, 14, 19, 26, 38, 57, 86,
12, 18, 21, 28, 35, 41, 54, 76,
14, 21, 25, 32, 44, 63, 92, 136,
19, 28, 32, 41, 54, 75, 107, 157,
26, 35, 44, 54, 70, 95, 132, 190,
38, 41, 63, 75, 95, 125, 170, 239,
57, 54, 92, 107, 132, 170, 227, 312,
86, 76, 136, 157, 190, 239, 312, 419
},
{
/* DCTune perceptual optimization of compressed dental X-Rays (1997) Watson, Taylor, Borthwick
* Copied from luma
*/
7, 8, 10, 14, 23, 44, 95, 241,
8, 8, 11, 15, 25, 47, 102, 255,
10, 11, 13, 19, 31, 58, 127, 255,
14, 15, 19, 27, 44, 83, 181, 255,
23, 25, 31, 44, 72, 136, 255, 255,
44, 47, 58, 83, 136, 255, 255, 255,
95, 102, 127, 181, 255, 255, 255, 255,
241, 255, 255, 255, 255, 255, 255, 255
},
{
/* A visual detection model for DCT coefficient quantization (12/9/93) Ahumada, Watson, Peterson
* Copied from luma
*/
15, 11, 11, 12, 15, 19, 25, 32,
11, 13, 10, 10, 12, 15, 19, 24,
11, 10, 14, 14, 16, 18, 22, 27,
12, 10, 14, 18, 21, 24, 28, 33,
15, 12, 16, 21, 26, 31, 36, 42,
19, 15, 18, 24, 31, 38, 45, 53,
25, 19, 22, 28, 36, 45, 55, 65,
32, 24, 27, 33, 42, 53, 65, 77
},
{
/* An improved detection model for DCT coefficient quantization (1993) Peterson, Ahumada and Watson
* Copied from luma
*/
14, 10, 11, 14, 19, 25, 34, 45,
10, 11, 11, 12, 15, 20, 26, 33,
11, 11, 15, 18, 21, 25, 31, 38,
14, 12, 18, 24, 28, 33, 39, 47,
19, 15, 21, 28, 36, 43, 51, 59,
25, 20, 25, 33, 43, 54, 64, 74,
34, 26, 31, 39, 51, 64, 77, 91,
45, 33, 38, 47, 59, 74, 91, 108
}
};
LOCAL(void)
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
{
int quant_tbl_master_idx = 0;
if (jpeg_c_int_param_supported(cinfo, JINT_BASE_QUANT_TBL_IDX))
quant_tbl_master_idx = jpeg_c_get_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX);
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl[quant_tbl_master_idx],
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl[quant_tbl_master_idx],
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
q_scale_factor[1], force_baseline);
}
#endif
@@ -524,46 +321,35 @@ set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
* If there are more q-table slots than parameters, the last value is replicated.
*/
{
float val = 75.f; /* default value */
int val = 75; /* default value */
int tblno;
char ch;
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
if (*arg) {
ch = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%f%c", &val, &ch) < 1)
if (sscanf(arg, "%d%c", &val, &ch) < 1)
return FALSE;
if (ch != ',') /* syntax check */
return FALSE;
/* Convert user 0-100 rating to percentage scaling */
#if JPEG_LIB_VERSION >= 70
cinfo->q_scale_factor[tblno] = jpeg_float_quality_scaling(val);
cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
#else
q_scale_factor[tblno] = jpeg_float_quality_scaling(val);
q_scale_factor[tblno] = jpeg_quality_scaling(val);
#endif
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
;
} else {
/* reached end of parameter, set remaining factors to last value */
#if JPEG_LIB_VERSION >= 70
cinfo->q_scale_factor[tblno] = jpeg_float_quality_scaling(val);
cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
#else
q_scale_factor[tblno] = jpeg_float_quality_scaling(val);
q_scale_factor[tblno] = jpeg_quality_scaling(val);
#endif
}
}
jpeg_default_qtables(cinfo, force_baseline);
/* For some images chroma subsampling significantly degrades color quality,
making it impossible to achieve high visual quality regardless of quality setting.
To make the quality setting more intuitive, disable subsampling when high-quality
color is desired. */
if (val >= 90) {
set_sample_factors(cinfo, "1x1");
} else if (val >= 80) {
set_sample_factors(cinfo, "2x1");
}
return TRUE;
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
<title>mozjpeg</title>
<title>libjpeg-turbo</title>
<welcome file="Welcome.rtf" />
<readme file="ReadMe.txt" />
<license file="License.rtf" />
@@ -12,13 +12,13 @@
<options customize="never" />
<choices-outline>
<line choice="default">
<line choice="com.mozilla.mozjpeg"/>
<line choice="com.libjpeg-turbo.libjpeg-turbo"/>
</line>
</choices-outline>
<choice id="default"/>
<choice id="com.mozilla.mozjpeg" visible="false">
<pkg-ref id="com.mozilla.mozjpeg"/>
<choice id="com.libjpeg-turbo.libjpeg-turbo" visible="false">
<pkg-ref id="com.libjpeg-turbo.libjpeg-turbo"/>
</choice>
<pkg-ref auth="root"
id="com.mozilla.mozjpeg">mozjpeg.pkg</pkg-ref>
id="com.libjpeg-turbo.libjpeg-turbo">libjpeg-turbo.pkg</pkg-ref>
</installer-gui-script>

View File

@@ -12,7 +12,7 @@
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls1\ilvl0\cf0 {\listtext \'95 }Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\
{\listtext \'95 }Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\
{\listtext \'95 }Neither the name of the mozjpeg Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\
{\listtext \'95 }Neither the name of the libjpeg-turbo Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\
\pard\pardeftab720\qc
\cf0 \
\pard\pardeftab720

View File

@@ -1,18 +1,17 @@
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460
{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red203\green233\blue242;}
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\deftab720
\pard\tx529\tx1059\tx1589\tx2119\tx2649\tx3178\tx3708\tx4238\tx4768\tx5298\tx5827\tx6357\tx6887\tx7417\tx7947\tx8476\tx9006\tx9536\tx10066\tx10596\tx11125\tx11655\tx12185\tx12715\tx13245\tx13774\tx14304\tx14834\tx15364\tx15894\tx16423\tx16953\tx17483\tx18013\tx18543\tx19072\tx19602\tx20132\tx20662\tx21192\tx21722\tx22251\tx22781\tx23311\tx23841\tx24371\tx24900\tx25430\tx25960\tx26490\tx27020\tx27549\tx28079\tx28609\tx29139\tx29669\tx30198\tx30728\tx31258\tx31788\tx32318\tx32847\tx33377\tx33907\tx34437\tx34967\tx35496\tx36026\tx36556\tx37086\tx37616\tx38145\tx38675\tx39205\tx39735\tx40265\tx40794\tx41324\tx41854\tx42384\tx42914\tx43443\tx43973\tx44503\tx45033\tx45563\tx46093\tx46622\tx47152\tx47682\tx48212\tx48742\tx49271\tx49801\tx50331\tx50861\tx51391\tx51920\tx52450\tx52980\pardeftab720\li529\fi-530\partightenfactor0
\pard\pardeftab720\ql\qnatural
\f0\fs22 \cf2 \CocoaLigature0 TThi /opt/mozjpeg/bin/uninstall\
\pard\tx529\tx1059\tx1589\tx2119\tx2649\tx3178\tx3708\tx4238\tx4768\tx5298\tx5827\tx6357\tx6887\tx7417\tx7947\tx8476\tx9006\tx9536\tx10066\tx10596\tx11125\tx11655\tx12185\tx12715\tx13245\tx13774\tx14304\tx14834\tx15364\tx15894\tx16423\tx16953\tx17483\tx18013\tx18543\tx19072\tx19602\tx20132\tx20662\tx21192\tx21722\tx22251\tx22781\tx23311\tx23841\tx24371\tx24900\tx25430\tx25960\tx26490\tx27020\tx27549\tx28079\tx28609\tx29139\tx29669\tx30198\tx30728\tx31258\tx31788\tx32318\tx32847\tx33377\tx33907\tx34437\tx34967\tx35496\tx36026\tx36556\tx37086\tx37616\tx38145\tx38675\tx39205\tx39735\tx40265\tx40794\tx41324\tx41854\tx42384\tx42914\tx43443\tx43973\tx44503\tx45033\tx45563\tx46093\tx46622\tx47152\tx47682\tx48212\tx48742\tx49271\tx49801\tx50331\tx50861\tx51391\tx51920\tx52450\tx52980\pardeftab720\li662\fi-663\partightenfactor0
\cf2 installer will install the mozjpeg SDK and run-time libraries onto your computer so that you can use mozjpeg to build new applications. To remove the mozjpeg package, run\
\pard\tx529\tx1059\tx1589\tx2119\tx2649\tx3178\tx3708\tx4238\tx4768\tx5298\tx5827\tx6357\tx6887\tx7417\tx7947\tx8476\tx9006\tx9536\tx10066\tx10596\tx11125\tx11655\tx12185\tx12715\tx13245\tx13774\tx14304\tx14834\tx15364\tx15894\tx16423\tx16953\tx17483\tx18013\tx18543\tx19072\tx19602\tx20132\tx20662\tx21192\tx21722\tx22251\tx22781\tx23311\tx23841\tx24371\tx24900\tx25430\tx25960\tx26490\tx27020\tx27549\tx28079\tx28609\tx29139\tx29669\tx30198\tx30728\tx31258\tx31788\tx32318\tx32847\tx33377\tx33907\tx34437\tx34967\tx35496\tx36026\tx36556\tx37086\tx37616\tx38145\tx38675\tx39205\tx39735\tx40265\tx40794\tx41324\tx41854\tx42384\tx42914\tx43443\tx43973\tx44503\tx45033\tx45563\tx46093\tx46622\tx47152\tx47682\tx48212\tx48742\tx49271\tx49801\tx50331\tx50861\tx51391\tx51920\tx52450\tx52980\pardeftab720\li529\fi-530\partightenfactor0
\cf2 is installer will install the \cb3 mozjpeg\cb1 SDK and run-time libraries onto your computer so that you can use \cb3 mozjpeg\cb1 to build new applications. To remove the \cb3 mozjpeg\cb1 package, run\
\f0\fs24 \cf0 This installer will install the libjpeg-turbo SDK and run-time libraries onto your computer so that you can use libjpeg-turbo to build new applications or accelerate existing ones. To remove the libjpeg-turbo package, run\
\
\pard\tx529\tx1059\tx1589\tx2119\tx2649\tx3178\tx3708\tx4238\tx4768\tx5298\tx5827\tx6357\tx6887\tx7417\tx7947\tx8476\tx9006\tx9536\tx10066\tx10596\tx11125\tx11655\tx12185\tx12715\tx13245\tx13774\tx14304\tx14834\tx15364\tx15894\tx16423\tx16953\tx17483\tx18013\tx18543\tx19072\tx19602\tx20132\tx20662\tx21192\tx21722\tx22251\tx22781\tx23311\tx23841\tx24371\tx24900\tx25430\tx25960\tx26490\tx27020\tx27549\tx28079\tx28609\tx29139\tx29669\tx30198\tx30728\tx31258\tx31788\tx32318\tx32847\tx33377\tx33907\tx34437\tx34967\tx35496\tx36026\tx36556\tx37086\tx37616\tx38145\tx38675\tx39205\tx39735\tx40265\tx40794\tx41324\tx41854\tx42384\tx42914\tx43443\tx43973\tx44503\tx45033\tx45563\tx46093\tx46622\tx47152\tx47682\tx48212\tx48742\tx49271\tx49801\tx50331\tx50861\tx51391\tx51920\tx52450\tx52980\pardeftab720\li794\fi-795\partightenfactor0
\cf2 /opt/\cb3 mozjpeg\cb1 /bin/uninstall\
\pard\tx529\tx1059\tx1589\tx2119\tx2649\tx3178\tx3708\tx4238\tx4768\tx5298\tx5827\tx6357\tx6887\tx7417\tx7947\tx8476\tx9006\tx9536\tx10066\tx10596\tx11125\tx11655\tx12185\tx12715\tx13245\tx13774\tx14304\tx14834\tx15364\tx15894\tx16423\tx16953\tx17483\tx18013\tx18543\tx19072\tx19602\tx20132\tx20662\tx21192\tx21722\tx22251\tx22781\tx23311\tx23841\tx24371\tx24900\tx25430\tx25960\tx26490\tx27020\tx27549\tx28079\tx28609\tx29139\tx29669\tx30198\tx30728\tx31258\tx31788\tx32318\tx32847\tx33377\tx33907\tx34437\tx34967\tx35496\tx36026\tx36556\tx37086\tx37616\tx38145\tx38675\tx39205\tx39735\tx40265\tx40794\tx41324\tx41854\tx42384\tx42914\tx43443\tx43973\tx44503\tx45033\tx45563\tx46093\tx46622\tx47152\tx47682\tx48212\tx48742\tx49271\tx49801\tx50331\tx50861\tx51391\tx51920\tx52450\tx52980\pardeftab720\li560\fi-561\partightenfactor0
\cf2 \
\pard\pardeftab720\ql\qnatural
\f1 \cf0 /opt/libjpeg-turbo/bin/uninstall\
\pard\pardeftab720\ql\qnatural
\f0 \cf0 \
from the command line.\
}

View File

@@ -4,21 +4,28 @@ Section: misc
Priority: optional
Architecture: {__ARCH}
Essential: no
Maintainer: Mozilla Research <joshmoz@gmail.com>
Homepage: https://github.com/mozilla/mozjpeg
Maintainer: The libjpeg-turbo Project <information@libjpeg-turbo.org>
Homepage: http://www.libjpeg-turbo.org
Installed-Size: {__SIZE}
Description: A JPEG codec that provides increased compression for JPEG images (at the expense of compression performance)
mozjpeg is a fork of libjpeg-turbo that aims to speed up load times of web
pages by reducing the size (and, by extension, the transmission time) of JPEG
files. It accomplishes this by enabling optimized Huffman trees and
progressive entropy coding by default in the JPEG compressor, as well as
splitting the spectrum of DCT coefficients into separate scans and using
Trellis quantisation.
Description: A SIMD-accelerated JPEG codec that provides both the libjpeg and TurboJPEG APIs
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
NEON, AltiVec) to accelerate baseline JPEG compression and decompression on
x86, x86-64, ARM, and PowerPC systems. On such systems, libjpeg-turbo is
generally 2-6x as fast as libjpeg, all else being equal. On other types of
systems, libjpeg-turbo can still outperform libjpeg by a significant amount,
by virtue of its highly-optimized Huffman coding routines. In many cases, the
performance of libjpeg-turbo rivals that of proprietary high-speed JPEG
codecs.
.
Although it is based on libjpeg-turbo, mozjpeg is not intended to be a
general-purpose or high-performance JPEG library. Its performance is highly
"asymmetric". That is, the JPEG files it generates require much more time to
compress than to decompress. When the default settings are used, mozjpeg is
considerably slower than libjpeg-turbo or even libjpeg at compressing images.
Thus, it is not generally suitable for real-time compression. It is best used
as part of a web encoding workflow.
libjpeg-turbo implements both the traditional libjpeg API as well as the less
powerful but more straightforward TurboJPEG API. libjpeg-turbo also features
colorspace extensions that allow it to compress from/decompress to 32-bit and
big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java
interface.
.
libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated
derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
broader range of users and developers.

View File

@@ -80,7 +80,7 @@ Section "@CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ (required)"
File "@CMAKE_SOURCE_DIR@\turbojpeg.h"
SetOutPath $INSTDIR\doc
File "@CMAKE_SOURCE_DIR@\README.ijg"
File "@CMAKE_SOURCE_DIR@\README-mozilla.txt"
File "@CMAKE_SOURCE_DIR@\README.md"
File "@CMAKE_SOURCE_DIR@\LICENSE.md"
File "@CMAKE_SOURCE_DIR@\example.c"
File "@CMAKE_SOURCE_DIR@\libjpeg.txt"
@@ -142,7 +142,7 @@ Section "Uninstall"
Delete $INSTDIR\include\turbojpeg.h"
Delete $INSTDIR\uninstall_@VERSION@.exe
Delete $INSTDIR\doc\README.ijg
Delete $INSTDIR\doc\README-mozilla.txt
Delete $INSTDIR\doc\README.md
Delete $INSTDIR\doc\LICENSE.md
Delete $INSTDIR\doc\example.c
Delete $INSTDIR\doc\libjpeg.txt

View File

@@ -1,4 +1,4 @@
# Path under which mozjpeg should be installed
# Path under which libjpeg-turbo should be installed
%define _prefix %{__prefix}
# Path under which executables should be installed
@@ -13,53 +13,69 @@
# Path under which headers should be installed
%define _includedir %{__includedir}
# _libdir is set to %{_prefix}/%{_lib} by default
%ifarch x86_64
%define _lib lib64
%if "%{?__isa_bits:1}" == "1"
%define _bits %{__isa_bits}
%else
%if "%{_prefix}" == "/opt/mozjpeg"
%define _lib lib32
# RPM < 4.6
%if "%{_lib}" == "lib64"
%define _bits 64
%else
%define _bits 32
%endif
%endif
%if "%{_bits}" == "64"
%define _libdir %{_exec_prefix}/lib64
%else
%if "%{_prefix}" == "/opt/libjpeg-turbo"
%define _libdir %{_exec_prefix}/lib32
%endif
%endif
# Path under which man pages should be installed
%define _mandir %{__mandir}
Summary: A JPEG codec that provides increased compression for JPEG images (at the expense of compression performance)
Summary: A SIMD-accelerated JPEG codec that provides both the libjpeg and TurboJPEG APIs
Name: @PKGNAME@
Version: @VERSION@
Vendor: Mozilla Research
URL: https://github.com/mozilla/mozjpeg
Vendor: The libjpeg-turbo Project
URL: http://www.libjpeg-turbo.org
Group: System Environment/Libraries
#-->Source0: https://github.com/mozilla/mozjpeg/archive/v%{version}.tar.gz
#-->Source0: http://prdownloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-%{version}.tar.gz
Release: @BUILD@
License: BSD-style
BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release}
Prereq: /sbin/ldconfig
%ifarch x86_64
%if "%{_bits}" == "64"
Provides: %{name} = %{version}-%{release}, @PACKAGE_NAME@ = %{version}-%{release}, libturbojpeg.so()(64bit)
%else
Provides: %{name} = %{version}-%{release}, @PACKAGE_NAME@ = %{version}-%{release}, libturbojpeg.so
%endif
%description
mozjpeg is a fork of libjpeg-turbo that aims to speed up load times of web
pages by reducing the size (and, by extension, the transmission time) of JPEG
files. It accomplishes this by enabling optimized Huffman trees and
progressive entropy coding by default in the JPEG compressor, as well as
splitting the spectrum of DCT coefficients into separate scans and using
Trellis quantisation.
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
NEON, AltiVec) to accelerate baseline JPEG compression and decompression on
x86, x86-64, ARM, and PowerPC systems. On such systems, libjpeg-turbo is
generally 2-6x as fast as libjpeg, all else being equal. On other types of
systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by
virtue of its highly-optimized Huffman coding routines. In many cases, the
performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs.
Although it is based on libjpeg-turbo, mozjpeg is not intended to be a
general-purpose or high-performance JPEG library. Its performance is highly
"asymmetric". That is, the JPEG files it generates require much more time to
compress than to decompress. When the default settings are used, mozjpeg is
considerably slower than libjpeg-turbo or even libjpeg at compressing images.
Thus, it is not generally suitable for real-time compression. It is best used
as part of a web encoding workflow.
libjpeg-turbo implements both the traditional libjpeg API as well as the less
powerful but more straightforward TurboJPEG API. libjpeg-turbo also features
colorspace extensions that allow it to compress from/decompress to 32-bit and
big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java
interface.
libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated
derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
broader range of users and developers.
#-->%prep
#-->%setup -q -n mozjpeg-%{version}
#-->%setup -q -n libjpeg-turbo-%{version}
#-->%build
#-->./configure prefix=%{_prefix} bindir=%{_bindir} datadir=%{_datadir} \
@@ -67,7 +83,8 @@ as part of a web encoding workflow.
#--> mandir=%{_mandir} JPEG_LIB_VERSION=@JPEG_LIB_VERSION@ \
#--> SO_MAJOR_VERSION=@SO_MAJOR_VERSION@ SO_MINOR_VERSION=@SO_MINOR_VERSION@ \
#--> --with-pic @RPM_CONFIG_ARGS@
#-->make DESTDIR=$RPM_BUILD_ROOT
#-->export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
#-->make -j$NUMCPUS --load-average=$NUMCPUS DESTDIR=$RPM_BUILD_ROOT
%install
@@ -80,14 +97,14 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
LJT_LIBDIR=%{__libdir}
if [ ! "$LJT_LIBDIR" = "%{_libdir}" ]; then
echo ERROR: mozjpeg must be configured with libdir=%{_prefix}/%{_lib} when generating an in-tree RPM for this architecture.
echo ERROR: libjpeg-turbo must be configured with libdir=%{_libdir} when generating an in-tree RPM for this architecture.
exit 1
fi
#-->%endif
LJT_DOCDIR=%{__docdir}
if [ "%{_prefix}" = "/opt/mozjpeg" -a "$LJT_DOCDIR" = "/opt/mozjpeg/doc" ]; then
if [ "%{_prefix}" = "/opt/libjpeg-turbo" -a "$LJT_DOCDIR" = "/opt/libjpeg-turbo/doc" ]; then
ln -fs %{_docdir} $RPM_BUILD_ROOT/$LJT_DOCDIR
fi
@@ -103,7 +120,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_docdir}
%doc %{_docdir}/*
%dir %{_prefix}
%if "%{_prefix}" == "/opt/mozjpeg" && "%{_docdir}" != "%{_prefix}/doc"
%if "%{_prefix}" == "/opt/libjpeg-turbo" && "%{_docdir}" != "%{_prefix}/doc"
%{_prefix}/doc
%endif
%dir %{_bindir}

View File

@@ -31,7 +31,7 @@ __PWD=`pwd`
make install DESTDIR=$TMPDIR/pkg docdir=/usr/share/doc/$PACKAGE_NAME-$VERSION \
exampledir=/usr/share/doc/$PACKAGE_NAME-$VERSION
rm $TMPDIR/pkg$LIBDIR/*.la
if [ "$PREFIX" = "/opt/mozjpeg" -a "$DOCDIR" = "/opt/mozjpeg/doc" ]; then
if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$DOCDIR" = "/opt/libjpeg-turbo/doc" ]; then
ln -fs /usr/share/doc/$PACKAGE_NAME-$VERSION $TMPDIR/pkg$DOCDIR
fi
cd $TMPDIR/pkg

View File

@@ -45,7 +45,7 @@ makedeb()
make install DESTDIR=$TMPDIR docdir=/usr/share/doc/$DIRNAME-$VERSION \
exampledir=/usr/share/doc/$DIRNAME-$VERSION
rm -f $TMPDIR$LIBDIR/*.la
if [ "$PREFIX" = "/opt/mozjpeg" -a "$DOCDIR" = "/opt/mozjpeg/doc" ]; then
if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$DOCDIR" = "/opt/libjpeg-turbo/doc" ]; then
ln -fs /usr/share/doc/$DIRNAME-$VERSION $TMPDIR$DOCDIR
fi
fi

View File

@@ -109,7 +109,7 @@ make install DESTDIR=$PKGROOT docdir=/Library/Documentation/$PACKAGE_NAME \
exampledir=/Library/Documentation/$PACKAGE_NAME
rm -f $PKGROOT$LIBDIR/*.la
if [ "$PREFIX" = "/opt/mozjpeg" -a "$DOCDIR" = "/opt/mozjpeg/doc" ]; then
if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$DOCDIR" = "/opt/libjpeg-turbo/doc" ]; then
ln -fs /Library/Documentation/$PACKAGE_NAME $PKGROOT$DOCDIR
fi
@@ -440,7 +440,7 @@ install_name_tool -id $LIBDIR/libturbojpeg.0.dylib $PKGROOT/$LIBDIR/libturbojpeg
if [ $WITH_JAVA = 1 ]; then
ln -fs libturbojpeg.0.dylib $PKGROOT/$LIBDIR/libturbojpeg.jnilib
fi
if [ "$PREFIX" = "/opt/mozjpeg" -a "$LIBDIR" = "/opt/mozjpeg/lib" ]; then
if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$LIBDIR" = "/opt/libjpeg-turbo/lib" ]; then
if [ ! -h $PKGROOT/$PREFIX/lib32 ]; then
ln -fs lib $PKGROOT/$PREFIX/lib32
fi
@@ -459,7 +459,7 @@ cp $SRCDIR/release/License.rtf $SRCDIR/release/Welcome.rtf $SRCDIR/release/ReadM
mkdir $TMPDIR/dmg
pkgbuild --root $PKGROOT --version $VERSION.$BUILD \
--identifier com.mozilla.$PACKAGE_NAME $TMPDIR/pkg/$PACKAGE_NAME.pkg
--identifier com.libjpeg-turbo.libjpeg-turbo $TMPDIR/pkg/$PACKAGE_NAME.pkg
productbuild --distribution $SRCDIR/release/Distribution.xml \
--package-path $TMPDIR/pkg/ --resources $TMPDIR/pkg/ \
$TMPDIR/dmg/$PACKAGE_NAME.pkg

View File

@@ -8,7 +8,7 @@
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# - Neither the name of the mozjpeg Project nor the names of its
# - Neither the name of the libjpeg-turbo Project nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
@@ -32,7 +32,7 @@ if [ ! "`id -u`" = "0" ]; then
fi
PACKAGE=@PKGNAME@
MACPACKAGE=com.mozilla.$PACKAGE
MACPACKAGE=com.$PACKAGE.$PACKAGE
RECEIPT=/Library/Receipts/$PACKAGE.pkg
LSBOM=
@@ -75,7 +75,7 @@ fi
if [ -d $INCLUDEDIR ]; then
rmdir $INCLUDEDIR 2>&1 || EXITSTATUS=-1
fi
if [ "$PREFIX" = "/opt/mozjpeg" -a "$LIBDIR" = "/opt/mozjpeg/lib" ]; then
if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$LIBDIR" = "/opt/libjpeg-turbo/lib" ]; then
if [ -h $LIBDIR\32 ]; then
rm $LIBDIR\32 2>&1 || EXITSTATUS=-1
fi
@@ -95,7 +95,7 @@ fi
if [ -d $DATADIR -a "$DATADIR" != "$PREFIX" ]; then
rmdir $DATADIR 2>&1 || EXITSTATUS=-1
fi
if [ "$PREFIX" = "/opt/mozjpeg" -a -h "$PREFIX/doc" ]; then
if [ "$PREFIX" = "/opt/libjpeg-turbo" -a -h "$PREFIX/doc" ]; then
rm $PREFIX/doc 2>&1 || EXITSTATUS=-1
fi
rmdir $PREFIX 2>&1 || EXITSTATUS=-1

View File

@@ -16,7 +16,7 @@ if(MSVC)
endif()
foreach(src ${JPEG_SOURCES})
list(APPEND JPEG_SRCS "${CMAKE_SOURCE_DIR}/${src}")
set(JPEG_SRCS ${JPEG_SRCS} ${CMAKE_SOURCE_DIR}/${src})
endforeach()
if(WITH_SIMD)
@@ -26,10 +26,10 @@ endif()
if(WITH_MEM_SRCDST AND NOT WITH_JPEG8)
add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS}
"${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}-memsrcdst.def")
${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}-memsrcdst.def)
else()
add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS}
"${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}.def")
${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}.def)
endif()
set_target_properties(jpeg PROPERTIES SOVERSION ${DLL_VERSION}
VERSION ${FULLVERSION})
@@ -50,7 +50,7 @@ else()
set(DJPEG_BMP_SOURCES ../wrbmp.c ../wrtarga.c)
endif()
add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c ../rdjpeg.c
add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c
../rdswitch.c ${CJPEG_BMP_SOURCES})
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
target_link_libraries(cjpeg jpeg)

View File

@@ -42,7 +42,7 @@ endif()
if(MSVC_IDE)
set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
else()
set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}")
set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
file(GLOB INC_FILES *.inc)

View File

@@ -4484,4 +4484,3 @@ LEAF_MIPS_DSPR2(jsimd_convsamp_float_mips_dspr2)
END(jsimd_convsamp_float_mips_dspr2)
/*****************************************************************************/

View File

@@ -281,5 +281,3 @@ LEAF_MIPS32R2(symbol) \
addiu sp, sp, \stack_offset
.endif
.endm

View File

@@ -502,7 +502,7 @@ int decompTest(char *filename)
char *temp=NULL, tempstr[80], tempstr2[80];
int row, col, i, iter, tilew, tileh, ntilesw=1, ntilesh=1, retval=0;
double start, elapsed;
int ps=tjPixelSize[pf], tile;
int ps=tjPixelSize[pf], tile, decompsrc=0;
if((file=fopen(filename, "rb"))==NULL)
_throwunix("opening file");
@@ -682,18 +682,17 @@ int decompTest(char *filename)
else
{
if(quiet==1) printf("N/A N/A ");
jpegsize[0]=srcsize;
free(jpegbuf[0]);
jpegbuf[0]=srcbuf;
srcbuf=NULL;
tjFree(jpegbuf[0]);
jpegbuf[0]=NULL;
decompsrc=1;
}
if(w==tilew) _tilew=_w;
if(h==tileh) _tileh=_h;
if(!(xformopt&TJXOPT_NOOUTPUT))
{
if(decomp(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0,
filename, _tilew, _tileh)==-1)
if(decomp(NULL, decompsrc? &srcbuf:jpegbuf, decompsrc? &srcsize:jpegsize,
NULL, _w, _h, _subsamp, 0, filename, _tilew, _tileh)==-1)
goto bailout;
}
else if(quiet==1) printf("N/A\n");
@@ -835,32 +834,32 @@ int main(int argc, char *argv[])
{
dotile=1; xformopt|=TJXOPT_CROP;
}
if(!strcasecmp(argv[i], "-fastupsample"))
else if(!strcasecmp(argv[i], "-fastupsample"))
{
printf("Using fast upsampling code\n\n");
flags|=TJFLAG_FASTUPSAMPLE;
}
if(!strcasecmp(argv[i], "-fastdct"))
else if(!strcasecmp(argv[i], "-fastdct"))
{
printf("Using fastest DCT/IDCT algorithm\n\n");
flags|=TJFLAG_FASTDCT;
}
if(!strcasecmp(argv[i], "-accuratedct"))
else if(!strcasecmp(argv[i], "-accuratedct"))
{
printf("Using most accurate DCT/IDCT algorithm\n\n");
flags|=TJFLAG_ACCURATEDCT;
}
if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB;
if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX;
if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR;
if(!strcasecmp(argv[i], "-bgrx")) pf=TJPF_BGRX;
if(!strcasecmp(argv[i], "-xbgr")) pf=TJPF_XBGR;
if(!strcasecmp(argv[i], "-xrgb")) pf=TJPF_XRGB;
if(!strcasecmp(argv[i], "-cmyk")) pf=TJPF_CMYK;
if(!strcasecmp(argv[i], "-bottomup")) flags|=TJFLAG_BOTTOMUP;
if(!strcasecmp(argv[i], "-quiet")) quiet=1;
if(!strcasecmp(argv[i], "-qq")) quiet=2;
if(!strcasecmp(argv[i], "-scale") && i<argc-1)
else if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB;
else if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX;
else if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR;
else if(!strcasecmp(argv[i], "-bgrx")) pf=TJPF_BGRX;
else if(!strcasecmp(argv[i], "-xbgr")) pf=TJPF_XBGR;
else if(!strcasecmp(argv[i], "-xrgb")) pf=TJPF_XRGB;
else if(!strcasecmp(argv[i], "-cmyk")) pf=TJPF_CMYK;
else if(!strcasecmp(argv[i], "-bottomup")) flags|=TJFLAG_BOTTOMUP;
else if(!strcasecmp(argv[i], "-quiet")) quiet=1;
else if(!strcasecmp(argv[i], "-qq")) quiet=2;
else if(!strcasecmp(argv[i], "-scale") && i<argc-1)
{
int temp1=0, temp2=0, match=0;
if(sscanf(argv[++i], "%d/%d", &temp1, &temp2)==2)
@@ -878,43 +877,42 @@ int main(int argc, char *argv[])
}
else usage(argv[0]);
}
if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP;
if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP;
if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRANSPOSE;
if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TRANSVERSE;
if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90;
if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180;
if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270;
if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_GRAY;
if(!strcasecmp(argv[i], "-custom")) customFilter=dummyDCTFilter;
if(!strcasecmp(argv[i], "-nooutput")) xformopt|=TJXOPT_NOOUTPUT;
if(!strcasecmp(argv[i], "-benchtime") && i<argc-1)
else if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP;
else if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP;
else if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRANSPOSE;
else if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TRANSVERSE;
else if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90;
else if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180;
else if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270;
else if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_GRAY;
else if(!strcasecmp(argv[i], "-custom")) customFilter=dummyDCTFilter;
else if(!strcasecmp(argv[i], "-nooutput")) xformopt|=TJXOPT_NOOUTPUT;
else if(!strcasecmp(argv[i], "-benchtime") && i<argc-1)
{
double temp=atof(argv[++i]);
if(temp>0.0) benchtime=temp;
else usage(argv[0]);
}
if(!strcasecmp(argv[i], "-warmup") && i<argc-1)
else if(!strcasecmp(argv[i], "-warmup") && i<argc-1)
{
double temp=atof(argv[++i]);
if(temp>=0.0) warmup=temp;
else usage(argv[0]);
printf("Warmup time = %.1f seconds\n\n", warmup);
}
if(!strcmp(argv[i], "-?")) usage(argv[0]);
if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
if(!strcasecmp(argv[i], "-bmp")) ext="bmp";
if(!strcasecmp(argv[i], "-yuv"))
else if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
else if(!strcasecmp(argv[i], "-bmp")) ext="bmp";
else if(!strcasecmp(argv[i], "-yuv"))
{
printf("Testing YUV planar encoding/decoding\n\n");
doyuv=1;
}
if(!strcasecmp(argv[i], "-yuvpad") && i<argc-1)
else if(!strcasecmp(argv[i], "-yuvpad") && i<argc-1)
{
int temp=atoi(argv[++i]);
if(temp>=1) yuvpad=temp;
}
if(!strcasecmp(argv[i], "-subsamp") && i<argc-1)
else if(!strcasecmp(argv[i], "-subsamp") && i<argc-1)
{
i++;
if(toupper(argv[i][0])=='G') subsamp=TJSAMP_GRAY;
@@ -931,8 +929,9 @@ int main(int argc, char *argv[])
}
}
}
if(!strcasecmp(argv[i], "-componly")) componly=1;
if(!strcasecmp(argv[i], "-nowrite")) dowrite=0;
else if(!strcasecmp(argv[i], "-componly")) componly=1;
else if(!strcasecmp(argv[i], "-nowrite")) dowrite=0;
else usage(argv[0]);
}
}

View File

@@ -36,10 +36,9 @@ if [ -d $OUTDIR ]; then
fi
mkdir -p $OUTDIR
exec >$EXEDIR/tjbenchtest.log
if [ $# -gt 0 ]; then
if [ "$1" = "-yuv" ]; then
while [ $# -gt 0 ]; do
case "$1" in
-yuv)
NSARG=-nosmooth
YUVARG=-yuv
@@ -60,12 +59,16 @@ if [ $# -gt 0 ]; then
# phenomenon is not yet fully understood but is also believed to be some sort
# of round-off error.)
IMAGES="vgl_6548_0026a.${EXT}"
fi
if [ "$1" = "-alloc" ]; then
;;
-alloc)
ALLOCARG=-alloc
ALLOC=1
fi
fi
;;
esac
shift
done
exec >$EXEDIR/tjbenchtest$YUVARG$ALLOCARG.log
# Standard tests
for image in $IMAGES; do

View File

@@ -33,8 +33,6 @@ if [ -d $OUTDIR ]; then
fi
mkdir -p $OUTDIR
exec >$EXEDIR/tjbenchtest-java.log
if [ $# -gt 0 ]; then
if [ "$1" = "-yuv" ]; then
NSARG=-nosmooth
@@ -60,6 +58,8 @@ if [ $# -gt 0 ]; then
fi
fi
exec >$EXEDIR/tjbenchtest-java$YUVARG.log
# Standard tests
for image in $IMAGES; do

View File

@@ -21,7 +21,7 @@ runme()
IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp"
IMGDIR=@srcdir@/testimages
OUTDIR=__tjexampletest_output
OUTDIR=`mktemp -d /tmp/__tjexampletest_output.XXXXXX`
EXEDIR=.
JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs"
@@ -36,23 +36,23 @@ for image in $IMAGES; do
cp $IMGDIR/$image $OUTDIR
basename=`basename $image .bmp`
$EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_fast_cjpeg.jpg
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_fast_cjpeg.jpg
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_fast_cjpeg.jpg
$EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_fast_cjpeg.jpg
$EXEDIR/cjpeg -quality 95 -dct int -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_accurate_cjpeg.jpg
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_accurate_cjpeg.jpg
$EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_accurate_cjpeg.jpg
runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
for samp in GRAY 420 422 444; do
$EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_djpeg.bmp
$EXEDIR/djpeg -dct fast -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_djpeg.bmp
$EXEDIR/djpeg -dct int -rgb -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_djpeg.bmp
runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_default_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $EXEDIR/djpeg -dct fast -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $EXEDIR/djpeg -dct int -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done
for samp in 420 422; do
$EXEDIR/djpeg -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp
$EXEDIR/djpeg -dct fast -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp
$EXEDIR/djpeg -dct int -nosmooth -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp
runme $EXEDIR/djpeg -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done
# Compression
@@ -87,7 +87,7 @@ for image in $IMAGES; do
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
scalearg=`echo $scale | sed s@_@/@g`
for samp in GRAY 420 422 444; do
$EXEDIR/djpeg -rgb -bmp -scale ${scalearg} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
runme $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${scale}.bmp -scale ${scalearg}
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
rm $OUTDIR/${basename}_${samp}_${scale}.bmp
@@ -96,25 +96,25 @@ for image in $IMAGES; do
# Transforms
for samp in GRAY 420 422 444; do
$EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg
runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
runme $EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
runme $EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
done
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
for samp in GRAY 420 422 444; do
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -crop 16,16,70x60
runme cmp $OUTDIR/${basename}_${samp}_${xform}.jpg $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
$EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
rm $OUTDIR/${basename}_${samp}_${xform}.bmp
done
for samp in 420 422; do
$EXEDIR/djpeg -nosmooth -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
runme $EXEDIR/djpeg -nosmooth -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60 -fastupsample
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
rm $OUTDIR/${basename}_${samp}_${xform}.bmp
@@ -137,7 +137,7 @@ for image in $IMAGES; do
for samp in GRAY 444 422 420; do
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
scalearg=`echo $scale | sed s@_@/@g`
$EXEDIR/djpeg -rgb -bmp -scale ${scalearg} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
runme $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp -$xform -scale ${scalearg} -crop 16,16,70x60
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
rm $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2009-2014 D. R. Commander. All Rights Reserved.
* Copyright (C)2009-2014, 2017 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -44,12 +44,12 @@
void usage(char *progName)
{
printf("\nUSAGE: %s [options]\n", progName);
printf("\nUSAGE: %s [options]\n\n", progName);
printf("Options:\n");
printf("-yuv = test YUV encoding/decoding support\n");
printf("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
printf(" 4-byte boundary\n");
printf("-alloc = test automatic buffer allocation\n");
printf("-alloc = test automatic buffer allocation\n\n");
exit(1);
}
@@ -697,10 +697,9 @@ int main(int argc, char *argv[])
for(i=1; i<argc; i++)
{
if(!strcasecmp(argv[i], "-yuv")) doyuv=1;
if(!strcasecmp(argv[i], "-noyuvpad")) pad=1;
if(!strcasecmp(argv[i], "-alloc")) alloc=1;
if(!strncasecmp(argv[i], "-h", 2) || !strcasecmp(argv[i], "-?"))
usage(argv[0]);
else if(!strcasecmp(argv[i], "-noyuvpad")) pad=1;
else if(!strcasecmp(argv[i], "-alloc")) alloc=1;
else usage(argv[0]);
}
}
if(alloc) printf("Testing automatic buffer allocation\n");

View File

@@ -1,7 +1,5 @@
/*
* Copyright (C)2009-2017 D. R. Commander. All Rights Reserved.
* mozjpeg Modifications:
* Copyright (C) 2014, Mozilla Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -219,14 +217,12 @@ static int setCompDefaults(struct jpeg_compress_struct *cinfo,
}
cinfo->input_components=tjPixelSize[pixelFormat];
if((env=getenv("TJ_REVERT"))!=NULL && strlen(env)>0 && !strcmp(env, "1"))
cinfo->master->compress_profile=JCP_FASTEST;
jpeg_set_defaults(cinfo);
#ifndef NO_GETENV
if((env=getenv("TJ_OPTIMIZE"))!=NULL && strlen(env)>0 && !strcmp(env, "1"))
cinfo->optimize_coding=TRUE;
if((env=getenv("TJ_ARITHMETIC"))!=NULL && strlen(env)>0 && !strcmp(env, "1"))
if((env=getenv("TJ_ARITHMETIC"))!=NULL && strlen(env)>0 && !strcmp(env, "1"))
cinfo->arith_code=TRUE;
if((env=getenv("TJ_RESTART"))!=NULL && strlen(env)>0)
{
@@ -262,10 +258,6 @@ static int setCompDefaults(struct jpeg_compress_struct *cinfo,
jpeg_simple_progression(cinfo);
#endif
/* Set scan pattern again as colorspace might have changed */
if(cinfo->master->compress_profile == JCP_MAX_COMPRESSION)
jpeg_simple_progression(cinfo);
cinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8;
cinfo->comp_info[1].h_samp_factor=1;
cinfo->comp_info[2].h_samp_factor=1;
@@ -798,8 +790,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
cinfo->image_width=width;
@@ -915,8 +906,7 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
cinfo->image_width=width;
@@ -998,8 +988,7 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
for(row=0; row<ph0; row+=cinfo->max_v_samp_factor)
@@ -1116,8 +1105,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
cinfo->image_width=width;
@@ -1179,8 +1167,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
for(row=0; row<(int)cinfo->image_height;
@@ -1412,8 +1399,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
@@ -1464,8 +1450,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
for(i=0; i<(int)dinfo->output_height; i++)
{
@@ -1597,8 +1582,7 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
if(pixelFormat==TJPF_CMYK)
@@ -1692,8 +1676,7 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
for(row=0; row<ph0; row+=dinfo->max_v_samp_factor)
@@ -1797,8 +1780,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
if(!this->headerRead)
@@ -1879,8 +1861,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE;
@@ -2068,8 +2049,7 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
retval=-1;
goto bailout;
retval=-1; goto bailout;
}
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
@@ -2150,10 +2130,6 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
&xinfo[i]);
if(!(t[i].options&TJXOPT_NOOUTPUT))
{
#ifdef C_PROGRESSIVE_SUPPORTED
if (cinfo->num_scans != 0) /* process -progressive; -scans can override */
jpeg_simple_progression(cinfo);
#endif
jpeg_write_coefficients(cinfo, dstcoefs);
jcopy_markers_execute(dinfo, cinfo, JCOPYOPT_ALL);
}

View File

@@ -275,7 +275,6 @@ static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1}
* then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>.
*/
static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1};
/**
* Pixel size (in bytes) for a given pixel format.
*/
@@ -667,7 +666,7 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
* @param jpegQual the image quality of the generated JPEG image (1 = worst,
* 100 = best)
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -731,7 +730,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
* @param jpegQual the image quality of the generated JPEG image (1 = worst,
* 100 = best)
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -801,7 +800,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle,
* @param jpegQual the image quality of the generated JPEG image (1 = worst,
* 100 = best)
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -961,7 +960,7 @@ DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp);
* Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
* image compatible with the I420 (AKA "YUV420P") format.
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -1019,7 +1018,7 @@ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle,
* Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
* image compatible with the I420 (AKA "YUV420P") format.
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -1126,7 +1125,7 @@ DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors);
* @param pixelFormat pixel format of the destination image (see @ref
* TJPF "Pixel formats".)
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -1176,7 +1175,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
* block height (see #tjMCUHeight), then an intermediate buffer copy will be
* performed within TurboJPEG.
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -1232,7 +1231,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
* block height (see #tjMCUHeight), then an intermediate buffer copy will be
* performed within TurboJPEG.
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -1284,7 +1283,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
* @param pixelFormat pixel format of the destination image (see @ref TJPF
* "Pixel formats".)
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -1341,7 +1340,7 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
* @param pixelFormat pixel format of the destination image (see @ref TJPF
* "Pixel formats".)
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
@@ -1415,7 +1414,7 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
* which specifies the transform parameters and/or cropping region for the
* corresponding transformed output image.
*
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
* "flags"
*
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)

View File

@@ -233,7 +233,12 @@ factor will visibly blur the image, however.
Switches for wizards:
-baseline Create baseline JPEG file (disable progressive coding)
-baseline Force baseline-compatible quantization tables to be
generated. This clamps quantization values to 8 bits
even at low quality settings. (This switch is poorly
named, since it does not ensure that the output is
actually baseline JPEG. For example, you can use
-baseline and -progressive together.)
-qtables file Use the quantization tables given in the specified
text file.

10
win/jpeg62-memsrcdst.def Normal file → Executable file
View File

@@ -104,13 +104,3 @@ EXPORTS
jpeg_mem_src @ 103 ;
jpeg_skip_scanlines @ 104 ;
jpeg_crop_scanline @ 105 ;
jpeg_c_bool_param_supported @ 200 ;
jpeg_c_set_bool_param @ 201 ;
jpeg_c_get_bool_param @ 202 ;
jpeg_c_float_param_supported @ 203 ;
jpeg_c_set_float_param @ 204 ;
jpeg_c_get_float_param @ 205 ;
jpeg_c_int_param_supported @ 206 ;
jpeg_c_set_int_param @ 207 ;
jpeg_c_get_int_param @ 208 ;
jpeg_float_quality_scaling @ 1000 ;

10
win/jpeg62.def Normal file → Executable file
View File

@@ -102,13 +102,3 @@ EXPORTS
jzero_far @ 101 ;
jpeg_skip_scanlines @ 102 ;
jpeg_crop_scanline @ 103 ;
jpeg_c_bool_param_supported @ 200 ;
jpeg_c_set_bool_param @ 201 ;
jpeg_c_get_bool_param @ 202 ;
jpeg_c_float_param_supported @ 203 ;
jpeg_c_set_float_param @ 204 ;
jpeg_c_get_float_param @ 205 ;
jpeg_c_int_param_supported @ 206 ;
jpeg_c_set_int_param @ 207 ;
jpeg_c_get_int_param @ 208 ;
jpeg_float_quality_scaling @ 1000 ;

View File

@@ -106,13 +106,3 @@ EXPORTS
jpeg_mem_src @ 105 ;
jpeg_skip_scanlines @ 106 ;
jpeg_crop_scanline @ 107 ;
jpeg_c_bool_param_supported @ 200 ;
jpeg_c_set_bool_param @ 201 ;
jpeg_c_get_bool_param @ 202 ;
jpeg_c_float_param_supported @ 203 ;
jpeg_c_set_float_param @ 204 ;
jpeg_c_get_float_param @ 205 ;
jpeg_c_int_param_supported @ 206 ;
jpeg_c_set_int_param @ 207 ;
jpeg_c_get_int_param @ 208 ;
jpeg_float_quality_scaling @ 1000 ;

View File

@@ -104,13 +104,3 @@ EXPORTS
jzero_far @ 103 ;
jpeg_skip_scanlines @ 104 ;
jpeg_crop_scanline @ 105 ;
jpeg_c_bool_param_supported @ 200 ;
jpeg_c_set_bool_param @ 201 ;
jpeg_c_get_bool_param @ 202 ;
jpeg_c_float_param_supported @ 203 ;
jpeg_c_set_float_param @ 204 ;
jpeg_c_get_float_param @ 205 ;
jpeg_c_int_param_supported @ 206 ;
jpeg_c_set_int_param @ 207 ;
jpeg_c_get_int_param @ 208 ;
jpeg_float_quality_scaling @ 1000 ;

View File

@@ -107,13 +107,3 @@ EXPORTS
jzero_far @ 106 ;
jpeg_skip_scanlines @ 107 ;
jpeg_crop_scanline @ 108 ;
jpeg_c_bool_param_supported @ 200 ;
jpeg_c_set_bool_param @ 201 ;
jpeg_c_get_bool_param @ 202 ;
jpeg_c_float_param_supported @ 203 ;
jpeg_c_set_float_param @ 204 ;
jpeg_c_get_float_param @ 205 ;
jpeg_c_int_param_supported @ 206 ;
jpeg_c_set_int_param @ 207 ;
jpeg_c_get_int_param @ 208 ;
jpeg_float_quality_scaling @ 1000 ;

0
win/jsimdcfg.inc Normal file → Executable file
View File

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited.
* Copyright (C) 2014-2015, D. R. Commander.
* Copyright (C) 2014-2015, 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -70,7 +70,7 @@ LOCAL(void) write_colormap
static INLINE boolean is_big_endian(void)
{
int test_value = 1;
if(*(char *)&test_value != 1)
if (*(char *)&test_value != 1)
return TRUE;
return FALSE;
}
@@ -104,7 +104,7 @@ put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
inptr = dest->pub.buffer[0];
outptr = image_ptr[0];
if(cinfo->out_color_space == JCS_RGB565) {
if (cinfo->out_color_space == JCS_RGB565) {
boolean big_endian = is_big_endian();
unsigned short *inptr2 = (unsigned short *)inptr;
for (col = cinfo->output_width; col > 0; col--) {
@@ -437,6 +437,7 @@ jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
sizeof(bmp_dest_struct));
dest->pub.start_output = start_output_bmp;
dest->pub.finish_output = finish_output_bmp;
dest->pub.calc_buffer_dimensions = NULL;
dest->is_os2 = is_os2;
if (cinfo->out_color_space == JCS_GRAYSCALE) {
@@ -446,7 +447,7 @@ jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
dest->pub.put_pixel_rows = put_gray_rows;
else
dest->pub.put_pixel_rows = put_pixel_rows;
} else if(cinfo->out_color_space == JCS_RGB565 ) {
} else if (cinfo->out_color_space == JCS_RGB565) {
dest->pub.put_pixel_rows = put_pixel_rows;
} else {
ERREXIT(cinfo, JERR_BMP_COLORSPACE);

13
wrgif.c
View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2015, D. R. Commander.
* Copyright (C) 2015, 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -355,6 +355,16 @@ finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
}
/*
* Re-calculate buffer dimensions based on output dimensions.
*/
METHODDEF(void)
calc_buffer_dimensions_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
}
/*
* The module selection routine for GIF format output.
*/
@@ -372,6 +382,7 @@ jinit_write_gif (j_decompress_ptr cinfo)
dest->pub.start_output = start_output_gif;
dest->pub.put_pixel_rows = put_pixel_rows;
dest->pub.finish_output = finish_output_gif;
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_gif;
if (cinfo->out_color_space != JCS_GRAYSCALE &&
cinfo->out_color_space != JCS_RGB)

View File

@@ -247,7 +247,7 @@ copy_variable (void)
if (length < 2)
ERREXIT("Erroneous JPEG marker length");
length -= 2;
/* Skip over the remaining bytes */
/* Copy the remaining bytes */
while (length > 0) {
write_1_byte(read_1_byte());
length--;

38
wrppm.c
View File

@@ -4,8 +4,8 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding.
* It was modified by The libjpeg-turbo Project to include only code and
* information relevant to libjpeg-turbo.
* libjpeg-turbo Modifications:
* Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -20,7 +20,6 @@
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "wrppm.h"
#ifdef PPM_SUPPORTED
@@ -63,6 +62,21 @@
*/
/* Private version of data destination object */
typedef struct {
struct djpeg_dest_struct pub; /* public fields */
/* Usually these two pointers point to the same place: */
char *iobuffer; /* fwrite's I/O buffer */
JSAMPROW pixrow; /* decompressor output buffer */
size_t buffer_width; /* width of I/O buffer */
JDIMENSION samples_per_row; /* JSAMPLEs per output row */
} ppm_dest_struct;
typedef ppm_dest_struct *ppm_dest_ptr;
/*
* Write some pixel data.
* In this module rows_supplied will always be 1.
@@ -196,6 +210,20 @@ finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
}
/*
* Re-calculate buffer dimensions based on output dimensions.
*/
METHODDEF(void)
calc_buffer_dimensions_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
}
/*
* The module selection routine for PPM format output.
*/
@@ -211,13 +239,13 @@ jinit_write_ppm (j_decompress_ptr cinfo)
sizeof(ppm_dest_struct));
dest->pub.start_output = start_output_ppm;
dest->pub.finish_output = finish_output_ppm;
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_ppm;
/* Calculate output image dimensions so we can allocate space */
jpeg_calc_output_dimensions(cinfo);
/* Create physical I/O buffer */
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
dest->pub.calc_buffer_dimensions (cinfo, (djpeg_dest_ptr) dest);
dest->iobuffer = (char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width);

26
wrppm.h
View File

@@ -1,26 +0,0 @@
/*
* wrppm.h
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994, Thomas G. Lane.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*/
#ifdef PPM_SUPPORTED
/* Private version of data destination object */
typedef struct {
struct djpeg_dest_struct pub; /* public fields */
/* Usually these two pointers point to the same place: */
char *iobuffer; /* fwrite's I/O buffer */
JSAMPROW pixrow; /* decompressor output buffer */
size_t buffer_width; /* width of I/O buffer */
JDIMENSION samples_per_row; /* JSAMPLEs per output row */
} ppm_dest_struct;
typedef ppm_dest_struct *ppm_dest_ptr;
#endif

View File

@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code and
* information relevant to libjpeg-turbo.
* libjpeg-turbo Modifications:
* Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -286,6 +286,7 @@ jinit_write_rle (j_decompress_ptr cinfo)
sizeof(rle_dest_struct));
dest->pub.start_output = start_output_rle;
dest->pub.finish_output = finish_output_rle;
dest->pub.calc_buffer_dimensions = NULL;
/* Calculate output image dimensions so we can allocate space */
jpeg_calc_output_dimensions(cinfo);

View File

@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code and
* information relevant to libjpeg-turbo.
* libjpeg-turbo Modifications:
* Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -211,6 +211,19 @@ finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
}
/*
* Re-calculate buffer dimensions based on output dimensions.
*/
METHODDEF(void)
calc_buffer_dimensions_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
tga_dest_ptr dest = (tga_dest_ptr) dinfo;
dest->buffer_width = cinfo->output_width * cinfo->output_components;
}
/*
* The module selection routine for Targa format output.
*/
@@ -226,12 +239,13 @@ jinit_write_targa (j_decompress_ptr cinfo)
sizeof(tga_dest_struct));
dest->pub.start_output = start_output_tga;
dest->pub.finish_output = finish_output_tga;
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_tga;
/* Calculate output image dimensions so we can allocate space */
jpeg_calc_output_dimensions(cinfo);
/* Create I/O buffer. */
dest->buffer_width = cinfo->output_width * cinfo->output_components;
dest->pub.calc_buffer_dimensions (cinfo, (djpeg_dest_ptr) dest);
dest->iobuffer = (char *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) (dest->buffer_width * sizeof(char)));

268
yuvjpeg.c
View File

@@ -1,268 +0,0 @@
/*
* Written by Josh Aas and Tim Terriberry
* Copyright (c) 2013, Mozilla Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the Mozilla Corporation nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Expects 4:2:0 YCbCr */
/* gcc -std=c99 yuvjpeg.c -I/opt/local/include/ -L/opt/local/lib/ -ljpeg -o yuvjpeg */
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "jpeglib.h"
void extend_edge(JSAMPLE *image, int width, int height, unsigned char *yuv,
int luma_width, int luma_height, int chroma_width, int chroma_height) {
int x;
int y;
for (y = 0; y < luma_height; y++) {
for (x = 0; x < luma_width; x++) {
image[width*y + x] = yuv[luma_width*y + x];
}
}
for (y = 0; y < chroma_height; y++) {
for (x = 0; x < chroma_width; x++) {
image[width*height + (width/2)*y + x] =
yuv[luma_width*luma_height + chroma_width*y + x];
image[width*height + (width/2)*((height/2) + y) + x] =
yuv[luma_width*luma_height + chroma_width*(chroma_height + y) + x];
}
}
/* Perform right edge extension. */
for (y = 0; y < luma_height; y++) {
for (x = luma_width; x < width; x++) {
image[width*y + x] = image[width*y + (x - 1)];
}
}
for (y = 0; y < chroma_height; y++) {
for (x = chroma_width; x < width/2; x++) {
image[width*height + (width/2)*y + x] =
image[width*height + (width/2)*y + (x - 1)];
image[width*height + (width/2)*((height/2) + y) + x] =
image[width*height + (width/2)*((height/2) + y) + (x - 1)];
}
}
/* Perform bottom edge extension. */
for (x = 0; x < width; x++) {
for (y = luma_height; y < height; y++) {
image[width*y + x] = image[width*(y - 1) + x];
}
}
for (x = 0; x < width/2; x++) {
for (y = chroma_height; y < height/2; y++) {
image[width*height + (width/2)*y + x] =
image[width*height + (width/2)*(y - 1) + x];
image[width*height + (width/2)*((height/2) + y) + x] =
image[width*height + (width/2)*((height/2) + (y - 1)) + x];
}
}
}
int main(int argc, char *argv[]) {
long quality;
int matches;
int luma_width;
int luma_height;
int chroma_width;
int chroma_height;
int frame_width;
int frame_height;
const char *yuv_path;
const char *jpg_path;
FILE *yuv_fd;
size_t yuv_size;
unsigned char *yuv_buffer;
JSAMPLE *jpg_buffer;
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE *jpg_fd;
JSAMPROW yrow_pointer[16];
JSAMPROW cbrow_pointer[8];
JSAMPROW crrow_pointer[8];
JSAMPROW *plane_pointer[3];
int y;
if (argc != 5) {
fprintf(stderr, "Required arguments:\n");
fprintf(stderr, "1. JPEG quality value, 0-100\n");
fprintf(stderr, "2. Image size (e.g. '512x512')\n");
fprintf(stderr, "3. Path to YUV input file\n");
fprintf(stderr, "4. Path to JPG output file\n");
return 1;
}
errno = 0;
quality = strtol(argv[1], NULL, 10);
if (errno != 0 || quality < 0 || quality > 100) {
fprintf(stderr, "Invalid JPEG quality value!\n");
return 1;
}
matches = sscanf(argv[2], "%dx%d", &luma_width, &luma_height);
if (matches != 2) {
fprintf(stderr, "Invalid image size input!\n");
return 1;
}
if (luma_width <= 0 || luma_height <= 0) {
fprintf(stderr, "Invalid image size input!\n");
return 1;
}
chroma_width = (luma_width + 1) >> 1;
chroma_height = (luma_height + 1) >> 1;
/* Will check these for validity when opening via 'fopen'. */
yuv_path = argv[3];
jpg_path = argv[4];
yuv_fd = fopen(yuv_path, "r");
if (!yuv_fd) {
fprintf(stderr, "Invalid path to YUV file!\n");
return 1;
}
fseek(yuv_fd, 0, SEEK_END);
yuv_size = ftell(yuv_fd);
fseek(yuv_fd, 0, SEEK_SET);
/* Check that the file size matches 4:2:0 yuv. */
if (yuv_size !=
(size_t)luma_width*luma_height + 2*chroma_width*chroma_height) {
fclose(yuv_fd);
fprintf(stderr, "Unexpected input format!\n");
return 1;
}
yuv_buffer = malloc(yuv_size);
if (!yuv_buffer) {
fclose(yuv_fd);
fprintf(stderr, "Memory allocation failure!\n");
return 1;
}
if (fread(yuv_buffer, yuv_size, 1, yuv_fd) != 1) {
fprintf(stderr, "Error reading yuv file\n");
};
fclose(yuv_fd);
frame_width = (luma_width + (16 - 1)) & ~(16 - 1);
frame_height = (luma_height + (16 - 1)) & ~(16 - 1);
jpg_buffer =
malloc(frame_width*frame_height + 2*(frame_width/2)*(frame_height/2));
if (!jpg_buffer) {
free(yuv_buffer);
fprintf(stderr, "Memory allocation failure!\n");
return 1;
}
extend_edge(jpg_buffer, frame_width, frame_height,
yuv_buffer, luma_width, luma_height, chroma_width, chroma_height);
free(yuv_buffer);
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
jpg_fd = fopen(jpg_path, "wb");
if (!jpg_fd) {
free(jpg_buffer);
fprintf(stderr, "Invalid path to JPEG file!\n");
return 1;
}
jpeg_stdio_dest(&cinfo, jpg_fd);
cinfo.image_width = luma_width;
cinfo.image_height = luma_height;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_YCbCr;
jpeg_set_defaults(&cinfo);
cinfo.raw_data_in = TRUE;
cinfo.comp_info[0].h_samp_factor = 2;
cinfo.comp_info[0].v_samp_factor = 2;
cinfo.comp_info[0].dc_tbl_no = 0;
cinfo.comp_info[0].ac_tbl_no = 0;
cinfo.comp_info[0].quant_tbl_no = 0;
cinfo.comp_info[1].h_samp_factor = 1;
cinfo.comp_info[1].v_samp_factor = 1;
cinfo.comp_info[1].dc_tbl_no = 1;
cinfo.comp_info[1].ac_tbl_no = 1;
cinfo.comp_info[1].quant_tbl_no = 1;
cinfo.comp_info[2].h_samp_factor = 1;
cinfo.comp_info[2].v_samp_factor = 1;
cinfo.comp_info[2].dc_tbl_no = 1;
cinfo.comp_info[2].ac_tbl_no = 1;
cinfo.comp_info[2].quant_tbl_no = 1;
jpeg_set_quality(&cinfo, quality, TRUE);
cinfo.optimize_coding = TRUE;
jpeg_start_compress(&cinfo, TRUE);
plane_pointer[0] = yrow_pointer;
plane_pointer[1] = cbrow_pointer;
plane_pointer[2] = crrow_pointer;
while (cinfo.next_scanline < cinfo.image_height) {
int scanline;
scanline = cinfo.next_scanline;
for (y = 0; y < 16; y++) {
yrow_pointer[y] = &jpg_buffer[frame_width*(scanline + y)];
}
for (y = 0; y < 8; y++) {
cbrow_pointer[y] = &jpg_buffer[frame_width*frame_height +
(frame_width/2)*((scanline/2) + y)];
crrow_pointer[y] = &jpg_buffer[frame_width*frame_height +
(frame_width/2)*(frame_height/2) + (frame_width/2)*((scanline/2) + y)];
}
jpeg_write_raw_data(&cinfo, plane_pointer, 16);
}
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
free(jpg_buffer);
fclose(jpg_fd);
return 0;
}