Merge remote-tracking branch 'libjpeg-turbo/1.4.x' into libjpeg-turbo
* libjpeg-turbo/1.4.x: (94 commits) CMakeLists.txt: Clarify that Un*x isn't supported Catch libjpeg errors in tjDecompressToYUV2() cjpeg: Fix buf overrun caused by bad bin PPM input Add version/build info to global string table Ensure that default Huffman tables are initialized Fix memory leak when running tjunittest -yuv Prevent overread when decoding malformed JPEG Guard against wrap-around in alloc functions Fix Visual C++ compiler warnings rdppm.c: formatting tweaks jmemmgr.c: formatting tweaks TurboJPEG: Avoid dangling pointers Update Android build instr. for ARMv8, PIE, etc. Makefile.am: formatting tweak Update build instructions for new autoconf, GitHub 1.4.3 Regression: Allow co-install of 32-bit/64-bit RPMs Build: Use FILEPATH type for NASM CMake variable Comment formatting tweaks Fix 'make dist' ...
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.DS_Store
|
||||
Makefile.in
|
||||
Makefile
|
||||
/CMakeFiles
|
||||
|
||||
63
BUILDING.txt
63
BUILDING.txt
@@ -15,11 +15,14 @@ Build Requirements
|
||||
provided. The easiest way to obtain them is from MacPorts
|
||||
(http://www.macports.org/).
|
||||
|
||||
-- NASM (if building x86 or x86-64 SIMD extensions)
|
||||
* 0.98, or 2.01 or later is required for a 32-bit build
|
||||
* NASM 2.00 or later is required for a 64-bit build
|
||||
* NASM 2.07 or later is required for a 64-bit build on OS X. This can be
|
||||
obtained from MacPorts (http://www.macports.org/).
|
||||
-- NASM or YASM (if building x86 or x86-64 SIMD extensions)
|
||||
* NASM 0.98, or 2.01 or later is required for an x86 build (0.99 and 2.00 do
|
||||
not work properly with libjpeg-turbo's x86 SIMD code.)
|
||||
* NASM 2.00 or later is required for an x86-64 build.
|
||||
* NASM 2.07, or 2.11.09 or later is required for an x86-64 Mac build
|
||||
(2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code when
|
||||
building macho64 objects.) NASM or YASM can be obtained from MacPorts
|
||||
(http://www.macports.org/).
|
||||
|
||||
The binary RPMs released by the NASM project do not work on older Linux
|
||||
systems, such as Red Hat Enterprise Linux 4. On such systems, you can
|
||||
@@ -36,7 +39,19 @@ Build Requirements
|
||||
|
||||
NOTE: the NASM build will fail if texinfo is not installed.
|
||||
|
||||
-- GCC v4.1 (or later) or clang recommended
|
||||
-- GCC v4.1 or later recommended for best performance
|
||||
* Beginning with Xcode 4, Apple stopped distributing GCC and switched to
|
||||
the LLVM compiler. Xcode v4.0 through v4.6 provides a GCC front end
|
||||
called LLVM-GCC. Unfortunately, as of this writing, neither LLVM-GCC nor
|
||||
the LLVM (clang) compiler produces optimal performance with libjpeg-turbo.
|
||||
Building mozjpeg with LLVM-GCC v4.2 results in a 10% performance
|
||||
degradation when compressing using 64-bit code, relative to building
|
||||
libjpeg-turbo with GCC v4.2. Building libjpeg-turbo with LLVM (clang)
|
||||
results in a 20% performance degradation when compressing using 64-bit
|
||||
code, relative to building libjpeg-turbo with GCC v4.2. If you are
|
||||
running Snow Leopard or earlier, it is suggested that you continue to use
|
||||
Xcode v3.2.6, which provides GCC v4.2. If you are using Lion or later, it
|
||||
is suggested that you install Apple GCC v4.2 or GCC v5 through MacPorts.
|
||||
|
||||
-- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
|
||||
required. Some systems, such as Solaris 10 and later and Red Hat Enterprise
|
||||
@@ -85,8 +100,8 @@ Non-Release Source Build (e.g. GitHub clone)
|
||||
sh {source_directory}/configure [additional configure flags]
|
||||
make
|
||||
|
||||
Results
|
||||
-------
|
||||
NOTE: Running autoreconf in the source directory is not necessary if building
|
||||
mozjpeg from one of the official release tarballs.
|
||||
|
||||
This will generate the following files under .libs/
|
||||
|
||||
@@ -331,7 +346,7 @@ mozjpeg for these platforms.
|
||||
Additional build requirements:
|
||||
|
||||
gas-preprocessor.pl
|
||||
(https://sourceforge.net/p/libjpeg-turbo/code/HEAD/tree/gas-preprocessor)
|
||||
(https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl)
|
||||
should be installed in your PATH.
|
||||
|
||||
|
||||
@@ -395,7 +410,7 @@ to the configure command line.
|
||||
|
||||
ARMv8 64-bit Build (Xcode 5.0.x and later, Clang):
|
||||
|
||||
Code will run on iPhone 5S/iPad Mini 2 and newer.
|
||||
Code will run on iPhone 5S/iPad Mini 2/iPad Air and newer.
|
||||
|
||||
Set the following shell variables for simplicity:
|
||||
|
||||
@@ -432,18 +447,25 @@ a general recipe script that can be modified for your specific needs.
|
||||
# Set these variables to suit your needs
|
||||
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/ndk}
|
||||
BUILD_PLATFORM={the platform name for the NDK package you installed--
|
||||
for example, "windows-x86" or "linux-x86_64"}
|
||||
TOOLCHAIN_VERSION={"4.6", "4.8", etc. This corresponds to a toolchain
|
||||
directory under ${NDK_PATH}/toolchains/.}
|
||||
for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
|
||||
TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
|
||||
toolchain directory under ${NDK_PATH}/toolchains/.}
|
||||
ANDROID_VERSION={The minimum version of Android to support-- for example,
|
||||
"9", "19", etc.}
|
||||
"16", "19", etc. "21" or later is required for a 64-bit build.}
|
||||
|
||||
# 32-bit ARMv7 build
|
||||
HOST=arm-linux-androideabi
|
||||
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
||||
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
|
||||
ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include"
|
||||
ANDROID_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
|
||||
-fstrict-aliasing --sysroot=${SYSROOT}"
|
||||
--sysroot=${SYSROOT}"
|
||||
|
||||
# 64-bit ARMv8 build
|
||||
HOST=aarch64-linux-android
|
||||
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm64
|
||||
ANDROID_CFLAGS="--sysroot=${SYSROOT}"
|
||||
|
||||
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
||||
ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include"
|
||||
export CPP=${TOOLCHAIN}/bin/${HOST}-cpp
|
||||
export AR=${TOOLCHAIN}/bin/${HOST}-ar
|
||||
export AS=${TOOLCHAIN}/bin/${HOST}-as
|
||||
@@ -455,11 +477,14 @@ a general recipe script that can be modified for your specific needs.
|
||||
export STRIP=${TOOLCHAIN}/bin/${HOST}-strip
|
||||
cd {build_directory}
|
||||
sh {source_directory}/configure --host=${HOST} \
|
||||
CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3" \
|
||||
CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3 -fPIE" \
|
||||
CPPFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS}" \
|
||||
LDFLAGS="${ANDROID_CFLAGS}" --with-simd ${1+"$@"}
|
||||
LDFLAGS="${ANDROID_CFLAGS} -pie" --with-simd ${1+"$@"}
|
||||
make
|
||||
|
||||
If building for Android 4.0.x (API level < 16) or earlier, remove -fPIE from
|
||||
CFLAGS and -pie from LDFLAGS.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
** Building on Windows (Visual C++ or MinGW)
|
||||
|
||||
@@ -11,10 +11,7 @@ endif()
|
||||
project(mozjpeg C)
|
||||
set(VERSION 3.1)
|
||||
|
||||
if(CYGWIN OR NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
|
||||
string(REGEX REPLACE "\n" "" BUILD "${BUILD}")
|
||||
elseif(WIN32)
|
||||
if(WIN32)
|
||||
execute_process(COMMAND "wmic.exe" "os" "get" "LocalDateTime" OUTPUT_VARIABLE
|
||||
BUILD)
|
||||
string(REGEX REPLACE "[^0-9]" "" BUILD "${BUILD}")
|
||||
@@ -59,6 +56,7 @@ option(ENABLE_SHARED "Build shared libraries" TRUE)
|
||||
if(WITH_12BIT)
|
||||
set(WITH_SIMD FALSE)
|
||||
set(WITH_TURBOJPEG FALSE)
|
||||
set(WITH_JAVA FALSE)
|
||||
set(WITH_ARITH_ENC FALSE)
|
||||
set(WITH_ARITH_DEC FALSE)
|
||||
set(BITS_IN_JSAMPLE 12)
|
||||
@@ -290,8 +288,8 @@ if(WITH_12BIT)
|
||||
set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED -DUSE_SETMODE")
|
||||
else()
|
||||
set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
|
||||
set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
|
||||
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
|
||||
set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
|
||||
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
|
||||
endif()
|
||||
|
||||
if(ENABLE_STATIC)
|
||||
|
||||
@@ -1,3 +1,88 @@
|
||||
1.4.3
|
||||
=====
|
||||
|
||||
[1] Fixed a regression caused by 1.4.1[6] that prevented 32-bit and 64-bit
|
||||
libjpeg-turbo RPMs from being installed simultaneously on recent Red Hat/Fedora
|
||||
distributions. This was due to the addition of a macro in jconfig.h that
|
||||
allows the Huffman codec to determine the word size at compile time. Since
|
||||
that macro differs between 32-bit and 64-bit builds, this caused a conflict
|
||||
between the i386 and x86_64 RPMs (any differing files, other than executables,
|
||||
are not allowed when 32-bit and 64-bit RPMs are installed simultaneously.)
|
||||
Since the macro is used only internally, it has been moved into jconfigint.h.
|
||||
|
||||
[2] Fixed an issue in the accelerated Huffman decoder that could have caused
|
||||
the decoder to read past the end of the input buffer when a malformed,
|
||||
specially-crafted JPEG image was being decompressed. In prior versions of
|
||||
libjpeg-turbo, the accelerated Huffman decoder was invoked (in most cases) only
|
||||
if there were > 128 bytes of data in the input buffer. However, it is possible
|
||||
to construct a JPEG image in which a single Huffman block is over 430 bytes
|
||||
long, so this version of libjpeg-turbo activates the accelerated Huffman
|
||||
decoder only if there are > 512 bytes of data in the input buffer.
|
||||
|
||||
[3] Fixed a memory leak in tjunittest encountered when running the program
|
||||
with the -yuv option.
|
||||
|
||||
[4] Fixed an issue whereby a malformed motion-JPEG frame could cause the "fast
|
||||
path" of libjpeg-turbo's Huffman decoder to read from uninitialized memory.
|
||||
|
||||
[5] Added libjpeg-turbo version and build information to the global string
|
||||
table of the libjpeg and TurboJPEG API libraries. This is a common practice in
|
||||
other infrastructure libraries, such as OpenSSL and libpng, because it makes it
|
||||
easy to examine an application binary and determine which version of the
|
||||
library the application was linked against.
|
||||
|
||||
[6] Fixed a couple of issues in the PPM reader that would cause buffer overruns
|
||||
in cjpeg if one of the values in a binary PPM/PGM input file exceeded the
|
||||
maximum value defined in the file's header. libjpeg-turbo 1.4.2 already
|
||||
included a similar fix for ASCII PPM/PGM files. Note that these issues were
|
||||
not security bugs, since they were confined to the cjpeg program and did not
|
||||
affect any of the libjpeg-turbo libraries.
|
||||
|
||||
[7] Fixed an issue whereby attempting to decompress a JPEG file with a corrupt
|
||||
header using the tjDecompressToYUV2() function would cause the function to
|
||||
abort without returning an error and, under certain circumstances, corrupt the
|
||||
stack. This only occurred if tjDecompressToYUV2() was called prior to calling
|
||||
calling tjDecompressHeader3(), or if the return value from
|
||||
tjDecompressHeader3() was ignored (both cases represent incorrect usage of the
|
||||
TurboJPEG API.)
|
||||
|
||||
|
||||
1.4.2
|
||||
=====
|
||||
|
||||
[1] Fixed an issue whereby cjpeg would segfault if a Windows bitmap with a
|
||||
negative width or height was used as an input image (Windows bitmaps can have
|
||||
a negative height if they are stored in top-down order, but such files are
|
||||
rare and not supported by libjpeg-turbo.)
|
||||
|
||||
[2] Fixed an issue whereby, under certain circumstances, libjpeg-turbo would
|
||||
incorrectly encode certain JPEG images when quality=100 and the fast integer
|
||||
forward DCT were used. This was known to cause 'make test' to fail when the
|
||||
library was built with '-march=haswell' on x86 systems.
|
||||
|
||||
[3] Fixed an issue whereby libjpeg-turbo would crash when built with the latest
|
||||
& greatest development version of the Clang/LLVM compiler. This was caused by
|
||||
an x86-64 ABI conformance issue in some of libjpeg-turbo's 64-bit SSE2 SIMD
|
||||
routines. Those routines were incorrectly using a 64-bit mov instruction to
|
||||
transfer a 32-bit JDIMENSION argument, whereas the x86-64 ABI allows the upper
|
||||
(unused) 32 bits of a 32-bit argument's register to be undefined. The new
|
||||
Clang/LLVM optimizer uses load combining to transfer multiple adjacent 32-bit
|
||||
structure members into a single 64-bit register, and this exposed the ABI
|
||||
conformance issue.
|
||||
|
||||
[4] Fixed a bug in the MIPS DSPr2 4:2:0 "plain" (non-fancy and non-merged)
|
||||
upsampling routine that caused a buffer overflow (and subsequent segfault) when
|
||||
decompressing a 4:2:0 JPEG image whose scaled output width was less than 16
|
||||
pixels. The "plain" upsampling routines are normally only used when
|
||||
decompressing a non-YCbCr JPEG image, but they are also used when decompressing
|
||||
a JPEG image whose scaled output height is 1.
|
||||
|
||||
[5] Fixed various negative left shifts and other issues reported by the GCC and
|
||||
Clang undefined behavior sanitizers. None of these was known to pose a
|
||||
security threat, but removing the warnings makes it easier to detect actual
|
||||
security issues, should they arise in the future.
|
||||
|
||||
|
||||
1.4.1
|
||||
=====
|
||||
|
||||
|
||||
82
LICENSE.txt
82
LICENSE.txt
@@ -1,7 +1,79 @@
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
libjpeg-turbo Licenses
|
||||
----------------------
|
||||
|
||||
* 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 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.
|
||||
libjpeg-turbo is covered by three compatible BSD-style open source licenses:
|
||||
|
||||
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.
|
||||
-- The IJG (Independent JPEG Group) License, which is listed in README
|
||||
|
||||
This license applies to the libjpeg API library and associated programs
|
||||
(any code inherited from libjpeg, and any modifications to that code.)
|
||||
|
||||
-- The Modified (3-clause) BSD License, which is listed in turbojpeg.c
|
||||
|
||||
This license covers the TurboJPEG API library and associated programs.
|
||||
|
||||
-- The zlib License, which is listed in simd/jsimdext.inc
|
||||
|
||||
This license is a subset of the other two, and it covers the libjpeg-turbo
|
||||
SIMD extensions.
|
||||
|
||||
|
||||
Complying with the libjpeg-turbo Licenses
|
||||
-----------------------------------------
|
||||
|
||||
This section provides a roll-up of the libjpeg-turbo licensing terms, to the
|
||||
best of our understanding.
|
||||
|
||||
1. If you are distributing a modified version of the libjpeg-turbo source,
|
||||
then:
|
||||
|
||||
a. You cannot alter or remove any existing copyright or license notices
|
||||
from the source.
|
||||
|
||||
Origin: Clause 1 of the IJG License
|
||||
Clause 1 of the Modified BSD License
|
||||
Clauses 1 and 3 of the zlib License
|
||||
|
||||
b. You must add your own copyright notice to the header of each source
|
||||
file you modified, so others can tell that you modified that file (if
|
||||
there is not an existing copyright header in that file, then you can
|
||||
simply add a notice stating that you modified the file.)
|
||||
|
||||
Origin: Clause 1 of the IJG License
|
||||
Clause 2 of the zlib License
|
||||
|
||||
c. You must include the IJG README file, and you must not alter any of the
|
||||
copyright or license text in that file.
|
||||
|
||||
Origin: Clause 1 of the IJG License
|
||||
|
||||
2. If you are distributing only libjpeg-turbo binaries without the source, or
|
||||
if you are distributing an application that statically links with
|
||||
libjpeg-turbo, then:
|
||||
|
||||
a. Your product documentation must include a message stating:
|
||||
|
||||
This software is based in part on the work of the Independent JPEG
|
||||
Group.
|
||||
|
||||
Origin: Clause 2 of the IJG license
|
||||
|
||||
b. If your binary distribution includes or uses the TurboJPEG API, then
|
||||
your product documentation must include the text of the Modified BSD
|
||||
License.
|
||||
|
||||
Origin: Clause 2 of the Modified BSD License
|
||||
|
||||
3. You cannot use the name of the IJG or The libjpeg-turbo Project or the
|
||||
contributors thereof in advertising, publicity, etc.
|
||||
|
||||
Origin: IJG License
|
||||
Clause 3 of the Modified BSD License
|
||||
|
||||
4. The IJG and The libjpeg-turbo Project do not warrant libjpeg-turbo to be
|
||||
free of defects, nor do we accept any liability for undesirable
|
||||
consequences resulting from your use of the software.
|
||||
|
||||
Origin: IJG License
|
||||
Modified BSD License
|
||||
zlib License
|
||||
|
||||
10
Makefile.am
10
Makefile.am
@@ -172,18 +172,17 @@ dist_man1_MANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1
|
||||
DOCS= coderules.txt jconfig.txt change.log rdrle.c wrrle.c BUILDING.txt \
|
||||
ChangeLog.txt
|
||||
|
||||
docdir = $(datadir)/doc
|
||||
dist_doc_DATA = README README-mozilla.txt README-turbo.txt libjpeg.txt structure.txt usage.txt \
|
||||
dist_doc_DATA = README README-turbo.txt libjpeg.txt structure.txt usage.txt \
|
||||
wizard.txt
|
||||
|
||||
exampledir = $(datadir)/doc
|
||||
exampledir = $(docdir)
|
||||
dist_example_DATA = example.c
|
||||
|
||||
|
||||
EXTRA_DIST = win release $(DOCS) testimages CMakeLists.txt \
|
||||
sharedlib/CMakeLists.txt cmakescripts libjpeg.map.in doc doxygen.config \
|
||||
doxygen-extra.css jccolext.c jdcolext.c jdcol565.c jdmrgext.c jdmrg565.c \
|
||||
jstdhuff.c
|
||||
jstdhuff.c LICENSE.txt
|
||||
|
||||
dist-hook:
|
||||
rm -rf `find $(distdir) -name .svn`
|
||||
@@ -456,7 +455,8 @@ endif
|
||||
# the output differs depending on the type of floating point math used, and
|
||||
# this is only deterministic if the DCT/IDCT are implemented using SIMD
|
||||
# instructions on a particular platform. Pass one of the following on the make
|
||||
# command line to validate the floating point tests against one of the expected # results:
|
||||
# command line to validate the floating point tests against one of the expected
|
||||
# results:
|
||||
#
|
||||
# FLOATTEST=sse validate against the expected results from the libjpeg-turbo
|
||||
# SSE SIMD extensions
|
||||
|
||||
@@ -28,33 +28,8 @@ broader range of users and developers.
|
||||
** License
|
||||
*******************************************************************************
|
||||
|
||||
Most of libjpeg-turbo inherits the non-restrictive, BSD-style license used by
|
||||
libjpeg (see README.) The TurboJPEG wrapper (both C and Java versions) and
|
||||
associated test programs bear a similar license, which is reproduced below:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- 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 libjpeg-turbo Project nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
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.
|
||||
libjpeg-turbo is covered by three compatible BSD-style open source licenses.
|
||||
Refer to LICENSE.txt for a roll-up of license terms.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
@@ -6,9 +6,10 @@ AC_INIT([mozjpeg], [3.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/mozjpeg)
|
||||
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
# Checks for programs.
|
||||
SAVED_CFLAGS=${CFLAGS}
|
||||
SAVED_CPPFLAGS=${CPPFLAGS}
|
||||
@@ -22,6 +23,10 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_LN_S
|
||||
|
||||
AC_ARG_WITH([build-date], [Use custom build string to enable reproducible builds (default: YYMMDD)],
|
||||
[BUILD="$with_build_date"],
|
||||
[BUILD=`date +%Y%m%d`])
|
||||
|
||||
# When the prefix is /opt/libjpeg-turbo, we assume that an "official" binary is
|
||||
# being created, and thus we install things into specific locations.
|
||||
|
||||
|
||||
@@ -1000,7 +1000,7 @@ Variables</h2></td></tr>
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing RGB, grayscale, or CMYK pixels to be compressed</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing RGB, grayscale, or CMYK pixels to be compressed. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">width</td><td>width (in pixels) of the source image</td></tr>
|
||||
<tr><td class="paramname">pitch</td><td>bytes per line in the source image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>height (in pixels) of the source image</td></tr>
|
||||
@@ -1098,7 +1098,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing a YUV planar image to be compressed. The size of this buffer should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> for the given image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.)</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing a YUV planar image to be compressed. The size of this buffer should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> for the given image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">width</td><td>width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
<tr><td class="paramname">pad</td><td>the line padding used in the source image. For instance, if each line in each plane of the YUV image is padded to the nearest multiple of 4 bytes, then <code>pad</code> should be set to 4.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
@@ -1195,7 +1195,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">srcPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if compressing a grayscale image) that contain a YUV image to be compressed. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> for the given image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details.</td></tr>
|
||||
<tr><td class="paramname">srcPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if compressing a grayscale image) that contain a YUV image to be compressed. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> for the given image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details. These image planes are not modified.</td></tr>
|
||||
<tr><td class="paramname">width</td><td>width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to specify an arbitrary amount of line padding in each plane or to create a JPEG image from a subregion of a larger YUV planar image.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
@@ -1293,7 +1293,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing a YUV planar image to be decoded. The size of this buffer should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> for the given image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.)</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing a YUV planar image to be decoded. The size of this buffer should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> for the given image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">pad</td><td>Use this parameter to specify that the width of each line in each plane of the YUV source image is padded to the nearest multiple of this number of bytes (must be a power of 2.)</td></tr>
|
||||
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling used in the YUV source image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
|
||||
<tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the decoded image. This buffer should normally be <code>pitch * height</code> bytes in size, but the <code>dstBuf</code> pointer can also be used to decode into a specific region of a larger buffer.</td></tr>
|
||||
@@ -1386,7 +1386,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">srcPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decoding a grayscale image) that contain a YUV image to be decoded. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> for the given image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details.</td></tr>
|
||||
<tr><td class="paramname">srcPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decoding a grayscale image) that contain a YUV image to be decoded. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> for the given image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details. These image planes are not modified.</td></tr>
|
||||
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to specify an arbitrary amount of line padding in each plane or to decode a subregion of a larger YUV planar image.</td></tr>
|
||||
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling used in the YUV source image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
|
||||
<tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the decoded image. This buffer should normally be <code>pitch * height</code> bytes in size, but the <code>dstBuf</code> pointer can also be used to decode into a specific region of a larger buffer.</td></tr>
|
||||
@@ -1472,7 +1472,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG image to decompress</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG image to decompress. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>size of the JPEG image (in bytes)</td></tr>
|
||||
<tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the decompressed image. This buffer should normally be <code>pitch * scaledHeight</code> bytes in size, where <code>scaledHeight</code> can be determined by calling <a class="el" href="group___turbo_j_p_e_g.html#ga84878bb65404204743aa18cac02781df" title="Compute the scaled value of dimension using the given scaling factor.">TJSCALED()</a> with the JPEG image height and one of the scaling factors returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8" title="Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of Tur...">tjGetScalingFactors()</a>. The <code>dstBuf</code> pointer may also be used to decompress into a specific region of a larger buffer.</td></tr>
|
||||
<tr><td class="paramname">width</td><td>desired width (in pixels) of the destination image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size.</td></tr>
|
||||
@@ -1545,7 +1545,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing a JPEG image</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing a JPEG image. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>size of the JPEG image (in bytes)</td></tr>
|
||||
<tr><td class="paramname">width</td><td>pointer to an integer variable that will receive the width (in pixels) of the JPEG image</td></tr>
|
||||
<tr><td class="paramname">height</td><td>pointer to an integer variable that will receive the height (in pixels) of the JPEG image</td></tr>
|
||||
@@ -1623,7 +1623,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG image to decompress</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG image to decompress. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>size of the JPEG image (in bytes)</td></tr>
|
||||
<tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> to determine the appropriate size for this buffer based on the image width, height, padding, and level of subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.)</td></tr>
|
||||
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
@@ -1702,7 +1702,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG image to decompress</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG image to decompress. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>size of the JPEG image (in bytes)</td></tr>
|
||||
<tr><td class="paramname">dstPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decompressing a grayscale image) that will receive the YUV image. These planes can be contiguous or non-contiguous in memory. Use <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> to determine the appropriate size for each plane based on the scaled image width, scaled image height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details.</td></tr>
|
||||
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
@@ -1818,7 +1818,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing RGB or grayscale pixels to be encoded</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing RGB or grayscale pixels to be encoded. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">width</td><td>width (in pixels) of the source image</td></tr>
|
||||
<tr><td class="paramname">pitch</td><td>bytes per line in the source image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>height (in pixels) of the source image</td></tr>
|
||||
@@ -1911,7 +1911,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor or transformer instance</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing RGB or grayscale pixels to be encoded</td></tr>
|
||||
<tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing RGB or grayscale pixels to be encoded. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">width</td><td>width (in pixels) of the source image</td></tr>
|
||||
<tr><td class="paramname">pitch</td><td>bytes per line in the source image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>height (in pixels) of the source image</td></tr>
|
||||
@@ -2264,7 +2264,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG transformer instance</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG source image to transform</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG source image to transform. This buffer is not modified.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>size of the JPEG source image (in bytes)</td></tr>
|
||||
<tr><td class="paramname">n</td><td>the number of transformed JPEG images to generate</td></tr>
|
||||
<tr><td class="paramname">dstBufs</td><td>pointer to an array of n image buffers. <code>dstBufs[i]</code> will receive a JPEG image that has been transformed using the parameters in <code>transforms[i]</code>. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||
|
||||
@@ -474,7 +474,7 @@ public TJCompressor(byte[] srcImage,
|
||||
<div class="block">Associate an uncompressed RGB, grayscale, or CMYK source image with this
|
||||
compressor instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>srcImage</code> - image buffer containing RGB, grayscale, or CMYK pixels to
|
||||
be compressed or encoded</dd><dd><code>x</code> - x offset (in pixels) of the region in the source image from which
|
||||
be compressed or encoded. This buffer is not modified.</dd><dd><code>x</code> - x offset (in pixels) of the region in the source image from which
|
||||
the JPEG or YUV image should be compressed/encoded</dd><dd><code>y</code> - y offset (in pixels) of the region in the source image from which
|
||||
the JPEG or YUV image should be compressed/encoded</dd><dd><code>width</code> - width (in pixels) of the region in the source image from
|
||||
which the JPEG or YUV image should be compressed/encoded</dd><dd><code>pitch</code> - bytes per line of the source image. Normally, this should be
|
||||
@@ -525,7 +525,7 @@ public void setSourceImage(byte[] srcImage,
|
||||
<div class="block">Associate an uncompressed RGB or grayscale source image with this
|
||||
compressor instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>srcImage</code> - a <code>BufferedImage</code> instance containing RGB or
|
||||
grayscale pixels to be compressed or encoded</dd><dd><code>x</code> - x offset (in pixels) of the region in the source image from which
|
||||
grayscale pixels to be compressed or encoded. This image is not modified.</dd><dd><code>x</code> - x offset (in pixels) of the region in the source image from which
|
||||
the JPEG or YUV image should be compressed/encoded</dd><dd><code>y</code> - y offset (in pixels) of the region in the source image from which
|
||||
the JPEG or YUV image should be compressed/encoded</dd><dd><code>width</code> - width (in pixels) of the region in the source image from
|
||||
which the JPEG or YUV image should be compressed/encoded (0 = use the
|
||||
@@ -546,7 +546,8 @@ public void setSourceImage(byte[] srcImage,
|
||||
throws java.lang.Exception</pre>
|
||||
<div class="block">Associate an uncompressed YUV planar source image with this compressor
|
||||
instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>srcImage</code> - YUV planar image to be compressed</dd>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>srcImage</code> - YUV planar image to be compressed. This image is not
|
||||
modified.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
|
||||
@@ -546,7 +546,7 @@ extends java.lang.Object</pre>
|
||||
<div class="block">Create a TurboJPEG decompressor instance and associate the JPEG source
|
||||
image stored in <code>jpegImage</code> with the newly created instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer (size of the JPEG image is assumed to
|
||||
be the length of the array)</dd>
|
||||
be the length of the array.) This buffer is not modified.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
@@ -563,7 +563,7 @@ extends java.lang.Object</pre>
|
||||
<div class="block">Create a TurboJPEG decompressor instance and associate the JPEG source
|
||||
image of length <code>imageSize</code> bytes stored in
|
||||
<code>jpegImage</code> with the newly created instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer. This buffer is not modified.</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
@@ -580,7 +580,7 @@ extends java.lang.Object</pre>
|
||||
source image stored in <code>yuvImage</code> with the newly created
|
||||
instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>yuvImage</code> - <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>YUVImage</code></a> instance containing a YUV planar
|
||||
image to be decoded</dd>
|
||||
image to be decoded. This image is not modified.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
@@ -605,7 +605,7 @@ extends java.lang.Object</pre>
|
||||
<div class="block">Associate the JPEG image of length <code>imageSize</code> bytes stored in
|
||||
<code>jpegImage</code> with this decompressor instance. This image will
|
||||
be used as the source image for subsequent decompress operations.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer. This buffer is not modified.</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
@@ -637,7 +637,7 @@ public void setJPEGImage(byte[] jpegImage,
|
||||
instance. Subsequent decompress operations will decode this image into an
|
||||
RGB or grayscale destination image.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>srcImage</code> - <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>YUVImage</code></a> instance containing a YUV planar image to
|
||||
be decoded</dd>
|
||||
be decoded. This image is not modified.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
|
||||
@@ -245,7 +245,7 @@ extends <a href="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html" title=
|
||||
<div class="block">Create a TurboJPEG lossless transformer instance and associate the JPEG
|
||||
image stored in <code>jpegImage</code> with the newly created instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer (size of the JPEG image is assumed to
|
||||
be the length of the array)</dd>
|
||||
be the length of the array.) This buffer is not modified.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
@@ -262,7 +262,7 @@ extends <a href="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html" title=
|
||||
<div class="block">Create a TurboJPEG lossless transformer instance and associate the JPEG
|
||||
image of length <code>imageSize</code> bytes stored in
|
||||
<code>jpegImage</code> with the newly created instance.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer. This buffer is not modified.</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
</li>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2011-2014 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2011-2015 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -111,7 +111,7 @@ public class TJCompressor {
|
||||
* compressor instance.
|
||||
*
|
||||
* @param srcImage image buffer containing RGB, grayscale, or CMYK pixels to
|
||||
* be compressed or encoded
|
||||
* be compressed or encoded. This buffer is not modified.
|
||||
*
|
||||
* @param x x offset (in pixels) of the region in the source image from which
|
||||
* the JPEG or YUV image should be compressed/encoded
|
||||
@@ -174,7 +174,7 @@ public class TJCompressor {
|
||||
* compressor instance.
|
||||
*
|
||||
* @param srcImage a <code>BufferedImage</code> instance containing RGB or
|
||||
* grayscale pixels to be compressed or encoded
|
||||
* grayscale pixels to be compressed or encoded. This image is not modified.
|
||||
*
|
||||
* @param x x offset (in pixels) of the region in the source image from which
|
||||
* the JPEG or YUV image should be compressed/encoded
|
||||
@@ -259,7 +259,8 @@ public class TJCompressor {
|
||||
* Associate an uncompressed YUV planar source image with this compressor
|
||||
* instance.
|
||||
*
|
||||
* @param srcImage YUV planar image to be compressed
|
||||
* @param srcImage YUV planar image to be compressed. This image is not
|
||||
* modified.
|
||||
*/
|
||||
public void setSourceImage(YUVImage srcImage) throws Exception {
|
||||
if (handle == 0) init();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2011-2014 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2011-2015 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -51,7 +51,7 @@ public class TJDecompressor {
|
||||
* image stored in <code>jpegImage</code> with the newly created instance.
|
||||
*
|
||||
* @param jpegImage JPEG image buffer (size of the JPEG image is assumed to
|
||||
* be the length of the array)
|
||||
* be the length of the array.) This buffer is not modified.
|
||||
*/
|
||||
public TJDecompressor(byte[] jpegImage) throws Exception {
|
||||
init();
|
||||
@@ -63,7 +63,7 @@ public class TJDecompressor {
|
||||
* image of length <code>imageSize</code> bytes stored in
|
||||
* <code>jpegImage</code> with the newly created instance.
|
||||
*
|
||||
* @param jpegImage JPEG image buffer
|
||||
* @param jpegImage JPEG image buffer. This buffer is not modified.
|
||||
*
|
||||
* @param imageSize size of the JPEG image (in bytes)
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ public class TJDecompressor {
|
||||
* instance.
|
||||
*
|
||||
* @param yuvImage {@link YUVImage} instance containing a YUV planar
|
||||
* image to be decoded
|
||||
* image to be decoded. This image is not modified.
|
||||
*/
|
||||
public TJDecompressor(YUVImage yuvImage) throws Exception {
|
||||
init();
|
||||
@@ -90,7 +90,7 @@ public class TJDecompressor {
|
||||
* <code>jpegImage</code> with this decompressor instance. This image will
|
||||
* be used as the source image for subsequent decompress operations.
|
||||
*
|
||||
* @param jpegImage JPEG image buffer
|
||||
* @param jpegImage JPEG image buffer. This buffer is not modified.
|
||||
*
|
||||
* @param imageSize size of the JPEG image (in bytes)
|
||||
*/
|
||||
@@ -118,7 +118,7 @@ public class TJDecompressor {
|
||||
* RGB or grayscale destination image.
|
||||
*
|
||||
* @param srcImage {@link YUVImage} instance containing a YUV planar image to
|
||||
* be decoded
|
||||
* be decoded. This image is not modified.
|
||||
*/
|
||||
public void setSourceImage(YUVImage srcImage) throws Exception {
|
||||
if (srcImage == null)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2011, 2013-2014 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2011, 2013-2015 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -45,7 +45,7 @@ public class TJTransformer extends TJDecompressor {
|
||||
* image stored in <code>jpegImage</code> with the newly created instance.
|
||||
*
|
||||
* @param jpegImage JPEG image buffer (size of the JPEG image is assumed to
|
||||
* be the length of the array)
|
||||
* be the length of the array.) This buffer is not modified.
|
||||
*/
|
||||
public TJTransformer(byte[] jpegImage) throws Exception {
|
||||
init();
|
||||
@@ -57,7 +57,7 @@ public class TJTransformer extends TJDecompressor {
|
||||
* image of length <code>imageSize</code> bytes stored in
|
||||
* <code>jpegImage</code> with the newly created instance.
|
||||
*
|
||||
* @param jpegImage JPEG image buffer
|
||||
* @param jpegImage JPEG image buffer. This buffer is not modified.
|
||||
*
|
||||
* @param imageSize size of the JPEG image (in bytes)
|
||||
*/
|
||||
|
||||
18
jcdctmgr.c
18
jcdctmgr.c
@@ -6,7 +6,7 @@
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2011, 2014 D. R. Commander
|
||||
* Copyright (C) 2011, 2014-2015 D. R. Commander
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
@@ -185,6 +185,19 @@ compute_reciprocal (UINT16 divisor, DCTELEM * dtbl)
|
||||
UDCTELEM c;
|
||||
int b, r;
|
||||
|
||||
if (divisor == 1) {
|
||||
/* divisor == 1 means unquantized, so these reciprocal/correction/shift
|
||||
* values will cause the C quantization algorithm to act like the
|
||||
* identity function. Since only the C quantization algorithm is used in
|
||||
* these cases, the scale value is irrelevant.
|
||||
*/
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM) 1; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM) 0; /* correction */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM) 1; /* scale */
|
||||
dtbl[DCTSIZE2 * 3] = -(DCTELEM) (sizeof(DCTELEM) * 8); /* shift */
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = flss(divisor) - 1;
|
||||
r = sizeof(DCTELEM) * 8 + b;
|
||||
|
||||
@@ -589,7 +602,8 @@ quantize (JCOEFPTR coef_block, DCTELEM * divisors, DCTELEM * workspace)
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
|
||||
UDCTELEM recip, corr, shift;
|
||||
UDCTELEM recip, corr;
|
||||
int shift;
|
||||
UDCTELEM2 product;
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
|
||||
3
jchuff.c
3
jchuff.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, 2014-2015 D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2014-2016 D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains Huffman entropy encoding routines.
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jchuff.h" /* Declarations shared with jcphuff.c */
|
||||
#include "jconfigint.h"
|
||||
#include <limits.h>
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2003-2010 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2014, D. R. Commander.
|
||||
* Copyright (C) 2010, 2016, D. R. Commander.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
#include "jconfigint.h"
|
||||
#include "jmemsys.h"
|
||||
#include "jcmaster.h"
|
||||
|
||||
@@ -929,6 +930,8 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
master->total_passes = cinfo->num_scans * 2;
|
||||
else
|
||||
master->total_passes = cinfo->num_scans;
|
||||
|
||||
master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
|
||||
|
||||
master->pass_number_scan_opt_base = 0;
|
||||
if (cinfo->master->trellis_quant) {
|
||||
|
||||
@@ -42,6 +42,15 @@ typedef struct {
|
||||
int best_Al_chroma; /* best value for Al found in scan search (luma) */
|
||||
boolean interleave_chroma_dc; /* indicate whether to interleave chroma DC scans */
|
||||
struct jpeg_destination_mgr * saved_dest; /* saved value of cinfo->dest */
|
||||
|
||||
/*
|
||||
* This is here so we can add libjpeg-turbo version/build information to the
|
||||
* global string table without introducing a new global symbol. Adding this
|
||||
* information to the global string table allows one to examine a binary
|
||||
* object and determine which version of libjpeg-turbo it was built from or
|
||||
* linked against.
|
||||
*/
|
||||
const char *jpeg_version;
|
||||
} my_comp_master;
|
||||
|
||||
typedef my_comp_master * my_master_ptr;
|
||||
|
||||
@@ -9,3 +9,6 @@
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#undef SIZEOF_SIZE_T
|
||||
|
||||
@@ -306,7 +306,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
|
||||
(*block)[0] = (JCOEF) (entropy->last_dc_val[ci] << cinfo->Al);
|
||||
(*block)[0] = (JCOEF) LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -181,6 +181,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#ifdef IDCT_SCALING_SUPPORTED
|
||||
case 9:
|
||||
method_ptr = jpeg_idct_9x9;
|
||||
method = JDCT_ISLOW; /* jidctint uses islow-style table */
|
||||
@@ -218,6 +219,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
method_ptr = jpeg_idct_16x16;
|
||||
method = JDCT_ISLOW; /* jidctint uses islow-style table */
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
|
||||
break;
|
||||
|
||||
20
jdhuff.c
20
jdhuff.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2016, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains Huffman entropy decoding routines.
|
||||
@@ -91,6 +91,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
int ci, blkn, dctbl, actbl;
|
||||
d_derived_tbl **pdtbl;
|
||||
jpeg_component_info * compptr;
|
||||
|
||||
/* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
|
||||
@@ -107,10 +108,10 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
actbl = compptr->ac_tbl_no;
|
||||
/* Compute derived values for Huffman tables */
|
||||
/* We may do this more than once for a table, but it's not expensive */
|
||||
jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl,
|
||||
& entropy->dc_derived_tbls[dctbl]);
|
||||
jpeg_make_d_derived_tbl(cinfo, FALSE, actbl,
|
||||
& entropy->ac_derived_tbls[actbl]);
|
||||
pdtbl = entropy->dc_derived_tbls + dctbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, pdtbl);
|
||||
pdtbl = entropy->ac_derived_tbls + actbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, pdtbl);
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->saved.last_dc_val[ci] = 0;
|
||||
}
|
||||
@@ -423,7 +424,7 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
|
||||
|
||||
/* Pre-fetch 48 bytes, because the holding register is 64-bit */
|
||||
#define FILL_BIT_BUFFER_FAST \
|
||||
if (bits_left < 16) { \
|
||||
if (bits_left <= 16) { \
|
||||
GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE GET_BYTE \
|
||||
}
|
||||
|
||||
@@ -431,7 +432,7 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
|
||||
|
||||
/* Pre-fetch 16 bytes, because the holding register is 32-bit */
|
||||
#define FILL_BIT_BUFFER_FAST \
|
||||
if (bits_left < 16) { \
|
||||
if (bits_left <= 16) { \
|
||||
GET_BYTE GET_BYTE \
|
||||
}
|
||||
|
||||
@@ -490,7 +491,8 @@ jpeg_huff_decode (bitread_working_state * state,
|
||||
#define AVOID_TABLES
|
||||
#ifdef AVOID_TABLES
|
||||
|
||||
#define HUFF_EXTEND(x,s) ((x) + ((((x) - (1<<((s)-1))) >> 31) & (((-1)<<(s)) + 1)))
|
||||
#define NEG_1 ((unsigned int)-1)
|
||||
#define HUFF_EXTEND(x,s) ((x) + ((((x) - (1<<((s)-1))) >> 31) & (((NEG_1)<<(s)) + 1)))
|
||||
|
||||
#else
|
||||
|
||||
@@ -744,7 +746,7 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
* this module, since we'll just re-assign them on the next call.)
|
||||
*/
|
||||
|
||||
#define BUFSIZE (DCTSIZE2 * 2)
|
||||
#define BUFSIZE (DCTSIZE2 * 8)
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
4
jdhuff.h
4
jdhuff.h
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010-2011, D. R. Commander.
|
||||
* Copyright (C) 2010-2011, 2015-2016, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains declarations for Huffman entropy decoding routines
|
||||
@@ -12,6 +12,8 @@
|
||||
* progressive decoder (jdphuff.c). No other modules need to see these.
|
||||
*/
|
||||
|
||||
#include "jconfigint.h"
|
||||
|
||||
|
||||
/* Derived data constructed for each Huffman table */
|
||||
|
||||
|
||||
24
jdphuff.c
24
jdphuff.c
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains Huffman entropy decoding routines for progressive JPEG.
|
||||
@@ -96,6 +96,7 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
boolean is_DC_band, bad;
|
||||
int ci, coefi, tbl;
|
||||
d_derived_tbl **pdtbl;
|
||||
int *coef_bit_ptr;
|
||||
jpeg_component_info * compptr;
|
||||
|
||||
@@ -168,13 +169,13 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
if (is_DC_band) {
|
||||
if (cinfo->Ah == 0) { /* DC refinement needs no table */
|
||||
tbl = compptr->dc_tbl_no;
|
||||
jpeg_make_d_derived_tbl(cinfo, TRUE, tbl,
|
||||
& entropy->derived_tbls[tbl]);
|
||||
pdtbl = entropy->derived_tbls + tbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, pdtbl);
|
||||
}
|
||||
} else {
|
||||
tbl = compptr->ac_tbl_no;
|
||||
jpeg_make_d_derived_tbl(cinfo, FALSE, tbl,
|
||||
& entropy->derived_tbls[tbl]);
|
||||
pdtbl = entropy->derived_tbls + tbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, pdtbl);
|
||||
/* remember the single active table */
|
||||
entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
|
||||
}
|
||||
@@ -203,7 +204,8 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
#define AVOID_TABLES
|
||||
#ifdef AVOID_TABLES
|
||||
|
||||
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))
|
||||
#define NEG_1 ((unsigned)-1)
|
||||
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((NEG_1)<<(s)) + 1) : (x))
|
||||
|
||||
#else
|
||||
|
||||
@@ -336,7 +338,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
s += state.last_dc_val[ci];
|
||||
state.last_dc_val[ci] = s;
|
||||
/* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
|
||||
(*block)[0] = (JCOEF) (s << Al);
|
||||
(*block)[0] = (JCOEF) LEFT_SHIFT(s, Al);
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
@@ -404,7 +406,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
r = GET_BITS(s);
|
||||
s = HUFF_EXTEND(r, s);
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) LEFT_SHIFT(s, Al);
|
||||
} else {
|
||||
if (r == 15) { /* ZRL */
|
||||
k += 15; /* skip 15 zeroes in band */
|
||||
@@ -495,8 +497,8 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
int Se = cinfo->Se;
|
||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
int m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
register int s, k, r;
|
||||
unsigned int EOBRUN;
|
||||
JBLOCKROW block;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jfdctint.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software.
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains a slow-but-accurate integer implementation of the
|
||||
@@ -170,8 +172,8 @@ jpeg_fdct_islow (DCTELEM * data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
|
||||
dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
|
||||
dataptr[0] = (DCTELEM) LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[4] = (DCTELEM) LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
|
||||
|
||||
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
|
||||
dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Modified 2010 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2014, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains a floating-point implementation of the
|
||||
* inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
|
||||
|
||||
123
jidctint.c
123
jidctint.c
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* jidctint.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software.
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modification developed 2002-2009 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains a slow-but-accurate integer implementation of the
|
||||
@@ -205,7 +207,8 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
|
||||
inptr[DCTSIZE*7] == 0) {
|
||||
/* AC terms all zero */
|
||||
int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
|
||||
PASS1_BITS);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
@@ -235,8 +238,8 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
|
||||
|
||||
tmp0 = (z2 + z3) << CONST_BITS;
|
||||
tmp1 = (z2 - z3) << CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(z2 + z3, CONST_BITS);
|
||||
tmp1 = LEFT_SHIFT(z2 - z3, CONST_BITS);
|
||||
|
||||
tmp10 = tmp0 + tmp3;
|
||||
tmp13 = tmp0 - tmp3;
|
||||
@@ -337,8 +340,8 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);
|
||||
tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
|
||||
|
||||
tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS;
|
||||
tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT((INT32) wsptr[0] + (INT32) wsptr[4], CONST_BITS);
|
||||
tmp1 = LEFT_SHIFT((INT32) wsptr[0] - (INT32) wsptr[4], CONST_BITS);
|
||||
|
||||
tmp10 = tmp0 + tmp3;
|
||||
tmp13 = tmp0 - tmp3;
|
||||
@@ -444,7 +447,7 @@ jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp13 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp13 <<= CONST_BITS;
|
||||
tmp13 = LEFT_SHIFT(tmp13, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp13 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
|
||||
@@ -499,7 +502,7 @@ jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp13 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
tmp13 <<= CONST_BITS;
|
||||
tmp13 = LEFT_SHIFT(tmp13, CONST_BITS);
|
||||
|
||||
z1 = (INT32) wsptr[2];
|
||||
z2 = (INT32) wsptr[4];
|
||||
@@ -593,7 +596,7 @@ jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
|
||||
@@ -611,9 +614,9 @@ jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */
|
||||
tmp0 = tmp1 + ((z1 + z2) << CONST_BITS);
|
||||
tmp2 = tmp1 + ((z3 - z2) << CONST_BITS);
|
||||
tmp1 = (z1 - z2 - z3) << PASS1_BITS;
|
||||
tmp0 = tmp1 + LEFT_SHIFT(z1 + z2, CONST_BITS);
|
||||
tmp2 = tmp1 + LEFT_SHIFT(z3 - z2, CONST_BITS);
|
||||
tmp1 = LEFT_SHIFT(z1 - z2 - z3, PASS1_BITS);
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
@@ -635,7 +638,7 @@ jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
tmp2 = (INT32) wsptr[4];
|
||||
tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */
|
||||
tmp1 = tmp0 + tmp10;
|
||||
@@ -651,9 +654,9 @@ jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z2 = (INT32) wsptr[3];
|
||||
z3 = (INT32) wsptr[5];
|
||||
tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */
|
||||
tmp0 = tmp1 + ((z1 + z2) << CONST_BITS);
|
||||
tmp2 = tmp1 + ((z3 - z2) << CONST_BITS);
|
||||
tmp1 = (z1 - z2 - z3) << CONST_BITS;
|
||||
tmp0 = tmp1 + LEFT_SHIFT(z1 + z2, CONST_BITS);
|
||||
tmp2 = tmp1 + LEFT_SHIFT(z3 - z2, CONST_BITS);
|
||||
tmp1 = LEFT_SHIFT(z1 - z2 - z3, CONST_BITS);
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
@@ -714,7 +717,7 @@ jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp12 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp12 <<= CONST_BITS;
|
||||
tmp12 = LEFT_SHIFT(tmp12, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp12 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
@@ -724,7 +727,7 @@ jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z3 = tmp12 + z2;
|
||||
tmp10 = z3 + z1;
|
||||
tmp11 = z3 - z1;
|
||||
tmp12 -= z2 << 2;
|
||||
tmp12 -= LEFT_SHIFT(z2, 2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
@@ -754,7 +757,7 @@ jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp12 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
tmp12 <<= CONST_BITS;
|
||||
tmp12 = LEFT_SHIFT(tmp12, CONST_BITS);
|
||||
tmp0 = (INT32) wsptr[2];
|
||||
tmp1 = (INT32) wsptr[4];
|
||||
z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */
|
||||
@@ -762,7 +765,7 @@ jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z3 = tmp12 + z2;
|
||||
tmp10 = z3 + z1;
|
||||
tmp11 = z3 - z1;
|
||||
tmp12 -= z2 << 2;
|
||||
tmp12 -= LEFT_SHIFT(z2, 2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
@@ -828,7 +831,7 @@ jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
@@ -858,7 +861,7 @@ jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
tmp2 = (INT32) wsptr[2];
|
||||
tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */
|
||||
tmp10 = tmp0 + tmp12;
|
||||
@@ -919,7 +922,7 @@ jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
|
||||
@@ -983,7 +986,7 @@ jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
|
||||
z1 = (INT32) wsptr[2];
|
||||
z2 = (INT32) wsptr[4];
|
||||
@@ -1091,7 +1094,7 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
z3 <<= CONST_BITS;
|
||||
z3 = LEFT_SHIFT(z3, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
z3 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
|
||||
@@ -1100,8 +1103,8 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp10 = z3 + z1;
|
||||
tmp11 = z3 - z2;
|
||||
|
||||
tmp22 = RIGHT_SHIFT(z3 - ((z1 - z2) << 1), /* c0 = (c4-c8)*2 */
|
||||
CONST_BITS-PASS1_BITS);
|
||||
tmp22 = RIGHT_SHIFT(z3 - LEFT_SHIFT(z1 - z2, 1),
|
||||
CONST_BITS-PASS1_BITS); /* c0 = (c4-c8)*2 */
|
||||
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
@@ -1126,7 +1129,7 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp13 = z2 - z4;
|
||||
|
||||
tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */
|
||||
z5 = z3 << CONST_BITS;
|
||||
z5 = LEFT_SHIFT(z3, CONST_BITS);
|
||||
|
||||
z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */
|
||||
z4 = z5 + tmp12;
|
||||
@@ -1135,9 +1138,9 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */
|
||||
|
||||
z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */
|
||||
z4 = z5 - tmp12 - (tmp13 << (CONST_BITS - 1));
|
||||
z4 = z5 - tmp12 - LEFT_SHIFT(tmp13, CONST_BITS - 1);
|
||||
|
||||
tmp12 = (z1 - tmp13 - z3) << PASS1_BITS;
|
||||
tmp12 = LEFT_SHIFT(z1 - tmp13 - z3, PASS1_BITS);
|
||||
|
||||
tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */
|
||||
tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */
|
||||
@@ -1166,14 +1169,14 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
z3 <<= CONST_BITS;
|
||||
z3 = LEFT_SHIFT(z3, CONST_BITS);
|
||||
z4 = (INT32) wsptr[4];
|
||||
z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */
|
||||
z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */
|
||||
tmp10 = z3 + z1;
|
||||
tmp11 = z3 - z2;
|
||||
|
||||
tmp22 = z3 - ((z1 - z2) << 1); /* c0 = (c4-c8)*2 */
|
||||
tmp22 = z3 - LEFT_SHIFT(z1 - z2, 1); /* c0 = (c4-c8)*2 */
|
||||
|
||||
z2 = (INT32) wsptr[2];
|
||||
z3 = (INT32) wsptr[6];
|
||||
@@ -1192,7 +1195,7 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z1 = (INT32) wsptr[1];
|
||||
z2 = (INT32) wsptr[3];
|
||||
z3 = (INT32) wsptr[5];
|
||||
z3 <<= CONST_BITS;
|
||||
z3 = LEFT_SHIFT(z3, CONST_BITS);
|
||||
z4 = (INT32) wsptr[7];
|
||||
|
||||
tmp11 = z2 + z4;
|
||||
@@ -1207,9 +1210,9 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */
|
||||
|
||||
z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */
|
||||
z4 = z3 - tmp12 - (tmp13 << (CONST_BITS - 1));
|
||||
z4 = z3 - tmp12 - LEFT_SHIFT(tmp13, CONST_BITS - 1);
|
||||
|
||||
tmp12 = ((z1 - tmp13) << CONST_BITS) - z3;
|
||||
tmp12 = LEFT_SHIFT(z1 - tmp13, CONST_BITS) - z3;
|
||||
|
||||
tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */
|
||||
tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */
|
||||
@@ -1286,7 +1289,7 @@ jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp10 <<= CONST_BITS;
|
||||
tmp10 = LEFT_SHIFT(tmp10, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp10 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
|
||||
@@ -1359,7 +1362,7 @@ jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp10 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
tmp10 <<= CONST_BITS;
|
||||
tmp10 = LEFT_SHIFT(tmp10, CONST_BITS);
|
||||
|
||||
z1 = (INT32) wsptr[2];
|
||||
z2 = (INT32) wsptr[4];
|
||||
@@ -1480,7 +1483,7 @@ jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
z3 <<= CONST_BITS;
|
||||
z3 = LEFT_SHIFT(z3, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
z3 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
|
||||
@@ -1492,9 +1495,9 @@ jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
z2 <<= CONST_BITS;
|
||||
z2 = LEFT_SHIFT(z2, CONST_BITS);
|
||||
|
||||
tmp12 = z1 - z2;
|
||||
|
||||
@@ -1563,7 +1566,7 @@ jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
z3 <<= CONST_BITS;
|
||||
z3 = LEFT_SHIFT(z3, CONST_BITS);
|
||||
|
||||
z4 = (INT32) wsptr[4];
|
||||
z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */
|
||||
@@ -1573,9 +1576,9 @@ jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
z1 = (INT32) wsptr[2];
|
||||
z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
z2 = (INT32) wsptr[6];
|
||||
z2 <<= CONST_BITS;
|
||||
z2 = LEFT_SHIFT(z2, CONST_BITS);
|
||||
|
||||
tmp12 = z1 - z2;
|
||||
|
||||
@@ -1696,7 +1699,7 @@ jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
z1 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
|
||||
@@ -1784,7 +1787,7 @@ jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
|
||||
z2 = (INT32) wsptr[2];
|
||||
z3 = (INT32) wsptr[4];
|
||||
@@ -1924,7 +1927,7 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
z1 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
|
||||
@@ -1936,8 +1939,8 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp11 = z1 + z3;
|
||||
tmp12 = z1 - z4;
|
||||
|
||||
tmp23 = RIGHT_SHIFT(z1 - ((z2 + z3 - z4) << 1), /* c0 = (c4+c12-c8)*2 */
|
||||
CONST_BITS-PASS1_BITS);
|
||||
tmp23 = RIGHT_SHIFT(z1 - LEFT_SHIFT(z2 + z3 - z4, 1),
|
||||
CONST_BITS-PASS1_BITS); /* c0 = (c4+c12-c8)*2 */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
@@ -1962,7 +1965,7 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
||||
tmp13 = z4 << CONST_BITS;
|
||||
tmp13 = LEFT_SHIFT(z4, CONST_BITS);
|
||||
|
||||
tmp14 = z1 + z3;
|
||||
tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */
|
||||
@@ -1981,7 +1984,7 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp14 += z4 + tmp13 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */
|
||||
tmp15 += z4 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */
|
||||
|
||||
tmp13 = (z1 - z3) << PASS1_BITS;
|
||||
tmp13 = LEFT_SHIFT(z1 - z3, PASS1_BITS);
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
@@ -2011,7 +2014,7 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
z4 = (INT32) wsptr[4];
|
||||
z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */
|
||||
z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */
|
||||
@@ -2021,7 +2024,7 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp11 = z1 + z3;
|
||||
tmp12 = z1 - z4;
|
||||
|
||||
tmp23 = z1 - ((z2 + z3 - z4) << 1); /* c0 = (c4+c12-c8)*2 */
|
||||
tmp23 = z1 - LEFT_SHIFT(z2 + z3 - z4, 1); /* c0 = (c4+c12-c8)*2 */
|
||||
|
||||
z1 = (INT32) wsptr[2];
|
||||
z2 = (INT32) wsptr[6];
|
||||
@@ -2046,7 +2049,7 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
z2 = (INT32) wsptr[3];
|
||||
z3 = (INT32) wsptr[5];
|
||||
z4 = (INT32) wsptr[7];
|
||||
z4 <<= CONST_BITS;
|
||||
z4 = LEFT_SHIFT(z4, CONST_BITS);
|
||||
|
||||
tmp14 = z1 + z3;
|
||||
tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */
|
||||
@@ -2064,7 +2067,7 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
tmp14 += tmp13 + z4 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */
|
||||
tmp15 += tmp13 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */
|
||||
|
||||
tmp13 = ((z1 - z3) << CONST_BITS) + z4;
|
||||
tmp13 = LEFT_SHIFT(z1 - z3, CONST_BITS) + z4;
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
@@ -2150,7 +2153,7 @@ jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
z1 += ONE << (CONST_BITS-PASS1_BITS-1);
|
||||
|
||||
@@ -2163,7 +2166,7 @@ jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
tmp12 = z1 - tmp10;
|
||||
tmp13 = z1 + tmp11;
|
||||
z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */
|
||||
z1 -= LEFT_SHIFT(tmp11 - tmp10, 1); /* c0 = (c6-c12)*2 */
|
||||
|
||||
z4 = z2 - z3;
|
||||
z3 += z2;
|
||||
@@ -2243,7 +2246,7 @@ jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
z1 <<= CONST_BITS;
|
||||
z1 = LEFT_SHIFT(z1, CONST_BITS);
|
||||
|
||||
z2 = (INT32) wsptr[2];
|
||||
z3 = (INT32) wsptr[4];
|
||||
@@ -2254,7 +2257,7 @@ jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
tmp12 = z1 - tmp10;
|
||||
tmp13 = z1 + tmp11;
|
||||
z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */
|
||||
z1 -= LEFT_SHIFT(tmp11 - tmp10, 1); /* c0 = (c6-c12)*2 */
|
||||
|
||||
z4 = z2 - z3;
|
||||
z3 += z2;
|
||||
@@ -2392,7 +2395,7 @@ jpeg_idct_16x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 += 1 << (CONST_BITS-PASS1_BITS-1);
|
||||
|
||||
@@ -2494,7 +2497,7 @@ jpeg_idct_16x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
|
||||
tmp0 <<= CONST_BITS;
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS);
|
||||
|
||||
z1 = (INT32) wsptr[4];
|
||||
tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */
|
||||
|
||||
18
jidctred.c
18
jidctred.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jidctred.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software.
|
||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains inverse-DCT routines that produce reduced-size output:
|
||||
@@ -143,7 +145,8 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
|
||||
inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
|
||||
/* AC terms all zero; we need not examine term 4 for 4x4 output */
|
||||
int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
|
||||
PASS1_BITS);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
@@ -156,7 +159,7 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp0 <<= (CONST_BITS+1);
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS+1);
|
||||
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
@@ -217,7 +220,7 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1);
|
||||
tmp0 = LEFT_SHIFT((INT32) wsptr[0], CONST_BITS+1);
|
||||
|
||||
tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065)
|
||||
+ MULTIPLY((INT32) wsptr[6], - FIX_0_765366865);
|
||||
@@ -294,7 +297,8 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
|
||||
/* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
|
||||
int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
|
||||
PASS1_BITS);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
@@ -305,7 +309,7 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
/* Even part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp10 = z1 << (CONST_BITS+2);
|
||||
tmp10 = LEFT_SHIFT(z1, CONST_BITS+2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
@@ -347,7 +351,7 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2);
|
||||
tmp10 = LEFT_SHIFT((INT32) wsptr[0], CONST_BITS+2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
|
||||
38
jmemmgr.c
38
jmemmgr.c
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2016, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains the JPEG system-independent memory management
|
||||
@@ -69,9 +69,9 @@ round_up_pow2 (size_t a, size_t b)
|
||||
* There isn't any really portable way to determine the worst-case alignment
|
||||
* requirement. This module assumes that the alignment requirement is
|
||||
* multiples of ALIGN_SIZE.
|
||||
* By default, we define ALIGN_SIZE as sizeof(double). This is necessary on some
|
||||
* workstations (where doubles really do need 8-byte alignment) and will work
|
||||
* fine on nearly everything. If your machine has lesser alignment needs,
|
||||
* By default, we define ALIGN_SIZE as sizeof(double). This is necessary on
|
||||
* some workstations (where doubles really do need 8-byte alignment) and will
|
||||
* work fine on nearly everything. If your machine has lesser alignment needs,
|
||||
* you can save a few bytes by making ALIGN_SIZE smaller.
|
||||
* The only place I know of where this will NOT work is certain Macintosh
|
||||
* 680x0 compilers that define double as a 10-byte IEEE extended float.
|
||||
@@ -275,10 +275,16 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
* and so that algorithms can straddle outside the proper area up
|
||||
* to the next alignment.
|
||||
*/
|
||||
if (sizeofobject > MAX_ALLOC_CHUNK) {
|
||||
/* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
|
||||
is close to SIZE_MAX. */
|
||||
out_of_memory(cinfo, 7);
|
||||
}
|
||||
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||
if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
|
||||
MAX_ALLOC_CHUNK)
|
||||
out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
|
||||
|
||||
/* See if space is available in any existing pool */
|
||||
@@ -363,10 +369,16 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
* algorithms can straddle outside the proper area up to the next
|
||||
* alignment.
|
||||
*/
|
||||
if (sizeofobject > MAX_ALLOC_CHUNK) {
|
||||
/* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
|
||||
is close to SIZE_MAX. */
|
||||
out_of_memory(cinfo, 8);
|
||||
}
|
||||
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||
if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) >
|
||||
MAX_ALLOC_CHUNK)
|
||||
out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
|
||||
|
||||
/* Always make a new pool */
|
||||
@@ -378,7 +390,8 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
ALIGN_SIZE - 1);
|
||||
if (hdr_ptr == NULL)
|
||||
out_of_memory(cinfo, 4); /* jpeg_get_large failed */
|
||||
mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
|
||||
mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) +
|
||||
ALIGN_SIZE - 1;
|
||||
|
||||
/* Success, initialize the new pool header and add to list */
|
||||
hdr_ptr->next = mem->large_list[pool_id];
|
||||
@@ -428,7 +441,14 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
/* Make sure each row is properly aligned */
|
||||
if ((ALIGN_SIZE % sizeof(JSAMPLE)) != 0)
|
||||
out_of_memory(cinfo, 5); /* safety check */
|
||||
samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) / sizeof(JSAMPLE));
|
||||
|
||||
if (samplesperrow > MAX_ALLOC_CHUNK) {
|
||||
/* This prevents overflow/wrap-around in round_up_pow2() if sizeofobject
|
||||
is close to SIZE_MAX. */
|
||||
out_of_memory(cinfo, 9);
|
||||
}
|
||||
samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) /
|
||||
sizeof(JSAMPLE));
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
|
||||
14
jmorecfg.h
14
jmorecfg.h
@@ -3,8 +3,9 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, 2014, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains additional configuration options that customize the
|
||||
@@ -148,14 +149,23 @@ typedef short INT16;
|
||||
/* INT32 must hold at least signed 32-bit values. */
|
||||
|
||||
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
|
||||
#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
|
||||
#ifndef _BASETSD_H /* MinGW is slightly different */
|
||||
#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
|
||||
#define __INT32_IS_ACTUALLY_LONG
|
||||
typedef long INT32;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Datatype used for image dimensions. The JPEG standard only supports
|
||||
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
|
||||
* "unsigned int" is sufficient on all machines. However, if you need to
|
||||
* handle larger images and you don't mind deviating from the spec, you
|
||||
* can change this datatype.
|
||||
* can change this datatype. (Note that changing this datatype will
|
||||
* potentially require modifying the SIMD code. The x86-64 SIMD extensions,
|
||||
* in particular, assume a 32-bit JDIMENSION.)
|
||||
*/
|
||||
|
||||
typedef unsigned int JDIMENSION;
|
||||
|
||||
16
jpegint.h
16
jpegint.h
@@ -4,8 +4,8 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
@@ -45,6 +45,18 @@ typedef enum { /* Operating modes for buffer controllers */
|
||||
#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
|
||||
|
||||
|
||||
/*
|
||||
* Left shift macro that handles a negative operand without causing any
|
||||
* sanitizer warnings
|
||||
*/
|
||||
|
||||
#ifdef __INT32_IS_ACTUALLY_LONG
|
||||
#define LEFT_SHIFT(a, b) ((INT32)((unsigned long)(a) << (b)))
|
||||
#else
|
||||
#define LEFT_SHIFT(a, b) ((INT32)((unsigned int)(a) << (b)))
|
||||
#endif
|
||||
|
||||
|
||||
/* Declarations for compression modules */
|
||||
|
||||
/* Master control module */
|
||||
|
||||
23
jstdhuff.c
23
jstdhuff.c
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* jstdhuff.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2013, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains routines to set the default Huffman tables, if they are
|
||||
* not already set.
|
||||
*/
|
||||
* jstdhuff.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2013, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains routines to set the default Huffman tables, if they are
|
||||
* not already set.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Huffman table setup routines
|
||||
@@ -41,6 +41,7 @@ add_huff_table (j_common_ptr cinfo,
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
MEMCOPY((*htblptr)->huffval, val, nsymbols * sizeof(UINT8));
|
||||
MEMZERO(&((*htblptr)->huffval[nsymbols]), (256 - nsymbols) * sizeof(UINT8));
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
(*htblptr)->sent_table = FALSE;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2012-2014, D. R. Commander.
|
||||
* Copyright (C) 2010, 2012-2016, D. R. Commander.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
@@ -30,10 +30,10 @@
|
||||
#define JCOPYRIGHT "Copyright (C) 1991-2012 Thomas G. Lane, Guido Vollbeding\n" \
|
||||
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
||||
"Copyright (C) 2009 Pierre Ossman for Cendio AB\n" \
|
||||
"Copyright (C) 2009-2015 D. R. Commander\n" \
|
||||
"Copyright (C) 2009-2016 D. R. Commander\n" \
|
||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||
"Copyright (C) 2014 Mozilla Corporation\n" \
|
||||
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
||||
"Copyright (C) 2013 Linaro Limited"
|
||||
|
||||
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2015 The libjpeg-turbo Project and many others"
|
||||
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2016 The libjpeg-turbo Project and many others"
|
||||
|
||||
59
rdbmp.c
59
rdbmp.c
@@ -6,6 +6,7 @@
|
||||
* Modified 2009-2010 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Modified 2011 by Siarhei Siamashka.
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains routines to read input images in Microsoft "BMP"
|
||||
@@ -279,22 +280,22 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
bmp_source_ptr source = (bmp_source_ptr) sinfo;
|
||||
U_CHAR bmpfileheader[14];
|
||||
U_CHAR bmpinfoheader[64];
|
||||
#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \
|
||||
(((unsigned int) UCH(array[offset+1])) << 8))
|
||||
#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \
|
||||
(((INT32) UCH(array[offset+1])) << 8) + \
|
||||
(((INT32) UCH(array[offset+2])) << 16) + \
|
||||
(((INT32) UCH(array[offset+3])) << 24))
|
||||
INT32 bfOffBits;
|
||||
INT32 headerSize;
|
||||
INT32 biWidth;
|
||||
INT32 biHeight;
|
||||
unsigned int biPlanes;
|
||||
INT32 biCompression;
|
||||
INT32 biXPelsPerMeter,biYPelsPerMeter;
|
||||
INT32 biClrUsed = 0;
|
||||
#define GET_2B(array,offset) ((unsigned short) UCH(array[offset]) + \
|
||||
(((unsigned short) UCH(array[offset+1])) << 8))
|
||||
#define GET_4B(array,offset) ((unsigned int) UCH(array[offset]) + \
|
||||
(((unsigned int) UCH(array[offset+1])) << 8) + \
|
||||
(((unsigned int) UCH(array[offset+2])) << 16) + \
|
||||
(((unsigned int) UCH(array[offset+3])) << 24))
|
||||
unsigned int bfOffBits;
|
||||
unsigned int headerSize;
|
||||
int biWidth;
|
||||
int biHeight;
|
||||
unsigned short biPlanes;
|
||||
unsigned int biCompression;
|
||||
int biXPelsPerMeter,biYPelsPerMeter;
|
||||
unsigned int biClrUsed = 0;
|
||||
int mapentrysize = 0; /* 0 indicates no colormap */
|
||||
INT32 bPad;
|
||||
int bPad;
|
||||
JDIMENSION row_width;
|
||||
|
||||
/* Read and verify the bitmap file header */
|
||||
@@ -302,7 +303,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */
|
||||
ERREXIT(cinfo, JERR_BMP_NOT);
|
||||
bfOffBits = (INT32) GET_4B(bmpfileheader,10);
|
||||
bfOffBits = GET_4B(bmpfileheader,10);
|
||||
/* We ignore the remaining fileheader fields */
|
||||
|
||||
/* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows),
|
||||
@@ -310,27 +311,27 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
*/
|
||||
if (! ReadOK(source->pub.input_file, bmpinfoheader, 4))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
headerSize = (INT32) GET_4B(bmpinfoheader,0);
|
||||
headerSize = GET_4B(bmpinfoheader,0);
|
||||
if (headerSize < 12 || headerSize > 64)
|
||||
ERREXIT(cinfo, JERR_BMP_BADHEADER);
|
||||
if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
|
||||
switch ((int) headerSize) {
|
||||
switch (headerSize) {
|
||||
case 12:
|
||||
/* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */
|
||||
biWidth = (INT32) GET_2B(bmpinfoheader,4);
|
||||
biHeight = (INT32) GET_2B(bmpinfoheader,6);
|
||||
biWidth = (int) GET_2B(bmpinfoheader,4);
|
||||
biHeight = (int) GET_2B(bmpinfoheader,6);
|
||||
biPlanes = GET_2B(bmpinfoheader,8);
|
||||
source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10);
|
||||
|
||||
switch (source->bits_per_pixel) {
|
||||
case 8: /* colormapped image */
|
||||
mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight);
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, biWidth, biHeight);
|
||||
break;
|
||||
case 24: /* RGB image */
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight);
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP_OS2, biWidth, biHeight);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
|
||||
@@ -341,26 +342,26 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
case 64:
|
||||
/* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */
|
||||
/* or OS/2 2.x header, which has additional fields that we ignore */
|
||||
biWidth = GET_4B(bmpinfoheader,4);
|
||||
biHeight = GET_4B(bmpinfoheader,8);
|
||||
biWidth = (int) GET_4B(bmpinfoheader,4);
|
||||
biHeight = (int) GET_4B(bmpinfoheader,8);
|
||||
biPlanes = GET_2B(bmpinfoheader,12);
|
||||
source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14);
|
||||
biCompression = GET_4B(bmpinfoheader,16);
|
||||
biXPelsPerMeter = GET_4B(bmpinfoheader,24);
|
||||
biYPelsPerMeter = GET_4B(bmpinfoheader,28);
|
||||
biXPelsPerMeter = (int) GET_4B(bmpinfoheader,24);
|
||||
biYPelsPerMeter = (int) GET_4B(bmpinfoheader,28);
|
||||
biClrUsed = GET_4B(bmpinfoheader,32);
|
||||
/* biSizeImage, biClrImportant fields are ignored */
|
||||
|
||||
switch (source->bits_per_pixel) {
|
||||
case 8: /* colormapped image */
|
||||
mapentrysize = 4; /* Windows uses RGBQUAD colormap */
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight);
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, biWidth, biHeight);
|
||||
break;
|
||||
case 24: /* RGB image */
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP, biWidth, biHeight);
|
||||
break;
|
||||
case 32: /* RGB image + Alpha channel */
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
|
||||
TRACEMS2(cinfo, 1, JTRC_BMP, biWidth, biHeight);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
|
||||
|
||||
32
rdppm.c
32
rdppm.c
@@ -4,8 +4,8 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2009 by Bill Allombert, Guido Vollbeding.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2016, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains routines to read input images in PPM/PGM format.
|
||||
@@ -92,7 +92,7 @@ pbm_getc (FILE * infile)
|
||||
|
||||
|
||||
LOCAL(unsigned int)
|
||||
read_pbm_integer (j_compress_ptr cinfo, FILE * infile, int maxval)
|
||||
read_pbm_integer (j_compress_ptr cinfo, FILE * infile, unsigned int maxval)
|
||||
/* Read an unsigned decimal integer from the PPM file */
|
||||
/* Swallows one trailing character after the integer */
|
||||
/* Note that on a 16-bit-int machine, only values up to 64k can be read. */
|
||||
@@ -116,10 +116,10 @@ read_pbm_integer (j_compress_ptr cinfo, FILE * infile, int maxval)
|
||||
val *= 10;
|
||||
val += ch - '0';
|
||||
}
|
||||
|
||||
|
||||
if (val > maxval)
|
||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
int maxval = source->maxval;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
ptr = source->pub.buffer[0];
|
||||
for (col = cinfo->image_width; col > 0; col--) {
|
||||
@@ -163,7 +163,7 @@ get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
int maxval = source->maxval;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
ptr = source->pub.buffer[0];
|
||||
for (col = cinfo->image_width; col > 0; col--) {
|
||||
@@ -243,6 +243,7 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register U_CHAR * bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
@@ -252,6 +253,8 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register int temp;
|
||||
temp = UCH(*bufferptr++) << 8;
|
||||
temp |= UCH(*bufferptr++);
|
||||
if (temp > maxval)
|
||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
||||
*ptr++ = rescale[temp];
|
||||
}
|
||||
return 1;
|
||||
@@ -267,6 +270,7 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register U_CHAR * bufferptr;
|
||||
register JSAMPLE *rescale = source->rescale;
|
||||
JDIMENSION col;
|
||||
unsigned int maxval = source->maxval;
|
||||
|
||||
if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
|
||||
ERREXIT(cinfo, JERR_INPUT_EOF);
|
||||
@@ -276,12 +280,18 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
register int temp;
|
||||
temp = UCH(*bufferptr++) << 8;
|
||||
temp |= UCH(*bufferptr++);
|
||||
if (temp > maxval)
|
||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
||||
*ptr++ = rescale[temp];
|
||||
temp = UCH(*bufferptr++) << 8;
|
||||
temp |= UCH(*bufferptr++);
|
||||
if (temp > maxval)
|
||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
||||
*ptr++ = rescale[temp];
|
||||
temp = UCH(*bufferptr++) << 8;
|
||||
temp |= UCH(*bufferptr++);
|
||||
if (temp > maxval)
|
||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
||||
*ptr++ = rescale[temp];
|
||||
}
|
||||
return 1;
|
||||
@@ -386,7 +396,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
|
||||
if (need_iobuffer) {
|
||||
source->buffer_width = (size_t) w * cinfo->input_components *
|
||||
((maxval<=255) ? sizeof(U_CHAR) : (2*sizeof(U_CHAR)));
|
||||
((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));
|
||||
source->iobuffer = (U_CHAR *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
source->buffer_width);
|
||||
@@ -414,11 +424,13 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* On 16-bit-int machines we have to be careful of maxval = 65535 */
|
||||
source->rescale = (JSAMPLE *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) (((long) maxval + 1L) * sizeof(JSAMPLE)));
|
||||
(size_t) (((long) maxval + 1L) *
|
||||
sizeof(JSAMPLE)));
|
||||
half_maxval = maxval / 2;
|
||||
for (val = 0; val <= (INT32) maxval; val++) {
|
||||
/* The multiplication here must be done in 32 bits to avoid overflow */
|
||||
source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval);
|
||||
source->rescale[val] = (JSAMPLE) ((val * MAXJSAMPLE + half_maxval) /
|
||||
maxval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
source->pixel_size < 1 || source->pixel_size > 4 ||
|
||||
(UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
|
||||
interlace_type != 0 || /* currently don't allow interlaced image */
|
||||
width == 0 || height == 0) /* image width/height must be nonzero */
|
||||
width == 0 || height == 0) /* image width/height must be non-zero */
|
||||
ERREXIT(cinfo, JERR_TGA_BADPARMS);
|
||||
|
||||
if (subtype > 8) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
if(NOT DEFINED NASM)
|
||||
set(NASM nasm CACHE PATH "Path to NASM/YASM executable")
|
||||
set(NASM nasm CACHE FILEPATH "Path to NASM/YASM executable")
|
||||
endif()
|
||||
|
||||
if(SIMD_X86_64)
|
||||
|
||||
@@ -50,14 +50,14 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
|
||||
collect_args
|
||||
push rbx
|
||||
|
||||
mov rcx, r10
|
||||
mov ecx, r10d
|
||||
test rcx,rcx
|
||||
jz near .return
|
||||
|
||||
push rcx
|
||||
|
||||
mov rsi, r12
|
||||
mov rcx, r13
|
||||
mov ecx, r13d
|
||||
mov rdi, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY]
|
||||
mov rbx, JSAMPARRAY [rsi+1*SIZEOF_JSAMPARRAY]
|
||||
mov rdx, JSAMPARRAY [rsi+2*SIZEOF_JSAMPARRAY]
|
||||
|
||||
@@ -50,14 +50,14 @@ EXTN(jsimd_rgb_gray_convert_sse2):
|
||||
collect_args
|
||||
push rbx
|
||||
|
||||
mov rcx, r10
|
||||
mov ecx, r10d
|
||||
test rcx,rcx
|
||||
jz near .return
|
||||
|
||||
push rcx
|
||||
|
||||
mov rsi, r12
|
||||
mov rcx, r13
|
||||
mov ecx, r13d
|
||||
mov rdi, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY]
|
||||
lea rdi, [rdi+rcx*SIZEOF_JSAMPROW]
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@ EXTN(jsimd_h2v1_downsample_sse2):
|
||||
mov rbp,rsp
|
||||
collect_args
|
||||
|
||||
mov rcx, r13
|
||||
mov ecx, r13d
|
||||
shl rcx,3 ; imul rcx,DCTSIZE (rcx = output_cols)
|
||||
jz near .return
|
||||
|
||||
mov rdx, r10
|
||||
mov edx, r10d
|
||||
|
||||
; -- expand_right_edge
|
||||
|
||||
@@ -90,7 +90,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
|
||||
|
||||
; -- h2v1_downsample
|
||||
|
||||
mov rax, r12 ; rowctr
|
||||
mov eax, r12d ; rowctr
|
||||
test eax,eax
|
||||
jle near .return
|
||||
|
||||
@@ -193,11 +193,11 @@ EXTN(jsimd_h2v2_downsample_sse2):
|
||||
mov rbp,rsp
|
||||
collect_args
|
||||
|
||||
mov rcx, r13
|
||||
mov ecx, r13d
|
||||
shl rcx,3 ; imul rcx,DCTSIZE (rcx = output_cols)
|
||||
jz near .return
|
||||
|
||||
mov rdx, r10
|
||||
mov edx, r10d
|
||||
|
||||
; -- expand_right_edge
|
||||
|
||||
@@ -234,7 +234,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
|
||||
|
||||
; -- h2v2_downsample
|
||||
|
||||
mov rax, r12 ; rowctr
|
||||
mov eax, r12d ; rowctr
|
||||
test rax,rax
|
||||
jle near .return
|
||||
|
||||
|
||||
@@ -52,14 +52,14 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
|
||||
collect_args
|
||||
push rbx
|
||||
|
||||
mov rcx, r10 ; num_cols
|
||||
mov ecx, r10d ; num_cols
|
||||
test rcx,rcx
|
||||
jz near .return
|
||||
|
||||
push rcx
|
||||
|
||||
mov rdi, r11
|
||||
mov rcx, r12
|
||||
mov ecx, r12d
|
||||
mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
|
||||
mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
|
||||
mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
|
||||
|
||||
@@ -52,14 +52,14 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
|
||||
collect_args
|
||||
push rbx
|
||||
|
||||
mov rcx, r10 ; col
|
||||
mov ecx, r10d ; col
|
||||
test rcx,rcx
|
||||
jz near .return
|
||||
|
||||
push rcx
|
||||
|
||||
mov rdi, r11
|
||||
mov rcx, r12
|
||||
mov ecx, r12d
|
||||
mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
|
||||
mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
|
||||
mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
|
||||
@@ -455,10 +455,10 @@ EXTN(jsimd_h2v2_merged_upsample_sse2):
|
||||
collect_args
|
||||
push rbx
|
||||
|
||||
mov rax, r10
|
||||
mov eax, r10d
|
||||
|
||||
mov rdi, r11
|
||||
mov rcx, r12
|
||||
mov ecx, r12d
|
||||
mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
|
||||
mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
|
||||
mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
|
||||
|
||||
@@ -67,7 +67,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
|
||||
mov rbp,rsp
|
||||
collect_args
|
||||
|
||||
mov rax, r11 ; colctr
|
||||
mov eax, r11d ; colctr
|
||||
test rax,rax
|
||||
jz near .return
|
||||
|
||||
@@ -214,7 +214,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
|
||||
collect_args
|
||||
push rbx
|
||||
|
||||
mov rax, r11 ; colctr
|
||||
mov eax, r11d ; colctr
|
||||
test rax,rax
|
||||
jz near .return
|
||||
|
||||
@@ -506,7 +506,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
|
||||
mov rbp,rsp
|
||||
collect_args
|
||||
|
||||
mov rdx, r11
|
||||
mov edx, r11d
|
||||
add rdx, byte (2*SIZEOF_XMMWORD)-1
|
||||
and rdx, byte -(2*SIZEOF_XMMWORD)
|
||||
jz near .return
|
||||
@@ -596,7 +596,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
|
||||
collect_args
|
||||
push rbx
|
||||
|
||||
mov rdx, r11
|
||||
mov edx, r11d
|
||||
add rdx, byte (2*SIZEOF_XMMWORD)-1
|
||||
and rdx, byte -(2*SIZEOF_XMMWORD)
|
||||
jz near .return
|
||||
|
||||
@@ -326,7 +326,7 @@ EXTN(jsimd_idct_float_sse2):
|
||||
mov rax, [original_rbp]
|
||||
lea rsi, [workspace] ; FAST_FLOAT * wsptr
|
||||
mov rdi, r12 ; (JSAMPROW *)
|
||||
mov rax, r13
|
||||
mov eax, r13d
|
||||
mov rcx, DCTSIZE/4 ; ctr
|
||||
.rowloop:
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
; can *not* be assembled with Microsoft's MASM or any compatible
|
||||
; assembler (including Borland's Turbo Assembler).
|
||||
; NASM is available from http://nasm.sourceforge.net/ or
|
||||
; http://sourceforge.net/projecpt/showfiles.php?group_id=6208
|
||||
; http://sourceforge.net/project/showfiles.php?group_id=6208
|
||||
;
|
||||
; This file contains a fast, not so accurate integer implementation of
|
||||
; the inverse DCT (Discrete Cosine Transform). The following code is
|
||||
@@ -323,7 +323,7 @@ EXTN(jsimd_idct_ifast_sse2):
|
||||
|
||||
mov rax, [original_rbp]
|
||||
mov rdi, r12 ; (JSAMPROW *)
|
||||
mov rax, r13
|
||||
mov eax, r13d
|
||||
|
||||
; -- Even part
|
||||
|
||||
|
||||
@@ -515,7 +515,7 @@ EXTN(jsimd_idct_islow_sse2):
|
||||
|
||||
mov rax, [original_rbp]
|
||||
mov rdi, r12 ; (JSAMPROW *)
|
||||
mov rax, r13
|
||||
mov eax, r13d
|
||||
|
||||
; -- Even part
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ EXTN(jsimd_idct_4x4_sse2):
|
||||
|
||||
mov rax, [original_rbp]
|
||||
mov rdi, r12 ; (JSAMPROW *)
|
||||
mov rax, r13
|
||||
mov eax, r13d
|
||||
|
||||
; -- Even part
|
||||
|
||||
@@ -521,7 +521,7 @@ EXTN(jsimd_idct_2x2_sse2):
|
||||
; ---- Pass 2: process rows, store into output array.
|
||||
|
||||
mov rdi, r12 ; (JSAMPROW *)
|
||||
mov rax, r13
|
||||
mov eax, r13d
|
||||
|
||||
; | input:| result:|
|
||||
; | A0 B0 | |
|
||||
|
||||
@@ -50,7 +50,7 @@ EXTN(jsimd_convsamp_float_sse2):
|
||||
packsswb xmm7,xmm7 ; xmm7 = PB_CENTERJSAMPLE (0x808080..)
|
||||
|
||||
mov rsi, r10
|
||||
mov rax, r11
|
||||
mov eax, r11d
|
||||
mov rdi, r12
|
||||
mov rcx, DCTSIZE/2
|
||||
.convloop:
|
||||
|
||||
@@ -50,7 +50,7 @@ EXTN(jsimd_convsamp_sse2):
|
||||
psllw xmm7,7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
|
||||
|
||||
mov rsi, r10
|
||||
mov rax, r11
|
||||
mov eax, r11d
|
||||
mov rdi, r12
|
||||
mov rcx, DCTSIZE/4
|
||||
.convloop:
|
||||
|
||||
@@ -1811,12 +1811,11 @@ LEAF_MIPS_DSPR2(jsimd_h2v2_upsample_mips_dspr2)
|
||||
bgtz t4, 2b
|
||||
addiu t5, 2
|
||||
3:
|
||||
ulw t6, 0(t7) // t6 = outptr
|
||||
ulw t5, 4(t7) // t5 = outptr[1]
|
||||
lw t6, 0(t7) // t6 = outptr[0]
|
||||
lw t5, 4(t7) // t5 = outptr[1]
|
||||
addu t4, t6, a1 // t4 = new end address
|
||||
subu t8, t4, t9
|
||||
beqz t8, 5f
|
||||
nop
|
||||
beq a1, t9, 5f
|
||||
subu t8, t4, t9
|
||||
4:
|
||||
ulw t0, 0(t6)
|
||||
ulw t1, 4(t6)
|
||||
|
||||
@@ -638,7 +638,7 @@ void bufSizeTest(void)
|
||||
&dstSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC));
|
||||
}
|
||||
free(srcBuf); srcBuf=NULL;
|
||||
if(!alloc)
|
||||
if(!alloc || doyuv)
|
||||
{
|
||||
tjFree(dstBuf); dstBuf=NULL;
|
||||
}
|
||||
@@ -670,7 +670,7 @@ void bufSizeTest(void)
|
||||
&dstSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC));
|
||||
}
|
||||
free(srcBuf); srcBuf=NULL;
|
||||
if(!alloc)
|
||||
if(!alloc || doyuv)
|
||||
{
|
||||
tjFree(dstBuf); dstBuf=NULL;
|
||||
}
|
||||
|
||||
19
turbojpeg.c
19
turbojpeg.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2009-2016 D. R. Commander. All Rights Reserved.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
*
|
||||
@@ -564,7 +564,8 @@ DLLEXPORT unsigned char *DLLCALL tjAlloc(int bytes)
|
||||
|
||||
static tjhandle _tjInitCompress(tjinstance *this)
|
||||
{
|
||||
unsigned char buffer[1], *buf=buffer; unsigned long size=1;
|
||||
static unsigned char buffer[1];
|
||||
unsigned char *buf=buffer; unsigned long size=1;
|
||||
|
||||
/* This is also straight out of example.c */
|
||||
this->cinfo.err=jpeg_std_error(&this->jerr.pub);
|
||||
@@ -1221,7 +1222,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, unsigned char *srcBuf,
|
||||
|
||||
static tjhandle _tjInitDecompress(tjinstance *this)
|
||||
{
|
||||
unsigned char buffer[1];
|
||||
static unsigned char buffer[1];
|
||||
|
||||
/* This is also straight out of example.c */
|
||||
this->dinfo.err=jpeg_std_error(&this->jerr.pub);
|
||||
@@ -1389,7 +1390,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, unsigned char *jpegBuf,
|
||||
if(scaledw<=width && scaledh<=height)
|
||||
break;
|
||||
}
|
||||
if(scaledw>width || scaledh>height)
|
||||
if(i>=NUMSF)
|
||||
_throw("tjDecompress2(): Could not scale down to desired image dimensions");
|
||||
width=scaledw; height=scaledh;
|
||||
dinfo->scale_num=sf[i].num;
|
||||
@@ -1764,7 +1765,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
|
||||
if(scaledw<=width && scaledh<=height)
|
||||
break;
|
||||
}
|
||||
if(scaledw>width || scaledh>height)
|
||||
if(i>=NUMSF)
|
||||
_throw("tjDecompressToYUVPlanes(): Could not scale down to desired image dimensions");
|
||||
if(dinfo->num_components>3)
|
||||
_throw("tjDecompressToYUVPlanes(): JPEG image must have 3 or fewer components");
|
||||
@@ -1893,6 +1894,12 @@ DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
|
||||
|| !isPow2(pad) || height<0)
|
||||
_throw("tjDecompressToYUV2(): Invalid argument");
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
||||
jpeg_read_header(dinfo, TRUE);
|
||||
jpegSubsamp=getSubsamp(dinfo);
|
||||
@@ -1910,7 +1917,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
|
||||
if(scaledw<=width && scaledh<=height)
|
||||
break;
|
||||
}
|
||||
if(scaledw>width || scaledh>height)
|
||||
if(i>=NUMSF)
|
||||
_throw("tjDecompressToYUV2(): Could not scale down to desired image dimensions");
|
||||
|
||||
pw0=tjPlaneWidth(0, width, jpegSubsamp);
|
||||
|
||||
48
turbojpeg.h
48
turbojpeg.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2014 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -619,7 +619,7 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
|
||||
* @param handle a handle to a TurboJPEG compressor or transformer instance
|
||||
*
|
||||
* @param srcBuf pointer to an image buffer containing RGB, grayscale, or
|
||||
* CMYK pixels to be compressed
|
||||
* CMYK pixels to be compressed. This buffer is not modified.
|
||||
*
|
||||
* @param width width (in pixels) of the source image
|
||||
*
|
||||
@@ -687,7 +687,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf,
|
||||
* #tjBufSizeYUV2() for the given image width, height, padding, and level of
|
||||
* chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be
|
||||
* stored sequentially in the source buffer (refer to @ref YUVnotes
|
||||
* "YUV Image Format Notes".)
|
||||
* "YUV Image Format Notes".) This buffer is not modified.
|
||||
*
|
||||
* @param width width (in pixels) of the source image. If the width is not an
|
||||
* even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
|
||||
@@ -752,7 +752,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, unsigned char *srcBuf,
|
||||
* memory. The size of each plane should match the value returned by
|
||||
* #tjPlaneSizeYUV() for the given image width, height, strides, and level of
|
||||
* chrominance subsampling. Refer to @ref YUVnotes "YUV Image Format Notes"
|
||||
* for more details.
|
||||
* for more details. These image planes are not modified.
|
||||
*
|
||||
* @param width width (in pixels) of the source image. If the width is not an
|
||||
* even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
|
||||
@@ -762,7 +762,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, unsigned char *srcBuf,
|
||||
* line in the corresponding plane of the YUV source image. Setting the stride
|
||||
* for any plane to 0 is the same as setting it to the plane width (see
|
||||
* @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
|
||||
* the strides for all planes will be set to their respective plane widths.
|
||||
* the strides for all planes will be set to their respective plane widths.
|
||||
* You can adjust the strides in order to specify an arbitrary amount of line
|
||||
* padding in each plane or to create a JPEG image from a subregion of a larger
|
||||
* YUV planar image.
|
||||
@@ -807,8 +807,8 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, unsigned char *srcBuf,
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
*/
|
||||
DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
|
||||
unsigned char **srcPlanes, int width, int *strides, int height, int subsamp,
|
||||
unsigned char **jpegBuf, unsigned long *jpegSize, int jpegQual, int flags);
|
||||
unsigned char **srcPlanes, int width, int *strides, int height, int subsamp,
|
||||
unsigned char **jpegBuf, unsigned long *jpegSize, int jpegQual, int flags);
|
||||
|
||||
|
||||
/**
|
||||
@@ -880,7 +880,7 @@ DLLEXPORT unsigned long DLLCALL tjBufSizeYUV2(int width, int pad, int height,
|
||||
* plane, or -1 if the arguments are out of bounds.
|
||||
*/
|
||||
DLLEXPORT unsigned long DLLCALL tjPlaneSizeYUV(int componentID, int width,
|
||||
int stride, int height, int subsamp);
|
||||
int stride, int height, int subsamp);
|
||||
|
||||
|
||||
/**
|
||||
@@ -921,12 +921,12 @@ DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp);
|
||||
* Encode an RGB or grayscale image into a YUV planar image. This function
|
||||
* uses the accelerated color conversion routines in the underlying
|
||||
* codec but does not execute any of the other steps in the JPEG compression
|
||||
* process.
|
||||
* process.
|
||||
*
|
||||
* @param handle a handle to a TurboJPEG compressor or transformer instance
|
||||
*
|
||||
* @param srcBuf pointer to an image buffer containing RGB or grayscale pixels
|
||||
* to be encoded
|
||||
* to be encoded. This buffer is not modified.
|
||||
*
|
||||
* @param width width (in pixels) of the source image
|
||||
*
|
||||
@@ -979,7 +979,7 @@ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle,
|
||||
* @param handle a handle to a TurboJPEG compressor or transformer instance
|
||||
*
|
||||
* @param srcBuf pointer to an image buffer containing RGB or grayscale pixels
|
||||
* to be encoded
|
||||
* to be encoded. This buffer is not modified.
|
||||
*
|
||||
* @param width width (in pixels) of the source image
|
||||
*
|
||||
@@ -1042,7 +1042,8 @@ DLLEXPORT tjhandle DLLCALL tjInitDecompress(void);
|
||||
*
|
||||
* @param handle a handle to a TurboJPEG decompressor or transformer instance
|
||||
*
|
||||
* @param jpegBuf pointer to a buffer containing a JPEG image
|
||||
* @param jpegBuf pointer to a buffer containing a JPEG image. This buffer is
|
||||
* not modified.
|
||||
*
|
||||
* @param jpegSize size of the JPEG image (in bytes)
|
||||
*
|
||||
@@ -1085,7 +1086,8 @@ DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors);
|
||||
*
|
||||
* @param handle a handle to a TurboJPEG decompressor or transformer instance
|
||||
*
|
||||
* @param jpegBuf pointer to a buffer containing the JPEG image to decompress
|
||||
* @param jpegBuf pointer to a buffer containing the JPEG image to decompress.
|
||||
* This buffer is not modified.
|
||||
*
|
||||
* @param jpegSize size of the JPEG image (in bytes)
|
||||
*
|
||||
@@ -1141,7 +1143,8 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
|
||||
*
|
||||
* @param handle a handle to a TurboJPEG decompressor or transformer instance
|
||||
*
|
||||
* @param jpegBuf pointer to a buffer containing the JPEG image to decompress
|
||||
* @param jpegBuf pointer to a buffer containing the JPEG image to decompress.
|
||||
* This buffer is not modified.
|
||||
*
|
||||
* @param jpegSize size of the JPEG image (in bytes)
|
||||
*
|
||||
@@ -1191,7 +1194,8 @@ DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
|
||||
*
|
||||
* @param handle a handle to a TurboJPEG decompressor or transformer instance
|
||||
*
|
||||
* @param jpegBuf pointer to a buffer containing the JPEG image to decompress
|
||||
* @param jpegBuf pointer to a buffer containing the JPEG image to decompress.
|
||||
* This buffer is not modified.
|
||||
*
|
||||
* @param jpegSize size of the JPEG image (in bytes)
|
||||
*
|
||||
@@ -1253,7 +1257,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
|
||||
* #tjBufSizeYUV2() for the given image width, height, padding, and level of
|
||||
* chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be
|
||||
* stored sequentially in the source buffer (refer to @ref YUVnotes
|
||||
* "YUV Image Format Notes".)
|
||||
* "YUV Image Format Notes".) This buffer is not modified.
|
||||
*
|
||||
* @param pad Use this parameter to specify that the width of each line in each
|
||||
* plane of the YUV source image is padded to the nearest multiple of this
|
||||
@@ -1288,8 +1292,8 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
*/
|
||||
DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf,
|
||||
int pad, int subsamp, unsigned char *dstBuf, int width, int pitch,
|
||||
int height, int pixelFormat, int flags);
|
||||
int pad, int subsamp, unsigned char *dstBuf, int width, int pitch,
|
||||
int height, int pixelFormat, int flags);
|
||||
|
||||
|
||||
/**
|
||||
@@ -1306,7 +1310,7 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf,
|
||||
* The size of each plane should match the value returned by #tjPlaneSizeYUV()
|
||||
* for the given image width, height, strides, and level of chrominance
|
||||
* subsampling. Refer to @ref YUVnotes "YUV Image Format Notes" for more
|
||||
* details.
|
||||
* details. These image planes are not modified.
|
||||
*
|
||||
* @param strides an array of integers, each specifying the number of bytes per
|
||||
* line in the corresponding plane of the YUV source image. Setting the stride
|
||||
@@ -1345,8 +1349,8 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf,
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
*/
|
||||
DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
|
||||
unsigned char **srcPlanes, int *strides, int subsamp, unsigned char *dstBuf,
|
||||
int width, int pitch, int height, int pixelFormat, int flags);
|
||||
unsigned char **srcPlanes, int *strides, int subsamp, unsigned char *dstBuf,
|
||||
int width, int pitch, int height, int pixelFormat, int flags);
|
||||
|
||||
|
||||
/**
|
||||
@@ -1374,7 +1378,7 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
|
||||
* @param handle a handle to a TurboJPEG transformer instance
|
||||
*
|
||||
* @param jpegBuf pointer to a buffer containing the JPEG source image to
|
||||
* transform
|
||||
* transform. This buffer is not modified.
|
||||
*
|
||||
* @param jpegSize size of the JPEG source image (in bytes)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user