aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml11
-rw-r--r--BUILDING.md160
-rw-r--r--CMakeLists.txt43
-rw-r--r--ChangeLog.md70
-rw-r--r--LICENSE.md29
-rw-r--r--METADATA8
-rw-r--r--README.android4
-rw-r--r--cmakescripts/GNUInstallDirs.cmake4
-rw-r--r--java/CMakeLists.txt20
-rw-r--r--java/TJBench.java14
-rw-r--r--jconfig.h35
-rw-r--r--jconfig.h.in28
-rw-r--r--jconfigint.h30
-rw-r--r--jdcolor.c2
-rw-r--r--jdmerge.c2
-rw-r--r--jquant1.c2
-rw-r--r--jversion.h6
-rw-r--r--rdtarga.c11
-rwxr-xr-xrelease/installer.nsi.in12
-rw-r--r--release/rpm.spec.in6
-rwxr-xr-xsharedlib/CMakeLists.txt8
-rwxr-xr-xsimd/CMakeLists.txt4
-rw-r--r--simd/arm64/jsimd_neon.S2
-rw-r--r--simd/i386/jsimdcpu.asm5
-rw-r--r--simd/loongson/jccolext-mmi.c32
-rw-r--r--simd/loongson/loongson-mmintrin.h21
-rw-r--r--simd/mips/jsimd.c8
-rw-r--r--simd/mips/jsimd_dspr2.S8
-rw-r--r--simd/x86_64/jsimdcpu.asm5
-rw-r--r--tjbench.c14
-rw-r--r--turbojpeg-jni.c10
-rw-r--r--turbojpeg.c26
-rw-r--r--wrbmp.c15
-rw-r--r--wrjpgcom.c2
-rw-r--r--wrppm.c19
35 files changed, 402 insertions, 274 deletions
diff --git a/.travis.yml b/.travis.yml
index acfdb7c6..25389549 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -52,10 +52,13 @@ matrix:
compiler: gcc
env: CMAKE_FLAGS="-DWITH_SIMD=0"
+addons:
+ homebrew:
+ brewfile: true
+ update: true
+
before_install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
- brew update &&
- brew bundle &&
ln -fs /usr/local/bin/gpg1 /usr/local/bin/gpg &&
git clone --depth=1 https://github.com/libjpeg-turbo/gas-preprocessor.git ~/src/gas-preprocessor &&
ln -fs /Applications/Xcode.app /Applications/Xcode72.app;
@@ -79,7 +82,9 @@ script:
- if [ "${BUILD_OFFICIAL:-}" != "" ]; then
mkdir -p ~/src/ljt.nightly &&
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
- docker run -v $HOME/src/ljt.nightly:/root/src/ljt.nightly -v $HOME/src/buildscripts:/root/src/buildscripts -v $TRAVIS_BUILD_DIR:/root/src/libjpeg-turbo -v $HOME/.gnupg:/root/.gnupg -t dcommander/buildljt:latest bash -c "rpm --import http://pool.sks-keyservers.net/pks/lookup?op=get\&search=0x0575F26BD5B3FDB1 && ~/src/buildscripts/buildljt -d /root/src/libjpeg-turbo -v" &&
+ mkdir $HOME/rpmkeys &&
+ wget --no-check-certificate "http://www.libjpeg-turbo.org/key/LJTPR-GPG-KEY" -O $HOME/rpmkeys/LJTPR-GPG-KEY &&
+ docker run -v $HOME/src/ljt.nightly:/root/src/ljt.nightly -v $HOME/src/buildscripts:/root/src/buildscripts -v $TRAVIS_BUILD_DIR:/root/src/libjpeg-turbo -v $HOME/.gnupg:/root/.gnupg -v $HOME/rpmkeys:/rpmkeys -t dcommander/buildljt:latest bash -c "rpm --import /rpmkeys/LJTPR-GPG-KEY && ~/src/buildscripts/buildljt -d /root/src/libjpeg-turbo -v" &&
sudo chown -R travis:travis ~/src/ljt.nightly &&
mv ~/src/ljt.nightly/latest/log-$TRAVIS_OS_NAME.txt ~/src/ljt.nightly/latest/files/;
else
diff --git a/BUILDING.md b/BUILDING.md
index b11ab8b3..9ef1f45e 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -48,8 +48,9 @@ Build Requirements
install the Java Developer Package, which can be downloaded from
<http://developer.apple.com/downloads> (Apple ID required.) For other
systems, you can obtain the Oracle Java Development Kit from
- <http://www.java.com>.
+ <http://www.oracle.com/technetwork/java/javase/downloads>.
+ * If using JDK 11 or later, CMake 3.10.x or later must also be used.
### Windows
@@ -83,7 +84,10 @@ Build Requirements
appropriate compiler paths automatically set.
- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
- can be downloaded from <http://www.java.com>.
+ can be downloaded from
+ <http://www.oracle.com/technetwork/java/javase/downloads>.
+
+ * If using JDK 11 or later, CMake 3.10.x or later must also be used.
Out-of-Tree Builds
@@ -521,7 +525,7 @@ a universal library.
Building libjpeg-turbo for Android
----------------------------------
-Building libjpeg-turbo for Android platforms requires the
+Building libjpeg-turbo for Android platforms requires v13b or later of the
[Android NDK](https://developer.android.com/tools/sdk/ndk).
@@ -531,35 +535,21 @@ The following is a general recipe script that can be modified for your specific
needs.
# Set these variables to suit your needs
- NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
- BUILD_PLATFORM={the platform name for the NDK package you installed--
- for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
- TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
- toolchain directory under ${NDK_PATH}/toolchains/.}
- ANDROID_VERSION={The minimum version of Android to support-- for example,
+ NDK_PATH={full path to the NDK directory-- for example,
+ /opt/android/android-ndk-r16b}
+ TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r16b and earlier,
+ and "clang" must be used with NDK r17c and later}
+ ANDROID_VERSION={the minimum version of Android to support-- for example,
"16", "19", etc.}
- # It should not be necessary to modify the rest
- HOST=arm-linux-androideabi
- SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
- export CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
- -D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
- -isystem ${NDK_PATH}/sysroot/usr/include \
- -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
- export LDFLAGS=-pie
- TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
-
cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Linux)
- set(CMAKE_SYSTEM_PROCESSOR arm)
- set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
- set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
+ cmake -G"Unix Makefiles" \
+ -DANDROID_ABI=armeabi-v7a \
+ -DANDROID_ARM_MODE=arm \
+ -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
+ -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
+ -DCMAKE_ASM_FLAGS="--target=arm-linux-androideabi${ANDROID_VERSION}" \
+ -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
[additional CMake flags] {source_directory}
make
@@ -570,34 +560,21 @@ The following is a general recipe script that can be modified for your specific
needs.
# Set these variables to suit your needs
- NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
- BUILD_PLATFORM={the platform name for the NDK package you installed--
- for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
- TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
- toolchain directory under ${NDK_PATH}/toolchains/.}
- ANDROID_VERSION={The minimum version of Android to support. "21" or later
+ NDK_PATH={full path to the NDK directory-- for example,
+ /opt/android/android-ndk-r16b}
+ TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
+ and "clang" must be used with NDK r17c and later}
+ ANDROID_VERSION={the minimum version of Android to support. "21" or later
is required for a 64-bit build.}
- # It should not be necessary to modify the rest
- HOST=aarch64-linux-android
- SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm64
- export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
- -isystem ${NDK_PATH}/sysroot/usr/include \
- -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
- export LDFLAGS=-pie
- TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
-
cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Linux)
- set(CMAKE_SYSTEM_PROCESSOR aarch64)
- set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
- set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
+ cmake -G"Unix Makefiles" \
+ -DANDROID_ABI=arm64-v8a \
+ -DANDROID_ARM_MODE=arm \
+ -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
+ -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
+ -DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${ANDROID_VERSION}" \
+ -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
[additional CMake flags] {source_directory}
make
@@ -608,34 +585,19 @@ The following is a general recipe script that can be modified for your specific
needs.
# Set these variables to suit your needs
- NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
- BUILD_PLATFORM={the platform name for the NDK package you installed--
- for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
- TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
- toolchain directory under ${NDK_PATH}/toolchains/.}
+ NDK_PATH={full path to the NDK directory-- for example,
+ /opt/android/android-ndk-r16b}
+ TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
+ and "clang" must be used with NDK r17c and later}
ANDROID_VERSION={The minimum version of Android to support-- for example,
"16", "19", etc.}
- # It should not be necessary to modify the rest
- HOST=i686-linux-android
- SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-x86
- export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
- -isystem ${NDK_PATH}/sysroot/usr/include \
- -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
- export LDFLAGS=-pie
- TOOLCHAIN=${NDK_PATH}/toolchains/x86-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
-
cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Linux)
- set(CMAKE_SYSTEM_PROCESSOR i386)
- set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
- set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
+ cmake -G"Unix Makefiles" \
+ -DANDROID_ABI=x86 \
+ -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
+ -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
+ -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
[additional CMake flags] {source_directory}
make
@@ -646,45 +608,23 @@ The following is a general recipe script that can be modified for your specific
needs.
# Set these variables to suit your needs
- NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
- BUILD_PLATFORM={the platform name for the NDK package you installed--
- for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
- TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
- toolchain directory under ${NDK_PATH}/toolchains/.}
- ANDROID_VERSION={The minimum version of Android to support. "21" or later
+ NDK_PATH={full path to the NDK directory-- for example,
+ /opt/android/android-ndk-r16b}
+ TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
+ and "clang" must be used with NDK r17c and later}
+ ANDROID_VERSION={the minimum version of Android to support. "21" or later
is required for a 64-bit build.}
- # It should not be necessary to modify the rest
- HOST=x86_64-linux-android
- SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-x86_64
- export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
- -isystem ${NDK_PATH}/sysroot/usr/include \
- -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
- export LDFLAGS=-pie
- TOOLCHAIN=${NDK_PATH}/toolchains/x86_64-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
-
cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Linux)
- set(CMAKE_SYSTEM_PROCESSOR x86_64)
- set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
- set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
+ cmake -G"Unix Makefiles" \
+ -DANDROID_ABI=x86_64 \
+ -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
+ -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
+ -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
[additional CMake flags] {source_directory}
make
-If building for Android 4.0.x (API level < 16) or earlier, remove
-`-DCMAKE_POSITION_INDEPENDENT_CODE=1` from the CMake arguments and `-pie` from
-`LDFLAGS`.
-
-If building on Windows, add `.exe` to the end of `CMAKE_C_COMPILER`.
-
-
Advanced CMake Options
----------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1719522f..2bc34581 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ if(CMAKE_EXECUTABLE_SUFFIX)
endif()
project(libjpeg-turbo C)
-set(VERSION 2.0.0)
+set(VERSION 2.0.2)
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
@@ -109,8 +109,6 @@ endif()
include(cmakescripts/GNUInstallDirs.cmake)
-set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
-
macro(report_directory var)
if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
@@ -191,6 +189,10 @@ endif()
report_option(ENABLE_SHARED "Shared libraries")
report_option(ENABLE_STATIC "Static libraries")
+if(ENABLE_SHARED)
+ set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
+endif()
+
if(WITH_12BIT)
set(WITH_ARITH_DEC 0)
set(WITH_ARITH_ENC 0)
@@ -468,8 +470,8 @@ if(UNIX AND NOT APPLE)
# still work.
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map
"VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;")
- set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
- check_c_source_compiles("void foo() {} void foo2() {} int main(void) { return 0; }"
+ set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared")
+ check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }"
HAVE_MAPFILE)
set(CMAKE_REQUIRED_FLAGS)
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
@@ -997,6 +999,8 @@ foreach(libtype ${TEST_LIBTYPES})
add_test(djpeg-${libtype}-rgb-islow-icc-cmp
${MD5CMP} b06a39d730129122e85c1363ed1bbc9e testout_rgb_islow.icc)
+ set_tests_properties(djpeg-${libtype}-rgb-islow-icc-cmp PROPERTIES
+ DEPENDS djpeg-${libtype}-rgb-islow)
add_bittest(jpegtran icc "-copy;all;-icc;${TESTIMAGES}/test2.icc"
testout_rgb_islow2.jpg testout_rgb_islow.jpg ${MD5_JPEG_RGB_ISLOW2})
@@ -1328,12 +1332,22 @@ if(WITH_TURBOJPEG)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
+ CMAKE_C_LINKER_SUPPORTS_PDB)
+ install(FILES "$<TARGET_PDB_FILE:turbojpeg>"
+ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
+ endif()
endif()
if(ENABLE_STATIC)
install(TARGETS turbojpeg-static ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(NOT ENABLE_SHARED)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static${EXE}
+ if(MSVC_IDE)
+ set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
+ else()
+ set(DIR ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+ install(PROGRAMS ${DIR}/tjbench-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
endif()
endif()
@@ -1344,11 +1358,16 @@ endif()
if(ENABLE_STATIC)
install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(NOT ENABLE_SHARED)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static${EXE}
+ if(MSVC_IDE)
+ set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
+ else()
+ set(DIR ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+ install(PROGRAMS ${DIR}/cjpeg-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static${EXE}
+ install(PROGRAMS ${DIR}/djpeg-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jpegtran-static${EXE}
+ install(PROGRAMS ${DIR}/jpegtran-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
endif()
endif()
@@ -1373,10 +1392,10 @@ if(UNIX OR MINGW)
${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
- ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
+ ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
diff --git a/ChangeLog.md b/ChangeLog.md
index 8f0d11b1..7cf92c30 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,73 @@
+2.0.2
+=====
+
+### Significant changes relative to 2.0.1:
+
+1. Fixed a regression introduced by 2.0.1[5] that prevented a runtime search
+path (rpath) from being embedded in the libjpeg-turbo shared libraries and
+executables for macOS and iOS. This caused a fatal error of the form
+"dyld: Library not loaded" when attempting to use one of the executables,
+unless `DYLD_LIBRARY_PATH` was explicitly set to the location of the
+libjpeg-turbo shared libraries.
+
+2. Fixed an integer overflow and subsequent segfault (CVE-2018-20330) that
+occurred when attempting to load a BMP file with more than 1 billion pixels
+using the `tjLoadImage()` function.
+
+3. Fixed a buffer overrun (CVE-2018-19664) that occurred when attempting to
+decompress a specially-crafted malformed JPEG image to a 256-color BMP using
+djpeg.
+
+4. Fixed a floating point exception that occurred when attempting to
+decompress a specially-crafted malformed JPEG image with a specified image
+width or height of 0 using the C version of TJBench.
+
+5. The TurboJPEG API will now decompress 4:4:4 JPEG images with 2x1, 1x2, 3x1,
+or 1x3 luminance and chrominance sampling factors. This is a non-standard way
+of specifying 1x subsampling (normally 4:4:4 JPEGs have 1x1 luminance and
+chrominance sampling factors), but the JPEG format and the libjpeg API both
+allow it.
+
+6. Fixed a regression introduced by 2.0 beta1[7] that caused djpeg to generate
+incorrect PPM images when used with the `-colors` option.
+
+7. Fixed an issue whereby a static build of libjpeg-turbo (a build in which
+`ENABLE_SHARED` is `0`) could not be installed using the Visual Studio IDE.
+
+8. Fixed a severe performance issue in the Loongson MMI SIMD extensions that
+occurred when compressing RGB images whose image rows were not 64-bit-aligned.
+
+
+2.0.1
+=====
+
+### Significant changes relative to 2.0.0:
+
+1. Fixed a regression introduced with the new CMake-based Un*x build system,
+whereby jconfig.h could cause compiler warnings of the form
+`"HAVE_*_H" redefined` if it was included by downstream Autotools-based
+projects that used `AC_CHECK_HEADERS()` to check for the existence of locale.h,
+stddef.h, or stdlib.h.
+
+2. The `jsimd_quantize_float_dspr2()` and `jsimd_convsamp_float_dspr2()`
+functions in the MIPS DSPr2 SIMD extensions are now disabled at compile time
+if the soft float ABI is enabled. Those functions use instructions that are
+incompatible with the soft float ABI.
+
+3. Fixed a regression in the SIMD feature detection code, introduced by
+the AVX2 SIMD extensions (2.0 beta1[1]), that caused libjpeg-turbo to crash on
+Windows 7 if Service Pack 1 was not installed.
+
+4. Fixed out-of-bounds read in cjpeg that occurred when attempting to compress
+a specially-crafted malformed color-index (8-bit-per-sample) Targa file in
+which some of the samples (color indices) exceeded the bounds of the Targa
+file's color table.
+
+5. Fixed an issue whereby installing a fully static build of libjpeg-turbo
+(a build in which `CFLAGS` contains `-static` and `ENABLE_SHARED` is `0`) would
+fail with "No valid ELF RPATH or RUNPATH entry exists in the file."
+
+
2.0.0
=====
diff --git a/LICENSE.md b/LICENSE.md
index 0f6ec4b3..5ca512b3 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -14,7 +14,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
This license covers the TurboJPEG API library and associated programs, as
well as the build system.
-- The zlib License, which is listed below
+- The [zlib License](https://opensource.org/licenses/Zlib)
This license is a subset of the other two, and it covers the libjpeg-turbo
SIMD extensions.
@@ -66,7 +66,7 @@ best of our understanding.
2. If your binary distribution includes or uses the TurboJPEG API, then
your product documentation must include the text of the Modified BSD
- License.
+ License (see below.)
**Origin**
- Clause 2 of the Modified BSD License
@@ -91,7 +91,8 @@ best of our understanding.
The Modified (3-clause) BSD License
===================================
-Copyright (C)\<YEAR\> \<AUTHOR\>. All Rights Reserved.
+Copyright (C)2009-2019 D. R. Commander. All Rights Reserved.
+Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -118,28 +119,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-The zlib License
-================
-
-Copyright (C) \<YEAR\>, \<AUTHOR\>.
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-3. This notice may not be removed or altered from any source distribution.
-
-
Why Three Licenses?
===================
diff --git a/METADATA b/METADATA
index d0ae4449..8f4252eb 100644
--- a/METADATA
+++ b/METADATA
@@ -5,10 +5,10 @@ third_party {
type: GIT
value: "https://github.com/libjpeg-turbo/libjpeg-turbo.git"
}
- version: "2.0.0"
+ version: "2.0.2"
last_upgrade_date {
- year: 2018
- month: 8
- day: 28
+ year: 2019
+ month: 3
+ day: 15
}
}
diff --git a/README.android b/README.android
index 7f09a06e..12f476d1 100644
--- a/README.android
+++ b/README.android
@@ -1,5 +1,5 @@
-Any Android specific modifications to upstream libjpeg-turbo (2.0.0) should
-be listed here:
+Any Android specific modifications to upstream libjpeg-turbo (the version
+specified in METADATA) should be listed here:
(1) jconfig.h and jconfigint.h
diff --git a/cmakescripts/GNUInstallDirs.cmake b/cmakescripts/GNUInstallDirs.cmake
index ef564bb6..7c411965 100644
--- a/cmakescripts/GNUInstallDirs.cmake
+++ b/cmakescripts/GNUInstallDirs.cmake
@@ -118,7 +118,7 @@
# absolute paths where necessary, using the same logic.
#=============================================================================
-# Copyright 2016 D. R. Commander
+# Copyright 2016, 2019 D. R. Commander
# Copyright 2016 Dmitry Marakasov
# Copyright 2016 Roger Leigh
# Copyright 2015 Alex Turbov
@@ -184,7 +184,7 @@ macro(GNUInstallDirs_set_install_dir var docstring)
"${docstring} (Default: ${CMAKE_INSTALL_DEFAULT_${var}})"
${_GNUInstallDirs_CMAKE_INSTALL_FORCE_${var}})
- if(NOT "${CMAKE_INSTALL_${var}}" STREQUAL "${CMAKE_INSTALL_DEFAULT_${var}}")
+ if(NOT CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_DEFAULT_${var})
unset(_GNUInstallDirs_CMAKE_INSTALL_DEFAULT_${var} CACHE)
endif()
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index d51ada74..3d863bdd 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -58,11 +58,21 @@ endif()
add_custom_target(javadoc COMMAND
javadoc -notimestamp -d ${CMAKE_CURRENT_SOURCE_DIR}/doc -sourcepath ${CMAKE_CURRENT_SOURCE_DIR} org.libjpegturbo.turbojpeg)
set(JAVACLASSPATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/turbojpeg-java.dir)
-add_custom_target(javah
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJ
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJCompressor
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJDecompressor
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJTransformer)
+if(Java_VERSION_MAJOR GREATER 9)
+ add_custom_target(javah
+ COMMAND javac -h ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH}
+ -d ${CMAKE_CURRENT_BINARY_DIR}/__unused
+ ${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJ.java
+ ${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJCompressor.java
+ ${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJDecompressor.java
+ ${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJTransformer.java)
+else()
+ add_custom_target(javah
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJ
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJCompressor
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJDecompressor
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJTransformer)
+endif()
if(NOT DEFINED CMAKE_INSTALL_DEFAULT_JAVADIR)
set(CMAKE_INSTALL_DEFAULT_JAVADIR "<CMAKE_INSTALL_DATAROOTDIR>/java")
diff --git a/java/TJBench.java b/java/TJBench.java
index bd555626..7829e53c 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2014, 2016-2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2014, 2016-2019 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:
@@ -202,7 +202,9 @@ final class TJBench {
int width = doTile ? Math.min(tilew, w - x) : scaledw;
int height = doTile ? Math.min(tileh, h - y) : scaledh;
- tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]);
+ try {
+ tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]);
+ } catch (TJException e) { handleTJException(e); }
if (doYUV) {
yuvImage.setBuf(yuvImage.getBuf(), width, yuvPad, height, subsamp);
try {
@@ -500,7 +502,9 @@ final class TJBench {
tjt = new TJTransformer();
- tjt.setSourceImage(srcBuf, srcSize);
+ try {
+ tjt.setSourceImage(srcBuf, srcSize);
+ } catch (TJException e) { handleTJException(e); }
w = tjt.getWidth();
h = tjt.getHeight();
subsamp = tjt.getSubsamp();
@@ -607,7 +611,9 @@ final class TJBench {
elapsed = 0.;
while (true) {
start = getTime();
- tjt.transform(jpegBuf, t, flags);
+ try {
+ tjt.transform(jpegBuf, t, flags);
+ } catch (TJException e) { handleTJException(e); }
jpegSize = tjt.getTransformedSizes();
elapsed += getTime() - start;
if (iter >= 0) {
diff --git a/jconfig.h b/jconfig.h
index 060b32b2..4a14b9ec 100644
--- a/jconfig.h
+++ b/jconfig.h
@@ -1,14 +1,13 @@
-/* jconfig.h. Generated from jconfig.h.in by configure. */
/* Version ID for the JPEG library.
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
*/
-#define JPEG_LIB_VERSION 62
+#define JPEG_LIB_VERSION 62
/* libjpeg-turbo version */
-#define LIBJPEG_TURBO_VERSION 2.0.0
+#define LIBJPEG_TURBO_VERSION 2.0.2
/* libjpeg-turbo version in integer form */
-#define LIBJPEG_TURBO_VERSION_NUMBER 2000000
+#define LIBJPEG_TURBO_VERSION_NUMBER 2000002
/* Support arithmetic encoding */
#define C_ARITH_CODING_SUPPORTED 1
@@ -16,6 +15,12 @@
/* Support arithmetic decoding */
#define D_ARITH_CODING_SUPPORTED 1
+/* Support in-memory source/destination managers */
+#define MEM_SRCDST_SUPPORTED 1
+
+/* Use accelerated SIMD routines. */
+#define WITH_SIMD 1
+
/*
* Define BITS_IN_JSAMPLE as either
* 8 for 8-bit sample values (the usual setting)
@@ -36,6 +41,13 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
+/* Define if you need to include <sys/types.h> to get size_t. */
+#define NEED_SYS_TYPES_H 1
+
+/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
+ memset/memcpy in <string.h>. */
+/* #undef NEED_BSD_STRINGS */
+
/* Define to 1 if the system has the type `unsigned char'. */
#define HAVE_UNSIGNED_CHAR 1
@@ -45,26 +57,13 @@
/* Compiler does not support pointers to undefined structures. */
/* #undef INCOMPLETE_TYPES_BROKEN */
-/* Support in-memory source/destination managers */
-#define MEM_SRCDST_SUPPORTED 1
-
-/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
- memset/memcpy in <string.h>. */
-/* #undef NEED_BSD_STRINGS */
-
-/* Define if you need to include <sys/types.h> to get size_t. */
-/* #undef NEED_SYS_TYPES_H */
-
/* Define if your (broken) compiler shifts signed values as if they were
unsigned. */
/* #undef RIGHT_SHIFT_IS_UNSIGNED */
-/* Use accelerated SIMD routines. */
-#define WITH_SIMD 1
-
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
#ifndef __CHAR_UNSIGNED__
-/* # undef __CHAR_UNSIGNED__ */
+/* #undef __CHAR_UNSIGNED__ */
#endif
/* Define to empty if `const' does not conform to ANSI C. */
diff --git a/jconfig.h.in b/jconfig.h.in
index 28427548..18a69a48 100644
--- a/jconfig.h.in
+++ b/jconfig.h.in
@@ -10,16 +10,16 @@
#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
/* Support arithmetic encoding */
-#cmakedefine C_ARITH_CODING_SUPPORTED
+#cmakedefine C_ARITH_CODING_SUPPORTED 1
/* Support arithmetic decoding */
-#cmakedefine D_ARITH_CODING_SUPPORTED
+#cmakedefine D_ARITH_CODING_SUPPORTED 1
/* Support in-memory source/destination managers */
-#cmakedefine MEM_SRCDST_SUPPORTED
+#cmakedefine MEM_SRCDST_SUPPORTED 1
/* Use accelerated SIMD routines. */
-#cmakedefine WITH_SIMD
+#cmakedefine WITH_SIMD 1
/*
* Define BITS_IN_JSAMPLE as either
@@ -33,37 +33,37 @@
#define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */
/* Define to 1 if you have the <locale.h> header file. */
-#cmakedefine HAVE_LOCALE_H
+#cmakedefine HAVE_LOCALE_H 1
/* Define to 1 if you have the <stddef.h> header file. */
-#cmakedefine HAVE_STDDEF_H
+#cmakedefine HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
-#cmakedefine HAVE_STDLIB_H
+#cmakedefine HAVE_STDLIB_H 1
/* Define if you need to include <sys/types.h> to get size_t. */
-#cmakedefine NEED_SYS_TYPES_H
+#cmakedefine NEED_SYS_TYPES_H 1
/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
memset/memcpy in <string.h>. */
-#cmakedefine NEED_BSD_STRINGS
+#cmakedefine NEED_BSD_STRINGS 1
/* Define to 1 if the system has the type `unsigned char'. */
-#cmakedefine HAVE_UNSIGNED_CHAR
+#cmakedefine HAVE_UNSIGNED_CHAR 1
/* Define to 1 if the system has the type `unsigned short'. */
-#cmakedefine HAVE_UNSIGNED_SHORT
+#cmakedefine HAVE_UNSIGNED_SHORT 1
/* Compiler does not support pointers to undefined structures. */
-#cmakedefine INCOMPLETE_TYPES_BROKEN
+#cmakedefine INCOMPLETE_TYPES_BROKEN 1
/* Define if your (broken) compiler shifts signed values as if they were
unsigned. */
-#cmakedefine RIGHT_SHIFT_IS_UNSIGNED
+#cmakedefine RIGHT_SHIFT_IS_UNSIGNED 1
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
#ifndef __CHAR_UNSIGNED__
- #cmakedefine __CHAR_UNSIGNED__
+ #cmakedefine __CHAR_UNSIGNED__ 1
#endif
/* Define to empty if `const' does not conform to ANSI C. */
diff --git a/jconfigint.h b/jconfigint.h
index bf988da3..5b28a1f4 100644
--- a/jconfigint.h
+++ b/jconfigint.h
@@ -4,7 +4,10 @@
#define __JCONFIGINT_H__
/* libjpeg-turbo build number */
-#define BUILD ""
+#define BUILD ""
+
+/* Compiler's inline keyword */
+#undef inline
/* How to obtain function inlining. */
#ifndef INLINE
@@ -22,19 +25,34 @@
#endif
/* Define to the full name of this package. */
-#define PACKAGE_NAME "libjpeg-turbo"
+#define PACKAGE_NAME "libjpeg-turbo"
/* Version number of package */
-#define VERSION "2.0.0"
+#define VERSION "2.0.2"
+/* The size of `size_t', as computed by sizeof. */
/* The size of `size_t', as reported by the compiler through the
* builtin macro __SIZEOF_SIZE_T__. If the compiler does not
* report __SIZEOF_SIZE_T__ add a custom rule for the compiler
* here. */
#ifdef __SIZEOF_SIZE_T__
-#define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
+ #define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
#else
-#error cannot determine the size of size_t
+ #error cannot determine the size of size_t
+#endif
+
+/* Define if your compiler has __builtin_ctzl() and sizeof(unsigned long) == sizeof(size_t). */
+#define HAVE_BUILTIN_CTZL
+
+/* Define to 1 if you have the <intrin.h> header file. */
+/* #undef HAVE_INTRIN_H */
+
+#if defined(_MSC_VER) && defined(HAVE_INTRIN_H)
+#if (SIZEOF_SIZE_T == 8)
+#define HAVE_BITSCANFORWARD64
+#elif (SIZEOF_SIZE_T == 4)
+#define HAVE_BITSCANFORWARD
+#endif
#endif
-#endif // __JCONFIGINT_H__
+#endif // __JCONFIGINT_H__
diff --git a/jdcolor.c b/jdcolor.c
index fd7f661d..dc0e3b6c 100644
--- a/jdcolor.c
+++ b/jdcolor.c
@@ -592,7 +592,7 @@ ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
/* Declarations for ordered dithering
*
* We use a 4x4 ordered dither array packed into 32 bits. This array is
- * sufficent for dithering RGB888 to RGB565.
+ * sufficient for dithering RGB888 to RGB565.
*/
#define DITHER_MASK 0x3
diff --git a/jdmerge.c b/jdmerge.c
index d67faec0..b3fec04f 100644
--- a/jdmerge.c
+++ b/jdmerge.c
@@ -448,7 +448,7 @@ h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
/* Declarations for ordered dithering
*
* We use a 4x4 ordered dither array packed into 32 bits. This array is
- * sufficent for dithering RGB888 to RGB565.
+ * sufficient for dithering RGB888 to RGB565.
*/
#define DITHER_MASK 0x3
diff --git a/jquant1.c b/jquant1.c
index a336abdb..40bbb28c 100644
--- a/jquant1.c
+++ b/jquant1.c
@@ -154,7 +154,7 @@ typedef struct {
*/
boolean is_padded; /* is the colorindex padded for odither? */
- int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */
+ int Ncolors[MAX_Q_COMPS]; /* # of values allocated to each component */
/* Variables for ordered dithering */
int row_index; /* cur row's vertical index in dither matrix */
diff --git a/jversion.h b/jversion.h
index 2039f44c..191fb6bb 100644
--- a/jversion.h
+++ b/jversion.h
@@ -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-2018, D. R. Commander.
+ * Copyright (C) 2010, 2012-2019, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -36,7 +36,7 @@
*/
#define JCOPYRIGHT \
- "Copyright (C) 2009-2018 D. R. Commander\n" \
+ "Copyright (C) 2009-2019 D. R. Commander\n" \
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
"Copyright (C) 2015 Intel Corporation\n" \
@@ -49,4 +49,4 @@
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding"
#define JCOPYRIGHT_SHORT \
- "Copyright (C) 1991-2018 The libjpeg-turbo Project and many others"
+ "Copyright (C) 1991-2019 The libjpeg-turbo Project and many others"
diff --git a/rdtarga.c b/rdtarga.c
index e0c6947b..37bd286a 100644
--- a/rdtarga.c
+++ b/rdtarga.c
@@ -3,8 +3,9 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
+ * Modified 2017 by Guido Vollbeding.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2018, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -66,6 +67,7 @@ typedef struct _tga_source_struct {
U_CHAR tga_pixel[4];
int pixel_size; /* Bytes per Targa pixel (1 to 4) */
+ int cmap_length; /* colormap length */
/* State info for reading RLE-coded pixels; both counts must be init to 0 */
int block_count; /* # of pixels remaining in RLE block */
@@ -196,11 +198,14 @@ get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
register JSAMPROW ptr;
register JDIMENSION col;
register JSAMPARRAY colormap = source->colormap;
+ int cmaplen = source->cmap_length;
ptr = source->pub.buffer[0];
for (col = cinfo->image_width; col > 0; col--) {
(*source->read_pixel) (source); /* Load next pixel into tga_pixel */
t = UCH(source->tga_pixel[0]);
+ if (t >= cmaplen)
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
*ptr++ = colormap[0][t];
*ptr++ = colormap[1][t];
*ptr++ = colormap[2][t];
@@ -452,12 +457,14 @@ start_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* Allocate space to store the colormap */
source->colormap = (*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)maplen, (JDIMENSION)3);
+ source->cmap_length = (int)maplen;
/* and read it from the file */
read_colormap(source, (int)maplen, UCH(targaheader[7]));
} else {
if (cmaptype) /* but you promised a cmap! */
ERREXIT(cinfo, JERR_TGA_BADPARMS);
source->colormap = NULL;
+ source->cmap_length = 0;
}
cinfo->input_components = components;
diff --git a/release/installer.nsi.in b/release/installer.nsi.in
index 00cd5f87..44419fa8 100755
--- a/release/installer.nsi.in
+++ b/release/installer.nsi.in
@@ -62,15 +62,15 @@ Section "@CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ (required)"
File "@CMAKE_CURRENT_BINARY_DIR@\libturbojpeg.a"
File "@CMAKE_CURRENT_BINARY_DIR@\libjpeg.dll.a"
File "@CMAKE_CURRENT_BINARY_DIR@\libjpeg.a"
- SetOutPath $INSTDIR\lib\pkgconfig
- File "@CMAKE_CURRENT_BINARY_DIR@\pkgscripts\libjpeg.pc"
- File "@CMAKE_CURRENT_BINARY_DIR@\pkgscripts\libturbojpeg.pc"
!else
File "@CMAKE_CURRENT_BINARY_DIR@\${BUILDDIR}turbojpeg.lib"
File "@CMAKE_CURRENT_BINARY_DIR@\${BUILDDIR}turbojpeg-static.lib"
File "@CMAKE_CURRENT_BINARY_DIR@\${BUILDDIR}jpeg.lib"
File "@CMAKE_CURRENT_BINARY_DIR@\${BUILDDIR}jpeg-static.lib"
!endif
+ SetOutPath $INSTDIR\lib\pkgconfig
+ File "@CMAKE_CURRENT_BINARY_DIR@\pkgscripts\libjpeg.pc"
+ File "@CMAKE_CURRENT_BINARY_DIR@\pkgscripts\libturbojpeg.pc"
!ifdef JAVA
SetOutPath $INSTDIR\classes
File "@CMAKE_CURRENT_BINARY_DIR@\java\turbojpeg.jar"
@@ -130,8 +130,6 @@ Section "Uninstall"
Delete $INSTDIR\lib\libturbojpeg.a
Delete $INSTDIR\lib\libjpeg.dll.a
Delete $INSTDIR\lib\libjpeg.a
- Delete $INSTDIR\lib\pkgconfig\libjpeg.pc
- Delete $INSTDIR\lib\pkgconfig\libturbojpeg.pc
!else
Delete $INSTDIR\bin\jpeg@SO_MAJOR_VERSION@.dll
Delete $INSTDIR\bin\turbojpeg.dll
@@ -141,6 +139,8 @@ Section "Uninstall"
Delete $INSTDIR\lib\turbojpeg.lib
Delete $INSTDIR\lib\turbojpeg-static.lib
!endif
+ Delete $INSTDIR\lib\pkgconfig\libjpeg.pc
+ Delete $INSTDIR\lib\pkgconfig\libturbojpeg.pc
!ifdef JAVA
Delete $INSTDIR\classes\turbojpeg.jar
!endif
@@ -175,9 +175,7 @@ Section "Uninstall"
!endif
RMDir "$INSTDIR\include"
-!ifdef GCC
RMDir "$INSTDIR\lib\pkgconfig"
-!endif
RMDir "$INSTDIR\lib"
RMDir "$INSTDIR\doc"
!ifdef GCC
diff --git a/release/rpm.spec.in b/release/rpm.spec.in
index a22c5e1a..e5730e6c 100644
--- a/release/rpm.spec.in
+++ b/release/rpm.spec.in
@@ -1,7 +1,7 @@
+%global _docdir %{_defaultdocdir}/%{name}-%{version}
%define _prefix @CMAKE_INSTALL_PREFIX@
%define _bindir @CMAKE_INSTALL_FULL_BINDIR@
%define _datarootdir @CMAKE_INSTALL_FULL_DATAROOTDIR@
-%define _docdir %{_defaultdocdir}/%{name}-%{version}
%define _includedir @CMAKE_INSTALL_FULL_INCLUDEDIR@
%define _javadir @CMAKE_INSTALL_FULL_JAVADIR@
%define _mandir @CMAKE_INSTALL_FULL_MANDIR@
@@ -43,7 +43,7 @@ Group: System Environment/Libraries
Release: @BUILD@
License: BSD-style
BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release}
-Prereq: /sbin/ldconfig
+Requires: /sbin/ldconfig
%if "%{_bits}" == "64"
Provides: %{name} = %{version}-%{release}, @CMAKE_PROJECT_NAME@ = %{version}-%{release}, libturbojpeg.so()(64bit)
%else
@@ -183,7 +183,7 @@ rm -rf $RPM_BUILD_ROOT
%if "%{_enable_static}" == "1"
%{_libdir}/libjpeg.a
%endif
-%{_libdir}/pkgconfig
+%dir %{_libdir}/pkgconfig
%{_libdir}/pkgconfig/libjpeg.pc
%if "%{_with_turbojpeg}" == "1"
%if "%{_enable_shared}" == "1" || "%{_with_java}" == "1"
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index 2bab8320..a5c4e399 100755
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -52,7 +52,8 @@ if(MAPFLAG)
LINK_FLAGS "${MAPFLAG}${CMAKE_CURRENT_BINARY_DIR}/../libjpeg.map")
endif()
if(MSVC)
- set_target_properties(jpeg PROPERTIES SUFFIX ${SO_MAJOR_VERSION}.dll)
+ set_target_properties(jpeg PROPERTIES
+ RUNTIME_OUTPUT_NAME jpeg${SO_MAJOR_VERSION})
# The jsimd_*.c file is built using /MT, so this prevents a linker warning.
set_target_properties(jpeg PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBCMTD")
elseif(MINGW)
@@ -91,3 +92,8 @@ install(TARGETS jpeg cjpeg djpeg jpegtran
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
+ CMAKE_C_LINKER_SUPPORTS_PDB)
+ install(FILES "$<TARGET_PDB_FILE:jpeg>"
+ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
+endif()
diff --git a/simd/CMakeLists.txt b/simd/CMakeLists.txt
index 346994cb..8dbd7f1e 100755
--- a/simd/CMakeLists.txt
+++ b/simd/CMakeLists.txt
@@ -262,7 +262,7 @@ endif()
# MIPS (GAS)
###############################################################################
-elseif(CPU_TYPE STREQUAL "mips")
+elseif(CPU_TYPE STREQUAL "mips" OR CPU_TYPE STREQUAL "mipsel")
enable_language(ASM)
@@ -293,7 +293,7 @@ if(NOT HAVE_DSPR2)
return()
endif()
-add_library(simd OBJECT ${CPU_TYPE}/jsimd_dspr2.S ${CPU_TYPE}/jsimd.c)
+add_library(simd OBJECT mips/jsimd_dspr2.S mips/jsimd.c)
if(CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED)
set_target_properties(simd PROPERTIES POSITION_INDEPENDENT_CODE 1)
diff --git a/simd/arm64/jsimd_neon.S b/simd/arm64/jsimd_neon.S
index 447dedf8..d30715a3 100644
--- a/simd/arm64/jsimd_neon.S
+++ b/simd/arm64/jsimd_neon.S
@@ -309,7 +309,7 @@ _\fname:
trn2 \x1\literal, \xi\literal, \x1\literal
.endm
-/* Transpose elements of 2 differnet registers */
+/* Transpose elements of 2 different registers */
.macro transpose x0, x1, xi, xilen, literal
mov \xi\xilen, \x0\xilen
trn1 \x0\literal, \x0\literal, \x1\literal
diff --git a/simd/i386/jsimdcpu.asm b/simd/i386/jsimdcpu.asm
index 50a0d516..faddd389 100644
--- a/simd/i386/jsimdcpu.asm
+++ b/simd/i386/jsimdcpu.asm
@@ -94,9 +94,10 @@ EXTN(jpeg_simd_cpu_support):
xor ecx, ecx
xgetbv
- test eax, 6 ; O/S does not manage XMM/YMM state
+ and eax, 6
+ cmp eax, 6 ; O/S does not manage XMM/YMM state
; using XSAVE
- jz short .no_avx2
+ jnz short .no_avx2
or edi, JSIMD_AVX2
.no_avx2:
diff --git a/simd/loongson/jccolext-mmi.c b/simd/loongson/jccolext-mmi.c
index e1c4e69e..6cdeb5e0 100644
--- a/simd/loongson/jccolext-mmi.c
+++ b/simd/loongson/jccolext-mmi.c
@@ -2,12 +2,13 @@
* Loongson MMI optimizations for libjpeg-turbo
*
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2014-2015, D. R. Commander. All Rights Reserved.
- * Copyright (C) 2016-2017, Loongson Technology Corporation Limited, BeiJing.
+ * Copyright (C) 2014-2015, 2019, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
* All Rights Reserved.
* Authors: ZhuChen <zhuchen@loongson.cn>
* SunZhangzhi <sunzhangzhi-cq@loongson.cn>
* CaiWanwei <caiwanwei@loongson.cn>
+ * ZhangLixia <zhanglixia-hf@loongson.cn>
*
* Based on the x86 SIMD extension for IJG JPEG library
* Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -184,9 +185,15 @@ void jsimd_rgb_ycc_convert_mmi(JDIMENSION image_width, JSAMPARRAY input_buf,
"$14", "memory"
);
} else {
- mmA = _mm_load_si64((__m64 *)&inptr[0]);
- mmG = _mm_load_si64((__m64 *)&inptr[8]);
- mmF = _mm_load_si64((__m64 *)&inptr[16]);
+ if (!(((long)inptr) & 7)) {
+ mmA = _mm_load_si64((__m64 *)&inptr[0]);
+ mmG = _mm_load_si64((__m64 *)&inptr[8]);
+ mmF = _mm_load_si64((__m64 *)&inptr[16]);
+ } else {
+ mmA = _mm_loadu_si64((__m64 *)&inptr[0]);
+ mmG = _mm_loadu_si64((__m64 *)&inptr[8]);
+ mmF = _mm_loadu_si64((__m64 *)&inptr[16]);
+ }
inptr += RGB_PIXELSIZE * 8;
}
mmD = mmA;
@@ -268,10 +275,17 @@ void jsimd_rgb_ycc_convert_mmi(JDIMENSION image_width, JSAMPARRAY input_buf,
: "$f0", "$f2", "$8", "$9", "$10", "$11", "$13", "memory"
);
} else {
- mmA = _mm_load_si64((__m64 *)&inptr[0]);
- mmF = _mm_load_si64((__m64 *)&inptr[8]);
- mmD = _mm_load_si64((__m64 *)&inptr[16]);
- mmC = _mm_load_si64((__m64 *)&inptr[24]);
+ if (!(((long)inptr) & 7)) {
+ mmA = _mm_load_si64((__m64 *)&inptr[0]);
+ mmF = _mm_load_si64((__m64 *)&inptr[8]);
+ mmD = _mm_load_si64((__m64 *)&inptr[16]);
+ mmC = _mm_load_si64((__m64 *)&inptr[24]);
+ } else {
+ mmA = _mm_loadu_si64((__m64 *)&inptr[0]);
+ mmF = _mm_loadu_si64((__m64 *)&inptr[8]);
+ mmD = _mm_loadu_si64((__m64 *)&inptr[16]);
+ mmC = _mm_loadu_si64((__m64 *)&inptr[24]);
+ }
inptr += RGB_PIXELSIZE * 8;
}
mmB = mmA;
diff --git a/simd/loongson/loongson-mmintrin.h b/simd/loongson/loongson-mmintrin.h
index 4aea7636..50d166b7 100644
--- a/simd/loongson/loongson-mmintrin.h
+++ b/simd/loongson/loongson-mmintrin.h
@@ -1,8 +1,9 @@
/*
* Loongson MMI optimizations for libjpeg-turbo
*
- * Copyright (C) 2016-2017, Loongson Technology Corporation Limited, BeiJing.
+ * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
* All Rights Reserved.
+ * Copyright (C) 2019, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -41,7 +42,7 @@ typedef float __m32;
/********** Set Operations **********/
-extern __inline __m64
+extern __inline __m64 FUNCTION_ATTRIBS
_mm_setzero_si64(void)
{
return 0.0;
@@ -1245,6 +1246,22 @@ _mm_load_si64(const __m64 *src)
asm("ldc1 %0, %1\n\t"
: "=f" (ret)
: "m" (*src)
+ : "memory"
+ );
+
+ return ret;
+}
+
+extern __inline __m64 FUNCTION_ATTRIBS
+_mm_loadu_si64(const __m64 *src)
+{
+ __m64 ret;
+
+ asm("gsldlc1 %0, 7(%1)\n\t"
+ "gsldrc1 %0, 0(%1)\n\t"
+ : "=f" (ret)
+ : "r" (src)
+ : "memory"
);
return ret;
diff --git a/simd/mips/jsimd.c b/simd/mips/jsimd.c
index af886f60..454cc99c 100644
--- a/simd/mips/jsimd.c
+++ b/simd/mips/jsimd.c
@@ -692,8 +692,10 @@ jsimd_can_convsamp_float(void)
if (sizeof(ISLOW_MULT_TYPE) != 2)
return 0;
+#ifndef __mips_soft_float
if (simd_support & JSIMD_DSPR2)
return 1;
+#endif
return 0;
}
@@ -709,7 +711,9 @@ GLOBAL(void)
jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
FAST_FLOAT *workspace)
{
+#ifndef __mips_soft_float
jsimd_convsamp_float_dspr2(sample_data, start_col, workspace);
+#endif
}
GLOBAL(int)
@@ -805,8 +809,10 @@ jsimd_can_quantize_float(void)
if (sizeof(ISLOW_MULT_TYPE) != 2)
return 0;
+#ifndef __mips_soft_float
if (simd_support & JSIMD_DSPR2)
return 1;
+#endif
return 0;
}
@@ -821,7 +827,9 @@ GLOBAL(void)
jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
FAST_FLOAT *workspace)
{
+#ifndef __mips_soft_float
jsimd_quantize_float_dspr2(coef_block, divisors, workspace);
+#endif
}
GLOBAL(int)
diff --git a/simd/mips/jsimd_dspr2.S b/simd/mips/jsimd_dspr2.S
index 2ec543e2..a28c1161 100644
--- a/simd/mips/jsimd_dspr2.S
+++ b/simd/mips/jsimd_dspr2.S
@@ -2810,6 +2810,8 @@ LEAF_DSPR2(jsimd_quantize_dspr2)
END(jsimd_quantize_dspr2)
+#ifndef __mips_soft_float
+
/*****************************************************************************/
LEAF_DSPR2(jsimd_quantize_float_dspr2)
/*
@@ -2890,6 +2892,8 @@ LEAF_DSPR2(jsimd_quantize_float_dspr2)
END(jsimd_quantize_float_dspr2)
+#endif
+
/*****************************************************************************/
LEAF_DSPR2(jsimd_idct_2x2_dspr2)
@@ -4110,6 +4114,8 @@ LEAF_DSPR2(jsimd_convsamp_dspr2)
END(jsimd_convsamp_dspr2)
+#ifndef __mips_soft_float
+
/*****************************************************************************/
LEAF_DSPR2(jsimd_convsamp_float_dspr2)
/*
@@ -4468,4 +4474,6 @@ LEAF_DSPR2(jsimd_convsamp_float_dspr2)
END(jsimd_convsamp_float_dspr2)
+#endif
+
/*****************************************************************************/
diff --git a/simd/x86_64/jsimdcpu.asm b/simd/x86_64/jsimdcpu.asm
index 42979bef..38e1a7b9 100644
--- a/simd/x86_64/jsimdcpu.asm
+++ b/simd/x86_64/jsimdcpu.asm
@@ -60,9 +60,10 @@ EXTN(jpeg_simd_cpu_support):
xor rcx, rcx
xgetbv
- test rax, 6 ; O/S does not manage XMM/YMM state
+ and rax, 6
+ cmp rax, 6 ; O/S does not manage XMM/YMM state
; using XSAVE
- jz short .return
+ jnz short .return
or rdi, JSIMD_AVX2
diff --git a/tjbench.c b/tjbench.c
index 9ab0ea2a..0ddcd7b2 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2019 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:
@@ -60,8 +60,8 @@ int tjErrorLine = -1, tjErrorCode = -1;
if (strncmp(tjErrorStr, _tjErrorStr, JMSG_LENGTH_MAX) || \
strncmp(tjErrorMsg, m, JMSG_LENGTH_MAX) || \
tjErrorCode != _tjErrorCode || tjErrorLine != __LINE__) { \
- strncpy(tjErrorStr, _tjErrorStr, JMSG_LENGTH_MAX); \
- strncpy(tjErrorMsg, m, JMSG_LENGTH_MAX); \
+ strncpy(tjErrorStr, _tjErrorStr, JMSG_LENGTH_MAX - 1); \
+ strncpy(tjErrorMsg, m, JMSG_LENGTH_MAX - 1); \
tjErrorCode = _tjErrorCode; \
tjErrorLine = __LINE__; \
printf("WARNING in line %d while %s:\n%s\n", __LINE__, m, _tjErrorStr); \
@@ -139,7 +139,7 @@ int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
unsigned long *jpegSize, unsigned char *dstBuf, int w, int h,
int subsamp, int jpegQual, char *fileName, int tilew, int tileh)
{
- char tempStr[1024], sizeStr[20] = "\0", qualStr[6] = "\0", *ptr;
+ char tempStr[1024], sizeStr[20] = "\0", qualStr[13] = "\0", *ptr;
FILE *file = NULL;
tjhandle handle = NULL;
int row, col, iter = 0, dstBufAlloc = 0, retval = 0;
@@ -152,8 +152,8 @@ int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
unsigned char *dstPtr, *dstPtr2, *yuvBuf = NULL;
if (jpegQual > 0) {
- snprintf(qualStr, 6, "_Q%d", jpegQual);
- qualStr[5] = 0;
+ snprintf(qualStr, 13, "_Q%d", jpegQual);
+ qualStr[12] = 0;
}
if ((handle = tjInitDecompress()) == NULL)
@@ -541,6 +541,8 @@ int decompTest(char *fileName)
if (tjDecompressHeader3(handle, srcBuf, srcSize, &w, &h, &subsamp,
&cs) == -1)
_throwtj("executing tjDecompressHeader3()");
+ if (w < 1 || h < 1)
+ _throw("reading JPEG header", "Invalid image dimensions");
if (cs == TJCS_YCCK || cs == TJCS_CMYK) {
pf = TJPF_CMYK; ps = tjPixelSize[pf];
}
diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c
index d0ca37d9..d0a0935b 100644
--- a/turbojpeg-jni.c
+++ b/turbojpeg-jni.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011-2017 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011-2018 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:
@@ -235,11 +235,11 @@ static jint TJCompressor_compress
if ((*env)->GetArrayLength(env, dst) < (jsize)jpegSize)
_throwarg("Destination buffer is not large enough");
+ if (ProcessSystemProperties(env) < 0) goto bailout;
+
bailif0(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
bailif0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
- if (ProcessSystemProperties(env) < 0) goto bailout;
-
if (tjCompress2(handle, &srcBuf[y * actualPitch + x * tjPixelSize[pf]],
width, pitch, height, pf, &jpegBuf, &jpegSize, jpegSubsamp,
jpegQual, flags | TJFLAG_NOREALLOC) == -1)
@@ -341,6 +341,8 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compressFrom
if ((*env)->GetArrayLength(env, dst) < (jsize)jpegSize)
_throwarg("Destination buffer is not large enough");
+ if (ProcessSystemProperties(env) < 0) goto bailout;
+
bailif0(srcOffsets = (*env)->GetPrimitiveArrayCritical(env, jSrcOffsets, 0));
bailif0(srcStrides = (*env)->GetPrimitiveArrayCritical(env, jSrcStrides, 0));
for (i = 0; i < nc; i++) {
@@ -365,8 +367,6 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compressFrom
}
bailif0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
- if (ProcessSystemProperties(env) < 0) goto bailout;
-
if (tjCompressFromYUVPlanes(handle, srcPlanes, width, srcStrides, height,
subsamp, &jpegBuf, &jpegSize, jpegQual,
flags | TJFLAG_NOREALLOC) == -1)
diff --git a/turbojpeg.c b/turbojpeg.c
index 90a9ce6a..b3caa0d4 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2019 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:
@@ -359,6 +359,23 @@ static int getSubsamp(j_decompress_ptr dinfo)
retval = i; break;
}
}
+ /* Handle 4:4:4 images whose sampling factors are specified in
+ non-standard ways. */
+ if (dinfo->comp_info[0].h_samp_factor *
+ dinfo->comp_info[0].v_samp_factor <=
+ D_MAX_BLOCKS_IN_MCU / pixelsize[i] && i == TJSAMP_444) {
+ int match = 0;
+ for (k = 1; k < dinfo->num_components; k++) {
+ if (dinfo->comp_info[i].h_samp_factor ==
+ dinfo->comp_info[0].h_samp_factor &&
+ dinfo->comp_info[i].v_samp_factor ==
+ dinfo->comp_info[0].v_samp_factor)
+ match++;
+ if (match == dinfo->num_components - 1) {
+ retval = i; break;
+ }
+ }
+ }
}
}
return retval;
@@ -1960,7 +1977,8 @@ DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
int align, int *height, int *pixelFormat,
int flags)
{
- int retval = 0, tempc, pitch;
+ int retval = 0, tempc;
+ size_t pitch;
tjhandle handle = NULL;
tjinstance *this;
j_compress_ptr cinfo = NULL;
@@ -2013,7 +2031,9 @@ DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
*pixelFormat = cs2pf[cinfo->in_color_space];
pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
- if ((dstBuf = (unsigned char *)malloc(pitch * (*height))) == NULL)
+ if ((unsigned long long)pitch * (unsigned long long)(*height) >
+ (unsigned long long)((size_t)-1) ||
+ (dstBuf = (unsigned char *)malloc(pitch * (*height))) == NULL)
_throwg("tjLoadImage(): Memory allocation failure");
if (setjmp(this->jerr.setjmp_buffer)) {
diff --git a/wrbmp.c b/wrbmp.c
index 38a64e87..239f64eb 100644
--- a/wrbmp.c
+++ b/wrbmp.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2017, D. R. Commander.
+ * Copyright (C) 2014-2015, 2017, 2019, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -303,9 +303,7 @@ write_os2_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
int bits_per_pixel, cmap_entries;
/* Compute colormap size and total file size */
- if (cinfo->out_color_space == JCS_RGB ||
- (cinfo->out_color_space >= JCS_EXT_RGB &&
- cinfo->out_color_space <= JCS_EXT_ARGB)) {
+ if (IsExtRGB(cinfo->out_color_space)) {
if (cinfo->quantize_colors) {
/* Colormapped RGB */
bits_per_pixel = 8;
@@ -499,15 +497,14 @@ jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
if (cinfo->out_color_space == JCS_GRAYSCALE) {
dest->pub.put_pixel_rows = put_gray_rows;
- } else if (cinfo->out_color_space == JCS_RGB ||
- (cinfo->out_color_space >= JCS_EXT_RGB &&
- cinfo->out_color_space <= JCS_EXT_ARGB)) {
+ } else if (IsExtRGB(cinfo->out_color_space)) {
if (cinfo->quantize_colors)
dest->pub.put_pixel_rows = put_gray_rows;
else
dest->pub.put_pixel_rows = put_pixel_rows;
- } else if (cinfo->out_color_space == JCS_RGB565 ||
- cinfo->out_color_space == JCS_CMYK) {
+ } else if (!cinfo->quantize_colors &&
+ (cinfo->out_color_space == JCS_RGB565 ||
+ cinfo->out_color_space == JCS_CMYK)) {
dest->pub.put_pixel_rows = put_pixel_rows;
} else {
ERREXIT(cinfo, JERR_BMP_COLORSPACE);
diff --git a/wrjpgcom.c b/wrjpgcom.c
index faf77b41..8a4e7416 100644
--- a/wrjpgcom.c
+++ b/wrjpgcom.c
@@ -580,7 +580,7 @@ main(int argc, char **argv)
}
}
/* Duplicate the remainder of the source file.
- * Note that any COM markers occuring after SOF will not be touched.
+ * Note that any COM markers occurring after SOF will not be touched.
*/
write_marker(marker);
copy_rest_of_file();
diff --git a/wrppm.c b/wrppm.c
index 819a0a7e..69f91e81 100644
--- a/wrppm.c
+++ b/wrppm.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, D. R. Commander.
+ * Copyright (C) 2017, 2019, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -256,6 +256,8 @@ start_output_ppm(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
case JCS_EXT_ABGR:
case JCS_EXT_ARGB:
case JCS_CMYK:
+ if (!IsExtRGB(cinfo->out_color_space) && cinfo->quantize_colors)
+ ERREXIT(cinfo, JERR_PPM_COLORSPACE);
/* emit header for raw PPM format */
fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n",
(long)cinfo->output_width, (long)cinfo->output_height, PPM_MAXVAL);
@@ -337,13 +339,14 @@ jinit_write_ppm(j_decompress_ptr cinfo)
((j_common_ptr)cinfo, JPOOL_IMAGE,
cinfo->output_width * cinfo->output_components, (JDIMENSION)1);
dest->pub.buffer_height = 1;
- if (IsExtRGB(cinfo->out_color_space))
- dest->pub.put_pixel_rows = put_rgb;
- else if (cinfo->out_color_space == JCS_CMYK)
- dest->pub.put_pixel_rows = put_cmyk;
- else if (!cinfo->quantize_colors)
- dest->pub.put_pixel_rows = copy_pixel_rows;
- else if (cinfo->out_color_space == JCS_GRAYSCALE)
+ if (!cinfo->quantize_colors) {
+ if (IsExtRGB(cinfo->out_color_space))
+ dest->pub.put_pixel_rows = put_rgb;
+ else if (cinfo->out_color_space == JCS_CMYK)
+ dest->pub.put_pixel_rows = put_cmyk;
+ else
+ dest->pub.put_pixel_rows = copy_pixel_rows;
+ } else if (cinfo->out_color_space == JCS_GRAYSCALE)
dest->pub.put_pixel_rows = put_demapped_gray;
else
dest->pub.put_pixel_rows = put_demapped_rgb;