The instructions for libjpeg-turbo here describes the TurboJPEG API thus: "This API wraps libjpeg-turbo and provides an easy-to-use interface for compressing and decompressing JPEG images in memory". Great, but are there some solid examples of using this API available? Just looking to decompress a fairly vanilla jpeg in memory.
From version 6b of libjpeg of 27 March 1998, Miyasaka Masaru forked a branch named libjpeg/SIMD, which included x86 SIMD optimisations. It got substantial contributions from the TigerVNC and the VirtualGL projects in 2009. On that basis the libjpeg-turbo project was created in 2010.[9]
On 4 March 2014, the first version of the filesize-optimising fork mozjpeg was published. For this version Josh Aas from Mozilla Research reworked the Perl script jpegcrush from x264's main developer Loren Merritt and integrated it into the code base of libjpeg-turbo.[10]
libjpeg-turbo is a fork of libjpeg that uses SIMD instructions to accelerate baseline JPEG encoding and decoding. Many projects are now using libjpeg-turbo instead of libjpeg, including popular Linux distributions (Fedora, Debian, Mageia, openSUSE, ...), Mozilla, and Chrome.[25][26][27] Apart from performance, some projects have chosen to use libjpeg-turbo because it allows them to retain backward ABI compatibility with the older libjpeg v6b release.[28] libjpeg v7, v8 and v9 broke ABI compatibility with prior releases.[14]
libjpeg-turbo implements the standard-compliant arithmetic coding and lossless crop features seen in libjpeg v7. It can also be configured to be compatible with the libjpeg v7 or v8 ABI, but it does implement DCT scaling and the proprietary SmartScale, which builds on DCT scaling.[29] libjpeg-turbo chooses not to support SmartScale, because it is not an ITU-T standard and because their own research finds it (and DCT scaling) ineffective.[20] By extension, since the only major new feature in libjpeg v9 is specific to the SmartScale format, the libjpeg-turbo Project has chosen to forgo emulating libjpeg v9.[17]
Since 2019, libjpeg-turbo is one of the two JPEG reference implementations, available as ISO/IEC 10918-7 and ITU-T T.873.[13] The other reference implementation is ISO libjpeg which also includes support for JPEG XT and JPEG LS.
mozjpeg is a fork from libjpeg-turbo done by Josh Aas and others from Mozilla Research. It aims to speed up loading times of webpages by achieving a reduction in file size (of about 10%) and therefore transmission time through improvement of coding efficiency while retaining image quality. To achieve this, it uses more processing power for the encoding (asymmetry) while retaining full compatibility with the JPEG standard and requiring no changes on the decoder side.
:: Do you want to skip the above package for this upgrade? [y/N]
error: failed to prepare transaction (could not satisfy dependencies)
:: unable to satisfy dependency 'libjpeg-turbo=2.1.5.1' required by lib32-libjpeg-turbo
:: unable to satisfy dependency 'libjpeg-turbo=2.1.5.1' required by lib32-libjpeg-turbo
:: unable to satisfy dependency 'libjpeg-turbo=2.1.5.1' required by lib32-libjpeg-
The problem is that both the libjpeg-turbo and the jpeg port in MacPorts provide libjpeg.dylib and corresponding headers (consequently, they conflict with each other and cannot be installed simultaneously), but the jpeg port ships libjpeg.9.dylib, which is ABI-incompatible with libjpeg-turbo's libjpeg.8.dylib.
This sanity checks determines that your tiff port is broken, because one of its binaries or libraries links against libjpeg.9.dylib -- this file doesn't exist because it is provided by the jpeg port, but you only have libjpeg-turbo installed. The rebuild then attempts to install the jpeg port as a dependency of tiff and fails because of the conflict.
I am using OpenCV 2.3.1 on OS X Lion in one of my C++ projects. While my project works great as-is, it depends heavily on JPEG decoding and encoding. I would like to gain a speedup by using libjpeg-turbo, but I cannot find the correct way to link with libjpeg-turbo. Depending on my hackery attempts and which files I edit, I either end up with compiling errors or with a useless OpenCV library (everything compiles correctly, but I cannot open or write JPEG files, though no errors appear in the C++ project).
So it turns out that the best solution (at least, the one that doesn't require any custom builds of libs or extra passes through the buffer) is to use libjpeg-turbo. As of 1.1.90 they provide a colorspace constant JCS_EXT_RGBX that adds a fake alpha channel. To my knowledge this is only documented in the release notes of a beta version on SourceForge so barring that this URL changes or no longer exists (read: the internet revolts against sf for its shady insertion of code into "inactive" popular repos and they are forced to shut down), here is the relevant bit reproduced:
When decompressing a JPEG image using an output colorspace of JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR, or JCS_EXT_XRGB, libjpeg-turbo will now set the unused byte to 0xFF, which allows applications to interpret that byte as an alpha channel (0xFF = opaque).
The PPM reader in libjpeg-turbo through 2.0.90 mishandles use of tjLoadImage for loading a 16-bit binary PPM file into a grayscale buffer and loading a 16-bit binary PGM file into an RGB buffer. This is related to a heap-based buffer overflow in the get_word_rgb_row function in rdppm.c. (CVE-2021-46822)
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 API/ABI-compatible with libjpeg v8. See README.md for more information about libjpeg v7 and v8 emulation.
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 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 for more information.
Since the patent on arithmetic coding has expired, this functionality has been 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 disable encoding or decoding (respectively.)
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 CMAKE_JAVA_COMPILE_FLAGS CMake variable or the JAVAFLAGS environment variable to specify arguments that should be passed to the Java compiler when building the TurboJPEG classes, and the JAVAARGS CMake variable to specify arguments that should be passed to the JRE when running the TurboJPEG Java unit tests.
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.
from the build directory after initially configuring the build. CCMake is a text-based interactive version of CMake, and CMake-GUI is a GUI version. Both will display all variables that are relevant to the libjpeg-turbo build, their current values, and a help string describing what they do.
The default value of CMAKE_INSTALL_PREFIX causes the libjpeg-turbo files to be installed with a directory structure resembling that of the official libjpeg-turbo binary packages. Changing the value of CMAKE_INSTALL_PREFIX (for instance, to /usr/local) causes the libjpeg-turbo files to be installed with a directory structure that conforms to GNU standards.
The CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATAROOTDIR, CMAKE_INSTALL_DOCDIR, CMAKE_INSTALL_INCLUDEDIR, CMAKE_INSTALL_JAVADIR, CMAKE_INSTALL_LIBDIR, and CMAKE_INSTALL_MANDIR CMake variables allow a finer degree of control over where specific files in the libjpeg-turbo distribution should be installed. These directory variables can either be specified as absolute paths or as paths relative to CMAKE_INSTALL_PREFIX (for instance, setting CMAKE_INSTALL_DOCDIR to doc would cause the documentation to be installed in $CMAKE_INSTALL_PREFIX/doc.) If a directory variable contains the name of another directory variable in angle brackets, then its final value will depend on the final value of that other variable. For instance, the default value of CMAKE_INSTALL_MANDIR is /man.
Installing the libjpeg-turbo native library is a precondition to have the relative GeoServer Map Encoder properly installed; once the GeoServer extension has been installed as we explain in the following section, the needed JARs with the Java bridge to the library are in the classpath, therefore all we need to do is to install the native library itself to start encoding JPEG at turbo speed.
The libjpeg-turbo packages contain a library of functions for manipulating JPEG images. They also contain simple client programs for accessing the libjpeg functions. These packages provide the same functionality and API as libjpeg but with better performance.
libjpeg-turbo is a JPEG image codec that uses SIMD instructions to accelerate baseline JPEG compression and decompression on x86, x86-64, Arm, PowerPC, and MIPS systems, as well as progressive JPEG compression on x86, x86-64, and Arm systems. On such systems, libjpeg-turbo is generally 2-6x as fast as libjpeg, all else being equal. On other types of systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by virtue of its highly-optimized Huffman coding routines. In many cases, the performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs.
df19127ead