diff --git a/BUILDING.md b/BUILDING.md index 4a147ce4..2725f30a 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,5 +1,5 @@ -Building on Un*x Platforms (including Cygwin and OS X) -======================================================= +Un*x Platforms (including Mac and Cygwin) +========================================= Build Requirements @@ -10,21 +10,21 @@ Build Requirements - libtool 1.4 or later * If using Xcode 4.3 or later on OS X, autoconf and automake are no longer provided. The easiest way to obtain them is from - [MacPorts](http://www.MacPorts.org). + [MacPorts](http://www.MacPorts.org) or [Homebrew](http://brew.sh/). -- NASM or YASM (if building x86 or x86-64 SIMD extensions) +- [NASM](http://www.nasm.us) or [YASM](http://yasm.tortall.net) + (if building x86 or x86-64 SIMD extensions) * If using 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.) * If using NASM, 2.00 or later is required for an x86-64 build. * If using NASM, 2.07 or later (except 2.11.08) 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/). + [MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/). The binary RPMs released by the NASM project do not work on older Linux - systems, such as Red Hat Enterprise Linux 4. On such systems, you can - easily build and install NASM from a source RPM by downloading one of the - SRPMs from + systems, such as Red Hat Enterprise Linux 5. On such systems, you can easily + build and install NASM from a source RPM by downloading one of the SRPMs from @@ -36,13 +36,13 @@ Build Requirements NOTE: the NASM build will fail if texinfo is not installed. -- GCC v4.1 (or later) or clang recommended for best performance +- GCC v4.1 (or later) or Clang recommended for best performance - If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is - required. Some systems, such as Solaris 10 and later and Red Hat Enterprise - Linux 5 and later, have this pre-installed. On OS X 10.5 and 10.6, it will - be necessary to install the Java Developer Package, which can be downloaded - from (Apple ID required.) For other + required. Most modern Linux distributions, as well as Solaris 10 and later, + include JDK or OpenJDK. On OS X 10.5 and 10.6, it will be necessary to + install the Java Developer Package, which can be downloaded from + (Apple ID required.) For other systems, you can obtain the Oracle Java Development Kit from . @@ -50,23 +50,22 @@ Build Requirements Out-of-Tree Builds ------------------ -Binary objects, libraries, and executables are generated in the same directory -from which `configure` was executed (the "binary directory"), and this -directory need not necessarily be the same as the libjpeg-turbo source -directory. You can create multiple independent binary directories, in which -different versions of libjpeg-turbo can be built from the same source tree -using different compilers or settings. In the sections below, -*{build_directory}* refers to the binary directory, whereas -*{source_directory}* refers to the libjpeg-turbo source directory. For in-tree -builds, these directories are the same. +Binary objects, libraries, and executables are generated in the directory from +which `configure` is executed (the "binary directory"), and this directory need +not necessarily be the same as the libjpeg-turbo source directory. You can +create multiple independent binary directories, in which different versions of +libjpeg-turbo can be built from the same source tree using different compilers +or settings. In the sections below, *{build_directory}* refers to the binary +directory, whereas *{source_directory}* refers to the libjpeg-turbo source +directory. For in-tree builds, these directories are the same. -Building libjpeg-turbo ----------------------- +Build Procedure +--------------- -The following procedure will build libjpeg-turbo on Linux, FreeBSD, Cygwin, and -Solaris/x86 systems (on Solaris, this generates a 32-bit library. See below -for 64-bit build instructions.) +The following procedure will build libjpeg-turbo on Unix and Unix-like systems. +(On Solaris, this generates a 32-bit build. See "Build Recipes" below for +64-bit build instructions.) cd {source_directory} autoreconf -fiv @@ -77,40 +76,40 @@ for 64-bit build instructions.) NOTE: Running autoreconf in the source directory is not necessary if building libjpeg-turbo from one of the official release tarballs. -This will generate the following files under .libs/: +This will generate the following files under **.libs/**: -**libjpeg.a** +**libjpeg.a**
Static link library for the libjpeg API -**libjpeg.so.{version}** (Linux, Unix) -**libjpeg.{version}.dylib** (OS X) -**cygjpeg-{version}.dll** (Cygwin) +**libjpeg.so.{version}** (Linux, Unix)
+**libjpeg.{version}.dylib** (Mac)
+**cygjpeg-{version}.dll** (Cygwin)
Shared library for the libjpeg API -By default, *{version}* is 62.1.0, 7.1.0, or 8.0.2, depending on whether +By default, *{version}* is 62.2.0, 7.2.0, or 8.1.2, depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled. If using Cygwin, *{version}* is 62, 7, or 8. -**libjpeg.so** (Linux, Unix) -**libjpeg.dylib** (OS X) +**libjpeg.so** (Linux, Unix)
+**libjpeg.dylib** (Mac)
Development symlink for the libjpeg API -**libjpeg.dll.a** (Cygwin) +**libjpeg.dll.a** (Cygwin)
Import library for the libjpeg API -**libturbojpeg.a** +**libturbojpeg.a**
Static link library for the TurboJPEG API -**libturbojpeg.so.0.1.0** (Linux, Unix) -**libturbojpeg.0.1.0.dylib** (OS X) -**cygturbojpeg-0.dll** (Cygwin) +**libturbojpeg.so.0.1.0** (Linux, Unix)
+**libturbojpeg.0.1.0.dylib** (Mac)
+**cygturbojpeg-0.dll** (Cygwin)
Shared library for the TurboJPEG API -**libturbojpeg.so** (Linux, Unix) -**libturbojpeg.dylib** (OS X) +**libturbojpeg.so** (Linux, Unix)
+**libturbojpeg.dylib** (Mac)
Development symlink for the TurboJPEG API -**libturbojpeg.dll.a** (Cygwin) +**libturbojpeg.dll.a** (Cygwin)
Import library for the TurboJPEG API @@ -120,7 +119,7 @@ Add `--with-jpeg7` to the `configure` command line to build a version of libjpeg-turbo that is API/ABI-compatible with libjpeg v7. Add `--with-jpeg8` to the `configure` command to build a version of libjpeg-turbo that is API/ABI-compatible with libjpeg v8. See [README.md](README.md) for more -information on libjpeg v7 and v8 emulation. +information about libjpeg v7 and v8 emulation. ### In-Memory Source/Destination Managers @@ -146,46 +145,19 @@ line to disable encoding or decoding (respectively.) ### TurboJPEG Java Wrapper Add `--with-java` to the `configure` command line to incorporate an optional -Java Native Interface wrapper into the TurboJPEG shared library and build the -Java front-end classes to support it. This allows the TurboJPEG shared library -to be used directly from Java applications. See [java/README](java/README) for -more details. +Java Native Interface (JNI) wrapper into the TurboJPEG shared library and build +the Java front-end classes to support it. This allows the TurboJPEG shared +library to be used directly from Java applications. See +[java/README](java/README) for more details. You can set the `JAVAC`, `JAR`, and `JAVA` configure variables to specify alternate commands for javac, jar, and java (respectively.) You can also set the `JAVACFLAGS` configure variable to specify arguments that should be -passed to the Java compiler when building the front-end classes, and +passed to the Java compiler when building the TurboJPEG classes, and `JNI_CFLAGS` to specify arguments that should be passed to the C compiler when building the JNI wrapper. Run `configure --help` for more details. -Installing libjpeg-turbo ------------------------- - -If you intend to install these libraries and the associated header files, then -replace 'make' in the instructions above with - - make install prefix={base dir} libdir={library directory} - -For example, - - make install prefix=/usr/local libdir=/usr/local/lib64 - -will install the header files in /usr/local/include and the library files in -/usr/local/lib64. If `prefix` and `libdir` are not specified, then the default -is to install the header files in /opt/libjpeg-turbo/include and the library -files in /opt/libjpeg-turbo/lib32 (32-bit) or /opt/libjpeg-turbo/lib64 -(64-bit.) - -NOTE: You can specify a prefix of /usr and a libdir of, for instance, -/usr/lib64 to overwrite the system's version of libjpeg. If you do this, -however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before -overwriting it. It is recommended that you instead install libjpeg-turbo into -a non-system directory and manipulate the `LD_LIBRARY_PATH` or create symlinks -to force applications to use libjpeg-turbo instead of libjpeg. See -[README.md](README.md) for more information. - - Build Recipes ------------- @@ -205,8 +177,9 @@ Add --host x86_64-apple-darwin NASM=/opt/local/bin/nasm -to the `configure` command line. NASM 2.07 or later from MacPorts must be -installed. +to the `configure` command line. NASM 2.07 or later from MacPorts or Homebrew +must be installed. If using Homebrew, then replace `/opt/local` with +`/usr/local`. ### 32-bit Build on 64-bit OS X @@ -226,8 +199,9 @@ Add CFLAGS='-mmacosx-version-min=10.5 -O3' \ LDFLAGS='-mmacosx-version-min=10.5' -to the `configure` command line. NASM 2.07 or later from MacPorts must be -installed. +to the `configure` command line. NASM 2.07 or later from MacPorts or Homebrew +must be installed. If using Homebrew, then replace `/opt/local` with +`/usr/local`. ### 32-bit Backward-Compatible Build on OS X @@ -254,8 +228,7 @@ to the `configure` command line. Add - --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \ - LDFLAGS='-B/usr/lib32' + --host i386-unknown-freebsd CFLAGS='-O3 -m32' LDFLAGS=-m32 to the `configure` command line. NASM 2.07 or later from FreeBSD ports must be installed. @@ -282,153 +255,144 @@ to the `configure` command line. Use CMake (see recipes below) -ARM Support ------------ +Building libjpeg-turbo for iOS +------------------------------ -This release of libjpeg-turbo can use ARM NEON SIMD instructions to accelerate -JPEG compression/decompression by approximately 2-4x on ARMv7 and later -platforms. If libjpeg-turbo is configured on an ARM Linux platform, then the -build system will automatically include the NEON SIMD routines, if they are -supported. Build instructions for other ARM-based platforms follow. +iOS platforms, such as the iPhone and iPad, use ARM processors, and all +currently supported models include NEON instructions. Thus, they can take +advantage of libjpeg-turbo's SIMD extensions to significantly accelerate JPEG +compression/decompression. This section describes how to build libjpeg-turbo +for these platforms. -### Building libjpeg-turbo for iOS +### Additional build requirements -iOS platforms, such as the iPhone and iPad, use ARM processors, some of which -support NEON instructions. Additional steps are required in order to build -libjpeg-turbo for these platforms. +- For configurations that require [gas-preprocessor.pl] + (https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl), + it should be installed in your `PATH`. -#### Additional build requirements +### ARMv7 (32-bit) -- [gas-preprocessor.pl] - (https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl) - should be installed in your `PATH`. +**gas-preprocessor.pl required** +The following scripts demonstrate how to build libjpeg-turbo to run on the +iPhone 3GS-4S/iPad 1st-3rd Generation and newer: -#### ARM 32-bit Build (Xcode 4.6.x and earlier, LLVM-GCC) +#### Xcode 4.2 and earlier (LLVM-GCC) -Set the following shell variables for simplicity: + IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform + IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) - *Xcode 4.2 and earlier* + export host_alias=arm-apple-darwin10 + export CC=${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 + export CFLAGS="-mfloat-abi=softfp -isysroot ${IOS_SYSROOT[0]} -O3 -march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -miphoneos-version-min=3.0" - IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform` + cd {build_directory} + sh {source_directory}/configure [additional configure flags] + make - *Xcode 4.3 and later* +#### Xcode 4.3-4.6 (LLVM-GCC) + +Same as above, but replace the first line with: IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform - *All Xcode versions* - - IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk - IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 - - *ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer)* - - IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon" - - *ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer)* - [NOTE: Requires Xcode 4.5 or later] - - IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon" - -Follow the procedure under "Building libjpeg-turbo" above, adding - - --host arm-apple-darwin10 \ - CC="$IOS_GCC" LD="$IOS_GCC" \ - CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \ - LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" - -to the `configure` command line. - - -#### ARM 32-bit Build (Xcode 5.0.x and later, Clang) - -Set the following shell variables for simplicity: +#### Xcode 5 and later (Clang) IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform - IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk - IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang + IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) - *ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer)* + export host_alias=arm-apple-darwin10 + export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang + export CFLAGS="-mfloat-abi=softfp -isysroot ${IOS_SYSROOT[0]} -O3 -arch armv7 -miphoneos-version-min=3.0" + export CCASFLAGS="$CFLAGS -no-integrated-as" - IOS_CFLAGS="-arch armv7" - - *ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer)* - - IOS_CFLAGS="-arch armv7s" - -Follow the procedure under "Building libjpeg-turbo" above, adding - - --host arm-apple-darwin10 \ - CC="$IOS_GCC" LD="$IOS_GCC" \ - CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \ - LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" \ - CCASFLAGS="-no-integrated-as $IOS_CFLAGS" - -to the `configure` command line. + cd {build_directory} + sh {source_directory}/configure [additional configure flags] + make -#### ARMv8 64-bit Build (Xcode 5.0.x and later, Clang) +### ARMv7s (32-bit) -Code will run on iPhone 5S/iPad Mini 2/iPad Air and newer. +**gas-preprocessor.pl required** -Set the following shell variables for simplicity: +The following scripts demonstrate how to build libjpeg-turbo to run on the +iPhone 5/iPad 4th Generation and newer: + +#### Xcode 4.5-4.6 (LLVM-GCC) IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform - IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk - IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - IOS_CFLAGS="-arch arm64" + IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) -Follow the procedure under "Building libjpeg-turbo" above, adding + export host_alias=arm-apple-darwin10 + export CC=${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 + export CFLAGS="-mfloat-abi=softfp -isysroot ${IOS_SYSROOT[0]} -O3 -march=armv7s -mcpu=swift -mtune=swift -mfpu=neon -miphoneos-version-min=6.0" - --host aarch64-apple-darwin \ - CC="$IOS_GCC" LD="$IOS_GCC" \ - CFLAGS="-isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \ - LDFLAGS="-isysroot $IOS_SYSROOT $IOS_CFLAGS" + cd {build_directory} + sh {source_directory}/configure [additional configure flags] + make -to the `configure` command line. +#### Xcode 5 and later (Clang) + +Same as the ARMv7 build procedure for Xcode 5 and later, except replace the +compiler flags as follows: + + export CFLAGS="-mfloat-abi=softfp -isysroot ${IOS_SYSROOT[0]} -O3 -arch armv7s -miphoneos-version-min=6.0" -NOTE: You can also add `-miphoneos-version-min={version}` to `$IOS_CFLAGS` -above in order to support older versions of iOS than the default version -supported by the SDK. +### ARMv8 (64-bit) + +**gas-preprocessor.pl required if using Xcode < 6** + +The following script demonstrates how to build libjpeg-turbo to run on the +iPhone 5S/iPad Mini 2/iPad Air and newer. + + IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform + IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) + + export host_alias=aarch64-apple-darwin + export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang + export CFLAGS="-isysroot ${IOS_SYSROOT[0]} -O3 -arch arm64 -miphoneos-version-min=7.0 -funwind-tables" + + cd {build_directory} + sh {source_directory}/configure [additional configure flags] + make Once built, lipo can be used to combine the ARMv7, v7s, and/or v8 variants into a universal library. -### Building libjpeg-turbo for Android +Building libjpeg-turbo for Android +---------------------------------- Building libjpeg-turbo for Android platforms requires the -{Android NDK}(https://developer.android.com/tools/sdk/ndk) -and autotools. The following is a general recipe script that can be modified for your specific needs. +[Android NDK](https://developer.android.com/tools/sdk/ndk) and autotools. + + +### ARMv7 (32-bit) + +The following is a general recipe script that can be modified for your specific +needs. # Set these variables to suit your needs - NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/ndk} + 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, - "16", "19", etc. "21" or later is required for a 64-bit build.} + "16", "19", etc.} - # 32-bit ARMv7 build + # It should not be necessary to modify the rest HOST=arm-linux-androideabi SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm ANDROID_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \ --sysroot=${SYSROOT}" - # 64-bit ARMv8 build - HOST=aarch64-linux-android - SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm64 - ANDROID_CFLAGS="--sysroot=${SYSROOT}" - TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM} - ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include" export CPP=${TOOLCHAIN}/bin/${HOST}-cpp export AR=${TOOLCHAIN}/bin/${HOST}-ar - export AS=${TOOLCHAIN}/bin/${HOST}-as export NM=${TOOLCHAIN}/bin/${HOST}-nm export CC=${TOOLCHAIN}/bin/${HOST}-gcc export LD=${TOOLCHAIN}/bin/${HOST}-ld @@ -437,17 +401,144 @@ and autotools. The following is a general recipe script that can be modified fo export STRIP=${TOOLCHAIN}/bin/${HOST}-strip cd {build_directory} sh {source_directory}/configure --host=${HOST} \ - CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3 -fPIE" \ - CPPFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS}" \ + CFLAGS="${ANDROID_CFLAGS} -O3 -fPIE" \ + CPPFLAGS="${ANDROID_CFLAGS}" \ LDFLAGS="${ANDROID_CFLAGS} -pie" --with-simd ${1+"$@"} make + +### ARMv8 (64-bit) + +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 + 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 + ANDROID_CFLAGS="--sysroot=${SYSROOT}" + + TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM} + export CPP=${TOOLCHAIN}/bin/${HOST}-cpp + export AR=${TOOLCHAIN}/bin/${HOST}-ar + export NM=${TOOLCHAIN}/bin/${HOST}-nm + export CC=${TOOLCHAIN}/bin/${HOST}-gcc + export LD=${TOOLCHAIN}/bin/${HOST}-ld + export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib + export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump + export STRIP=${TOOLCHAIN}/bin/${HOST}-strip + cd {build_directory} + sh {source_directory}/configure --host=${HOST} \ + CFLAGS="${ANDROID_CFLAGS} -O3 -fPIE" \ + CPPFLAGS="${ANDROID_CFLAGS}" \ + LDFLAGS="${ANDROID_CFLAGS} -pie" --with-simd ${1+"$@"} + make + + +### x86 (32-bit) + +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, + "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 + ANDROID_CFLAGS="--sysroot=${SYSROOT}" + + TOOLCHAIN=${NDK_PATH}/toolchains/x86-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM} + export CPP=${TOOLCHAIN}/bin/${HOST}-cpp + export AR=${TOOLCHAIN}/bin/${HOST}-ar + export NM=${TOOLCHAIN}/bin/${HOST}-nm + export CC=${TOOLCHAIN}/bin/${HOST}-gcc + export LD=${TOOLCHAIN}/bin/${HOST}-ld + export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib + export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump + export STRIP=${TOOLCHAIN}/bin/${HOST}-strip + cd {build_directory} + sh {source_directory}/configure --host=${HOST} \ + CFLAGS="${ANDROID_CFLAGS} -O3 -fPIE" \ + CPPFLAGS="${ANDROID_CFLAGS}" \ + LDFLAGS="${ANDROID_CFLAGS} -pie" --with-simd ${1+"$@"} + make + + +### x86-64 (64-bit) + +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 + 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 + ANDROID_CFLAGS="--sysroot=${SYSROOT}" + + TOOLCHAIN=${NDK_PATH}/toolchains/x86_64-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM} + export CPP=${TOOLCHAIN}/bin/${HOST}-cpp + export AR=${TOOLCHAIN}/bin/${HOST}-ar + export NM=${TOOLCHAIN}/bin/${HOST}-nm + export CC=${TOOLCHAIN}/bin/${HOST}-gcc + export LD=${TOOLCHAIN}/bin/${HOST}-ld + export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib + export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump + export STRIP=${TOOLCHAIN}/bin/${HOST}-strip + cd {build_directory} + sh {source_directory}/configure --host=${HOST} \ + CFLAGS="${ANDROID_CFLAGS} -O3 -fPIE" \ + CPPFLAGS="${ANDROID_CFLAGS}" \ + LDFLAGS="${ANDROID_CFLAGS} -pie" --with-simd ${1+"$@"} + make + + If building for Android 4.0.x (API level < 16) or earlier, remove `-fPIE` from `CFLAGS` and `-pie` from `LDFLAGS`. -Building on Windows (Visual C++ or MinGW) -========================================= +Installing libjpeg-turbo +------------------------ + +To install libjpeg-turbo after it is built, replace `make` in the build +instructions with `make install`. + +The `--prefix` argument to configure (or the `prefix` configure variable) can +be used to specify an installation directory of your choosing. If you don't +specify an installation directory, then the default is to install libjpeg-turbo +under **/opt/libjpeg-turbo** and to place the libraries in +**/opt/libjpeg-turbo/lib32** (32-bit) or **/opt/libjpeg-turbo/lib64** (64-bit.) + +The `bindir`, `datadir`, `docdir`, `includedir`, `libdir`, and `mandir` +configure variables allow a finer degree of control over where specific files in +the libjpeg-turbo distribution should be installed. These variables can either +be specified at configure time or passed as arguments to `make install`. + + +Windows (Visual C++ or MinGW) +============================= Build Requirements @@ -458,7 +549,7 @@ Build Requirements - [NASM](http://www.nasm.us) or [YASM](http://yasm.tortall.net) * If using NASM, 0.98 or later is required for an x86 build. * If using NASM, 2.05 or later is required for an x86-64 build. - * nasm.exe/yasm.exe should be in your `PATH`. + * **nasm.exe**/**yasm.exe** should be in your `PATH`. - Microsoft Visual C++ 2005 or later @@ -484,11 +575,10 @@ Build Requirements - MinGW - [MinGW-builds](http://sourceforge.net/projects/mingwbuilds/) or - [tdm-gcc](http://tdm-gcc.tdragon.net/) recommended if building on a Windows - machine. Both distributions install a Start Menu link that can be used to - launch a command prompt with the appropriate compiler paths automatically - set. + [MSYS2](http://msys2.github.io/) or [tdm-gcc](http://tdm-gcc.tdragon.net/) + recommended if building on a Windows machine. Both distributions install a + Start Menu link that can be used to launch a command prompt with the + appropriate compiler paths automatically set. - If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This can be downloaded from . @@ -497,47 +587,51 @@ Build Requirements Out-of-Tree Builds ------------------ -Binary objects, libraries, and executables are generated in the same directory -from which `cmake` was executed (the "binary directory"), and this directory -need not necessarily be the same as the libjpeg-turbo source directory. You -can create multiple independent binary directories, in which different versions -of libjpeg-turbo can be built from the same source tree using different -compilers or settings. In the sections below, *{build_directory}* refers to -the binary directory, whereas *{source_directory}* refers to the libjpeg-turbo -source directory. For in-tree builds, these directories are the same. +Binary objects, libraries, and executables are generated in the directory from +which CMake is executed (the "binary directory"), and this directory need not +necessarily be the same as the libjpeg-turbo source directory. You can create +multiple independent binary directories, in which different versions of +libjpeg-turbo can be built from the same source tree using different compilers +or settings. In the sections below, *{build_directory}* refers to the binary +directory, whereas *{source_directory}* refers to the libjpeg-turbo source +directory. For in-tree builds, these directories are the same. -Building libjpeg-turbo ----------------------- +Build Procedure +--------------- + +NOTE: The build procedures below assume that CMake is invoked from the command +line, but all of these procedures can be adapted to the CMake GUI as +well. ### Visual C++ (Command Line) cd {build_directory} - cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory} + cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [additional CMake flags] {source_directory} nmake This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending -on which version of cl.exe is in the `PATH`. +on which version of **cl.exe** is in the `PATH`. The following files will be generated under *{build_directory}*: -**jpeg-static.lib** +**jpeg-static.lib**
Static link library for the libjpeg API -**sharedlib/jpeg{version}.dll** +**sharedlib/jpeg{version}.dll**
DLL for the libjpeg API -**sharedlib/jpeg.lib** +**sharedlib/jpeg.lib**
Import library for the libjpeg API -**turbojpeg-static.lib** +**turbojpeg-static.lib**
Static link library for the TurboJPEG API -**turbojpeg.dll** +**turbojpeg.dll**
DLL for the TurboJPEG API -**turbojpeg.lib** +**turbojpeg.lib**
Import library for the TurboJPEG API *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or @@ -551,35 +645,34 @@ Choose the appropriate CMake generator option for your version of Visual Studio instance: cd {build_directory} - cmake -G "Visual Studio 10" {source_directory} + cmake -G"Visual Studio 10" [additional CMake flags] {source_directory} -NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10 -Win64") to build a 64-bit version of libjpeg-turbo. Recent versions of CMake -no longer document that. A separate build directory must be used for 32-bit -and 64-bit builds. +NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10 +Win64") to build a 64-bit version of libjpeg-turbo. A separate build directory +must be used for 32-bit and 64-bit builds. -You can then open ALL_BUILD.vcproj in Visual Studio and build one of the +You can then open **ALL_BUILD.vcproj** in Visual Studio and build one of the configurations in that project ("Debug", "Release", etc.) to generate a full build of libjpeg-turbo. This will generate the following files under *{build_directory}*: -**{configuration}/jpeg-static.lib** +**{configuration}/jpeg-static.lib**
Static link library for the libjpeg API -**sharedlib/{configuration}/jpeg{version}.dll** +**sharedlib/{configuration}/jpeg{version}.dll**
DLL for the libjpeg API -**sharedlib/{configuration}/jpeg.lib** +**sharedlib/{configuration}/jpeg.lib**
Import library for the libjpeg API -**{configuration}/turbojpeg-static.lib** +**{configuration}/turbojpeg-static.lib**
Static link library for the TurboJPEG API -**{configuration}/turbojpeg.dll** +**{configuration}/turbojpeg.dll**
DLL for the TurboJPEG API -**{configuration}/turbojpeg.lib** +**{configuration}/turbojpeg.lib**
Import library for the TurboJPEG API *{configuration}* is Debug, Release, RelWithDebInfo, or MinSizeRel, depending @@ -589,31 +682,32 @@ depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled. ### MinGW -NOTE: This assumes that you are building on a Windows machine. If you are -cross-compiling on a Linux/Unix machine, then see "Build Recipes" below. +NOTE: This assumes that you are building on a Windows machine using the MSYS +environment. If you are cross-compiling on a Un*x platform (including Mac and +Cygwin), then see "Build Recipes" below. cd {build_directory} - cmake -G "MinGW Makefiles" {source_directory} - mingw32-make + cmake -G"MSYS Makefiles" [additional CMake flags] {source_directory} + make This will generate the following files under *{build_directory}*: -**libjpeg.a** +**libjpeg.a**
Static link library for the libjpeg API -**sharedlib/libjpeg-{version}.dll** +**sharedlib/libjpeg-{version}.dll**
DLL for the libjpeg API -**sharedlib/libjpeg.dll.a** +**sharedlib/libjpeg.dll.a**
Import library for the libjpeg API -**libturbojpeg.a** +**libturbojpeg.a**
Static link library for the TurboJPEG API -**libturbojpeg.dll** +**libturbojpeg.dll**
DLL for the TurboJPEG API -**libturbojpeg.dll.a** +**libturbojpeg.dll.a**
Import library for the TurboJPEG API *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or @@ -622,24 +716,24 @@ v8 emulation is enabled. ### Debug Build -Add `-DCMAKE_BUILD_TYPE=Debug` to the `cmake` command line. Or, if building +Add `-DCMAKE_BUILD_TYPE=Debug` to the CMake command line. Or, if building with NMake, remove `-DCMAKE_BUILD_TYPE=Release` (Debug builds are the default with NMake.) ### libjpeg v7 or v8 API/ABI Emulation -Add `-DWITH_JPEG7=1` to the `cmake` command line to build a version of +Add `-DWITH_JPEG7=1` to the CMake command line to build a version of libjpeg-turbo that is API/ABI-compatible with libjpeg v7. Add `-DWITH_JPEG8=1` -to the `cmake` command line to build a version of libjpeg-turbo that is +to the CMake command line to build a version of libjpeg-turbo that is API/ABI-compatible with libjpeg v8. See [README.md](README.md) for more -information on libjpeg v7 and v8 emulation. +information about libjpeg v7 and v8 emulation. ### In-Memory Source/Destination Managers When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to -the `cmake` command line to build a version of libjpeg-turbo that lacks the +the CMake command line to build a version of libjpeg-turbo that lacks the `jpeg_mem_src()` and `jpeg_mem_dest()` functions. These functions were not part of the original libjpeg v6b and v7 APIs, so removing them ensures strict conformance with those APIs. See [README.md](README.md) for more information. @@ -652,98 +746,105 @@ included in this release of libjpeg-turbo. libjpeg-turbo's implementation is based on the implementation in libjpeg v8, but it works when emulating libjpeg v7 or v6b as well. The default is to enable both arithmetic encoding and decoding, but those who have philosophical objections to arithmetic coding can -add `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the `cmake` command line to +add `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the CMake command line to disable encoding or decoding (respectively.) ### TurboJPEG Java Wrapper -Add `-DWITH_JAVA=1` to the `cmake` command line to incorporate an optional Java -Native Interface wrapper into the TurboJPEG shared library and build the Java -front-end classes to support it. This allows the TurboJPEG shared library to -be used directly from Java applications. See [java/README](java/README) for +Add `-DWITH_JAVA=1` to the CMake command line to incorporate an optional Java +Native Interface (JNI) wrapper into the TurboJPEG shared library and build the +Java front-end classes to support it. This allows the TurboJPEG shared library +to be used directly from Java applications. See [java/README](java/README) for more details. -You can set the `Java_JAVAC_EXECUTABLE`, `Java_JAVA_EXECUTABLE`, and -`Java_JAR_EXECUTABLE` CMake variables to specify alternate commands or -locations for javac, jar, and java (respectively.) You can also set the -`JAVACFLAGS` CMake variable to specify arguments that should be passed to the -Java compiler when building the front-end classes. - - -Installing libjpeg-turbo ------------------------- - -You can use the build system to install libjpeg-turbo into a directory of your -choosing (as opposed to creating an installer.) To do this, add: - - -DCMAKE_INSTALL_PREFIX={install_directory} - -to the cmake command line. - -For example, - - cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=c:\libjpeg-turbo {source_directory} - nmake install - -will install the header files in c:\libjpeg-turbo\include, the library files -in c:\libjpeg-turbo\lib, the DLL's in c:\libjpeg-turbo\bin, and the -documentation in c:\libjpeg-turbo\doc. +If Java is not in your `PATH`, or if you wish to use an alternate JDK to +build/test libjpeg-turbo, then (prior to running CMake) set the `JAVA_HOME` +environment variable to the location of the JDK that you wish to use. The +`Java_JAVAC_EXECUTABLE`, `Java_JAVA_EXECUTABLE`, and `Java_JAR_EXECUTABLE` +CMake variables can also be used to specify alternate commands or locations for +javac, jar, and java (respectively.) You can also set the `JAVACFLAGS` CMake +variable to specify arguments that should be passed to the Java compiler when +building the TurboJPEG classes. Build Recipes ------------- -### 64-bit MinGW Build on Cygwin +### 32-bit MinGW Build on Un*x (including Mac and Cygwin) + +Create a file called **toolchain.cmake** under *{build_directory}*, with the +following contents: + + set(CMAKE_SYSTEM_NAME Windows) + set(CMAKE_SYSTEM_PROCESSOR X86) + set(CMAKE_C_COMPILER {mingw_binary_path}/i686-w64-mingw32-gcc) + set(CMAKE_RC_COMPILER {mingw_binary_path}/i686-w64-mingw32-windres) + +*{mingw\_binary\_path}* is the directory under which the MinGW binaries are +located (usually **/usr/bin**.) Next, execute the following commands: cd {build_directory} - CC=/usr/bin/x86_64-w64-mingw32-gcc \ - cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \ - -DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe \ - {source_directory} - make - -This produces a 64-bit build of libjpeg-turbo that does not depend on -cygwin1.dll or other Cygwin DLL's. The mingw64-x86\_64-gcc-core and -mingw64-x86\_64-gcc-g++ packages (and their dependencies) must be installed. - - -### 32-bit MinGW Build on Cygwin - - cd {build_directory} - CC=/usr/bin/i686-w64-mingw32-gcc \ - cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \ - -DCMAKE_RC_COMPILER=/usr/bin/i686-w64-mingw32-windres.exe \ - {source_directory} - make - -This produces a 32-bit build of libjpeg-turbo that does not depend on -cygwin1.dll or other Cygwin DLL's. The mingw64-i686-gcc-core and -mingw64-i686-gcc-g++ packages (and their dependencies) must be installed. - - -### MinGW Build on Linux - - cd {build_directory} - CC={mingw_binary_path}/i686-pc-mingw32-gcc \ - cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \ - -DCMAKE_RC_COMPILER={mingw_binary_path}/i686-pc-mingw32-windres \ - -DCMAKE_AR={mingw_binary_path}/i686-pc-mingw32-ar \ - -DCMAKE_RANLIB={mingw_binary_path}/i686-pc-mingw32-ranlib \ - {source_directory} + cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ + [additional CMake flags] {source_directory} make -Creating Release Packages -========================= +### 64-bit MinGW Build on Un*x (including Mac and Cygwin) -The following commands can be used to create various types of release packages: +Create a file called **toolchain.cmake** under *{build_directory}*, with the +following contents: + + set(CMAKE_SYSTEM_NAME Windows) + set(CMAKE_SYSTEM_PROCESSOR AMD64) + set(CMAKE_C_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-gcc) + set(CMAKE_RC_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-windres) + +*{mingw\_binary\_path}* is the directory under which the MinGW binaries are +located (usually **/usr/bin**.) Next, execute the following commands: + + cd {build_directory} + cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ + [additional CMake flags] {source_directory} + make -Unix/Linux ----------- +Installing libjpeg-turbo +------------------------ + +You can use the build system to install libjpeg-turbo (as opposed to creating +an installer package.) To do this, run `make install` or `nmake install` +(or build the "install" target in the Visual Studio IDE.) Running +`make uninstall` or `nmake uninstall` (or building the "uninstall" target in +the Visual Studio IDE) will uninstall libjpeg-turbo. + +The `CMAKE_INSTALL_PREFIX` CMake variable can be modified in order to install +libjpeg-turbo into a directory of your choosing. If you don't specify +`CMAKE_INSTALL_PREFIX`, then the default is: + +**c:\libjpeg-turbo**
+Visual Studio 32-bit build + +**c:\libjpeg-turbo64**
+Visual Studio 64-bit build + +**c:\libjpeg-turbo-gcc**
+MinGW 32-bit build + +**c:\libjpeg-turbo-gcc64**
+MinGW 64-bit build + + +Creating Distribution Packages +============================== + +The following commands can be used to create various types of distribution +packages: + + +Linux +----- make rpm @@ -758,43 +859,47 @@ Red Hat-style source RPM package from the tarball. Requires RPM v4 or later. Create Debian-style binary package. Requires dpkg. + +Mac +--- + make dmg -Create Macintosh package/disk image. This requires pkgbuild and -productbuild, which are installed by default on OS X 10.7 and later and which -can be obtained by installing Xcode 3.2.6 (with the "Unix Development" -option) on OS X 10.6. Packages built in this manner can be installed on OS X -10.5 and later, but they must be built on OS X 10.6 or later. +Create Mac package/disk image. This requires pkgbuild and productbuild, which +are installed by default on OS X 10.7 and later and which can be obtained by +installing Xcode 3.2.6 (with the "Unix Development" option) on OS X 10.6. +Packages built in this manner can be installed on OS X 10.5 and later, but they +must be built on OS X 10.6 or later. make udmg [BUILDDIR32={32-bit build directory}] -On 64-bit OS X systems, this creates a Macintosh package and disk image that -contains universal i386/x86-64 binaries. You should first configure a 32-bit -out-of-tree build of libjpeg-turbo, then configure a 64-bit out-of-tree -build, then run `make udmg` from the 64-bit build directory. The build -system will look for the 32-bit build under *{source_directory}*/osxx86 by -default, but you can override this by setting the `BUILDDIR32` variable on the -make command line as shown above. +On 64-bit OS X systems, this creates a Mac package/disk image that contains +universal i386/x86-64 binaries. You should first configure a 32-bit +out-of-tree build of libjpeg-turbo, then configure a 64-bit out-of-tree build, +then run `make udmg` from the 64-bit build directory. The build system will +look for the 32-bit build under *{source_directory}*/osxx86 by default, but you +can override this by setting the `BUILDDIR32` variable on the make command line +as shown above. make iosdmg [BUILDDIR32={32-bit build directory}] \ [BUILDDIRARMV7={ARMv7 build directory}] \ [BUILDDIRARMV7S={ARMv7s build directory}] \ [BUILDDIRARMV8={ARMv8 build directory}] -On OS X systems, this creates a Macintosh package and disk image in which the -libjpeg-turbo static libraries contain ARM architectures necessary to build -iOS applications. If building on an x86-64 system, the binaries will also -contain the i386 architecture, as with `make udmg` above. You should first -configure ARMv7, ARMv7s, and/or ARMv8 out-of-tree builds of libjpeg-turbo (see -"Building libjpeg-turbo for iOS" above.) If you are building an x86-64 version -of libjpeg-turbo, you should configure a 32-bit out-of-tree build as well. -Next, build libjpeg-turbo as you would normally, using an out-of-tree build. -When it is built, run `make iosdmg` from the build directory. The build system -will look for the ARMv7 build under *{source_directory}*/iosarmv7 by default, -the ARMv7s build under *{source_directory}*/iosarmv7s by default, the ARMv8 -build under *{source_directory}*/iosarmv8 by default, and (if applicable) the -32-bit build under *{source_directory}*/osxx86 by default, but you can override -this by setting the `BUILDDIR32`, `BUILDDIRARMV7`, `BUILDDIRARMV7S`, and/or +This creates a Mac package/disk image in which the libjpeg-turbo libraries +contain ARM architectures necessary to build iOS applications. If building on +an x86-64 system, the binaries will also contain the i386 architecture, as with +`make udmg` above. You should first configure ARMv7, ARMv7s, and/or ARMv8 +out-of-tree builds of libjpeg-turbo (see "Building libjpeg-turbo for iOS" +above.) If you are building an x86-64 version of libjpeg-turbo, you should +configure a 32-bit out-of-tree build as well. Next, build libjpeg-turbo as you +would normally, using an out-of-tree build. When it is built, run `make +iosdmg` from the build directory. The build system will look for the ARMv7 +build under *{source_directory}*/iosarmv7 by default, the ARMv7s build under +*{source_directory}*/iosarmv7s by default, the ARMv8 build under +*{source_directory}*/iosarmv8 by default, and (if applicable) the 32-bit build +under *{source_directory}*/osxx86 by default, but you can override this by +setting the `BUILDDIR32`, `BUILDDIRARMV7`, `BUILDDIRARMV7S`, and/or `BUILDDIRARMV8` variables on the `make` command line as shown above. NOTE: If including an ARMv8 build in the package, then you may need to use @@ -819,38 +924,40 @@ If using MinGW: cd {build_directory} make installer -If using the Visual Studio IDE, build the "installer" project. +If using the Visual Studio IDE, build the "installer" target. -The installer package (libjpeg-turbo[-gcc][64].exe) will be located under -*{build_directory}*. If building using the Visual Studio IDE, then the -installer package will be located in a subdirectory with the same name as the -configuration you built (such as *{build_directory}*\Debug\ or +The installer package (libjpeg-turbo-*{version}*[-gcc|-vc][64].exe) will be +located under *{build_directory}*. If building using the Visual Studio IDE, +then the installer package will be located in a subdirectory with the same name +as the configuration you built (such as *{build_directory}*\Debug\ or *{build_directory}*\Release\). -Building a Windows installer requires the Nullsoft Install System -(http://nsis.sourceforge.net/.) makensis.exe should be in your `PATH`. +Building a Windows installer requires the +[Nullsoft Install System](http://nsis.sourceforge.net/). makensis.exe should +be in your `PATH`. Regression testing ================== -The most common way to test libjpeg-turbo is by invoking `make test` on -Unix/Linux platforms or `ctest` on Windows platforms, once the build has -completed. This runs a series of tests to ensure that mathematical -compatibility has been maintained between libjpeg-turbo and libjpeg v6b. This -also invokes the TurboJPEG unit tests, which ensure that the colorspace -extensions, YUV encoding, decompression scaling, and other features of the -TurboJPEG C and Java APIs are working properly (and, by extension, that the -equivalent features of the underlying libjpeg API are also working.) +The most common way to test libjpeg-turbo is by invoking `make test` (Un*x) or +`nmake test` (Windows command line) or by building the "RUN_TESTS" target +(Visual Studio IDE), once the build has completed. This runs a series of tests +to ensure that mathematical compatibility has been maintained between +libjpeg-turbo and libjpeg v6b. This also invokes the TurboJPEG unit tests, +which ensure that the colorspace extensions, YUV encoding, decompression +scaling, and other features of the TurboJPEG C and Java APIs are working +properly (and, by extension, that the equivalent features of the underlying +libjpeg API are also working.) -Invoking `make testclean` or `nmake testclean` (if using NMake) or building -the 'testclean' target (if using the Visual Studio IDE) will clean up the -output images generated by `make test`. +Invoking `make testclean` (Un*x) or `nmake testclean` (Windows command line) or +building the "testclean" target (Visual Studio IDE) will clean up the output +images generated by the tests. -On Unix/Linux platforms, more extensive tests of the TurboJPEG C and Java -wrappers can be run by invoking `make tjtest`. These extended TurboJPEG tests +On Un*x platforms, more extensive tests of the TurboJPEG C and Java wrappers +can be run by invoking `make tjtest`. These extended TurboJPEG tests essentially iterate through all of the available features of the TurboJPEG APIs -that are not covered by the TurboJPEG unit tests (this includes the lossless +that are not covered by the TurboJPEG unit tests (including the lossless transform options) and compare the images generated by each feature to images generated using the equivalent feature in the libjpeg API. The extended TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers, diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ee6cfb0..9f521513 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,8 +349,20 @@ if(WITH_12BIT) set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca) set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d) set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e) + if(64BIT) + # Windows/x64 uses SSE for floating point set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8) set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956) + else() + # Windows/x86 uses the 387 FPU for floating point + if(MSVC) + set(MD5_JPEG_3x2_FLOAT_PROG e27840755870fa849872e58aa0cd1400) + set(MD5_PPM_3x2_FLOAT 6c2880b83bb1aa41dfe330e7a9768690) + else() + set(MD5_JPEG_3x2_FLOAT_PROG bc6dbbefac2872f6b9d6c4a0ae60c3c0) + set(MD5_PPM_3x2_FLOAT f58119ee294198ac9b4a9f5645a34266) + endif() + endif() set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0) set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb) set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96) @@ -392,8 +404,18 @@ else() set(MD5_JPEG_3x2_FLOAT_PROG 343e3f8caf8af5986ebaf0bdc13b5c71) set(MD5_PPM_3x2_FLOAT 1a75f36e5904d6fc3a85a43da9ad89bb) else() + if(64BIT) set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5) set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc) + else() + if(MSVC) + set(MD5_JPEG_3x2_FLOAT_PROG 7999ce9cd0ee9b6c7043b7351ab7639d) + set(MD5_PPM_3x2_FLOAT 28cdc448a6b75e97892f0e0f8d4b21f3) + else() + set(MD5_JPEG_3x2_FLOAT_PROG 1657664a410e0822c924b54f6f65e6e9) + set(MD5_PPM_3x2_FLOAT cb0a1f027f3d2917c902b5640214e025) + endif() + endif() endif() set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1) set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617) @@ -826,7 +848,7 @@ foreach(libtype ${TEST_LIBTYPES}) endforeach() -add_custom_target(testclean COMMAND ${MD5CMP} -P +add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake) @@ -915,3 +937,8 @@ install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README-mozilla. install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h DESTINATION include) + +configure_file("${CMAKE_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in" + "cmake_uninstall.cmake" IMMEDIATE @ONLY) + +add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake) diff --git a/ChangeLog.md b/ChangeLog.md index 7f417a49..2aaa50c1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,74 @@ +1.5.2 +===== + +### Significant changes relative to 1.5.1: + +1. Fixed a regression introduced by 1.5.1[7] that prevented libjpeg-turbo from +building with Android NDK platforms prior to android-21 (5.0). + +2. Fixed a regression introduced by 1.5.1[1] that prevented the MIPS DSPR2 SIMD +code in libjpeg-turbo from building. + +3. Fixed a regression introduced by 1.5 beta1[11] that prevented the Java +version of TJBench from outputting any reference images (the `-nowrite` switch +was accidentally enabled by default.) + +4. libjpeg-turbo should now build and run with full AltiVec SIMD acceleration +on PowerPC-based AmigaOS 4 and OpenBSD systems. + +5. Fixed build and runtime errors on Windows that occurred when building +libjpeg-turbo with libjpeg v7 API/ABI emulation and the in-memory +source/destination managers. Due to an oversight, the `jpeg_skip_scanlines()` +and `jpeg_crop_scanlines()` functions were not being included in jpeg7.dll when +libjpeg-turbo was built with `-DWITH_JPEG7=1` and `-DWITH_MEMSRCDST=1`. + +6. Fixed "Bogus virtual array access" error that occurred when using the +lossless crop feature in jpegtran or the TurboJPEG API, if libjpeg-turbo was +built with libjpeg v7 API/ABI emulation. This was apparently a long-standing +bug that has existed since the introduction of libjpeg v7/v8 API/ABI emulation +in libjpeg-turbo v1.1. + +7. The lossless transform features in jpegtran and the TurboJPEG API will now +always attempt to adjust the EXIF image width and height tags if the image size +changed as a result of the transform. This behavior has always existed when +using libjpeg v8 API/ABI emulation. It was supposed to be available with +libjpeg v7 API/ABI emulation as well but did not work properly due to a bug. +Furthermore, there was never any good reason not to enable it with libjpeg v6b +API/ABI emulation, since the behavior is entirely internal. Note that +`-copy all` must be passed to jpegtran in order to transfer the EXIF tags from +the source image to the destination image. + +8. Fixed several memory leaks in the TurboJPEG API library that could occur +if the library was built with certain compilers and optimization levels +(known to occur with GCC 4.x and clang with `-O1` and higher but not with +GCC 5.x or 6.x) and one of the underlying libjpeg API functions threw an error +after a TurboJPEG API function allocated a local buffer. + +9. The libjpeg-turbo memory manager will now honor the `max_memory_to_use` +structure member in jpeg\_memory\_mgr, which can be set to the maximum amount +of memory (in bytes) that libjpeg-turbo should use during decompression or +multi-pass (including progressive) compression. This limit can also be set +using the `JPEGMEM` environment variable or using the `-maxmemory` switch in +cjpeg/djpeg/jpegtran (refer to the respective man pages for more details.) +This has been a documented feature of libjpeg since v5, but the +`malloc()`/`free()` implementation of the memory manager (jmemnobs.c) never +implemented the feature. Restricting libjpeg-turbo's memory usage is useful +for two reasons: it allows testers to more easily work around the 2 GB limit +in libFuzzer, and it allows developers of security-sensitive applications to +more easily defend against one of the progressive JPEG exploits (LJT-01-004) +identified in +[this report](http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf). + +10. TJBench will now run each benchmark for 1 second prior to starting the +timer, in order to improve the consistency of the results. Furthermore, the +`-warmup` option is now used to specify the amount of warmup time rather than +the number of warmup iterations. + +11. Fixed an error (`short jump is out of range`) that occurred when assembling +the 32-bit x86 SIMD extensions with NASM versions prior to 2.04. This was a +regression introduced by 1.5 beta1[12]. + + 1.5.1 ===== diff --git a/LICENSE.md b/LICENSE.md index 4623e294..05723906 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -9,12 +9,11 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses: 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](turbojpeg.c) +- The Modified (3-clause) BSD License, which is listed below This license covers the TurboJPEG API library and associated programs. -- The zlib License, which is listed in [simd/jsimdext.inc](simd/jsimdext.inc) +- The zlib License, which is listed below This license is a subset of the other two, and it covers the libjpeg-turbo SIMD extensions. @@ -86,3 +85,55 @@ best of our understanding. - IJG License - Modified BSD License - zlib License + + +The Modified (3-clause) BSD License +=================================== + +Copyright (C)\ \. All Rights Reserved. + +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. + + +The zlib License +================ + +Copyright (C) \, \. + +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. diff --git a/Makefile.am b/Makefile.am index 55415402..a0648051 100644 --- a/Makefile.am +++ b/Makefile.am @@ -216,6 +216,8 @@ MD5_PPM_3x2_FLOAT_SSE = 42876ab9e5c2f76a87d08db5fbd57956 MD5_JPEG_3x2_FLOAT_PROG_32BIT = a8c17daf77b457725ec929e215b603f8 MD5_PPM_3x2_FLOAT_32BIT = 42876ab9e5c2f76a87d08db5fbd57956 MD5_PPM_3x2_FLOAT_64BIT = d6fbc71153b3d8ded484dbc17c7b9cf4 +MD5_JPEG_3x2_FLOAT_PROG_387 = bc6dbbefac2872f6b9d6c4a0ae60c3c0 +MD5_PPM_3x2_FLOAT_387 = bcc5723c61560463ac60f772e742d092 MD5_JPEG_3x2_IFAST_PROG = 1396cc2b7185cfe943d408c9d305339e MD5_PPM_3x2_IFAST = 3975985ef6eeb0a2cdc58daa651ccc00 MD5_PPM_420M_ISLOW_2_1 = 4ca6be2a6f326ff9eaab63e70a8259c0 @@ -263,6 +265,8 @@ MD5_PPM_3x2_FLOAT_SSE = 1a75f36e5904d6fc3a85a43da9ad89bb MD5_JPEG_3x2_FLOAT_PROG_32BIT = 9bca803d2042bd1eb03819e2bf92b3e5 MD5_PPM_3x2_FLOAT_32BIT = f6bfab038438ed8f5522fbd33595dcdc MD5_PPM_3x2_FLOAT_64BIT = 0e917a34193ef976b679a6b069b1be26 +MD5_JPEG_3x2_FLOAT_PROG_387 = 1657664a410e0822c924b54f6f65e6e9 +MD5_PPM_3x2_FLOAT_387 = cb0a1f027f3d2917c902b5640214e025 MD5_JPEG_3x2_IFAST_PROG = 1ee5d2c1a77f2da495f993c8c7cceca5 MD5_PPM_3x2_IFAST = fd283664b3b49127984af0a7f118fccd MD5_JPEG_420_ISLOW_ARI = e986fb0a637a8d833d96e8a6d6d84ea1 @@ -351,7 +355,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3 # Test compressing from/decompressing to an arbitrary subregion of a larger # image buffer cp $(srcdir)/testimages/testorig.ppm testout_tile.ppm - TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 >/dev/null 2>&1 + TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1 for i in 8 16 32 64 128; do \ md5/md5cmp $(MD5_PPM_GRAY_TILE) testout_tile_GRAY_Q95_$$i\x$$i.ppm; \ done @@ -370,7 +374,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3 done rm -f testout_tile_GRAY_* testout_tile_420_* testout_tile_422_* testout_tile_444_* - TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 >/dev/null 2>&1 + TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1 md5/md5cmp $(MD5_PPM_420M_8x8_TILE) testout_tile_420_Q95_8x8.ppm for i in 16 32 64 128; do \ md5/md5cmp $(MD5_PPM_420M_TILE) testout_tile_420_Q95_$$i\x$$i.ppm; \ @@ -495,6 +499,9 @@ endif # x86-64 compilers) # FLOATTEST=64bit validate against the exepected results from the C code # when running on a 64-bit FPU +# FLOATTEST=387 validate against the expected results from the C code when +# the 387 FPU is being used for floating point math (which is +# generally the default with x86 compilers) # CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff ./cjpeg -revert -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm @@ -502,6 +509,8 @@ endif md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_SSE) testout_3x2_float_prog.jpg; \ elif [ "${FLOATTEST}" = "32bit" -o "${FLOATTEST}" = "64bit" ]; then \ md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_32BIT) testout_3x2_float_prog.jpg; \ + elif [ "${FLOATTEST}" = "387" ]; then \ + md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_387) testout_3x2_float_prog.jpg; \ fi # CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff ./djpeg -dct float -outfile testout_3x2_float.ppm testout_3x2_float_prog.jpg @@ -511,6 +520,8 @@ endif md5/md5cmp $(MD5_PPM_3x2_FLOAT_32BIT) testout_3x2_float.ppm; \ elif [ "${FLOATTEST}" = "64bit" ]; then \ md5/md5cmp $(MD5_PPM_3x2_FLOAT_64BIT) testout_3x2_float.ppm; \ + elif [ "${FLOATTEST}" = "387" ]; then \ + md5/md5cmp $(MD5_PPM_3x2_FLOAT_387) testout_3x2_float.ppm; \ fi rm -f testout_3x2_float.ppm testout_3x2_float_prog.jpg diff --git a/cjpeg.1 b/cjpeg.1 index d1dc3041..283fc81f 100644 --- a/cjpeg.1 +++ b/cjpeg.1 @@ -1,4 +1,4 @@ -.TH CJPEG 1 "17 February 2016" +.TH CJPEG 1 "18 March 2017" .SH NAME cjpeg \- compress an image file to a JPEG file .SH SYNOPSIS @@ -202,7 +202,7 @@ Set limit for amount of memory to use in processing large images. Value is in thousands of bytes, or millions of bytes if "M" is attached to the number. For example, .B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. +selects 4000000 bytes. If more space is needed, an error will occur. .TP .BI \-outfile " name" Send output image to the named file, not to standard output. diff --git a/cjpeg.c b/cjpeg.c index 9c8e02e8..b6215a32 100644 --- a/cjpeg.c +++ b/cjpeg.c @@ -5,7 +5,7 @@ * Copyright (C) 1991-1998, Thomas G. Lane. * Modified 2003-2011 by Guido Vollbeding. * libjpeg-turbo Modifications: - * Copyright (C) 2010, 2013-2014, D. R. Commander. + * Copyright (C) 2010, 2013-2014, 2017, D. R. Commander. * mozjpeg Modifications: * Copyright (C) 2014, Mozilla Corporation. * For conditions of distribution and use, see the accompanying README file. @@ -231,11 +231,11 @@ usage (void) fprintf(stderr, " -verbose or -debug Emit debug output\n"); fprintf(stderr, " -version Print version information and exit\n"); fprintf(stderr, "Switches for wizards:\n"); - fprintf(stderr, " -qtables file Use quantization tables given in file\n"); + fprintf(stderr, " -qtables FILE Use quantization tables given in FILE\n"); fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); #ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); + fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n"); #endif exit(EXIT_FAILURE); } diff --git a/cmakescripts/cmake_uninstall.cmake.in b/cmakescripts/cmake_uninstall.cmake.in new file mode 100644 index 00000000..b35d1009 --- /dev/null +++ b/cmakescripts/cmake_uninstall.cmake.in @@ -0,0 +1,24 @@ +# This code is from the CMake FAQ + +if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +list(REVERSE files) +foreach (file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (EXISTS "$ENV{DESTDIR}${file}") + execute_process( + COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/cmakescripts/testclean.cmake b/cmakescripts/testclean.cmake index e3577875..38bb03b0 100644 --- a/cmakescripts/testclean.cmake +++ b/cmakescripts/testclean.cmake @@ -24,7 +24,12 @@ file(GLOB FILES *_440_*.png *_440_*.ppm *_440_*.jpg - *_440.yuv) + *_440.yuv + *_411_*.bmp + *_411_*.png + *_411_*.ppm + *_411_*.jpg + *_411.yuv) if(NOT FILES STREQUAL "") message(STATUS "Removing test files") diff --git a/configure.ac b/configure.ac index 4e7d79d2..c999a023 100644 --- a/configure.ac +++ b/configure.ac @@ -233,9 +233,9 @@ AC_SUBST(MEM_SRCDST_FUNCTIONS) AC_DEFINE_UNQUOTED(MOZJPEG_VERSION, [$VERSION], [mozjpeg version]) m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]])) -m4_define(version_major,m4_argn(1,version_triplet)) -m4_define(version_minor,m4_argn(2,version_triplet)) -m4_define(version_revision,m4_argn(3,version_triplet)) +m4_define(version_major,m4_car(m4_shiftn(1,[],version_triplet))) +m4_define(version_minor,m4_car(m4_shiftn(2,[],version_triplet))) +m4_define(version_revision,m4_car(m4_shiftn(3,[],version_triplet))) VERSION_MAJOR=version_major VERSION_MINOR=version_minor VERSION_REVISION=version_revision diff --git a/djpeg.1 b/djpeg.1 index 7efde43b..b1e7f76e 100644 --- a/djpeg.1 +++ b/djpeg.1 @@ -1,4 +1,4 @@ -.TH DJPEG 1 "18 February 2016" +.TH DJPEG 1 "18 March 2017" .SH NAME djpeg \- decompress a JPEG file to an image file .SH SYNOPSIS @@ -185,7 +185,7 @@ Set limit for amount of memory to use in processing large images. Value is in thousands of bytes, or millions of bytes if "M" is attached to the number. For example, .B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. +selects 4000000 bytes. If more space is needed, an error will occur. .TP .BI \-outfile " name" Send output image to the named file, not to standard output. diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html index 4b8d306e..8d7626db 100644 --- a/doc/html/group___turbo_j_p_e_g.html +++ b/doc/html/group___turbo_j_p_e_g.html @@ -455,7 +455,7 @@ Variables

Disable buffer (re)allocation.

-

If passed to tjCompress2() or tjTransform(), this flag will cause those functions to generate an error if the JPEG image buffer is invalid or too small rather than attempting to allocate or reallocate that buffer. This reproduces the behavior of earlier versions of TurboJPEG.

+

If passed to one of the JPEG compression or transform functions, this flag will cause those functions to generate an error if the JPEG image buffer is invalid or too small rather than attempting to allocate or reallocate that buffer. This reproduces the behavior of earlier versions of TurboJPEG.

@@ -812,7 +812,7 @@ Variables

Allocate an image buffer for use with TurboJPEG.

-

You should always use this function to allocate the JPEG destination buffer(s) for tjCompress2() and tjTransform() unless you are disabling automatic buffer (re)allocation (by setting TJFLAG_NOREALLOC.)

+

You should always use this function to allocate the JPEG destination buffer(s) for the compression and transform functions unless you are disabling automatic buffer (re)allocation (by setting TJFLAG_NOREALLOC.)

Parameters
@@ -1008,7 +1008,7 @@ Variables @@ -1106,7 +1106,7 @@ If you choose option 1, *jpegSize should be set to the size of your @@ -1203,7 +1203,7 @@ If you choose option 1, *jpegSize should be set to the size of your @@ -1942,7 +1942,7 @@ If you choose option 1, *jpegSize should be set to the size of your

Free an image buffer previously allocated by TurboJPEG.

-

You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by tjCompress2() or tjTransform() or that were manually allocated using tjAlloc().

+

You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by the compression and transform functions or that were manually allocated using tjAlloc().

Parameters
bytesthe number of bytes to allocate
jpegBufaddress of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
  1. pre-allocate the JPEG buffer with an arbitrary size using tjAlloc() and let TurboJPEG grow the buffer as needed,
  2. set *jpegBuf to NULL to tell TurboJPEG to allocate the buffer for you, or
  3. -
  4. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize(). This should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees this.)
  5. +
  6. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize(). This should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees that it won't be.)
If you choose option 1, *jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed.
jpegSizepointer to an unsigned long variable that holds the size of the JPEG image buffer. If *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored.
jpegBufaddress of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
  1. pre-allocate the JPEG buffer with an arbitrary size using tjAlloc() and let TurboJPEG grow the buffer as needed,
  2. set *jpegBuf to NULL to tell TurboJPEG to allocate the buffer for you, or
  3. -
  4. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize(). This should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees this.)
  5. +
  6. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize(). This should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees that it won't be.)
If you choose option 1, *jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed.
jpegSizepointer to an unsigned long variable that holds the size of the JPEG image buffer. If *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored.
jpegBufaddress of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
  1. pre-allocate the JPEG buffer with an arbitrary size using tjAlloc() and let TurboJPEG grow the buffer as needed,
  2. set *jpegBuf to NULL to tell TurboJPEG to allocate the buffer for you, or
  3. -
  4. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize(). This should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees this.)
  5. +
  6. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize(). This should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees that it won't be.)
If you choose option 1, *jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed.
jpegSizepointer to an unsigned long variable that holds the size of the JPEG image buffer. If *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored.
@@ -2270,7 +2270,7 @@ If you choose option 1, *jpegSize should be set to the size of your diff --git a/java/TJBench.java b/java/TJBench.java index 19db789c..5185d658 100644 --- a/java/TJBench.java +++ b/java/TJBench.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2014, 2016 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2014, 2016-2017 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,8 +34,8 @@ import org.libjpegturbo.turbojpeg.*; class TJBench { - static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1, warmup = 1; - static boolean compOnly, decompOnly, doTile, doYUV, write; + static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1; + static boolean compOnly, decompOnly, doTile, doYUV, write = true; static final String[] pixFormatStr = { "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY" @@ -55,7 +55,7 @@ class TJBench { static TJScalingFactor sf; static int xformOp = TJTransform.OP_NONE, xformOpt = 0; - static double benchTime = 5.0; + static double benchTime = 5.0, warmup = 1.0; static final double getTime() { @@ -162,7 +162,7 @@ class TJBench { } /* Benchmark */ - iter -= warmup; + iter = -1; elapsed = elapsedDecode = 0.0; while (true) { int tile = 0; @@ -184,11 +184,14 @@ class TJBench { tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags); } } - iter++; - if (iter >= 1) { - elapsed += getTime() - start; + elapsed += getTime() - start; + if (iter >= 0) { + iter++; if (elapsed >= benchTime) break; + } else if (elapsed >= warmup) { + iter = 0; + elapsed = elapsedDecode = 0.0; } } if(doYUV) @@ -321,7 +324,7 @@ class TJBench { } /* Benchmark */ - iter = -warmup; + iter = -1; elapsed = elapsedEncode = 0.0; while (true) { int tile = 0; @@ -346,11 +349,14 @@ class TJBench { totalJpegSize += jpegSize[tile]; } } - iter++; - if (iter >= 1) { - elapsed += getTime() - start; + elapsed += getTime() - start; + if (iter >= 0) { + iter++; if (elapsed >= benchTime) break; + } else if (elapsed >= warmup) { + iter = 0; + elapsed = elapsedEncode = 0.0; } } if (doYUV) @@ -541,17 +547,20 @@ class TJBench { } } - iter = -warmup; + iter = -1; elapsed = 0.; while (true) { start = getTime(); tjt.transform(jpegBuf, t, flags); jpegSize = tjt.getTransformedSizes(); - iter++; - if (iter >= 1) { - elapsed += getTime() - start; + elapsed += getTime() - start; + if (iter >= 0) { + iter++; if (elapsed >= benchTime) break; + } else if (elapsed >= warmup) { + iter = 0; + elapsed = 0.0; } } t = null; @@ -582,8 +591,8 @@ class TJBench { System.out.print("N/A N/A "); jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)]; jpegSize = new int[1]; + jpegBuf[0] = srcBuf; jpegSize[0] = srcSize; - System.arraycopy(srcBuf, 0, jpegBuf[0], 0, srcSize); } if (w == tilew) @@ -659,8 +668,9 @@ class TJBench { System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression"); System.out.println(" test (can be combined with the other transforms above)"); System.out.println("-benchtime = Run each benchmark for at least seconds (default = 5.0)"); - System.out.println("-warmup = Execute each benchmark times to prime the cache before"); - System.out.println(" taking performance measurements (default = 1)"); + System.out.println("-warmup = Run each benchmark for seconds (default = 1.0) prior to"); + System.out.println(" starting the timer, in order to prime the caches and thus improve the"); + System.out.println(" consistency of the results."); System.out.println("-componly = Stop after running compression tests. Do not test decompression."); System.out.println("-nowrite = Do not write reference or output images (improves consistency"); System.out.println(" of performance measurements.)\n"); @@ -824,14 +834,15 @@ class TJBench { if (argv[i].equalsIgnoreCase("-nowrite")) write = false; if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) { - int temp = -1; + double temp = -1; try { - temp = Integer.parseInt(argv[++i]); + temp = Double.parseDouble(argv[++i]); } catch (NumberFormatException e) {} - if (temp >= 0) { + if (temp >= 0.0) { warmup = temp; - System.out.format("Warmup runs = %d\n\n", warmup); - } + System.out.format("Warmup time = %.1f seconds\n\n", warmup); + } else + usage(); } if (argv[i].equalsIgnoreCase("-?")) usage(); diff --git a/jconfigint.h.in b/jconfigint.h.in index 940424ea..963e7602 100644 --- a/jconfigint.h.in +++ b/jconfigint.h.in @@ -1,6 +1,9 @@ /* libjpeg-turbo build number */ #undef BUILD +/* Compiler's inline keyword */ +#undef inline + /* How to obtain function inlining. */ #undef INLINE diff --git a/jdarith.c b/jdarith.c index df3540ee..ce0f9209 100644 --- a/jdarith.c +++ b/jdarith.c @@ -21,6 +21,9 @@ #include "jpeglib.h" +#define NEG_1 ((unsigned int)-1) + + /* Expanded entropy decoder object for arithmetic decoding. */ typedef struct { @@ -450,7 +453,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) tbl = cinfo->cur_comp_info[0]->ac_tbl_no; p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ + m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */ /* Establish EOBx (previous stage end-of-block) index */ for (kex = cinfo->Se; kex > 0; kex--) diff --git a/jmemmgr.c b/jmemmgr.c index adccbdfa..8dfb633d 100644 --- a/jmemmgr.c +++ b/jmemmgr.c @@ -32,7 +32,10 @@ #include "jinclude.h" #include "jpeglib.h" #include "jmemsys.h" /* import the system-dependent declarations */ +#ifndef _WIN32 #include +#endif +#include #ifndef NO_GETENV #ifndef HAVE_STDLIB_H /* should declare getenv() */ diff --git a/jmemnobs.c b/jmemnobs.c index 5797198d..ac12afa5 100644 --- a/jmemnobs.c +++ b/jmemnobs.c @@ -3,8 +3,8 @@ * * This file was part of the Independent JPEG Group's software: * Copyright (C) 1992-1996, Thomas G. Lane. - * It was modified by The libjpeg-turbo Project to include only code and - * information relevant to libjpeg-turbo. + * libjpeg-turbo Modifications: + * Copyright (C) 2017, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * @@ -15,7 +15,6 @@ * This is very portable in the sense that it'll compile on almost anything, * but you'd better have lots of main memory (or virtual memory) if you want * to process big images. - * Note that the max_memory_to_use option is ignored by this implementation. */ #define JPEG_INTERNALS @@ -66,14 +65,21 @@ jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject) /* * This routine computes the total memory space available for allocation. - * Here we always say, "we got all you want bud!" */ GLOBAL(size_t) jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed, size_t max_bytes_needed, size_t already_allocated) { - return max_bytes_needed; + if (cinfo->mem->max_memory_to_use) { + if (cinfo->mem->max_memory_to_use > already_allocated) + return cinfo->mem->max_memory_to_use - already_allocated; + else + return 0; + } else { + /* Here we always say, "we got all you want bud!" */ + return max_bytes_needed; + } } diff --git a/jpegtran.1 b/jpegtran.1 index 7f3c8531..631455b6 100644 --- a/jpegtran.1 +++ b/jpegtran.1 @@ -1,4 +1,4 @@ -.TH JPEGTRAN 1 "18 February 2016" +.TH JPEGTRAN 1 "18 March 2017" .SH NAME jpegtran \- lossless transformation of JPEG files .SH SYNOPSIS @@ -222,7 +222,7 @@ Set limit for amount of memory to use in processing large images. Value is in thousands of bytes, or millions of bytes if "M" is attached to the number. For example, .B \-max 4m -selects 4000000 bytes. If more space is needed, temporary files will be used. +selects 4000000 bytes. If more space is needed, an error will occur. .TP .BI \-outfile " name" Send output image to the named file, not to standard output. diff --git a/jpegtran.c b/jpegtran.c index 8385871f..de089b04 100644 --- a/jpegtran.c +++ b/jpegtran.c @@ -4,7 +4,7 @@ * This file was part of the Independent JPEG Group's software: * Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding. * libjpeg-turbo Modifications: - * Copyright (C) 2010, 2014, D. R. Commander. + * Copyright (C) 2010, 2014, 2017, D. R. Commander. * mozjpeg Modifications: * Copyright (C) 2014, Mozilla Corporation. * For conditions of distribution and use, see the accompanying README file. @@ -95,7 +95,7 @@ usage (void) fprintf(stderr, " -version Print version information and exit\n"); fprintf(stderr, "Switches for wizards:\n"); #ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); + fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n"); #endif exit(EXIT_FAILURE); } diff --git a/jversion.h b/jversion.h index 61a6863b..0b9a3bab 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-2016, D. R. Commander. + * Copyright (C) 2010, 2012-2017, D. R. Commander. * mozjpeg Modifications: * Copyright (C) 2014, Mozilla Corporation. * For conditions of distribution and use, see the accompanying README file. @@ -36,7 +36,7 @@ * their code */ -#define JCOPYRIGHT "Copyright (C) 2009-2016 D. R. Commander\n" \ +#define JCOPYRIGHT "Copyright (C) 2009-2017 D. R. Commander\n" \ "Copyright (C) 2011-2016 Siarhei Siamashka\n" \ "Copyright (C) 2015-2016 Matthieu Darbois\n" \ "Copyright (C) 2015 Google, Inc.\n" \ @@ -48,4 +48,4 @@ "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \ "Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding" \ -#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2016 The libjpeg-turbo Project and many others" +#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2017 The libjpeg-turbo Project and many others" diff --git a/libjpeg.txt b/libjpeg.txt index 71d37c61..5181afc0 100644 --- a/libjpeg.txt +++ b/libjpeg.txt @@ -3,7 +3,7 @@ USING THE IJG JPEG LIBRARY This file was part of the Independent JPEG Group's software: Copyright (C) 1994-2013, Thomas G. Lane, Guido Vollbeding. libjpeg-turbo Modifications: -Copyright (C) 2010, 2014-2016, D. R. Commander. +Copyright (C) 2010, 2014-2017, D. R. Commander. Copyright (C) 2015, Google, Inc. For conditions of distribution and use, see the accompanying README.ijg file. @@ -34,6 +34,7 @@ Basic library usage: Data formats Compression details Decompression details + Partial image decompression Mechanics of usage: include files, linking, etc Advanced features: Compression parameter selection @@ -2941,13 +2942,6 @@ Some operating modes (eg, two-pass color quantization) require full-image buffers. Such buffers are treated as "virtual arrays": only the current strip need be in memory, and the rest can be swapped out to a temporary file. -If you use the simplest memory manager back end (jmemnobs.c), then no -temporary files are used; virtual arrays are simply malloc()'d. Images bigger -than memory can be processed only if your system supports virtual memory. -The other memory manager back ends support temporary files of various flavors -and thus work in machines without virtual memory. They may also be useful on -Unix machines if you need to process images that exceed available swap space. - When using temporary files, the library will make the in-memory buffers for its virtual arrays just big enough to stay within a "maximum memory" setting. Your application can set this limit by setting cinfo->mem->max_memory_to_use @@ -2960,6 +2954,11 @@ that space allocated with alloc_small() is ignored, on the assumption that it's too small to be worth worrying about; so a reasonable safety margin should be left when setting max_memory_to_use. +NOTE: Unless you develop your own memory manager back end, then temporary files +will never be used. The back end provided in libjpeg-turbo (jmemnobs.c) simply +malloc()s and free()s virtual arrays, and an error occurs if the required +memory exceeds the limit specified in cinfo->mem->max_memory_to_use. + Memory usage ------------ diff --git a/md5/md5.c b/md5/md5.c index 087f4b02..4b5ba5ec 100644 --- a/md5/md5.c +++ b/md5/md5.c @@ -31,6 +31,15 @@ #include "./md5.h" +#ifdef __amigaos4__ +#include +#define le32toh(x) (((x & 0xff) << 24) | \ + ((x & 0xff00) << 8) | \ + ((x & 0xff0000) >> 8) | \ + ((x & 0xff000000) >> 24)) +#define htole32(x) le32toh(x) +#endif + static void MD5Transform(unsigned int [4], const unsigned char [64]); #if (BYTE_ORDER == LITTLE_ENDIAN) diff --git a/rdppm.c b/rdppm.c index b71d3378..33ff7495 100644 --- a/rdppm.c +++ b/rdppm.c @@ -251,7 +251,7 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) ptr = source->pub.buffer[0]; bufferptr = source->iobuffer; for (col = cinfo->image_width; col > 0; col--) { - register int temp; + register unsigned int temp; temp = UCH(*bufferptr++) << 8; temp |= UCH(*bufferptr++); if (temp > maxval) @@ -278,7 +278,7 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) ptr = source->pub.buffer[0]; bufferptr = source->iobuffer; for (col = cinfo->image_width; col > 0; col--) { - register int temp; + register unsigned int temp; temp = UCH(*bufferptr++) << 8; temp |= UCH(*bufferptr++); if (temp > maxval) diff --git a/simd/CMakeLists.txt b/simd/CMakeLists.txt index bc9cd5f0..60bd6405 100755 --- a/simd/CMakeLists.txt +++ b/simd/CMakeLists.txt @@ -1,6 +1,7 @@ if(NOT DEFINED NASM) - set(NASM nasm CACHE FILEPATH "Path to NASM/YASM executable") + find_program(NASM NAMES nasm yasm DOC "Path to NASM/YASM executable") endif() +message(STATUS "NASM = ${NASM}") if(SIMD_X86_64) set(NAFLAGS -fwin64 -DWIN64 -D__x86_64__) diff --git a/simd/jchuff-sse2.asm b/simd/jchuff-sse2.asm index 36d1f2db..b81db75b 100644 --- a/simd/jchuff-sse2.asm +++ b/simd/jchuff-sse2.asm @@ -1,7 +1,7 @@ ; ; jchuff-sse2.asm - Huffman entropy encoding (SSE2) ; -; Copyright (C) 2009-2011, 2014-2016, D. R. Commander. +; Copyright (C) 2009-2011, 2014-2017, D. R. Commander. ; Copyright (C) 2015, Matthieu Darbois. ; ; Based on the x86 SIMD extension for IJG JPEG library @@ -288,13 +288,13 @@ EXTN(jsimd_huff_encode_one_block_sse2): .BLOOP: bsf ecx, edx ; r = __builtin_ctzl(index); - jz .ELOOP + jz near .ELOOP lea esi, [esi+ecx*2] ; k += r; shr edx, cl ; index >>= r; mov DWORD [esp+temp3], edx .BRLOOP: cmp ecx, 16 ; while (r > 15) { - jl .ERLOOP + jl near .ERLOOP sub ecx, 16 ; r -= 16; mov DWORD [esp+temp], ecx mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0]; @@ -348,7 +348,7 @@ EXTN(jsimd_huff_encode_one_block_sse2): sub eax, esi shr eax, 1 bsf ecx, edx ; r = __builtin_ctzl(index); - jz .ELOOP2 + jz near .ELOOP2 shr edx, cl ; index >>= r; add ecx, eax lea esi, [esi+ecx*2] ; k += r; @@ -356,13 +356,13 @@ EXTN(jsimd_huff_encode_one_block_sse2): jmp .BRLOOP2 .BLOOP2: bsf ecx, edx ; r = __builtin_ctzl(index); - jz .ELOOP2 + jz near .ELOOP2 lea esi, [esi+ecx*2] ; k += r; shr edx, cl ; index >>= r; mov DWORD [esp+temp3], edx .BRLOOP2: cmp ecx, 16 ; while (r > 15) { - jl .ERLOOP2 + jl near .ERLOOP2 sub ecx, 16 ; r -= 16; mov DWORD [esp+temp], ecx mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0]; diff --git a/simd/jsimd_arm.c b/simd/jsimd_arm.c index 61cd073e..0b955cdd 100644 --- a/simd/jsimd_arm.c +++ b/simd/jsimd_arm.c @@ -2,6 +2,7 @@ * jsimd_arm.c * * Copyright 2009 Pierre Ossman for Cendio AB + * Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies). * Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander. * Copyright (C) 2015-2016, Matthieu Darbois. * diff --git a/simd/jsimd_arm64.c b/simd/jsimd_arm64.c index 09449bb6..f6e97364 100644 --- a/simd/jsimd_arm64.c +++ b/simd/jsimd_arm64.c @@ -2,6 +2,7 @@ * jsimd_arm64.c * * Copyright 2009 Pierre Ossman for Cendio AB + * Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies). * Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander. * Copyright (C) 2015-2016, Matthieu Darbois. * diff --git a/simd/jsimd_mips.c b/simd/jsimd_mips.c index 63b8115d..02e90cd9 100644 --- a/simd/jsimd_mips.c +++ b/simd/jsimd_mips.c @@ -63,6 +63,8 @@ parse_proc_cpuinfo(const char* search_string) LOCAL(void) init_simd (void) { + char *env = NULL; + if (simd_support != ~0U) return; diff --git a/simd/jsimd_powerpc.c b/simd/jsimd_powerpc.c index 42dc1e08..47dd746f 100644 --- a/simd/jsimd_powerpc.c +++ b/simd/jsimd_powerpc.c @@ -14,6 +14,11 @@ * PowerPC architecture. */ +#ifdef __amigaos4__ +/* This must be defined first as it re-defines GLOBAL otherwise */ +#include +#endif + #define JPEG_INTERNALS #include "../jinclude.h" #include "../jpeglib.h" @@ -26,6 +31,12 @@ #include #include +#if defined(__OpenBSD__) +#include +#include +#include +#endif + static unsigned int simd_support = ~0; #if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) @@ -101,6 +112,12 @@ init_simd (void) char *env = NULL; #if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)) int bufsize = 1024; /* an initial guess for the line buffer size limit */ +#elif defined(__amigaos4__) + uint32 altivec = 0; +#elif defined(__OpenBSD__) + int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC }; + int altivec; + size_t len = sizeof(altivec); #endif if (simd_support != ~0U) @@ -116,6 +133,13 @@ init_simd (void) if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT) break; } +#elif defined(__amigaos4__) + IExec->GetCPUInfoTags(GCIT_VectorUnit, &altivec, TAG_DONE); + if(altivec == VECTORTYPE_ALTIVEC) + simd_support |= JSIMD_ALTIVEC; +#elif defined(__OpenBSD__) + if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0) + simd_support |= JSIMD_ALTIVEC; #endif /* Force different settings through environment variables */ diff --git a/structure.txt b/structure.txt index 296d1250..f69c9d87 100644 --- a/structure.txt +++ b/structure.txt @@ -832,21 +832,19 @@ read_backing_store, manipulate a backing-store object write_backing_store, close_backing_store -On some systems there will be more than one type of backing-store object -(specifically, in MS-DOS a backing store file might be an area of extended -memory as well as a disk file). jpeg_open_backing_store is responsible for -choosing how to implement a given object. The read/write/close routines -are method pointers in the structure that describes a given object; this -lets them be different for different object types. +On some systems there will be more than one type of backing-store object. +jpeg_open_backing_store is responsible for choosing how to implement a given +object. The read/write/close routines are method pointers in the structure +that describes a given object; this lets them be different for different object +types. It may be necessary to ensure that backing store objects are explicitly -released upon abnormal program termination. For example, MS-DOS won't free -extended memory by itself. To support this, we will expect the main program -or surrounding application to arrange to call self_destruct (typically via -jpeg_destroy) upon abnormal termination. This may require a SIGINT signal -handler or equivalent. We don't want to have the back end module install its -own signal handler, because that would pre-empt the surrounding application's -ability to control signal handling. +released upon abnormal program termination. To support this, we will expect +the main program or surrounding application to arrange to call self_destruct +(typically via jpeg_destroy) upon abnormal termination. This may require a +SIGINT signal handler or equivalent. We don't want to have the back end module +install its own signal handler, because that would pre-empt the surrounding +application's ability to control signal handling. The IJG distribution includes several memory manager back end implementations. Usually the same back end should be suitable for all applications on a given diff --git a/tjbench.c b/tjbench.c index 9db1968c..21b297c6 100644 --- a/tjbench.c +++ b/tjbench.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2016 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2017 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -40,13 +40,13 @@ #define _throw(op, err) { \ printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \ - retval=-1; goto bailout;} + retval=-1; goto bailout;} #define _throwunix(m) _throw(m, strerror(errno)) #define _throwtj(m) _throw(m, tjGetErrorStr()) #define _throwbmp(m) _throw(m, bmpgeterr()) int flags=TJFLAG_NOREALLOC, componly=0, decomponly=0, doyuv=0, quiet=0, - dotile=0, pf=TJPF_BGR, yuvpad=1, warmup=1, dowrite=1; + dotile=0, pf=TJPF_BGR, yuvpad=1, dowrite=1; char *ext="ppm"; const char *pixFormatStr[TJ_NUMPF]= { @@ -64,7 +64,7 @@ const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440", "411"}; tjscalingfactor *scalingfactors=NULL, sf={1, 1}; int nsf=0; int xformop=TJXOP_NONE, xformopt=0; int (*customFilter)(short *, tjregion, tjregion, int, int, tjtransform *); -double benchtime=5.0; +double benchtime=5.0, warmup=1.0; char *formatName(int subsamp, int cs, char *buf) @@ -146,7 +146,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf, } /* Benchmark */ - iter=-warmup; + iter=-1; elapsed=elapsedDecode=0.; while(1) { @@ -176,12 +176,17 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf, _throwtj("executing tjDecompress2()"); } } - iter++; - if(iter>=1) + elapsed+=gettime()-start; + if(iter>=0) { - elapsed+=gettime()-start; + iter++; if(elapsed>=benchtime) break; } + else if(elapsed>=warmup) + { + iter=0; + elapsed=elapsedDecode=0.; + } } if(doyuv) elapsed-=elapsedDecode; @@ -207,7 +212,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf, (double)(w*h)/1000000.*(double)iter/elapsed); if(doyuv) { - printf("YUV Decode --> Frame rate:  %f fps\n", + printf("YUV Decode --> Frame rate: %f fps\n", (double)iter/elapsedDecode); printf(" Throughput: %f Megapixels/sec\n", (double)(w*h)/1000000.*(double)iter/elapsedDecode); @@ -340,7 +345,7 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, } /* Benchmark */ - iter=-warmup; + iter=-1; elapsed=elapsedEncode=0.; while(1) { @@ -374,12 +379,17 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, totaljpegsize+=jpegsize[tile]; } } - iter++; - if(iter>=1) + elapsed+=gettime()-start; + if(iter>=0) { - elapsed+=gettime()-start; + iter++; if(elapsed>=benchtime) break; } + else if(elapsed>=warmup) + { + iter=0; + elapsed=elapsedEncode=0.; + } } if(doyuv) elapsed-=elapsedEncode; @@ -623,7 +633,7 @@ int decompTest(char *filename) } } - iter=-warmup; + iter=-1; elapsed=0.; while(1) { @@ -631,12 +641,17 @@ int decompTest(char *filename) if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntilesh, jpegbuf, jpegsize, t, flags)==-1) _throwtj("executing tjTransform()"); - iter++; - if(iter>=1) + elapsed+=gettime()-start; + if(iter>=0) { - elapsed+=gettime()-start; + iter++; if(elapsed>=benchtime) break; } + else if(elapsed>=warmup) + { + iter=0; + elapsed=0.; + } } free(t); t=NULL; @@ -668,7 +683,9 @@ int decompTest(char *filename) { if(quiet==1) printf("N/A N/A "); jpegsize[0]=srcsize; - memcpy(jpegbuf[0], srcbuf, srcsize); + free(jpegbuf[0]); + jpegbuf[0]=srcbuf; + srcbuf=NULL; } if(w==tilew) _tilew=_w; @@ -763,8 +780,9 @@ void usage(char *progname) printf("-grayscale = Perform lossless grayscale conversion prior to decompression\n"); printf(" test (can be combined with the other transforms above)\n"); printf("-benchtime = Run each benchmark for at least seconds (default = 5.0)\n"); - printf("-warmup = Execute each benchmark times to prime the cache before\n"); - printf(" taking performance measurements (default = 1)\n"); + printf("-warmup = Run each benchmark for seconds (default = 1.0) prior to\n"); + printf(" starting the timer, in order to prime the caches and thus improve the\n"); + printf(" consistency of the results.\n"); printf("-componly = Stop after running compression tests. Do not test decompression.\n"); printf("-nowrite = Do not write reference or output images (improves consistency of\n"); printf(" performance measurements.)\n\n"); @@ -878,13 +896,10 @@ int main(int argc, char *argv[]) } if(!strcasecmp(argv[i], "-warmup") && i=0) - { - warmup=temp; - printf("Warmup runs = %d\n\n", warmup); - } + double temp=atof(argv[++i]); + if(temp>=0.0) warmup=temp; else usage(argv[0]); + printf("Warmup time = %.1f seconds\n\n", warmup); } if(!strcmp(argv[i], "-?")) usage(argv[0]); if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC); diff --git a/transupp.c b/transupp.c index d1c56c60..b51ef392 100644 --- a/transupp.c +++ b/transupp.c @@ -4,7 +4,7 @@ * This file was part of the Independent JPEG Group's software: * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding. * libjpeg-turbo Modifications: - * Copyright (C) 2010, D. R. Commander. + * Copyright (C) 2010, 2017, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * @@ -1177,7 +1177,6 @@ transpose_critical_parameters (j_compress_ptr dstinfo) * We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible. */ -#if JPEG_LIB_VERSION >= 70 LOCAL(void) adjust_exif_parameters (JOCTET *data, unsigned int length, JDIMENSION new_width, JDIMENSION new_height) @@ -1327,7 +1326,6 @@ adjust_exif_parameters (JOCTET *data, unsigned int length, offset += 12; } while (--number_of_tags); } -#endif /* Adjust output image parameters as needed. @@ -1384,7 +1382,7 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo, /* Correct the destination's image dimensions as necessary * for rotate/flip, resize, and crop operations. */ -#if JPEG_LIB_VERSION >= 70 +#if JPEG_LIB_VERSION >= 80 dstinfo->jpeg_width = info->output_width; dstinfo->jpeg_height = info->output_height; #endif @@ -1395,14 +1393,14 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo, case JXFORM_TRANSVERSE: case JXFORM_ROT_90: case JXFORM_ROT_270: -#if JPEG_LIB_VERSION < 70 +#if JPEG_LIB_VERSION < 80 dstinfo->image_width = info->output_height; dstinfo->image_height = info->output_width; #endif transpose_critical_parameters(dstinfo); break; default: -#if JPEG_LIB_VERSION < 70 +#if JPEG_LIB_VERSION < 80 dstinfo->image_width = info->output_width; dstinfo->image_height = info->output_height; #endif @@ -1421,14 +1419,21 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo, GETJOCTET(srcinfo->marker_list->data[5]) == 0) { /* Suppress output of JFIF marker */ dstinfo->write_JFIF_header = FALSE; -#if JPEG_LIB_VERSION >= 70 /* Adjust Exif image parameters */ +#if JPEG_LIB_VERSION >= 80 if (dstinfo->jpeg_width != srcinfo->image_width || dstinfo->jpeg_height != srcinfo->image_height) /* Align data segment to start of TIFF structure for parsing */ adjust_exif_parameters(srcinfo->marker_list->data + 6, srcinfo->marker_list->data_length - 6, dstinfo->jpeg_width, dstinfo->jpeg_height); +#else + if (dstinfo->image_width != srcinfo->image_width || + dstinfo->image_height != srcinfo->image_height) + /* Align data segment to start of TIFF structure for parsing */ + adjust_exif_parameters(srcinfo->marker_list->data + 6, + srcinfo->marker_list->data_length - 6, + dstinfo->image_width, dstinfo->image_height); #endif } diff --git a/turbojpeg.c b/turbojpeg.c index 9434e325..5b23349b 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2016 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2017 D. R. Commander. All Rights Reserved. * mozjpeg Modifications: * Copyright (C) 2014, Mozilla Corporation. * @@ -780,13 +780,6 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf, || jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT || jpegQual<0 || jpegQual>100) _throw("tjCompress2(): Invalid argument"); - if(setjmp(this->jerr.setjmp_buffer)) - { - /* If we get here, the JPEG code has signaled an error. */ - retval=-1; - goto bailout; - } - if(pitch==0) pitch=width*tjPixelSize[pixelFormat]; #ifndef JCS_EXTENSIONS @@ -799,6 +792,16 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf, } #endif + if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL) + _throw("tjCompress2(): Memory allocation failure"); + + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } + cinfo->image_width=width; cinfo->image_height=height; @@ -815,8 +818,6 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf, return -1; jpeg_start_compress(cinfo, TRUE); - if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL) - _throw("tjCompress2(): Memory allocation failure"); for(i=0; ijerr.setjmp_buffer)) - { - /* If we get here, the JPEG code has signaled an error. */ - retval=-1; - goto bailout; - } - if(pixelFormat==TJPF_CMYK) _throw("tjEncodeYUVPlanes(): Cannot generate YUV images from CMYK pixels"); @@ -918,6 +912,13 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle, } #endif + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } + cinfo->image_width=width; cinfo->image_height=height; @@ -994,6 +995,13 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle, } } + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } + for(row=0; rowmax_v_samp_factor) { (*cinfo->cconvert->color_convert)(cinfo, &row_pointer[row], tmpbuf, 0, @@ -1168,6 +1176,13 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle, } } + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } + for(row=0; row<(int)cinfo->image_height; row+=cinfo->max_v_samp_factor*DCTSIZE) { @@ -1446,6 +1461,12 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW) *dinfo->output_height))==NULL) _throw("tjDecompress2(): Memory allocation failure"); + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } for(i=0; i<(int)dinfo->output_height; i++) { if(flags&TJFLAG_BOTTOMUP) @@ -1668,6 +1689,13 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle, } } + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } + for(row=0; rowmax_v_samp_factor) { JDIMENSION inrow=0, outrow=0; @@ -1848,6 +1876,13 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle, } } + if(setjmp(this->jerr.setjmp_buffer)) + { + /* If we get here, the JPEG code has signaled an error. */ + retval=-1; + goto bailout; + } + if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE; if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST; dinfo->raw_data_out=TRUE; @@ -2025,6 +2060,11 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle, else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1"); else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1"); + if((xinfo=(jpeg_transform_info *)malloc(sizeof(jpeg_transform_info)*n)) + ==NULL) + _throw("tjTransform(): Memory allocation failure"); + MEMZERO(xinfo, sizeof(jpeg_transform_info)*n); + if(setjmp(this->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ @@ -2034,11 +2074,6 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle, jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize); - if((xinfo=(jpeg_transform_info *)malloc(sizeof(jpeg_transform_info)*n)) - ==NULL) - _throw("tjTransform(): Memory allocation failure"); - MEMZERO(xinfo, sizeof(jpeg_transform_info)*n); - for(i=0; i*jpegSize should be set to the size of your * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC, @@ -713,7 +713,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf, * for you, or * -# pre-allocate the buffer to a "worst case" size determined by calling * #tjBufSize(). This should ensure that the buffer never has to be - * re-allocated (setting #TJFLAG_NOREALLOC guarantees this.) + * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.) * . * If you choose option 1, *jpegSize should be set to the size of your * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC, @@ -783,7 +783,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, * for you, or * -# pre-allocate the buffer to a "worst case" size determined by calling * #tjBufSize(). This should ensure that the buffer never has to be - * re-allocated (setting #TJFLAG_NOREALLOC guarantees this.) + * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.) * . * If you choose option 1, *jpegSize should be set to the size of your * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC, @@ -1392,9 +1392,13 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void); * -# set dstBufs[i] to NULL to tell TurboJPEG to allocate the buffer * for you, or * -# pre-allocate the buffer to a "worst case" size determined by calling - * #tjBufSize() with the transformed or cropped width and height. This should - * ensure that the buffer never has to be re-allocated (setting - * #TJFLAG_NOREALLOC guarantees this.) + * #tjBufSize() with the transformed or cropped width and height. Under normal + * circumstances, this should ensure that the buffer never has to be + * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.) Note, + * however, that there are some rare cases (such as transforming images with a + * large amount of embedded EXIF or ICC profile data) in which the output image + * will be larger than the worst-case size, and #TJFLAG_NOREALLOC cannot be + * used in those cases. * . * If you choose option 1, dstSizes[i] should be set to the size of * your pre-allocated buffer. In any case, unless you have set @@ -1435,8 +1439,8 @@ DLLEXPORT int DLLCALL tjDestroy(tjhandle handle); /** * Allocate an image buffer for use with TurboJPEG. You should always use - * this function to allocate the JPEG destination buffer(s) for #tjCompress2() - * and #tjTransform() unless you are disabling automatic buffer + * this function to allocate the JPEG destination buffer(s) for the compression + * and transform functions unless you are disabling automatic buffer * (re)allocation (by setting #TJFLAG_NOREALLOC.) * * @param bytes the number of bytes to allocate @@ -1452,8 +1456,8 @@ DLLEXPORT unsigned char* DLLCALL tjAlloc(int bytes); /** * Free an image buffer previously allocated by TurboJPEG. You should always * use this function to free JPEG destination buffer(s) that were automatically - * (re)allocated by #tjCompress2() or #tjTransform() or that were manually - * allocated using #tjAlloc(). + * (re)allocated by the compression and transform functions or that were + * manually allocated using #tjAlloc(). * * @param buffer address of the buffer to free * diff --git a/usage.txt b/usage.txt index 084873bf..0b31a13e 100644 --- a/usage.txt +++ b/usage.txt @@ -212,7 +212,7 @@ Switches for advanced users: large images. Value is in thousands of bytes, or millions of bytes if "M" is attached to the number. For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. + space is needed, an error will occur. -verbose Enable debug printout. More -v's give more printout. or -debug Also, version information is printed at startup. @@ -372,7 +372,7 @@ Switches for advanced users: large images. Value is in thousands of bytes, or millions of bytes if "M" is attached to the number. For example, -max 4m selects 4000000 bytes. If more - space is needed, temporary files will be used. + space is needed, an error will occur. -verbose Enable debug printout. More -v's give more printout. or -debug Also, version information is printed at startup. @@ -418,11 +418,6 @@ When producing a color-quantized image, "-onepass -dither ordered" is fast but much lower quality than the default behavior. "-dither none" may give acceptable results in two-pass mode, but is seldom tolerable in one-pass mode. -Two-pass color quantization requires a good deal of memory; on MS-DOS machines -it may run out of memory even with -maxmemory 0. In that case you can still -decompress, with some loss of image quality, by specifying -onepass for -one-pass quantization. - To avoid the Unisys LZW patent (now expired), djpeg produces uncompressed GIF files. These are larger than they should be, but are readable by standard GIF decoders. @@ -430,24 +425,9 @@ decoders. HINTS FOR BOTH PROGRAMS -If more space is needed than will fit in the available main memory (as -determined by -maxmemory), temporary files will be used. (MS-DOS versions -will try to get extended or expanded memory first.) The temporary files are -often rather large: in typical cases they occupy three bytes per pixel, for -example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough -free disk space, leave out -progressive and -optimize (for cjpeg) or specify --onepass (for djpeg). - -On MS-DOS, the temporary files are created in the directory named by the TMP -or TEMP environment variable, or in the current directory if neither of those -exist. Amiga implementations put the temp files in the directory named by -JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free -space. - -The default memory usage limit (-maxmemory) is set when the software is -compiled. If you get an "insufficient memory" error, try specifying a smaller --maxmemory value, even -maxmemory 0 to use the absolute minimum space. You -may want to recompile with a smaller default value if this happens often. +If the memory needed by cjpeg or djpeg exceeds the limit specified by +-maxmemory, an error will occur. You can leave out -progressive and -optimize +(for cjpeg) or specify -onepass (for djpeg) to reduce memory usage. On machines that have "environment" variables, you can define the environment variable JPEGMEM to set the default memory limit. The value is specified as @@ -455,11 +435,6 @@ described for the -maxmemory switch. JPEGMEM overrides the default value specified when the program was compiled, and itself is overridden by an explicit -maxmemory switch. -On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to -use. (Extended or expanded memory is also used if available.) Most -DOS-specific versions of this software do their own memory space estimation -and do not need you to specify -maxmemory. - JPEGTRAN diff --git a/win/jpeg7-memsrcdst.def b/win/jpeg7-memsrcdst.def index 7b424a7f..a5af9b9d 100644 --- a/win/jpeg7-memsrcdst.def +++ b/win/jpeg7-memsrcdst.def @@ -104,6 +104,8 @@ EXPORTS jzero_far @ 103 ; jpeg_mem_dest @ 104 ; jpeg_mem_src @ 105 ; + jpeg_skip_scanlines @ 106 ; + jpeg_crop_scanline @ 107 ; jpeg_c_bool_param_supported @ 200 ; jpeg_c_set_bool_param @ 201 ; jpeg_c_get_bool_param @ 202 ;
bufferaddress of the buffer to free
dstBufspointer to an array of n image buffers. dstBufs[i] will receive a JPEG image that has been transformed using the parameters in transforms[i]. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
  1. pre-allocate the JPEG buffer with an arbitrary size using tjAlloc() and let TurboJPEG grow the buffer as needed,
  2. set dstBufs[i] to NULL to tell TurboJPEG to allocate the buffer for you, or
  3. -
  4. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize() with the transformed or cropped width and height. This should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees this.)
  5. +
  6. pre-allocate the buffer to a "worst case" size determined by calling tjBufSize() with the transformed or cropped width and height. Under normal circumstances, this should ensure that the buffer never has to be re-allocated (setting TJFLAG_NOREALLOC guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded EXIF or ICC profile data) in which the output image will be larger than the worst-case size, and TJFLAG_NOREALLOC cannot be used in those cases.
If you choose option 1, dstSizes[i] should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check dstBufs[i] upon return from this function, as it may have changed.
dstSizespointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If dstBufs[i] points to a pre-allocated buffer, then dstSizes[i] should be set to the size of the buffer. Upon return, dstSizes[i] will contain the size of the JPEG image (in bytes.)