Commit Graph

3972 Commits

Author SHA1 Message Date
Kornel Lesiński
8fb32c0a39 Work around fussy zlib on macOS v4.0.1-rc 2020-08-15 19:36:42 +01:00
Kornel Lesiński
b3e739028a Merge libjpeg-turbo 2.0.5
* tag '2.0.5':
  TurboJPEG: Make global error handling thread-safe
  ChangeLog.md: Add missing sub-header for 2.0.5
  ChangeLog.md: List CVE ID fixed by previous commit
  rdppm.c: Fix buf overrun caused by bad binary PPM
  Build: Add missing jpegtran-icc test dependency
  rdswitch.c: Eliminate spaces before semicolons
  TJCompressor.compress(int): Fix YUV-to-JPEG error
  Bump version to 2.0.5; Document previous commit
  MIPS DSPr2: Work around various 'make test' errors
  MIPS DSPr2: Fix compiler warning with -mdspr2
  MIPS SIMD: Always honor JSIMD_FORCE* env vars
  Test: Honor CMAKE_CROSSCOMPILING_EMULATOR variable
2020-08-15 19:36:31 +01:00
DRC
ae87a95861 TurboJPEG: Make global error handling thread-safe
... on platforms that support thread-local storage.  This currently
includes all supported platforms except 32-bit macOS.

Fixes #396
2020-06-18 23:40:20 -05:00
DRC
b443c541b9 ChangeLog.md: Add missing sub-header for 2.0.5 2020-06-03 16:08:08 -05:00
DRC
cf483eee49 ChangeLog.md: List CVE ID fixed by previous commit 2020-06-03 16:04:06 -05:00
DRC
3de15e0c34 rdppm.c: Fix buf overrun caused by bad binary PPM
This extends the fix in 1e81b0c3ea to
include binary PPM files with maximum values < 255, thus preventing a
malformed binary PPM input file with those specifications from
triggering an overrun of the rescale array and potentially crashing
cjpeg, TJBench, or any program that uses the tjLoadImage() function.

Fixes #433
2020-06-02 14:51:17 -05:00
Andrew Childs
a2291b252d Build: Add missing jpegtran-icc test dependency
The jpegtran-icc test must run after the cjpeg-rgb-islow test, since
the latter generates testout_rgb_islow.jpg.
2020-05-05 00:38:39 -05:00
DRC
a36deef563 rdswitch.c: Eliminate spaces before semicolons
(detected with a modified version of checkstyle)
2020-04-02 22:25:44 -05:00
Chan, Danny
6d95c51adf Fix markdown format 2020-03-11 14:31:37 +00:00
NancyLi1013
5ea5482872 Add vcpkg installation instructions (#353)
* Add vcpkg installation instructions
2020-02-26 10:51:25 +00:00
DRC
8cc1277b69 TJCompressor.compress(int): Fix YUV-to-JPEG error
Due to an oversight, the TJCompressor.compress(int) method did not
handle YUV source images.

Fixes #413
2020-02-24 13:35:30 -06:00
DRC
ecf5f9a96a Bump version to 2.0.5; Document previous commit 2020-02-18 10:43:48 -06:00
DRC
035262a18d MIPS DSPr2: Work around various 'make test' errors
Referring to #408, this commit #ifdefs DSPr2 SIMD functions that only
work on little endian processors, and it completely excludes
jsimd_h2v1_downsample_dspr2() and jsimd_h2v2_downsample_dspr2().  The
latter two functions fail with the TJBench tiling regression tests, most
likely because the implementation of the functions predates those tests.
2020-02-17 18:13:31 -06:00
DRC
ed7cab47d9 MIPS DSPr2: Fix compiler warning with -mdspr2
If -mdspr2 is passed to the compiler, __mips_dsp will be defined, and
__mips_dsp_rev will be >= 2, so parse_proc_cpuinfo() will not be used.
2020-02-17 16:35:00 -06:00
DRC
42d679b9fc MIPS SIMD: Always honor JSIMD_FORCE* env vars
Previously, these environment variables were not honored unless a 74K
CPU was detected, but this detection doesn't work properly with QEMU's
user mode emulation.  With all other CPU types, libjpeg-turbo honors
JSIMD_FORCE* regardless of CPU detection.
2020-02-17 15:19:32 -06:00
DRC
044c22e12f Test: Honor CMAKE_CROSSCOMPILING_EMULATOR variable
This CMake variable is intended to define a wrapper program for
executing cross-compiled executables.  However, CTest doesn't use
CMAKE_CROSSCOMPILING_EMULATOR, because it isn't obvious which tests
should be executed with the wrapper and which tests are scripts that
don't need it.  This commit manually prepends
${CMAKE_CROSSCOMPILING_EMULATOR} to all unit test command lines that
execute a program built by the libjpeg-turbo build system.  Thus, one
can set CMAKE_CROSSCOMPILING_EMULATOR in a CMake toolchain file to (for
instance) "qemu-{architecture} {qemu_arguments}") in order to execute
all eligible unit tests using QEMU.
2020-02-17 14:41:43 -06:00
Kornel Lesiński
1d2320994d Merge remote-tracking branch 'turbo/master'
* turbo/master: (105 commits)
  makemacpkg.in: Allow universal DMG w/o ARMv8 arch
  Remove more unnecessary NULL checks before free()
  Eliminate unnecessary NULL checks before tjFree()
  Eliminate unnecessary NULL checks before free()
  simd/arm64/jsimd_neon.S: Fix checkstyle issue
  tjTransform(): Use instance err. for bad crop spec
  README.md, package specs: Various tweaks
  djpeg.c: Fix compiler warning w/o mem. src manager
  ARMv8 SIMD: Support execute-only memory (XOM)
  Travis: Use MacPorts instead of Homebrew
  Huffman enc.: Fix very rare local buffer overrun
  TurboJPEG: Fix erroneous subsampling detection
  ChangeLog.md: List CVE IDs for specific fixes
  tjDecompressToYUV*(): Fix OOB write/double free
  64-bit tjbench: Fix signed int overflow/segfault
  Fix copyright header formatting buglets
  example.txt: Avoid undefined setjmp() behavior
  Mac: Support hiding SIMD fct symbols w/ NASM 2.14+
  TJBench: Fix output with -componly -quiet
  Build: Don't require ASM_NASM if !REQUIRE_SIMD
  ...
2020-02-13 10:45:55 +00:00
DRC
70327296e2 makemacpkg.in: Allow universal DMG w/o ARMv8 arch
(buglet)
2020-02-07 17:04:30 -06:00
DRC
f81833aed6 Remove more unnecessary NULL checks before free() 2020-01-08 15:01:38 -06:00
DRC
00607ec260 Eliminate unnecessary NULL checks before tjFree()
+ document that tjFree() accepts NULL pointers without complaint.
Effectively, it has had that behavior all along, but the API does not
guarantee that tjFree() will be implemented with free() behind the
scenes, so it's best to formalize the behavior.
2020-01-08 14:24:37 -06:00
DRC
fdf8903354 Eliminate unnecessary NULL checks before free()
This programming practice (which exists in other code bases as well)
is a by-product of having used early C compilers that did not properly
handle free(NULL).  All modern compilers should properly handle that.

Fixes #398
2020-01-07 16:15:23 -06:00
DRC
166e34213e simd/arm64/jsimd_neon.S: Fix checkstyle issue 2019-12-31 01:10:30 -06:00
DRC
6367924ac6 tjTransform(): Use instance err. for bad crop spec
Addresses a concern raised in #396
2019-12-31 00:35:08 -06:00
DRC
29f718ee63 README.md, package specs: Various tweaks
- Don't enumerate the types of SIMD instructions that libjpeg-turbo
  supports, as this can change without notice.
- Use more clear terminology when describing support for libjpeg v7/v8
  features ("libjpeg" is, colloquially but not officially, the name for
  the IJG's software, whereas the "libjpeg API" refers to our emulation
  of said software.)
- "PhotoShop" = "Photoshop" (StudLy Caps Police)
- Adjust dynamic library versions to reflect the addition of
  jpeg_read_icc_profile() and jpeg_write_icc_profile() in
  libjpeg-turbo 2.0.x.
2019-12-31 00:27:04 -06:00
DRC
fe50cd9978 djpeg.c: Fix compiler warning w/o mem. src manager
insize is only used when the in-memory source manager is compiled in.
2019-12-31 00:05:05 -06:00
DRC
b542e4c8e9 ARMv8 SIMD: Support execute-only memory (XOM)
Move constants out of the .text section in simd/arm64/jsimd_neon.S and
into a .rodata section.  This ensures that the ARMv8 NEON SIMD
extensions are compatible with memory layouts that are marked
execute-only (and thus unreadable.)

Based on:
88f3ca7664

Closes #318
2019-12-20 14:24:10 -06:00
DRC
52291467e1 Travis: Use MacPorts instead of Homebrew
Homebrew tends to drop support for a macOS release the second that Apple
stops releasing security updates for it, and that makes HB difficult to
use with some of the Travis macOS images.  Furthermore, even on
supported macOS releases, HB sometimes tries to build GCC from source
even if a binary (bottle) is available.  Long story short, MacPorts just
generally has better backward compatibility.  MacPorts is also what I
personally use on the official libjpeg-turbo build machine.
2019-12-05 22:28:18 -06:00
DRC
c76f4a0826 Huffman enc.: Fix very rare local buffer overrun
... detected by ASan.  This is a similar issue to the issue that was
fixed with 402a715f82.  Apparently it is
possible to create a malformed JPEG image that exceeds the Huffman
encoder's 256-byte local buffer when attempting to losslessly tranform
the image.  That makes sense, given that it was necessary to extend the
Huffman decoder's local buffer to 512 bytes in order to handle all
pathological cases (refer to 0463f7c9aad060fcd56e98d025ce16185279e2bc.)

Since this issue affected only lossless transformation, a workflow that
isn't generally exposed to arbitrary data exploits, and since the
overrun did not overflow the stack (i.e. it did not result in a segfault
or other user-visible issue, and valgrind didn't even detect it), it did
not likely pose a security risk.

Fixes #392
2019-12-05 14:47:05 -06:00
DRC
c0b16e3d2b TurboJPEG: Fix erroneous subsampling detection
... that caused some JPEG images with unusual sampling factors to be
misidentified as 4:4:4.  This led to a buffer overflow when attempting
to decompress some such images using tjDecompressToYUV*().

Regression introduced by 479501b07c

The correct behavior is for the TurboJPEG API to refuse to decompress
such images, which it did prior to the aforementioned commit.

Fixes #389
2019-11-15 13:48:50 -06:00
DRC
6cedf37c83 ChangeLog.md: List CVE IDs for specific fixes 2019-11-15 12:46:49 -06:00
DRC
bd20344b0a tjDecompressToYUV*(): Fix OOB write/double free
... when attempting to decompress grayscale JPEG images with sampling
factors != 1.

Fixes #387
2019-11-12 16:35:57 -06:00
DRC
c30b1e72da 64-bit tjbench: Fix signed int overflow/segfault
... that occurred when attempting to decompress images with more than
715827882 (2048*1024*1024 / 3) pixels.

Fixes #388
2019-11-12 12:51:35 -06:00
DRC
622c462e48 Fix copyright header formatting buglets 2019-11-06 17:24:34 -06:00
DRC
410c028f33 example.txt: Avoid undefined setjmp() behavior
Modifying a locally-defined non-volatile variable below the setjmp()
return point results in undefined behavior whereby the variable may not
have the expected value after setjmp() returns.

Fixes #379
2019-11-06 16:16:54 -06:00
DRC
cf54623b08 Mac: Support hiding SIMD fct symbols w/ NASM 2.14+
(NASM 2.14+ now supports the private_extern section directive, which was
previously only available with YASM.)
2019-11-05 15:41:59 -06:00
DRC
ac59b2c582 TJBench: Fix output with -componly -quiet 2019-11-04 18:49:46 -06:00
DRC
6902cdb177 Build: Don't require ASM_NASM if !REQUIRE_SIMD
The build system is supposed to fall back to a non-SIMD build if
WITH_SIMD==1 but REQUIRE_SIMD==0.

Based on:
972df912d0

Closes #384
2019-10-29 12:08:40 -05:00
DRC
55de97207d AppVeyor: Use MinGW-builds instead of MSYS2 MinGW
... to avoid backward compatibility issues with GCC 4-6 MinGW
toolchains.  Apparently GCC 7+ MinGW toolchains introduce a link-time
dependency with internal MinGW CRT functions that are meant to provide
compatibility with Microsoft's Universal CRT (ucrt) library, but those
internal functions are not available in GCC 4-6 MinGW toolchains.  This
made it impossible to use the official builds of libjpeg.a and
libturbojpeg.a with GCC 4-6 MinGW toolchains (a fatal link error--
"undefined reference to '__imp___acrt_iob_func'"-- occurred.)

This problem was not immediately apparent after switching to the MSYS2
implementation of MinGW (d6d7b53968)
because, for a while, MSYS2 was still using GCC 5 and 6.

Refer to libjpeg-turbo/libjpeg-turbo#382
2019-10-24 02:04:04 -05:00
DRC
708f013f89 Win packaging: Fix 64-bit VC/GCC co-install issue 2019-10-23 00:31:30 -05:00
DRC
163f0b1965 Bump version to 2.0.4 to prepare for new commits 2019-10-22 19:39:38 -05:00
DRC
3a32d199df x86 SIMD: Consistify capitalization of NASM types
byte, word, dword, qword, oword, and yword are all assembler keywords,
so it makes sense to use lowercase for these so as not to mistake them
for macros or constants.
2019-10-17 20:02:20 -05:00
DRC
9a51a87af3 x86 SIMD: Remove obsolete [TAB8] comments
With apologies to Richard Hendricks, our assembly code no longer uses
tabs.
2019-10-17 14:11:35 -05:00
DRC
74aeaddf8e jc*huff.c: Consistify preproc directive formatting
The rest of the libjpeg API code uses "#if defined(condition)" rather
than "#if defined condition".
2019-10-17 14:09:50 -05:00
DRC
ab6c4a5db1 Travis: Fix macOS build
Java 6 has moved to homebrew/cask-versions.
2019-10-04 15:02:18 -05:00
DRC
ec4cacc16e BUILDING.md: Document need for CRB/PowerTools repo
NASM and YASM are located in this non-default repository on
(respectively) RHEL and CentOS.
2019-10-02 16:42:03 -05:00
DRC
5db6a6819d README.md: Document memory debugger pitfalls
(more specifically, the need to disable libjpeg-turbo's SIMD extensions
when testing with valgrind, MSan, etc.)

Addresses a concern expressed in #365
2.0.3
2019-08-30 12:02:50 -05:00
DRC
f448279b14 README.md: Remove vestigial autotools references 2019-08-30 11:24:36 -05:00
DRC
ded5a504b4 tjDecodeYUV*: Fix err if TJ inst used for prog dec
If the TurboJPEG instance passed to tjDecodeYUV[Planes]() was previously
used to decompress a progressive JPEG image, then we need to disable the
progressive decompression parameters in the underlying libjpeg instance
before calling jinit_master_decompress().

This commit also modifies the build system so that the "tjtest" target
will test for this issue, and it corrects a previous oversight in the
build system whereby tjbenchtest did not test progressive
compression/decompression unless WITH_JAVA was true.
2019-08-15 13:57:36 -05:00
DRC
c0d0fe86d8 ChangeLog.md: Wordsmithing 2019-08-14 22:08:44 -05:00
DRC
a81a8c137b SSE2 SIMD: Fix prog Huffman enc. error if Sl%16==0
(regression introduced by 5b177b3cab)

The SSE2 implementation of progressive Huffman encoding performed
extraneous iterations when the scan length was a multiple of 16.

Based on:
bb7f1ef983

Fixes #335
Closes #367
2019-08-14 22:01:30 -05:00