Merge pull request #121 from dcommander/libjpeg-turbo-diff-review

Documentation and code cleanup from DRC
This commit is contained in:
Josh Aas
2014-11-18 17:58:36 -06:00
33 changed files with 715 additions and 834 deletions

View File

@@ -35,21 +35,9 @@ Build Requirements
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 libmozjpeg.
Building libmozjpeg with LLVM-GCC v4.2 results in a 10% performance
degradation when compressing using 64-bit code, relative to building
libmozjpeg with GCC v4.2. Building libmozjpeg with LLVM (clang)
results in a 20% performance degradation when compressing using 64-bit
code, relative to building libmozjpeg 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 through MacPorts.
-- GCC v4.1 (or later) or clang recommended
-- If building the MozJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
-- 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
@@ -64,19 +52,19 @@ 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 libmozjpeg source directory. You
need not necessarily be the same as the mozjpeg source directory. You
can create multiple independent binary directories, in which different versions
of libmozjpeg can be built from the same source tree using different
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 libmozjpeg source
binary directory, whereas {source_directory} refers to the mozjpeg source
directory. For in-tree builds, these directories are the same.
======================
Building libmozjpeg
======================
================
Building mozjpeg
================
The following procedure will build libmozjpeg on Linux, FreeBSD, Cygwin, and
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.)
@@ -86,9 +74,6 @@ for 64-bit build instructions.)
sh {source_directory}/configure [additional configure flags]
make
NOTE: Running autoreconf in the source directory is usually only necessary if
building libmozjpeg from the SVN repository.
This will generate the following files under .libs/
libjpeg.a
@@ -110,28 +95,28 @@ This will generate the following files under .libs/
libjpeg.dll.a (Cygwin)
Import library for the libjpeg API
libmozjpeg.a
Static link library for the MozJPEG API
libturbojpeg.a
Static link library for the TurboJPEG API
libmozjpeg.so.0.0.0 (Linux, Unix)
libmozjpeg.0.0.0.dylib (OS X)
cygmozjpeg-0.dll (Cygwin)
Shared library for the MozJPEG 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
libmozjpeg.so (Linux, Unix)
libmozjpeg.dylib (OS X)
Development symlink for the MozJPEG API
libturbojpeg.so (Linux, Unix)
libturbojpeg.dylib (OS X)
Development symlink for the TurboJPEG API
libmozjpeg.dll.a (Cygwin)
Import library for the MozJPEG 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
libmozjpeg that is API/ABI-compatible with libjpeg v7. Add --with-jpeg8 to
the configure command to build a version of libmozjpeg that is
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.
@@ -140,7 +125,7 @@ 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 libmozjpeg that lacks 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.
@@ -150,7 +135,7 @@ Arithmetic Coding Support
-------------------------
Since the patent on arithmetic coding has expired, this functionality has been
included in this release of libmozjpeg. libmozjpeg's implementation is
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
@@ -158,11 +143,11 @@ add --without-arith-enc or --without-arith-dec to the configure command line to
disable encoding or decoding (respectively.)
MozJPEG Java Wrapper
TurboJPEG Java Wrapper
----------------------
Add --with-java to the configure command line to incorporate an optional Java
Native Interface wrapper into the MozJPEG shared library and build the Java
front-end classes to support it. This allows the MozJPEG shared library to
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
@@ -173,9 +158,9 @@ to specify arguments that should be passed to the C compiler when building the
JNI wrapper. Run 'configure --help' for more details.
========================
Installing libmozjpeg
========================
==================
Installing mozjpeg
==================
If you intend to install these libraries and the associated header files, then
replace 'make' in the instructions above with
@@ -188,16 +173,16 @@ For example,
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/libmozjpeg/include and the library
files in /opt/libmozjpeg/lib32 (32-bit) or /opt/libmozjpeg/lib64
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 libmozjpeg into
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 libmozjpeg instead of libjpeg. See
to force applications to use mozjpeg instead of libjpeg. See
README-turbo.txt for more information.
@@ -284,10 +269,10 @@ Add
CC=cc
to the configure command line. libmozjpeg will automatically be built with
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 libmozjpeg using Oracle Solaris Studio, add
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
@@ -304,19 +289,19 @@ Use CMake (see recipes below)
ARM Support
===========
This release of libmozjpeg can use ARM NEON SIMD instructions to accelerate
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 libmozjpeg is configured on an ARM Linux platform, then the
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 libmozjpeg for iOS
------------------------------
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
libmozjpeg for these platforms.
mozjpeg for these platforms.
Additional build requirements:
@@ -355,7 +340,7 @@ Set the following shell variables for simplicity:
Xcode 5.0.x and later:
IOS_CFLAGS="-arch armv7s"
Follow the procedure under "Building libmozjpeg" above, adding
Follow the procedure under "Building mozjpeg" above, adding
--host arm-apple-darwin10 --enable-static --disable-shared \
CC="$IOS_GCC" LD="$IOS_GCC" \
@@ -375,12 +360,6 @@ the SDK.
Once built, lipo can be used to combine the ARM v6, v7, and/or v7s variants
into a universal library.
NOTE: If you are building libmozjpeg from the "official" project tarball,
then it is highly likely that you will need to run 'autoreconf -fiv' in the
source tree prior to building ARM v7 or v7s iOS binaries using the techniques
described above. Otherwise, you may get a libtool error such as "unable to
infer tagged configuration."
Building libjpeg-turbo for Android
----------------------------------
@@ -440,12 +419,12 @@ Build Requirements
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 libmozjpeg.
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 libmozjpeg from the command line, then add the
* 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
@@ -467,7 +446,7 @@ Build Requirements
-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
a 64-bit build)
-- If building the MozJPEG Java wrapper, JDK 1.5 or later is required. This
-- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
can be downloaded from http://www.java.com.
@@ -477,17 +456,17 @@ 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 libmozjpeg source directory. You can
not necessarily be the same as the mozjpeg source directory. You can
create multiple independent binary directories, in which different versions of
libmozjpeg can be built from the same source tree using different compilers
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 libmozjpeg source
directory, whereas {source_directory} refers to the mozjpeg source
directory. For in-tree builds, these directories are the same.
======================
Building libmozjpeg
======================
================
Building mozjpeg
================
Visual C++ (Command Line)
@@ -497,7 +476,7 @@ Visual C++ (Command Line)
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory}
nmake
This will build either a 32-bit or a 64-bit version of libmozjpeg, depending
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}:
@@ -508,12 +487,12 @@ The following files will be generated under {build_directory}:
DLL for the libjpeg API
sharedlib/jpeg.lib
Import library for the libjpeg API
mozjpeg-static.lib
Static link library for the MozJPEG API
mozjpeg.dll
DLL for the MozJPEG API
mozjpeg.lib
Import library for the MozJPEG 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.
@@ -536,7 +515,7 @@ 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 libmozjpeg.
build of mozjpeg.
This will generate the following files under {build_directory}:
@@ -546,12 +525,12 @@ This will generate the following files under {build_directory}:
DLL for the libjpeg API
sharedlib/{configuration}/jpeg.lib
Import library for the libjpeg API
{configuration}/mozjpeg-static.lib
Static link library for the MozJPEG API
{configuration}/mozjpeg.dll
DLL for the MozJPEG API
{configuration}/mozjpeg.lib
Import library for the MozJPEG 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,
@@ -576,12 +555,12 @@ This will generate the following files under {build_directory}
DLL for the libjpeg API
sharedlib/libjpeg.dll.a
Import library for the libjpeg API
libmozjpeg.a
Static link library for the MozJPEG API
libmozjpeg.dll
DLL for the MozJPEG API
libmozjpeg.dll.a
Import library for the MozJPEG 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.
@@ -599,8 +578,8 @@ libjpeg v7 or v8 API/ABI Emulation
-----------------------------------
Add "-DWITH_JPEG7=1" to the cmake command line to build a version of
libmozjpeg that is API/ABI-compatible with libjpeg v7. Add "-DWITH_JPEG8=1"
to the cmake command to build a version of libmozjpeg that is
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.
@@ -609,7 +588,7 @@ 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 libmozjpeg that lacks 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.
@@ -619,7 +598,7 @@ Arithmetic Coding Support
-------------------------
Since the patent on arithmetic coding has expired, this functionality has been
included in this release of libmozjpeg. libmozjpeg's implementation is
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
@@ -627,11 +606,11 @@ add "-DWITH_ARITH_ENC=0" or "-DWITH_ARITH_DEC=0" to the cmake command line to
disable encoding or decoding (respectively.)
MozJPEG Java Wrapper
TurboJPEG Java Wrapper
----------------------
Add "-DWITH_JAVA=1" to the cmake command line to incorporate an optional Java
Native Interface wrapper into the MozJPEG shared library and build the Java
front-end classes to support it. This allows the MozJPEG shared library to
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,
@@ -642,11 +621,11 @@ 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 libmozjpeg
========================
==================
Installing mozjpeg
==================
You can use the build system to install libmozjpeg into a directory of your
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}
@@ -656,12 +635,12 @@ to the cmake command line.
For example,
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=c:\libmozjpeg {source_directory}
-DCMAKE_INSTALL_PREFIX=c:\mozjpeg {source_directory}
nmake install
will install the header files in c:\libmozjpeg\include, the library files
in c:\libmozjpeg\lib, the DLL's in c:\libmozjpeg\bin, and the
documentation in c:\libmozjpeg\doc.
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.
=============
@@ -679,7 +658,7 @@ Build Recipes
{source_directory}
make
This produces a 64-bit build of libmozjpeg that does not depend on
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.
@@ -694,7 +673,7 @@ mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
{source_directory}
make
This produces a 32-bit build of libmozjpeg that does not depend on
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.
@@ -746,7 +725,7 @@ 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 libmozjpeg, then configure a 64-bit out-of-tree
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
@@ -758,13 +737,13 @@ make iosdmg [BUILDDIR32={32-bit build directory}] \
[BUILDDIRARMV7S={ARM v7s build directory}]
On OS X systems, this creates a Macintosh package and disk image in which the
libmozjpeg static libraries contain ARM architectures necessary to build
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 ARM v6, ARM v7, and/or ARM v7s out-of-tree builds of libmozjpeg
(see "Building libmozjpeg for iOS" above.) If you are building an x86-64
version of libmozjpeg, you should configure a 32-bit out-of-tree build as
well. Next, build libmozjpeg as you would normally, using an out-of-tree
configure ARM v6, ARM v7, and/or ARM v7s 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 ARM v6 build under {source_directory}/iosarmv6
by default, the ARM v7 build under {source_directory}/iosarmv7 by default,
@@ -794,7 +773,7 @@ If using MinGW:
If using the Visual Studio IDE, build the "installer" project.
The installer package (libmozjpeg[-gcc][64].exe) will be located under
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
@@ -808,24 +787,24 @@ Building a Windows installer requires the Nullsoft Install System
** Regression testing
*******************************************************************************
The most common way to test libmozjpeg is by invoking 'make test' on
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 between libmozjpeg and libjpeg v6b. This
also invokes the MozJPEG unit tests, which ensure that the colorspace
extensions, YUV encoding, decompression scaling, and other features of the
MozJPEG C and Java APIs are working properly (and, by extension, that the
equivalent features of the underlying libjpeg API are also working.)
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 MozJPEG C and Java
wrappers can be run by invoking 'make tjtest'. These extended MozJPEG tests
essentially iterate through all of the available features of the MozJPEG APIs
that are not covered by the MozJPEG unit tests (this includes the lossless
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
MozJPEG tests are meant to test for regressions in the MozJPEG wrappers,
TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
not in the underlying libjpeg API library.

View File

@@ -8,7 +8,7 @@ if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif()
project(libmozjpeg C)
project(mozjpeg C)
set(VERSION 2.1)
if(CYGWIN OR NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
@@ -47,8 +47,8 @@ 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 libmozjpeg backward incompatible with libjpeg v6b)" FALSE)
option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes libmozjpeg backward incompatible with libjpeg v6b)" FALSE)
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_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)
@@ -155,7 +155,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 libmozjpeg (default: c:/${CMAKE_INSTALL_PREFIX_DEFAULT})"
"Directory into which to install mozjpeg (default: c:/${CMAKE_INSTALL_PREFIX_DEFAULT})"
FORCE)
endif()
@@ -778,16 +778,16 @@ endif()
STRING(REGEX REPLACE "/" "\\\\" INST_DIR "${CMAKE_INSTALL_PREFIX}")
configure_file(release/libmozjpeg.nsi.in libmozjpeg.nsi @ONLY)
configure_file(release/mozjpeg.nsi.in mozjpeg.nsi @ONLY)
if(WITH_JAVA)
set(JAVA_DEPEND java)
endif()
add_custom_target(installer
makensis -nocd ${INST_DEFS} libmozjpeg.nsi
makensis -nocd ${INST_DEFS} mozjpeg.nsi
DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
cjpeg djpeg jpegtran tjbench ${JAVA_DEPEND}
SOURCES libmozjpeg.nsi)
SOURCES mozjpeg.nsi)
if(WITH_TURBOJPEG)
set(TURBOJPEG_TARGETS turbojpeg turbojpeg-static tjbench)

View File

@@ -132,14 +132,6 @@ compressed JPEG image. If the size of the previous JPEG image was not as large
as the current JPEG image, then TurboJPEG would unnecessarily reallocate the
destination buffer.
[7] Improved the accuracy and performance of the non-SIMD implementation of the
floating point inverse DCT (using code borrowed from libjpeg v8a and later.)
The accuracy of this implementation now matches the accuracy of the SSE/SSE2
implementation. Note, however, that the floating point DCT/IDCT algorithms are
mainly a legacy feature. They generally do not produce significantly better
accuracy than the slow integer DCT/IDCT algorithms, and they are quite a bit
slower.
1.3.1
=====

View File

@@ -2,6 +2,6 @@ Redistribution and use in source and binary forms, with or without modification,
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* 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 libmozjpeg Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
* 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.
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 HOLDERS 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.

View File

@@ -536,26 +536,26 @@ if WITH_JAVA
endif
pkgscripts/libmozjpeg.spec: pkgscripts/libmozjpeg.spec.tmpl
cat pkgscripts/libmozjpeg.spec.tmpl | sed s@%{__prefix}@$(prefix)@g | \
pkgscripts/mozjpeg.spec: pkgscripts/mozjpeg.spec.tmpl
cat pkgscripts/mozjpeg.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/libmozjpeg.spec
> pkgscripts/mozjpeg.spec
rpm: all pkgscripts/libmozjpeg.spec
rpm: all pkgscripts/mozjpeg.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/libmozjpeg.spec; \
--target ${RPMARCH} pkgscripts/mozjpeg.spec; \
cp $$TMPDIR/RPMS/${RPMARCH}/${PKGNAME}-${VERSION}-${BUILD}.${RPMARCH}.rpm \
${PKGNAME}-${VERSION}.${RPMARCH}.rpm; \
rm -rf $$TMPDIR
srpm: dist-gzip pkgscripts/libmozjpeg.spec
srpm: dist-gzip pkgscripts/mozjpeg.spec
TMPDIR=`mktemp -d /tmp/${PACKAGE_NAME}-build.XXXXXX`; \
mkdir -p $$TMPDIR/RPMS; \
mkdir -p $$TMPDIR/SRPMS; \
@@ -564,10 +564,10 @@ srpm: dist-gzip pkgscripts/libmozjpeg.spec
mkdir -p $$TMPDIR/SPECS; \
rm -f ${PKGNAME}-${VERSION}.src.rpm; \
cp ${PACKAGE_NAME}-${VERSION}.tar.gz $$TMPDIR/SOURCES; \
cat pkgscripts/libmozjpeg.spec | sed s/%{_blddir}/%{_tmppath}/g \
cat pkgscripts/mozjpeg.spec | sed s/%{_blddir}/%{_tmppath}/g \
| sed s/#--\>//g \
> $$TMPDIR/SPECS/libmozjpeg.spec; \
rpmbuild -bs --define "_topdir $$TMPDIR" $$TMPDIR/SPECS/libmozjpeg.spec; \
> $$TMPDIR/SPECS/mozjpeg.spec; \
rpmbuild -bs --define "_topdir $$TMPDIR" $$TMPDIR/SPECS/mozjpeg.spec; \
cp $$TMPDIR/SRPMS/${PKGNAME}-${VERSION}-${BUILD}.src.rpm \
${PKGNAME}-${VERSION}.src.rpm; \
rm -rf $$TMPDIR

View File

@@ -13,12 +13,12 @@
* cjpeg and djpeg. It is NOT used by the core JPEG library.
*/
#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h" /* get library error codes too */
#include "cderror.h" /* get application-specific error codes */
#include "jerror.h" /* get library error codes too */
#include "cderror.h" /* get application-specific error codes */
#define JPEG_RAW_READER 0
@@ -85,9 +85,9 @@ struct djpeg_dest_struct {
*/
struct cdjpeg_progress_mgr {
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
int completed_extra_passes; /* extra passes completed */
int total_extra_passes; /* total extra */
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
int completed_extra_passes; /* extra passes completed */
int total_extra_passes; /* total extra */
/* last printed percentage stored here to avoid multiple printouts */
int percent_done;
};
@@ -137,15 +137,15 @@ EXTERN(FILE *) write_stdout (void);
/* miscellaneous useful macros */
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
#define READ_BINARY "r"
#define WRITE_BINARY "w"
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
#define READ_BINARY "r"
#define WRITE_BINARY "w"
#else
#define READ_BINARY "rb"
#define WRITE_BINARY "wb"
#define READ_BINARY "rb"
#define WRITE_BINARY "wb"
#endif
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
#define EXIT_FAILURE 1
#endif
#ifndef EXIT_SUCCESS

21
cjpeg.c
View File

@@ -294,7 +294,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "dct", 2)) {
/* Select DCT algorithm. */
if (++argn >= argc) { /* advance to next argument */
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for dct\n", progname);
usage();
}
@@ -340,14 +340,14 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
jpeg_set_colorspace(cinfo, JCS_RGB);
} else if (keymatch(arg, "lambda1", 7)) {
if (++argn >= argc) /* advance to next argument */
usage();
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();
if (++argn >= argc) /* advance to next argument */
usage();
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2,
atof(argv[argn]));
@@ -379,7 +379,7 @@ 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 */
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for outfile\n", progname);
usage();
}
@@ -408,7 +408,7 @@ 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 */
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for quality\n", progname);
usage();
}
@@ -743,7 +743,7 @@ main (int argc, char **argv)
GETJOCTET(marker->data[2]) == 0x49 &&
GETJOCTET(marker->data[3]) == 0x46 &&
GETJOCTET(marker->data[4]) == 0)
continue; /* reject duplicate JFIF */
continue; /* reject duplicate JFIF */
if (cinfo.write_Adobe_marker &&
marker->marker == JPEG_APP0+14 &&
marker->data_length >= 5 &&
@@ -752,8 +752,9 @@ main (int argc, char **argv)
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);
continue; /* reject duplicate Adobe */
jpeg_write_marker(&cinfo, marker->marker, marker->data,
marker->data_length);
}
}

View File

@@ -2,12 +2,12 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.56])
AC_INIT([libmozjpeg], [2.1])
AC_INIT([mozjpeg], [2.1])
BUILD=`date +%Y%m%d`
AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
AC_PREFIX_DEFAULT(/opt/libmozjpeg)
AC_PREFIX_DEFAULT(/opt/mozjpeg)
# Checks for programs.
SAVED_CFLAGS=${CFLAGS}
@@ -22,7 +22,7 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LIBTOOL
AC_PROG_LN_S
# When the prefix is /opt/libmozjpeg, we assume that an "official" binary is
# When the prefix is /opt/mozjpeg, we assume that an "official" binary is
# being created, and thus we install things into specific locations.
old_prefix=${prefix}
@@ -31,12 +31,12 @@ if test "x$prefix" = "xNONE" -a "x$ac_default_prefix" != "x"; then
fi
DATADIR=`eval echo ${datadir}`
DATADIR=`eval echo $DATADIR`
if test "$DATADIR" = "/opt/libmozjpeg/share"; then
if test "$DATADIR" = "/opt/mozjpeg/share"; then
datadir='${prefix}'
fi
DATADIR=`eval echo ${datarootdir}`
DATADIR=`eval echo $DATADIR`
if test "$DATADIR" = "/opt/libmozjpeg/share"; then
if test "$DATADIR" = "/opt/mozjpeg/share"; then
datarootdir='${prefix}'
fi
@@ -48,7 +48,7 @@ fi
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/libmozjpeg/lib"; then
if test "$LIBDIR" = "/opt/mozjpeg/lib"; then
case $host_os in
darwin*)
;;
@@ -149,10 +149,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 libmozjpeg backward incompatible with libjpeg v6b.)]))
[Emulate libjpeg v7 API/ABI (this makes mozjpeg backward incompatible with libjpeg v6b.)]))
AC_ARG_WITH([jpeg8],
AC_HELP_STRING([--with-jpeg8],
[Emulate libjpeg v8 API/ABI (this makes libmozjpeg backward incompatible with libjpeg v6b.)]))
[Emulate libjpeg v8 API/ABI (this makes mozjpeg backward incompatible with libjpeg v6b.)]))
if test "x${with_jpeg8}" = "xyes"; then
JPEG_LIB_VERSION=80
else
@@ -170,9 +170,9 @@ AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION],
[libjpeg API version])
AC_ARG_VAR(SO_MAJOR_VERSION,
[Major version of the libmozjpeg shared library (default is determined by the API version)])
[Major version of the mozjpeg shared library (default is determined by the API version)])
AC_ARG_VAR(SO_MINOR_VERSION,
[Minor version of the libmozjpeg shared library (default is determined by the API version)])
[Minor version of the mozjpeg 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 ;;
@@ -217,12 +217,12 @@ AC_SUBST(SO_MINOR_VERSION)
AC_SUBST(SO_AGE)
AC_SUBST(MEM_SRCDST_FUNCTIONS)
AC_DEFINE_UNQUOTED(LIBMOZJPEG_VERSION, [$VERSION], [libmozjpeg version])
AC_DEFINE_UNQUOTED(MOZJPEG_VERSION, [$VERSION], [mozjpeg version])
VERSION_SCRIPT=yes
AC_ARG_ENABLE([ld-version-script],
AS_HELP_STRING([--disable-ld-version-script],
[Disable linker version script for libmozjpeg (default is to use linker version script if the linker supports it)]),
[Disable linker version script for mozjpeg (default is to use linker version script if the linker supports it)]),
[VERSION_SCRIPT=$enableval], [])
AC_MSG_CHECKING([whether the linker supports version scripts])
@@ -250,7 +250,7 @@ if test "x$VERSION_SCRIPT_FLAG" = "x"; then
fi
LDFLAGS="$SAVED_LDFLAGS"
AC_MSG_CHECKING([whether to use version script when building libmozjpeg])
AC_MSG_CHECKING([whether to use version script when building mozjpeg])
AC_MSG_RESULT($VERSION_SCRIPT)
AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
@@ -520,7 +520,7 @@ AM_CONDITIONAL([SIMD_POWERPC], [test "x$simd_arch" = "xpowerpc"])
AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
AC_ARG_VAR(PKGNAME, [distribution package name (default: libmozjpeg)])
AC_ARG_VAR(PKGNAME, [distribution package name (default: mozjpeg)])
if test "x$PKGNAME" = "x"; then
PKGNAME=$PACKAGE_NAME
fi
@@ -551,7 +551,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/libmozjpeg.spec.tmpl:release/libmozjpeg.spec.in])
AC_CONFIG_FILES([pkgscripts/mozjpeg.spec.tmpl:release/mozjpeg.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

@@ -19,6 +19,7 @@
#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
* step is run during the first pass, and subsequent passes need only read
@@ -190,7 +191,8 @@ 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,
NULL);
if (blockcnt < compptr->MCU_width) {
/* Create some dummy blocks at the right edge of the image. */
jzero_far((void *) coef->MCU_buffer[blkn + blockcnt],
@@ -302,7 +304,8 @@ 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,
buffer_dst[block_row]);
if (ndummy > 0) {
/* Create dummy blocks at the right edge of the image. */
thisblockrow += blocks_across; /* => first dummy block */
@@ -410,13 +413,13 @@ compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
&lastDC);
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;
}
/* 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.
@@ -425,22 +428,22 @@ compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
* 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 */
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;
}
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;
}
}
}
}
@@ -503,7 +506,6 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
}
}
}
/* Try to write the MCU. */
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
/* Suspension forced; update state counters and exit */

View File

@@ -25,6 +25,7 @@
#include <assert.h>
#include <math.h>
/* Private subobject for this module */
typedef void (*forward_DCT_method_ptr) (DCTELEM * data);
@@ -663,7 +664,7 @@ METHODDEF(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, JBLOCKROW dst)
/* This version is used for integer DCT implementations. */
{
/* This routine is heavily used, so it's worth coding it tightly. */
@@ -697,17 +698,17 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
if (dst) {
int i;
if (cinfo->dct_method == JDCT_IFAST) {
static const INT16 aanscales[DCTSIZE2] = {
/* precomputed values scaled up by 14 bits */
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
static const INT16 aanscales[DCTSIZE2] = {
/* precomputed values scaled up by 14 bits */
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,
4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247
};
};
for (i = 0; i < DCTSIZE2; i++) {
int x = workspace[i];
@@ -789,7 +790,7 @@ METHODDEF(void)
forward_DCT_float (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, JBLOCKROW dst)
/* This version is used for floating-point DCT implementations. */
{
/* This routine is heavily used, so it's worth coding it tightly. */

View File

@@ -29,8 +29,8 @@
/* Derived data constructed for each Huffman table */
typedef struct {
unsigned int ehufco[256]; /* code for each symbol */
char ehufsi[256]; /* length of code for each symbol */
unsigned int ehufco[256]; /* code for each symbol */
char ehufsi[256]; /* length of code for each symbol */
/* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
} c_derived_tbl;

View File

@@ -17,7 +17,7 @@
#include "jpegcomp.h"
typedef enum { /* JPEG marker codes */
typedef enum { /* JPEG marker codes */
M_SOF0 = 0xc0,
M_SOF1 = 0xc1,
M_SOF2 = 0xc2,
@@ -173,7 +173,7 @@ emit_dqt (j_compress_ptr cinfo, int index)
/* The table entries must be emitted in zigzag order. */
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
if (prec)
emit_byte(cinfo, (int) (qval >> 8));
emit_byte(cinfo, (int) (qval >> 8));
emit_byte(cinfo, (int) (qval & 0xFF));
}
@@ -256,7 +256,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
if (is_ac) {
htbl = cinfo->ac_huff_tbl_ptrs[index];
index += 0x10; /* output index has AC bit set */
index += 0x10; /* output index has AC bit set */
} else {
htbl = cinfo->dc_huff_tbl_ptrs[index];
}
@@ -427,12 +427,12 @@ emit_dac (j_compress_ptr cinfo)
for (i = 0; i < NUM_ARITH_TBLS; i++) {
if (dc_in_use[i]) {
emit_byte(cinfo, i);
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
emit_byte(cinfo, i);
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
}
if (ac_in_use[i]) {
emit_byte(cinfo, i + 0x10);
emit_byte(cinfo, cinfo->arith_ac_K[i]);
emit_byte(cinfo, i + 0x10);
emit_byte(cinfo, cinfo->arith_ac_K[i]);
}
}
}
@@ -446,7 +446,7 @@ emit_dri (j_compress_ptr cinfo)
{
emit_marker(cinfo, M_DRI);
emit_2bytes(cinfo, 4); /* fixed length */
emit_2bytes(cinfo, 4); /* fixed length */
emit_2bytes(cinfo, (int) cinfo->restart_interval);
}
@@ -523,22 +523,22 @@ emit_jfif_app0 (j_compress_ptr cinfo)
/* Emit a JFIF-compliant APP0 marker */
{
/*
* Length of APP0 block (2 bytes)
* Block ID (4 bytes - ASCII "JFIF")
* Zero byte (1 byte to terminate the ID string)
* Version Major, Minor (2 bytes - major first)
* Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
* Xdpu (2 bytes - dots per unit horizontal)
* Ydpu (2 bytes - dots per unit vertical)
* Thumbnail X size (1 byte)
* Thumbnail Y size (1 byte)
* Length of APP0 block (2 bytes)
* Block ID (4 bytes - ASCII "JFIF")
* Zero byte (1 byte to terminate the ID string)
* Version Major, Minor (2 bytes - major first)
* Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
* Xdpu (2 bytes - dots per unit horizontal)
* Ydpu (2 bytes - dots per unit vertical)
* Thumbnail X size (1 byte)
* Thumbnail Y size (1 byte)
*/
emit_marker(cinfo, M_APP0);
emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
emit_byte(cinfo, 0x46);
emit_byte(cinfo, 0x49);
emit_byte(cinfo, 0x46);
@@ -548,7 +548,7 @@ emit_jfif_app0 (j_compress_ptr cinfo)
emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
emit_2bytes(cinfo, (int) cinfo->X_density);
emit_2bytes(cinfo, (int) cinfo->Y_density);
emit_byte(cinfo, 0); /* No thumbnail image */
emit_byte(cinfo, 0); /* No thumbnail image */
emit_byte(cinfo, 0);
}
@@ -558,12 +558,12 @@ emit_adobe_app14 (j_compress_ptr cinfo)
/* Emit an Adobe APP14 marker */
{
/*
* Length of APP14 block (2 bytes)
* Block ID (5 bytes - ASCII "Adobe")
* Version Number (2 bytes - currently 100)
* Flags0 (2 bytes - currently 0)
* Flags1 (2 bytes - currently 0)
* Color transform (1 byte)
* Length of APP14 block (2 bytes)
* Block ID (5 bytes - ASCII "Adobe")
* Version Number (2 bytes - currently 100)
* Flags0 (2 bytes - currently 0)
* Flags1 (2 bytes - currently 0)
* Color transform (1 byte)
*
* Although Adobe TN 5116 mentions Version = 101, all the Adobe files
* now in circulation seem to use Version = 100, so that's what we write.
@@ -577,23 +577,23 @@ emit_adobe_app14 (j_compress_ptr cinfo)
emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
emit_byte(cinfo, 0x64);
emit_byte(cinfo, 0x6F);
emit_byte(cinfo, 0x62);
emit_byte(cinfo, 0x65);
emit_2bytes(cinfo, 100); /* Version */
emit_2bytes(cinfo, 0); /* Flags0 */
emit_2bytes(cinfo, 0); /* Flags1 */
emit_2bytes(cinfo, 100); /* Version */
emit_2bytes(cinfo, 0); /* Flags0 */
emit_2bytes(cinfo, 0); /* Flags1 */
switch (cinfo->jpeg_color_space) {
case JCS_YCbCr:
emit_byte(cinfo, 1); /* Color transform = 1 */
emit_byte(cinfo, 1); /* Color transform = 1 */
break;
case JCS_YCCK:
emit_byte(cinfo, 2); /* Color transform = 2 */
emit_byte(cinfo, 2); /* Color transform = 2 */
break;
default:
emit_byte(cinfo, 0); /* Color transform = 0 */
emit_byte(cinfo, 0); /* Color transform = 0 */
break;
}
}
@@ -611,12 +611,12 @@ METHODDEF(void)
write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
/* Emit an arbitrary marker header */
{
if (datalen > (unsigned int) 65533) /* safety check */
if (datalen > (unsigned int) 65533) /* safety check */
ERREXIT(cinfo, JERR_BAD_LENGTH);
emit_marker(cinfo, (JPEG_MARKER) marker);
emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
}
METHODDEF(void)
@@ -643,12 +643,12 @@ write_file_header (j_compress_ptr cinfo)
{
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
emit_marker(cinfo, M_SOI); /* first the SOI */
emit_marker(cinfo, M_SOI); /* first the SOI */
/* SOI is defined to reset restart interval to 0 */
marker->last_restart_interval = 0;
if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
emit_jfif_app0(cinfo);
if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
emit_adobe_app14(cinfo);
@@ -692,9 +692,9 @@ write_frame_header (j_compress_ptr cinfo)
} else {
is_baseline = TRUE;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
ci++, compptr++) {
if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
is_baseline = FALSE;
is_baseline = FALSE;
}
if (prec && is_baseline) {
is_baseline = FALSE;
@@ -711,11 +711,11 @@ write_frame_header (j_compress_ptr cinfo)
emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */
} else {
if (cinfo->progressive_mode)
emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
else if (is_baseline)
emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
else
emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
}
}
@@ -801,9 +801,9 @@ write_tables_only (j_compress_ptr cinfo)
if (! cinfo->arith_code) {
for (i = 0; i < NUM_HUFF_TBLS; i++) {
if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
emit_dht(cinfo, i, FALSE);
emit_dht(cinfo, i, FALSE);
if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
emit_dht(cinfo, i, TRUE);
emit_dht(cinfo, i, TRUE);
}
}

View File

@@ -26,21 +26,21 @@
/* 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 */
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 */
struct jpeg_comp_master pub; /* public fields */
c_pass_type pass_type; /* the type of the current pass */
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 pass_number; /* # of passes completed */
int total_passes; /* total # of passes needed */
int scan_number; /* current index in scan_info[] */
int scan_number; /* current index in scan_info[] */
/* fields for scan optimisation */
int pass_number_scan_opt_base; /* pass number where scan optimization begins */
@@ -122,7 +122,7 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
/* Check that number of components won't exceed internal array sizes */
if (cinfo->num_components > MAX_COMPONENTS)
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
MAX_COMPONENTS);
MAX_COMPONENTS);
/* Compute maximum sampling factors; check factor validity */
cinfo->max_h_samp_factor = 1;
@@ -130,12 +130,12 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
ERREXIT(cinfo, JERR_BAD_SAMPLING);
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
compptr->h_samp_factor);
compptr->h_samp_factor);
cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
compptr->v_samp_factor);
compptr->v_samp_factor);
}
/* Compute dimensions of components */
@@ -152,17 +152,17 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
/* Size in DCT blocks */
compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
(long) (cinfo->max_h_samp_factor * DCTSIZE));
(long) (cinfo->max_h_samp_factor * DCTSIZE));
compptr->height_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
(long) (cinfo->max_v_samp_factor * DCTSIZE));
(long) (cinfo->max_v_samp_factor * DCTSIZE));
/* Size in samples */
compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
(long) cinfo->max_h_samp_factor);
(long) cinfo->max_h_samp_factor);
compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
(long) cinfo->max_v_samp_factor);
(long) cinfo->max_v_samp_factor);
/* Mark component needed (this flag isn't actually used for compression) */
compptr->component_needed = TRUE;
}
@@ -172,7 +172,7 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
*/
cinfo->total_iMCU_rows = (JDIMENSION)
jdiv_round_up((long) cinfo->_jpeg_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE));
(long) (cinfo->max_v_samp_factor*DCTSIZE));
}
@@ -215,7 +215,7 @@ validate_script (j_compress_ptr cinfo)
last_bitpos_ptr = & last_bitpos[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (coefi = 0; coefi < DCTSIZE2; coefi++)
*last_bitpos_ptr++ = -1;
*last_bitpos_ptr++ = -1;
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
@@ -233,10 +233,10 @@ validate_script (j_compress_ptr cinfo)
for (ci = 0; ci < ncomps; ci++) {
thisi = scanptr->component_index[ci];
if (thisi < 0 || thisi >= cinfo->num_components)
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
/* Components must appear in SOF order within each scan */
if (ci > 0 && thisi <= scanptr->component_index[ci-1])
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
}
/* Validate progression parameters */
Ss = scanptr->Ss;
@@ -258,43 +258,43 @@ validate_script (j_compress_ptr cinfo)
#define MAX_AH_AL 13
#endif
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
if (Ss == 0) {
if (Se != 0) /* DC and AC together not OK */
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
if (Se != 0) /* DC and AC together not OK */
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
} else {
if (ncomps != 1) /* AC scans must be for only one component */
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
if (ncomps != 1) /* AC scans must be for only one component */
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
}
for (ci = 0; ci < ncomps; ci++) {
last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
for (coefi = Ss; coefi <= Se; coefi++) {
if (last_bitpos_ptr[coefi] < 0) {
/* first scan of this coefficient */
if (Ah != 0)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
} else {
/* not first scan */
if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
}
last_bitpos_ptr[coefi] = Al;
}
last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
for (coefi = Ss; coefi <= Se; coefi++) {
if (last_bitpos_ptr[coefi] < 0) {
/* first scan of this coefficient */
if (Ah != 0)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
} else {
/* not first scan */
if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
}
last_bitpos_ptr[coefi] = Al;
}
}
#endif
} else {
/* For sequential JPEG, all progression parameters must be these: */
if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
/* Make sure components are not sent twice */
for (ci = 0; ci < ncomps; ci++) {
thisi = scanptr->component_index[ci];
if (component_sent[thisi])
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
component_sent[thisi] = TRUE;
thisi = scanptr->component_index[ci];
if (component_sent[thisi])
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
component_sent[thisi] = TRUE;
}
}
}
@@ -309,13 +309,13 @@ validate_script (j_compress_ptr cinfo)
*/
for (ci = 0; ci < cinfo->num_components; ci++) {
if (last_bitpos[ci][0] < 0)
ERREXIT(cinfo, JERR_MISSING_DATA);
ERREXIT(cinfo, JERR_MISSING_DATA);
}
#endif
} else {
for (ci = 0; ci < cinfo->num_components; ci++) {
if (! component_sent[ci])
ERREXIT(cinfo, JERR_MISSING_DATA);
ERREXIT(cinfo, JERR_MISSING_DATA);
}
}
}
@@ -356,7 +356,7 @@ select_scan_parameters (j_compress_ptr cinfo)
cinfo->comps_in_scan = scanptr->comps_in_scan;
for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
cinfo->cur_comp_info[ci] =
&cinfo->comp_info[scanptr->component_index[ci]];
&cinfo->comp_info[scanptr->component_index[ci]];
}
cinfo->Ss = scanptr->Ss;
cinfo->Se = scanptr->Se;
@@ -384,7 +384,7 @@ select_scan_parameters (j_compress_ptr cinfo)
/* Prepare for single sequential-JPEG scan containing all components */
if (cinfo->num_components > MAX_COMPS_IN_SCAN)
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
MAX_COMPS_IN_SCAN);
MAX_COMPS_IN_SCAN);
cinfo->comps_in_scan = cinfo->num_components;
for (ci = 0; ci < cinfo->num_components; ci++) {
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
@@ -436,15 +436,15 @@ per_scan_setup (j_compress_ptr cinfo)
/* Interleaved (multi-component) scan */
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
MAX_COMPS_IN_SCAN);
MAX_COMPS_IN_SCAN);
/* Overall image size in MCUs */
cinfo->MCUs_per_row = (JDIMENSION)
jdiv_round_up((long) cinfo->_jpeg_width,
(long) (cinfo->max_h_samp_factor*DCTSIZE));
(long) (cinfo->max_h_samp_factor*DCTSIZE));
cinfo->MCU_rows_in_scan = (JDIMENSION)
jdiv_round_up((long) cinfo->_jpeg_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE));
(long) (cinfo->max_v_samp_factor*DCTSIZE));
cinfo->blocks_in_MCU = 0;
@@ -465,9 +465,9 @@ per_scan_setup (j_compress_ptr cinfo)
/* Prepare array describing MCU composition */
mcublks = compptr->MCU_blocks;
if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
while (mcublks-- > 0) {
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
}
}
@@ -512,8 +512,8 @@ prepare_for_pass (j_compress_ptr cinfo)
(*cinfo->fdct->start_pass) (cinfo);
(*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
(*cinfo->coef->start_pass) (cinfo,
(master->total_passes > 1 ?
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
(master->total_passes > 1 ?
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
(*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
if (cinfo->optimize_coding) {
/* No immediate data output; postpone writing frame/scan headers */
@@ -946,7 +946,7 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
cinfo->num_scans = 1;
}
if (cinfo->progressive_mode && !cinfo->arith_code) /* TEMPORARY HACK ??? */
if (cinfo->progressive_mode && !cinfo->arith_code) /* TEMPORARY HACK ??? */
cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */
/* Initialize my private state */

View File

@@ -78,10 +78,10 @@
/* Define "boolean" as unsigned char, not int, on Windows systems.
*/
#ifdef _WIN32
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#endif
@@ -114,12 +114,12 @@ 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 */
#undef RLE_SUPPORTED /* Utah RLE image file format */
#define TARGA_SUPPORTED /* Targa image file format */
#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 */
#undef RLE_SUPPORTED /* Utah RLE image file format */
#define TARGA_SUPPORTED /* Targa image file format */
/* Define this if you want to name both input and output files on the command
* line, rather than using stdout and optionally stdin. You MUST do this if

101
jcparam.c
View File

@@ -117,11 +117,11 @@ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
jpeg_add_quant_table(cinfo, 1, flat_quant_tbl,
cinfo->q_scale_factor[1], force_baseline);
} else {
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
cinfo->q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
cinfo->q_scale_factor[1], force_baseline);
}
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
cinfo->q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
cinfo->q_scale_factor[1], force_baseline);
}
}
#endif
@@ -142,11 +142,11 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
jpeg_add_quant_table(cinfo, 1, flat_quant_tbl,
scale_factor, force_baseline);
} else {
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
scale_factor, force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
scale_factor, force_baseline);
}
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
scale_factor, force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
scale_factor, force_baseline);
}
}
@@ -249,9 +249,9 @@ jpeg_set_defaults (j_compress_ptr cinfo)
cinfo->scan_info = NULL;
cinfo->num_scans = 0;
if (!cinfo->master->use_moz_defaults) {
/* Default is no multiple-scan output */
cinfo->scan_info = NULL;
cinfo->num_scans = 0;
/* Default is no multiple-scan output */
cinfo->scan_info = NULL;
cinfo->num_scans = 0;
}
#else
/* Default is no multiple-scan output */
@@ -270,8 +270,8 @@ jpeg_set_defaults (j_compress_ptr cinfo)
/* 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;
/* 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;
@@ -494,7 +494,7 @@ fill_a_scan (jpeg_scan_info * scanptr, int ci,
LOCAL(jpeg_scan_info *)
fill_a_scan_pair (jpeg_scan_info * scanptr, int ci,
int Ss, int Se, int Ah, int Al)
int Ss, int Se, int Ah, int Al)
/* Support routine: generate one scan for pair of components */
{
scanptr->comps_in_scan = 2;
@@ -705,16 +705,16 @@ jpeg_simple_progression (j_compress_ptr cinfo)
} else {
/* All-purpose script for other color spaces. */
if (cinfo->master->use_moz_defaults == TRUE) {
if (ncomps > MAX_COMPS_IN_SCAN)
nscans = 5 * ncomps; /* 2 DC + 4 AC scans per component */
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 */
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 */
}
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.
@@ -764,23 +764,23 @@ jpeg_simple_progression (j_compress_ptr cinfo)
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);
/* Chroma data is too small to be worth expending many scans on */
scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);
scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);
/* Complete spectral selection for luma AC */
scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);
/* Refine next bit of luma AC */
scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
/* Finish DC successive approximation */
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
/* Finish AC successive approximation */
scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
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);
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);
/* Chroma data is too small to be worth expending many scans on */
scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);
scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);
/* Complete spectral selection for luma AC */
scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);
/* Refine next bit of luma AC */
scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
/* Finish DC successive approximation */
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
/* Finish AC successive approximation */
scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
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. */
@@ -788,7 +788,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
/* 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 */
/* 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 */
@@ -797,17 +797,16 @@ jpeg_simple_progression (j_compress_ptr cinfo)
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);
/* Successive approximation second pass */
scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
/* Successive approximation final pass */
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
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);
/* Successive approximation second pass */
scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
/* Successive approximation final pass */
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
}
}
}
}
#endif /* C_PROGRESSIVE_SUPPORTED */

View File

@@ -177,7 +177,7 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
int i, j;
for (i = 0; i < 16; i++)
for (j = 0; j < 12; j++)
entropy->count_ptrs[tbl][16*i+j] = 1;
entropy->count_ptrs[tbl][16 * i + j] = 1;
}
} else {
/* Compute derived values for Huffman table */

View File

@@ -23,9 +23,8 @@ 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 */
JBUF_REQUANT /* Requantize */
} J_BUF_MODE;
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */

410
jpeglib.h
View File

@@ -25,10 +25,10 @@
* manual configuration options that most people need not worry about.
*/
#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
#include "jconfig.h" /* widely used configuration options */
#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
#include "jconfig.h" /* widely used configuration options */
#endif
#include "jmorecfg.h" /* seldom changed options */
#include "jmorecfg.h" /* seldom changed options */
#ifdef __cplusplus
@@ -43,13 +43,13 @@ extern "C" {
* if you want to be compatible.
*/
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
* the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
* If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
@@ -67,13 +67,13 @@ extern "C" {
*/
typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
@@ -88,13 +88,13 @@ typedef struct {
* (not the zigzag order in which they are stored in a JPEG DQT marker).
* CAUTION: IJG versions prior to v6a kept this array in zigzag order.
*/
UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
/* This field is used only during compression. It's initialized FALSE when
* the table is created, and set TRUE when it's been output to the file.
* You could suppress output of a table by setting this to TRUE.
* (See jpeg_suppress_tables for an example.)
*/
boolean sent_table; /* TRUE when table has been output */
boolean sent_table; /* TRUE when table has been output */
} JQUANT_TBL;
@@ -102,15 +102,15 @@ typedef struct {
typedef struct {
/* These two fields directly represent the contents of a JPEG DHT marker */
UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
/* length k bits; bits[0] is unused */
UINT8 huffval[256]; /* The symbols, in order of incr code length */
UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
/* length k bits; bits[0] is unused */
UINT8 huffval[256]; /* The symbols, in order of incr code length */
/* This field is used only during compression. It's initialized FALSE when
* the table is created, and set TRUE when it's been output to the file.
* You could suppress output of a table by setting this to TRUE.
* (See jpeg_suppress_tables for an example.)
*/
boolean sent_table; /* TRUE when table has been output */
boolean sent_table; /* TRUE when table has been output */
} JHUFF_TBL;
@@ -120,17 +120,17 @@ typedef struct {
/* These values are fixed over the whole image. */
/* For compression, they must be supplied by parameter setup; */
/* for decompression, they are read from the SOF marker. */
int component_id; /* identifier for this component (0..255) */
int component_index; /* its index in SOF or cinfo->comp_info[] */
int h_samp_factor; /* horizontal sampling factor (1..4) */
int v_samp_factor; /* vertical sampling factor (1..4) */
int quant_tbl_no; /* quantization table selector (0..3) */
int component_id; /* identifier for this component (0..255) */
int component_index; /* its index in SOF or cinfo->comp_info[] */
int h_samp_factor; /* horizontal sampling factor (1..4) */
int v_samp_factor; /* vertical sampling factor (1..4) */
int quant_tbl_no; /* quantization table selector (0..3) */
/* These values may vary between scans. */
/* For compression, they must be supplied by parameter setup; */
/* for decompression, they are read from the SOS marker. */
/* The decompressor output side may not use these variables. */
int dc_tbl_no; /* DC entropy table selector (0..3) */
int ac_tbl_no; /* AC entropy table selector (0..3) */
int dc_tbl_no; /* DC entropy table selector (0..3) */
int ac_tbl_no; /* AC entropy table selector (0..3) */
/* Remaining fields should be treated as private by applications. */
@@ -159,22 +159,22 @@ typedef struct {
* and similarly for height. For decompression, IDCT scaling is included, so
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_[h_]scaled_size/DCTSIZE)
*/
JDIMENSION downsampled_width; /* actual width in samples */
JDIMENSION downsampled_width; /* actual width in samples */
JDIMENSION downsampled_height; /* actual height in samples */
/* This flag is used only for decompression. In cases where some of the
* components will be ignored (eg grayscale output from YCbCr image),
* we can skip most computations for the unused components.
*/
boolean component_needed; /* do we need the value of this component? */
boolean component_needed; /* do we need the value of this component? */
/* These values are computed before starting a scan of the component. */
/* The decompressor output side may not use these variables. */
int MCU_width; /* number of blocks per MCU, horizontally */
int MCU_height; /* number of blocks per MCU, vertically */
int MCU_blocks; /* MCU_width * MCU_height */
int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
int last_col_width; /* # of non-dummy blocks across in last MCU */
int last_row_height; /* # of non-dummy blocks down in last MCU */
int MCU_width; /* number of blocks per MCU, horizontally */
int MCU_height; /* number of blocks per MCU, vertically */
int MCU_blocks; /* MCU_width * MCU_height */
int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
int last_col_width; /* # of non-dummy blocks across in last MCU */
int last_row_height; /* # of non-dummy blocks down in last MCU */
/* Saved quantization table for component; NULL if none yet saved.
* See jdinput.c comments about the need for this information.
@@ -190,10 +190,10 @@ typedef struct {
/* The script for encoding a multiple-scan file is an array of these: */
typedef struct {
int comps_in_scan; /* number of components encoded in this scan */
int comps_in_scan; /* number of components encoded in this scan */
int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
int Ss, Se; /* progressive JPEG spectral selection parms */
int Ah, Al; /* progressive JPEG successive approx. parms */
int Ss, Se; /* progressive JPEG spectral selection parms */
int Ah, Al; /* progressive JPEG successive approx. parms */
} jpeg_scan_info;
/* The decompressor can save APPn and COM markers in a list of these: */
@@ -201,10 +201,10 @@ typedef struct {
typedef struct jpeg_marker_struct * jpeg_saved_marker_ptr;
struct jpeg_marker_struct {
jpeg_saved_marker_ptr next; /* next in list, or NULL */
UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
unsigned int original_length; /* # bytes of data in the file */
unsigned int data_length; /* # bytes of data saved at data[] */
jpeg_saved_marker_ptr next; /* next in list, or NULL */
UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
unsigned int original_length; /* # bytes of data in the file */
unsigned int data_length; /* # bytes of data saved at data[] */
JOCTET * data; /* the data contained in the marker */
/* the marker length word is not counted in data_length or original_length */
};
@@ -215,28 +215,28 @@ struct jpeg_marker_struct {
#define JCS_ALPHA_EXTENSIONS 1
typedef enum {
JCS_UNKNOWN, /* error/unspecified */
JCS_GRAYSCALE, /* monochrome */
JCS_UNKNOWN, /* error/unspecified */
JCS_GRAYSCALE, /* monochrome */
JCS_RGB, /* red/green/blue as specified by the RGB_RED,
RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros */
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
JCS_CMYK, /* C/M/Y/K */
JCS_YCCK, /* Y/Cb/Cr/K */
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_YCbCr, /* Y/Cb/Cr (also known as YUV) */
JCS_CMYK, /* C/M/Y/K */
JCS_YCCK, /* Y/Cb/Cr/K */
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 */
/* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
or JCS_EXT_XRGB 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. Use the following colorspace constants to
ensure that the X byte is set to 0xFF, so that it can be interpreted as an
opaque alpha channel. */
JCS_EXT_RGBA, /* red/green/blue/alpha */
JCS_EXT_BGRA, /* blue/green/red/alpha */
JCS_EXT_ABGR, /* alpha/blue/green/red */
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 */
JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
} J_COLOR_SPACE;
@@ -244,24 +244,24 @@ typedef enum {
/* DCT/IDCT algorithm options. */
typedef enum {
JDCT_ISLOW, /* slow but accurate integer algorithm */
JDCT_IFAST, /* faster, less accurate integer method */
JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
JDCT_ISLOW, /* slow but accurate integer algorithm */
JDCT_IFAST, /* faster, less accurate integer method */
JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
} J_DCT_METHOD;
#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
#define JDCT_DEFAULT JDCT_ISLOW
#endif
#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
#define JDCT_FASTEST JDCT_IFAST
#endif
/* Dithering options for decompression. */
typedef enum {
JDITHER_NONE, /* no dithering */
JDITHER_ORDERED, /* simple ordered dither */
JDITHER_FS /* Floyd-Steinberg error diffusion dither */
JDITHER_NONE, /* no dithering */
JDITHER_ORDERED, /* simple ordered dither */
JDITHER_FS /* Floyd-Steinberg error diffusion dither */
} J_DITHER_MODE;
@@ -307,19 +307,19 @@ typedef enum {
/* Common fields between JPEG compression and decompression master structs. */
#define jpeg_common_fields \
struct jpeg_error_mgr * err; /* Error handler module */\
struct jpeg_memory_mgr * mem; /* Memory manager module */\
struct jpeg_error_mgr * err; /* Error handler module */\
struct jpeg_memory_mgr * mem; /* Memory manager module */\
struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\
void * client_data; /* Available for use by application */\
boolean is_decompressor; /* So common code can tell which is which */\
int global_state /* For checking call sequence validity */
void * client_data; /* Available for use by application */\
boolean is_decompressor; /* So common code can tell which is which */\
int global_state /* For checking call sequence validity */
/* Routines that are to be used by both halves of the library are declared
* to receive a pointer to this structure. There are no actual instances of
* jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
*/
struct jpeg_common_struct {
jpeg_common_fields; /* Fields common to both master struct types */
jpeg_common_fields; /* Fields common to both master struct types */
/* Additional fields follow in an actual jpeg_compress_struct or
* jpeg_decompress_struct. All three structs must agree on these
* initial fields! (This would be a lot cleaner in C++.)
@@ -334,7 +334,7 @@ typedef struct jpeg_decompress_struct * j_decompress_ptr;
/* Master record for a compression instance */
struct jpeg_compress_struct {
jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
/* Destination for compressed data */
struct jpeg_destination_mgr * dest;
@@ -344,12 +344,12 @@ struct jpeg_compress_struct {
* be correct before you can even call jpeg_set_defaults().
*/
JDIMENSION image_width; /* input image width */
JDIMENSION image_height; /* input image height */
int input_components; /* # of color components in input image */
J_COLOR_SPACE in_color_space; /* colorspace of input image */
JDIMENSION image_width; /* input image width */
JDIMENSION image_height; /* input image height */
int input_components; /* # of color components in input image */
J_COLOR_SPACE in_color_space; /* colorspace of input image */
double input_gamma; /* image gamma of input image */
double input_gamma; /* image gamma of input image */
/* Compression parameters --- these fields must be set before calling
* jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
@@ -362,8 +362,8 @@ struct jpeg_compress_struct {
#if JPEG_LIB_VERSION >= 70
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
JDIMENSION jpeg_width; /* scaled JPEG image width */
JDIMENSION jpeg_height; /* scaled JPEG image height */
JDIMENSION jpeg_width; /* scaled JPEG image width */
JDIMENSION jpeg_height; /* scaled JPEG image height */
/* Dimensions of actual JPEG image that will be written to file,
* derived from input dimensions by scaling factors above.
* These fields are computed by jpeg_start_compress().
@@ -372,9 +372,9 @@ struct jpeg_compress_struct {
*/
#endif
int data_precision; /* bits of precision in image data */
int data_precision; /* bits of precision in image data */
int num_components; /* # of color components in JPEG image */
int num_components; /* # of color components in JPEG image */
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
jpeg_component_info * comp_info;
@@ -396,22 +396,22 @@ struct jpeg_compress_struct {
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
int num_scans; /* # of entries in scan_info array */
int num_scans; /* # of entries in scan_info array */
const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */
/* The default value of scan_info is NULL, which causes a single-scan
* sequential JPEG file to be emitted. To create a multi-scan file,
* set num_scans and scan_info to point to an array of scan definitions.
*/
boolean raw_data_in; /* TRUE=caller supplies downsampled data */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
boolean raw_data_in; /* TRUE=caller supplies downsampled data */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
#if JPEG_LIB_VERSION >= 70
boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
#endif
int smoothing_factor; /* 1..100, or 0 for no input smoothing */
J_DCT_METHOD dct_method; /* DCT algorithm selector */
int smoothing_factor; /* 1..100, or 0 for no input smoothing */
J_DCT_METHOD dct_method; /* DCT algorithm selector */
/* The restart interval can be specified in absolute MCUs by setting
* restart_interval, or in MCU rows by setting restart_in_rows
@@ -419,28 +419,28 @@ struct jpeg_compress_struct {
* for each scan).
*/
unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
int restart_in_rows; /* if > 0, MCU rows per restart interval */
int restart_in_rows; /* if > 0, MCU rows per restart interval */
/* Parameters controlling emission of special markers. */
boolean write_JFIF_header; /* should a JFIF marker be written? */
UINT8 JFIF_major_version; /* What to write for the JFIF version number */
boolean write_JFIF_header; /* should a JFIF marker be written? */
UINT8 JFIF_major_version; /* What to write for the JFIF version number */
UINT8 JFIF_minor_version;
/* These three values are not used by the JPEG code, merely copied */
/* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
/* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */
/* ratio is defined by X_density/Y_density even when density_unit=0. */
UINT8 density_unit; /* JFIF code for pixel size units */
UINT16 X_density; /* Horizontal pixel density */
UINT16 Y_density; /* Vertical pixel density */
boolean write_Adobe_marker; /* should an Adobe marker be written? */
UINT8 density_unit; /* JFIF code for pixel size units */
UINT16 X_density; /* Horizontal pixel density */
UINT16 Y_density; /* Vertical pixel density */
boolean write_Adobe_marker; /* should an Adobe marker be written? */
/* State variable: index of next scanline to be written to
* jpeg_write_scanlines(). Application may use this to control its
* processing loop, e.g., "while (next_scanline < image_height)".
*/
JDIMENSION next_scanline; /* 0 .. image_height-1 */
JDIMENSION next_scanline; /* 0 .. image_height-1 */
/* Remaining fields are known throughout compressor, but generally
* should not be touched by a surrounding application.
@@ -449,16 +449,16 @@ struct jpeg_compress_struct {
/*
* These fields are computed during compression startup
*/
boolean progressive_mode; /* TRUE if scan script uses progressive mode */
int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */
boolean progressive_mode; /* TRUE if scan script uses progressive mode */
int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */
#if JPEG_LIB_VERSION >= 70
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
#endif
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
/* The coefficient controller receives data in units of MCU rows as defined
* for fully interleaved scans (whether the JPEG file is interleaved or not).
* There are v_samp_factor * DCTSIZE sample rows of each component in an
@@ -469,24 +469,24 @@ struct jpeg_compress_struct {
* These fields are valid during any one scan.
* They describe the components and MCUs actually appearing in the scan.
*/
int comps_in_scan; /* # of JPEG components in this scan */
int comps_in_scan; /* # of JPEG components in this scan */
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
/* *cur_comp_info[i] describes component that appears i'th in SOS */
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
int blocks_in_MCU; /* # of DCT blocks per MCU */
int blocks_in_MCU; /* # of DCT blocks per MCU */
int MCU_membership[C_MAX_BLOCKS_IN_MCU];
/* MCU_membership[i] is index in cur_comp_info of component owning */
/* i'th block in an MCU */
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
#if JPEG_LIB_VERSION >= 80
int block_size; /* the basic DCT block size: 1..16 */
const int * natural_order; /* natural-order position array */
int lim_Se; /* min( Se, DCTSIZE2-1 ) */
int block_size; /* the basic DCT block size: 1..16 */
const int * natural_order; /* natural-order position array */
int lim_Se; /* min( Se, DCTSIZE2-1 ) */
#endif
/*
@@ -509,7 +509,7 @@ struct jpeg_compress_struct {
/* Master record for a decompression instance */
struct jpeg_decompress_struct {
jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
/* Source of compressed data */
struct jpeg_source_mgr * src;
@@ -517,9 +517,9 @@ struct jpeg_decompress_struct {
/* Basic description of image --- filled in by jpeg_read_header(). */
/* Application may inspect these values to decide how to process image. */
JDIMENSION image_width; /* nominal image width (from SOF marker) */
JDIMENSION image_height; /* nominal image height */
int num_components; /* # of color components in JPEG image */
JDIMENSION image_width; /* nominal image width (from SOF marker) */
JDIMENSION image_height; /* nominal image height */
int num_components; /* # of color components in JPEG image */
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
/* Decompression processing parameters --- these fields must be set before
@@ -531,24 +531,24 @@ struct jpeg_decompress_struct {
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
double output_gamma; /* image gamma wanted in output */
double output_gamma; /* image gamma wanted in output */
boolean buffered_image; /* TRUE=multiple output passes */
boolean raw_data_out; /* TRUE=downsampled data wanted */
boolean buffered_image; /* TRUE=multiple output passes */
boolean raw_data_out; /* TRUE=downsampled data wanted */
J_DCT_METHOD dct_method; /* IDCT algorithm selector */
boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
J_DCT_METHOD dct_method; /* IDCT algorithm selector */
boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
boolean quantize_colors; /* TRUE=colormapped output wanted */
boolean quantize_colors; /* TRUE=colormapped output wanted */
/* the following are ignored if not quantize_colors: */
J_DITHER_MODE dither_mode; /* type of color dithering to use */
boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
int desired_number_of_colors; /* max # colors to use in created colormap */
J_DITHER_MODE dither_mode; /* type of color dithering to use */
boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
int desired_number_of_colors; /* max # colors to use in created colormap */
/* these are significant only in buffered-image mode: */
boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
boolean enable_external_quant;/* enable future use of external colormap */
boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
/* Description of actual output image that will be returned to application.
* These fields are computed by jpeg_start_decompress().
@@ -556,14 +556,14 @@ struct jpeg_decompress_struct {
* in advance of calling jpeg_start_decompress().
*/
JDIMENSION output_width; /* scaled image width */
JDIMENSION output_height; /* scaled image height */
int out_color_components; /* # of color components in out_color_space */
int output_components; /* # of color components returned */
JDIMENSION output_width; /* scaled image width */
JDIMENSION output_height; /* scaled image height */
int out_color_components; /* # of color components in out_color_space */
int output_components; /* # of color components returned */
/* output_components is 1 (a colormap index) when quantizing colors;
* otherwise it equals out_color_components.
*/
int rec_outbuf_height; /* min recommended height of scanline buffer */
int rec_outbuf_height; /* min recommended height of scanline buffer */
/* If the buffer passed to jpeg_read_scanlines() is less than this many rows
* high, space and time will be wasted due to unnecessary data copying.
* Usually rec_outbuf_height will be 1 or 2, at most 4.
@@ -575,8 +575,8 @@ struct jpeg_decompress_struct {
* jpeg_start_decompress or jpeg_start_output.
* The map has out_color_components rows and actual_number_of_colors columns.
*/
int actual_number_of_colors; /* number of entries in use */
JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
int actual_number_of_colors; /* number of entries in use */
JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
/* State variables: these variables indicate the progress of decompression.
* The application may examine these but must not modify them.
@@ -586,20 +586,20 @@ struct jpeg_decompress_struct {
* Application may use this to control its processing loop, e.g.,
* "while (output_scanline < output_height)".
*/
JDIMENSION output_scanline; /* 0 .. output_height-1 */
JDIMENSION output_scanline; /* 0 .. output_height-1 */
/* Current input scan number and number of iMCU rows completed in scan.
* These indicate the progress of the decompressor input side.
*/
int input_scan_number; /* Number of SOS markers seen so far */
JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
int input_scan_number; /* Number of SOS markers seen so far */
JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
/* The "output scan number" is the notional scan being displayed by the
* output side. The decompressor will not allow output scan/row number
* to get ahead of input scan/row, but it can fall arbitrarily far behind.
*/
int output_scan_number; /* Nominal scan number being displayed */
JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
int output_scan_number; /* Nominal scan number being displayed */
JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
/* Current progression status. coef_bits[c][i] indicates the precision
* with which component c's DCT coefficient i (in zigzag order) is known.
@@ -608,7 +608,7 @@ struct jpeg_decompress_struct {
* (thus, 0 at completion of the progression).
* This pointer is NULL when reading a non-progressive file.
*/
int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
/* Internal JPEG parameters --- the application usually need not look at
* these fields. Note that the decompressor output side may not use
@@ -630,16 +630,16 @@ struct jpeg_decompress_struct {
* are given in SOF/SOS markers or defined to be reset by SOI.
*/
int data_precision; /* bits of precision in image data */
int data_precision; /* bits of precision in image data */
jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */
#if JPEG_LIB_VERSION >= 80
boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
#endif
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
@@ -650,17 +650,17 @@ struct jpeg_decompress_struct {
/* These fields record data obtained from optional markers recognized by
* the JPEG library.
*/
boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
/* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
UINT8 JFIF_major_version; /* JFIF version number */
UINT8 JFIF_major_version; /* JFIF version number */
UINT8 JFIF_minor_version;
UINT8 density_unit; /* JFIF code for pixel size units */
UINT16 X_density; /* Horizontal pixel density */
UINT16 Y_density; /* Vertical pixel density */
boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
UINT8 Adobe_transform; /* Color transform code from Adobe marker */
UINT8 density_unit; /* JFIF code for pixel size units */
UINT16 X_density; /* Horizontal pixel density */
UINT16 Y_density; /* Vertical pixel density */
boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
UINT8 Adobe_transform; /* Color transform code from Adobe marker */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
/* Aside from the specific data retained from APPn markers known to the
* library, the uninterpreted contents of any or all APPn and COM markers
@@ -675,17 +675,17 @@ struct jpeg_decompress_struct {
/*
* These fields are computed during decompression startup
*/
int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */
int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */
#if JPEG_LIB_VERSION >= 70
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
#else
int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
#endif
JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
/* The coefficient controller's input and output progress is measured in
* units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
* in fully interleaved JPEG scans, but are used whether the scan is
@@ -701,26 +701,26 @@ struct jpeg_decompress_struct {
* They describe the components and MCUs actually appearing in the scan.
* Note that the decompressor output side must not use these fields.
*/
int comps_in_scan; /* # of JPEG components in this scan */
int comps_in_scan; /* # of JPEG components in this scan */
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
/* *cur_comp_info[i] describes component that appears i'th in SOS */
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
int blocks_in_MCU; /* # of DCT blocks per MCU */
int blocks_in_MCU; /* # of DCT blocks per MCU */
int MCU_membership[D_MAX_BLOCKS_IN_MCU];
/* MCU_membership[i] is index in cur_comp_info of component owning */
/* i'th block in an MCU */
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
#if JPEG_LIB_VERSION >= 80
/* These fields are derived from Se of first SOS marker.
*/
int block_size; /* the basic DCT block size: 1..16 */
int block_size; /* the basic DCT block size: 1..16 */
const int * natural_order; /* natural-order position array for entropy decode */
int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
#endif
/* This field is shared between entropy decoder and marker parser.
@@ -765,7 +765,7 @@ struct jpeg_error_mgr {
void (*output_message) (j_common_ptr cinfo);
/* Format a message string for the most recent JPEG error or message */
void (*format_message) (j_common_ptr cinfo, char * buffer);
#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
/* Reset error state variables at start of a new image */
void (*reset_error_mgr) (j_common_ptr cinfo);
@@ -781,7 +781,7 @@ struct jpeg_error_mgr {
/* Standard state variables for error facility */
int trace_level; /* max msg_level that will be displayed */
int trace_level; /* max msg_level that will be displayed */
/* For recoverable corrupt-data errors, we emit a warning message,
* but keep going unless emit_message chooses to abort. emit_message
@@ -789,7 +789,7 @@ struct jpeg_error_mgr {
* can check for bad data by seeing if num_warnings is nonzero at the
* end of processing.
*/
long num_warnings; /* number of corrupt-data warnings */
long num_warnings; /* number of corrupt-data warnings */
/* These fields point to the table(s) of error message strings.
* An application can change the table pointer to switch to a different
@@ -807,8 +807,8 @@ struct jpeg_error_mgr {
* It contains strings numbered first_addon_message..last_addon_message.
*/
const char * const * addon_message_table; /* Non-library errors */
int first_addon_message; /* code for first string in addon table */
int last_addon_message; /* code for last string in addon table */
int first_addon_message; /* code for first string in addon table */
int last_addon_message; /* code for last string in addon table */
};
@@ -817,18 +817,18 @@ struct jpeg_error_mgr {
struct jpeg_progress_mgr {
void (*progress_monitor) (j_common_ptr cinfo);
long pass_counter; /* work units completed in this pass */
long pass_limit; /* total number of work units in this pass */
int completed_passes; /* passes completed so far */
int total_passes; /* total number of passes expected */
long pass_counter; /* work units completed in this pass */
long pass_limit; /* total number of work units in this pass */
int completed_passes; /* passes completed so far */
int total_passes; /* total number of passes expected */
};
/* Data destination object for compression */
struct jpeg_destination_mgr {
JOCTET * next_output_byte; /* => next byte to write in buffer */
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
JOCTET * next_output_byte; /* => next byte to write in buffer */
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
void (*init_destination) (j_compress_ptr cinfo);
boolean (*empty_output_buffer) (j_compress_ptr cinfo);
@@ -840,7 +840,7 @@ struct jpeg_destination_mgr {
struct jpeg_source_mgr {
const JOCTET * next_input_byte; /* => next byte to read from buffer */
size_t bytes_in_buffer; /* # of bytes remaining in buffer */
size_t bytes_in_buffer; /* # of bytes remaining in buffer */
void (*init_source) (j_decompress_ptr cinfo);
boolean (*fill_input_buffer) (j_decompress_ptr cinfo);
@@ -861,9 +861,9 @@ struct jpeg_source_mgr {
* successful.
*/
#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
#define JPOOL_NUMPOOLS 2
#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
#define JPOOL_NUMPOOLS 2
typedef struct jvirt_sarray_control * jvirt_sarray_ptr;
typedef struct jvirt_barray_control * jvirt_barray_ptr;
@@ -879,14 +879,14 @@ struct jpeg_memory_mgr {
JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id,
JDIMENSION blocksperrow, JDIMENSION numrows);
jvirt_sarray_ptr (*request_virt_sarray) (j_common_ptr cinfo, int pool_id,
boolean pre_zero,
JDIMENSION samplesperrow,
JDIMENSION numrows,
boolean pre_zero,
JDIMENSION samplesperrow,
JDIMENSION numrows,
JDIMENSION maxaccess);
jvirt_barray_ptr (*request_virt_barray) (j_common_ptr cinfo, int pool_id,
boolean pre_zero,
JDIMENSION blocksperrow,
JDIMENSION numrows,
boolean pre_zero,
JDIMENSION blocksperrow,
JDIMENSION numrows,
JDIMENSION maxaccess);
void (*realize_virt_arrays) (j_common_ptr cinfo);
JSAMPARRAY (*access_virt_sarray) (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
@@ -928,10 +928,10 @@ EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr * err);
*/
#define jpeg_create_compress(cinfo) \
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
(size_t) sizeof(struct jpeg_compress_struct))
(size_t) sizeof(struct jpeg_compress_struct))
#define jpeg_create_decompress(cinfo) \
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
(size_t) sizeof(struct jpeg_decompress_struct))
(size_t) sizeof(struct jpeg_decompress_struct))
EXTERN(void) jpeg_CreateCompress (j_compress_ptr cinfo, int version,
size_t structsize);
EXTERN(void) jpeg_CreateDecompress (j_decompress_ptr cinfo, int version,
@@ -968,7 +968,7 @@ EXTERN(void) jpeg_default_qtables (j_compress_ptr cinfo,
boolean force_baseline);
#endif
EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
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);
@@ -981,7 +981,7 @@ EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table (j_common_ptr cinfo);
EXTERN(void) jpeg_start_compress (j_compress_ptr cinfo,
boolean write_all_tables);
EXTERN(JDIMENSION) jpeg_write_scanlines (j_compress_ptr cinfo,
JSAMPARRAY scanlines,
JSAMPARRAY scanlines,
JDIMENSION num_lines);
EXTERN(void) jpeg_finish_compress (j_compress_ptr cinfo);
@@ -1008,9 +1008,9 @@ EXTERN(void) jpeg_write_tables (j_compress_ptr cinfo);
/* Decompression startup: read start of JPEG datastream to see what's there */
EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
/* Return value is one of: */
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
/* If you pass require_image = TRUE (normal case), you need not check for
* a TABLES_ONLY return code; an abbreviated file will cause an error exit.
* JPEG_SUSPENDED is only possible if you use a data source module that can
@@ -1020,7 +1020,7 @@ EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
/* Main entry points for decompression */
EXTERN(boolean) jpeg_start_decompress (j_decompress_ptr cinfo);
EXTERN(JDIMENSION) jpeg_read_scanlines (j_decompress_ptr cinfo,
JSAMPARRAY scanlines,
JSAMPARRAY scanlines,
JDIMENSION max_lines);
EXTERN(boolean) jpeg_finish_decompress (j_decompress_ptr cinfo);
@@ -1036,11 +1036,11 @@ 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: */
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
#define JPEG_REACHED_EOI 2 /* Reached end of image */
#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
#define JPEG_REACHED_EOI 2 /* Reached end of image */
#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
/* Precalculate output dimensions for current decompression parameters. */
#if JPEG_LIB_VERSION >= 80
@@ -1108,10 +1108,10 @@ EXTERN(int) jpeg_c_get_int_param (j_compress_ptr cinfo, J_INT_PARAM param);
* are likely to want to use them.
*/
#define JPEG_RST0 0xD0 /* RST0 marker code */
#define JPEG_EOI 0xD9 /* EOI marker code */
#define JPEG_APP0 0xE0 /* APP0 marker code */
#define JPEG_COM 0xFE /* COM marker code */
#define JPEG_RST0 0xD0 /* RST0 marker code */
#define JPEG_EOI 0xD9 /* EOI marker code */
#define JPEG_APP0 0xE0 /* APP0 marker code */
#define JPEG_COM 0xFE /* COM marker code */
/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
@@ -1120,7 +1120,7 @@ EXTERN(int) jpeg_c_get_int_param (j_compress_ptr cinfo, J_INT_PARAM param);
*/
#ifdef INCOMPLETE_TYPES_BROKEN
#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
struct jvirt_sarray_control { long dummy; };
struct jvirt_barray_control { long dummy; };
struct jpeg_comp_master { long dummy; };
@@ -1155,8 +1155,8 @@ struct jpeg_color_quantizer { long dummy; };
*/
#ifdef JPEG_INTERNALS
#include "jpegint.h" /* fetch private declarations */
#include "jerror.h" /* fetch error codes too */
#include "jpegint.h" /* fetch private declarations */
#include "jerror.h" /* fetch error codes too */
#endif
#ifdef __cplusplus

View File

@@ -9,7 +9,7 @@
*
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#if JPEG_RAW_READER
#define NUM_ROWS 32
@@ -22,7 +22,7 @@ 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 */
j_compress_ptr cinfo; /* back link saves passing separate parm */
struct jpeg_decompress_struct dinfo;
struct jpeg_error_mgr jerr;
@@ -150,8 +150,8 @@ jinit_read_jpeg (j_compress_ptr cinfo)
/* 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 */
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;

View File

@@ -9,15 +9,15 @@
*
* This file contains routines to process some of cjpeg's more complicated
* command-line switches. Switches processed here are:
* -qtables file Read quantization tables from text file
* -scans file Read scan script from text file
* -quality N[,N,...] Set quality ratings
* -qslots N[,N,...] Set component quantization table selectors
* -sample HxV[,HxV,...] Set component sampling factors
* -qtables file Read quantization tables from text file
* -scans file Read scan script from text file
* -quality N[,N,...] Set quality ratings
* -qslots N[,N,...] Set component quantization table selectors
* -sample HxV[,HxV,...] Set component sampling factors
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include <ctype.h> /* to declare isdigit(), isspace() */
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include <ctype.h> /* to declare isdigit(), isspace() */
LOCAL(int)
@@ -108,15 +108,15 @@ read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline
table[0] = (unsigned int) val;
for (i = 1; i < DCTSIZE2; i++) {
if (! read_text_integer(fp, &val, &termchar)) {
fprintf(stderr, "Invalid table data in file %s\n", filename);
fclose(fp);
return FALSE;
fprintf(stderr, "Invalid table data in file %s\n", filename);
fclose(fp);
return FALSE;
}
table[i] = (unsigned int) val;
}
#if JPEG_LIB_VERSION >= 70
jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
force_baseline);
force_baseline);
#else
jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
force_baseline);
@@ -150,7 +150,7 @@ read_scan_integer (FILE * file, long * result, int * termchar)
ch = *termchar;
while (ch != EOF && isspace(ch))
ch = text_getc(file);
if (isdigit(ch)) { /* oops, put it back */
if (isdigit(ch)) { /* oops, put it back */
if (ungetc(ch, file) == EOF)
return FALSE;
ch = ' ';
@@ -188,7 +188,7 @@ read_scan_script (j_compress_ptr cinfo, char * filename)
int scanno, ncomps, termchar;
long val;
jpeg_scan_info * scanptr;
#define MAX_SCANS 100 /* quite arbitrary limit */
#define MAX_SCANS 100 /* quite arbitrary limit */
jpeg_scan_info scans[MAX_SCANS];
if ((fp = fopen(filename, "r")) == NULL) {
@@ -208,29 +208,29 @@ read_scan_script (j_compress_ptr cinfo, char * filename)
ncomps = 1;
while (termchar == ' ') {
if (ncomps >= MAX_COMPS_IN_SCAN) {
fprintf(stderr, "Too many components in one scan in file %s\n",
filename);
fclose(fp);
return FALSE;
fprintf(stderr, "Too many components in one scan in file %s\n",
filename);
fclose(fp);
return FALSE;
}
if (! read_scan_integer(fp, &val, &termchar))
goto bogus;
goto bogus;
scanptr->component_index[ncomps] = (int) val;
ncomps++;
}
scanptr->comps_in_scan = ncomps;
if (termchar == ':') {
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
goto bogus;
goto bogus;
scanptr->Ss = (int) val;
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
goto bogus;
goto bogus;
scanptr->Se = (int) val;
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
goto bogus;
goto bogus;
scanptr->Ah = (int) val;
if (! read_scan_integer(fp, &val, &termchar))
goto bogus;
goto bogus;
scanptr->Al = (int) val;
} else {
/* set non-progressive parameters */
@@ -337,7 +337,7 @@ 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 */
float val = 75.f; /* default value */
int tblno;
char ch;
@@ -355,7 +355,7 @@ set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
q_scale_factor[tblno] = jpeg_float_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
@@ -377,25 +377,25 @@ set_quant_slots (j_compress_ptr cinfo, char *arg)
* If there are more components than parameters, the last value is replicated.
*/
{
int val = 0; /* default table # */
int val = 0; /* default table # */
int ci;
char ch;
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
if (*arg) {
ch = ','; /* if not set by sscanf, will be ',' */
ch = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%d%c", &val, &ch) < 1)
return FALSE;
if (ch != ',') /* syntax check */
return FALSE;
return FALSE;
if (ch != ',') /* syntax check */
return FALSE;
if (val < 0 || val >= NUM_QUANT_TBLS) {
fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n",
NUM_QUANT_TBLS-1);
return FALSE;
fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n",
NUM_QUANT_TBLS-1);
return FALSE;
}
cinfo->comp_info[ci].quant_tbl_no = val;
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
;
;
} else {
/* reached end of parameter, set remaining components to last table */
cinfo->comp_info[ci].quant_tbl_no = val;
@@ -417,19 +417,19 @@ set_sample_factors (j_compress_ptr cinfo, char *arg)
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
if (*arg) {
ch2 = ','; /* if not set by sscanf, will be ',' */
ch2 = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
return FALSE;
return FALSE;
if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
return FALSE;
return FALSE;
if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) {
fprintf(stderr, "JPEG sampling factors must be 1..4\n");
return FALSE;
fprintf(stderr, "JPEG sampling factors must be 1..4\n");
return FALSE;
}
cinfo->comp_info[ci].h_samp_factor = val1;
cinfo->comp_info[ci].v_samp_factor = val2;
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
;
;
} else {
/* reached end of parameter, set remaining components to 1x1 sampling */
cinfo->comp_info[ci].h_samp_factor = 1;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
<title>libjpeg-turbo</title>
<title>mozjpeg</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.libjpeg-turbo.libjpeg-turbo"/>
<line choice="com.mozilla.mozjpeg"/>
</line>
</choices-outline>
<choice id="default"/>
<choice id="com.libjpeg-turbo.libjpeg-turbo" visible="false">
<pkg-ref id="com.libjpeg-turbo.libjpeg-turbo"/>
<choice id="com.mozilla.mozjpeg" visible="false">
<pkg-ref id="com.mozilla.mozjpeg"/>
</choice>
<pkg-ref auth="root"
id="com.libjpeg-turbo.libjpeg-turbo">libjpeg-turbo.pkg</pkg-ref>
id="com.mozilla.mozjpeg">mozjpeg.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 libmozjpeg 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 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.\
\pard\pardeftab720\qc
\cf0 \
\pard\pardeftab720

View File

@@ -1,5 +1,3 @@
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x 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 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 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.
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.

View File

@@ -5,11 +5,11 @@
\deftab720
\pard\pardeftab720
\f0\fs24 \cf0 This installer will install the libmozjpeg SDK and run-time libraries onto your computer so that you can use libmozjpeg to build new applications or accelerate existing ones. To remove the libmozjpeg package, run\
\f0\fs24 \cf0 This 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\pardeftab720
\f1 \cf0 /opt/libmozjpeg/bin/uninstall\
\f1 \cf0 /opt/mozjpeg/bin/uninstall\
\pard\pardeftab720
\f0 \cf0 \

View File

@@ -4,28 +4,21 @@ Section: misc
Priority: optional
Architecture: {__ARCH}
Essential: no
Maintainer: The libmozjpeg Project <joshmoz@gmail.com>
Maintainer: Mozilla Research <joshmoz@gmail.com>
Homepage: https://github.com/mozilla/mozjpeg
Installed-Size: {__SIZE}
Description: A SIMD-accelerated JPEG codec that provides both the libjpeg and TurboJPEG APIs
libmozjpeg is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
NEON) to accelerate baseline JPEG compression and decompression on x86,
x86-64, and ARM systems. On such systems, libmozjpeg is generally 2-4x as
fast as libjpeg, all else being equal. On other types of systems,
libmozjpeg can still outperform libjpeg by a significant amount, by virtue
of its highly-optimized Huffman coding routines. In many cases, the
performance of libmozjpeg rivals that of proprietary high-speed JPEG
codecs.
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.
.
libmozjpeg implements both the traditional libjpeg API as well as the less
powerful but more straightforward TurboJPEG API. libmozjpeg 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.
.
libmozjpeg was forked from libjpeg-turbo. 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.
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.

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/libmozjpeg" -a "$DOCDIR" = "/opt/libmozjpeg/doc" ]; then
if [ "$PREFIX" = "/opt/mozjpeg" -a "$DOCDIR" = "/opt/mozjpeg/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/libmozjpeg" -a "$DOCDIR" = "/opt/libmozjpeg/doc" ]; then
if [ "$PREFIX" = "/opt/mozjpeg" -a "$DOCDIR" = "/opt/mozjpeg/doc" ]; then
ln -fs /usr/share/doc/$DIRNAME-$VERSION $TMPDIR$DOCDIR
fi
fi

View File

@@ -91,7 +91,7 @@ make install DESTDIR=$PKGROOT docdir=/Library/Documentation/$PACKAGE_NAME \
exampledir=/Library/Documentation/$PACKAGE_NAME
rm -f $PKGROOT$LIBDIR/*.la
if [ "$PREFIX" = "/opt/libmozjpeg" -a "$DOCDIR" = "/opt/libmozjpeg/doc" ]; then
if [ "$PREFIX" = "/opt/mozjpeg" -a "$DOCDIR" = "/opt/mozjpeg/doc" ]; then
ln -fs /Library/Documentation/$PACKAGE_NAME $PKGROOT$DOCDIR
fi
@@ -235,7 +235,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/libmozjpeg" -a "$LIBDIR" = "/opt/libmozjpeg/lib" ]; then
if [ "$PREFIX" = "/opt/mozjpeg" -a "$LIBDIR" = "/opt/mozjpeg/lib" ]; then
if [ ! -h $PKGROOT/$PREFIX/lib32 ]; then
ln -fs lib $PKGROOT/$PREFIX/lib32
fi
@@ -254,7 +254,7 @@ cp $SRCDIR/release/License.rtf $SRCDIR/release/Welcome.rtf $SRCDIR/release/ReadM
mkdir $TMPDIR/dmg
pkgbuild --root $PKGROOT --version $VERSION.$BUILD \
--identifier com.libjpeg-turbo.libjpeg-turbo $TMPDIR/pkg/$PACKAGE_NAME.pkg
--identifier com.mozilla.$PACKAGE_NAME $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

@@ -1,4 +1,4 @@
# Path under which libmozjpeg should be installed
# Path under which mozjpeg should be installed
%define _prefix %{__prefix}
# Path under which executables should be installed
@@ -17,7 +17,7 @@
%ifarch x86_64
%define _lib lib64
%else
%if "%{_prefix}" == "/opt/libmozjpeg"
%if "%{_prefix}" == "/opt/mozjpeg"
%define _lib lib32
%endif
%endif
@@ -25,13 +25,13 @@
# Path under which man pages should be installed
%define _mandir %{__mandir}
Summary: A SIMD-accelerated JPEG codec that provides both the libjpeg and TurboJPEG APIs
Summary: A JPEG codec that provides increased compression for JPEG images (at the expense of compression performance)
Name: @PKGNAME@
Version: @VERSION@
Vendor: The libmozjpeg Project
Vendor: Mozilla Research
URL: https://github.com/mozilla/mozjpeg
Group: System Environment/Libraries
#-->Source0: http://prdownloads.sourceforge.net/libmozjpeg/libmozjpeg-%{version}.tar.gz
#-->Source0: https://github.com/mozilla/mozjpeg/archive/v%{version}.tar.gz
Release: @BUILD@
License: BSD-style
BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release}
@@ -43,30 +43,23 @@ Provides: %{name} = %{version}-%{release}, @PACKAGE_NAME@ = %{version}-%{release
%endif
%description
libmozjpeg is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64,
and ARM systems. On such systems, libmozjpeg is generally 2-4x as fast as
libjpeg, all else being equal. On other types of systems, libmozjpeg can
still outperform libjpeg by a significant amount, by virtue of its
highly-optimized Huffman coding routines. In many cases, the performance of
libmozjpeg rivals that of proprietary high-speed JPEG codecs.
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.
libmozjpeg implements both the traditional libjpeg API as well as the less
powerful but more straightforward TurboJPEG API. libmozjpeg 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.
libmozjpeg was forked from libjpeg-turbo.
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.
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.
#-->%prep
#-->%setup -q -n libmozjpeg-%{version}
#-->%setup -q -n mozjpeg-%{version}
#-->%build
#-->./configure prefix=%{_prefix} bindir=%{_bindir} datadir=%{_datadir} \
@@ -87,14 +80,14 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
LJT_LIBDIR=%{__libdir}
if [ ! "$LJT_LIBDIR" = "%{_libdir}" ]; then
echo ERROR: libmozjpeg must be configured with libdir=%{_prefix}/%{_lib} when generating an in-tree RPM for this architecture.
echo ERROR: mozjpeg must be configured with libdir=%{_prefix}/%{_lib} when generating an in-tree RPM for this architecture.
exit 1
fi
#-->%endif
LJT_DOCDIR=%{__docdir}
if [ "%{_prefix}" = "/opt/libmozjpeg" -a "$LJT_DOCDIR" = "/opt/libmozjpeg/doc" ]; then
if [ "%{_prefix}" = "/opt/mozjpeg" -a "$LJT_DOCDIR" = "/opt/mozjpeg/doc" ]; then
ln -fs %{_docdir} $RPM_BUILD_ROOT/$LJT_DOCDIR
fi
@@ -110,7 +103,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_docdir}
%doc %{_docdir}/*
%dir %{_prefix}
%if "%{_prefix}" == "/opt/libmozjpeg" && "%{_docdir}" != "%{_prefix}/doc"
%if "%{_prefix}" == "/opt/mozjpeg" && "%{_docdir}" != "%{_prefix}/doc"
%{_prefix}/doc
%endif
%dir %{_bindir}

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 libmozjpeg Project nor the names of its
# - 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.
#
@@ -32,7 +32,7 @@ if [ ! "`id -u`" = "0" ]; then
fi
PACKAGE=@PKGNAME@
MACPACKAGE=com.$PACKAGE.$PACKAGE
MACPACKAGE=com.mozilla.$PACKAGE
RECEIPT=/Library/Receipts/$PACKAGE.pkg
LSBOM=
@@ -72,7 +72,7 @@ fi
if [ -d $INCLUDEDIR ]; then
rmdir $INCLUDEDIR 2>&1 || EXITSTATUS=-1
fi
if [ "$PREFIX" = "/opt/libmozjpeg" -a "$LIBDIR" = "/opt/libmozjpeg/lib" ]; then
if [ "$PREFIX" = "/opt/mozjpeg" -a "$LIBDIR" = "/opt/mozjpeg/lib" ]; then
if [ -h $LIBDIR\32 ]; then
rm $LIBDIR\32 2>&1 || EXITSTATUS=-1
fi
@@ -92,7 +92,7 @@ fi
if [ -d $DATADIR -a "$DATADIR" != "$PREFIX" ]; then
rmdir $DATADIR 2>&1 || EXITSTATUS=-1
fi
if [ "$PREFIX" = "/opt/libmozjpeg" -a -h "$PREFIX/doc" ]; then
if [ "$PREFIX" = "/opt/mozjpeg" -a -h "$PREFIX/doc" ]; then
rm $PREFIX/doc 2>&1 || EXITSTATUS=-1
fi
rmdir $PREFIX 2>&1 || EXITSTATUS=-1

View File

@@ -273,82 +273,6 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
}
int dotestyuv(unsigned char *srcbuf, int w, int h, int subsamp,
char *filename)
{
char tempstr[1024], tempstr2[80];
FILE *file=NULL; tjhandle handle=NULL;
unsigned char *dstbuf=NULL;
double start, elapsed;
int i, retval=0, ps=tjPixelSize[pf];
int yuvsize=0;
yuvsize=tjBufSizeYUV(w, h, subsamp);
if((dstbuf=(unsigned char *)malloc(yuvsize)) == NULL)
_throwunix("allocating image buffer");
if(!quiet)
printf(">>>>> %s (%s) <--> YUV %s <<<<<\n", pixFormatStr[pf],
(flags&TJFLAG_BOTTOMUP)? "Bottom-up":"Top-down", subNameLong[subsamp]);
if(quiet==1)
printf("%s\t%s\t%s\tN/A\t", pixFormatStr[pf],
(flags&TJFLAG_BOTTOMUP)? "BU":"TD", subNameLong[subsamp]);
if((handle=tjInitCompress())==NULL)
_throwtj("executing tjInitCompress()");
/* Execute once to preload cache */
if(tjEncodeYUV2(handle, srcbuf, w, 0, h, pf, dstbuf, subsamp, flags)==-1)
_throwtj("executing tjEncodeYUV2()");
/* Benchmark */
for(i=0, start=gettime(); (elapsed=gettime()-start)<benchtime; i++)
{
if(tjEncodeYUV2(handle, srcbuf, w, 0, h, pf, dstbuf, subsamp, flags)==-1)
_throwtj("executing tjEncodeYUV2()");
}
if(tjDestroy(handle)==-1) _throwtj("executing tjDestroy()");
handle=NULL;
if(quiet==1) printf("%-4d %-4d\t", w, h);
if(quiet)
{
printf("%s%c%s%c",
sigfig((double)(w*h)/1000000.*(double)i/elapsed, 4, tempstr, 1024),
quiet==2? '\n':'\t',
sigfig((double)(w*h*ps)/(double)yuvsize, 4, tempstr2, 80),
quiet==2? '\n':'\t');
}
else
{
printf("\n%s size: %d x %d\n", "Image", w, h);
printf("C--> Frame rate: %f fps\n", (double)i/elapsed);
printf(" Output image size: %d bytes\n", yuvsize);
printf(" Compression ratio: %f:1\n",
(double)(w*h*ps)/(double)yuvsize);
printf(" Source throughput: %f Megapixels/sec\n",
(double)(w*h)/1000000.*(double)i/elapsed);
printf(" Output bit stream: %f Megabits/sec\n",
(double)yuvsize*8./1000000.*(double)i/elapsed);
}
snprintf(tempstr, 1024, "%s_%s.yuv", filename, subName[subsamp]);
if((file=fopen(tempstr, "wb"))==NULL)
_throwunix("opening reference image");
if(fwrite(dstbuf, yuvsize, 1, file)!=1)
_throwunix("writing reference image");
fclose(file); file=NULL;
if(!quiet) printf("Reference image written to %s\n", tempstr);
bailout:
if(file) {fclose(file); file=NULL;}
if(dstbuf) {free(dstbuf); dstbuf=NULL;}
if(handle) {tjDestroy(handle); handle=NULL;}
return retval;
}
int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
char *filename)
{