Commit Graph

2749 Commits

Author SHA1 Message Date
DRC
e0dcefd565 Arm/x86: Allow JSIMD_NOHUFFENC to disable prog.
Due to an oversight when the progressive Huffman encoding SIMD modules
were developed, JSIMD_NOHUFFENC was not extended to those modules.
2025-09-25 18:13:10 -04:00
DRC
0c7698a079 jfdctint-neon.c: Minor comment formatting tweaks 2025-09-25 17:24:58 -04:00
DRC
c2f81b6d79 AltiVec: Fix -Wshadow warnings 2025-09-25 17:24:58 -04:00
DRC
7fbdfd60f0 MMI: Fix some strict compiler warnings 2025-09-25 17:24:54 -04:00
DRC
f74989d8c7 Clean up #include directives
This is subtle, but #include <header.h> searches directories specified
with -I, then system include directories.  #include "header.h" searches
the current source directory, then directories specified with -I, then
system include directories.

Using bracketed #include directives for jpeglib.h, jinclude.h, jerror.h,
cdjpeg.h, and turbojpeg.h only worked because the build system
explicitly passed -I{source_directory}/src/ to the compiler.  Referring
to 51cee03629, it's better for the source
code to have as few dependencies on our specific build system as
possible.

Since jpeglib.h, jinclude.h, jerror.h, and turbojpeg.h can be installed
in system include directories, it's also better for internal references
to those headers to resolve internally first, to avoid potential
conflicts between the system-installed version of libjpeg-turbo and the
version being built.  (Such conflicts would never have occurred with our
build system, but they might have occurred due to misintegration with a
downstream build system.)
2025-09-25 12:24:31 -04:00
DRC
bf2c1efbb2 Build: Use correct compress12_lossless fuzzer src
(oops)
2025-09-25 11:14:56 -04:00
DRC
c53932d12d Win: Don't use GCC/Clang visibility attribute
Symbols are hidden by default on Windows, so
__attribute__((visibility("hidden"))) produced a warning ("visibility
attribute not supported in this configuration; ignored") with certain
versions of MinGW if libjpeg-turbo was built without SIMD extensions.
2025-09-23 08:40:41 -04:00
DRC
8af737edbe ChangeLog.md: List CVE ID for 2a9e3bd7 and c30b1e7 2025-09-23 08:26:20 -04:00
DRC
5e27ca23e7 x86: Reformat NASM code to improve readability
(and simplify the checkstyle script)
2025-09-22 23:54:14 -04:00
DRC
42d2a243b7 Build: Fix Loongson MMI detection with -Werror
If compiler warnings are treated as errors, then the apostrophe in
"Loongson MMI can't work with MIPS Release 6+" triggers a compiler
warning that causes the HAVE_MMI test to fail.  Surrounding the error
message with quotes fixes the issue.
2025-09-10 13:13:02 -04:00
DRC
4e151a4ad9 Remove vestigial filenames from SIMD code headers
These were a relic of libjpeg/SIMD, which attempted to follow the
conventions of the libjpeg source code, but they are no longer relevant
(or even accurate in some cases.)
3.1.2
2025-08-26 21:11:07 -04:00
DRC
98c458381f Fix issues with Windows Arm64EC builds
Arm64EC basically wraps native Arm64 functions with an emulated
Windows/x64 ABI, which can improve performance for Windows/x64
applications running under the x64 emulator on Windows/Arm.  When
building for Arm64EC, the compiler defines _M_X64 and _M_ARM64EC but not
_M_ARM64.
2025-08-21 13:03:56 -04:00
DRC
f2d1f1cbd4 Build, LICENSE.md: Update copyright year 2025-08-08 12:12:40 -04:00
DRC
f158143ec0 jpeg_skip_scanlines: Fix UAF w/merged upsamp/quant
jpeg_skip_scanlines() (more specifically, read_and_discard_scanlines())
should check whether merged upsampling is disabled before attempting
to dereference cinfo->cconvert, and it should check whether color
quantization is enabled before attempting to dereference
cinfo->cquantize.  Otherwise, executing one of the following sequences
with the same libjpeg API instance and any 4:2:0 or 4:2:2 JPEG image
will cause a use-after-free issue:

- Disable merged upsampling (default)
- jpeg_start_decompress()
- jpeg_finish_decompress()
  (frees but doesn't zero cinfo->cconvert)
- Enable merged upsampling
- jpeg_start_decompress()
  (doesn't re-allocate cinfo->cconvert, because
  j*init_color_deconverter() isn't called)
- jpeg_skip_scanlines()

- Enable 1-pass color quantization
- jpeg_start_decompress()
- jpeg_finish_decompress()
  (frees but doesn't zero cinfo->cquantize)
- Disable 1-pass color quantization
- jpeg_start_decompress()
  (doesn't re-allocate cinfo->cquantize, because j*init_*_quantizer()
  isn't called)
- jpeg_skip_scanlines()

These sequences are very unlikely to occur in a real-world application.
In practice, this issue does not even cause a segfault or other
user-visible errant behavior, so it is only detectable with ASan.  That
is because the memory region is small enough that it doesn't get
reclaimed by either the application or the O/S between the point at
which it is freed and the point at which it is used (even though a
subsequent malloc() call requests exactly the same amount of memory.)
Thus, this is an undefined behavior issue, but it is unlikely to be
exploitable.
2025-07-28 21:32:11 -04:00
DRC
81feffa632 Build: Add dire warning to WITH_TESTS description
(basically a CYA disclaimer that, if you don't build and run the
regression tests, then we assume no responsibility for any incorrect
JPEGage or other hilarity that may ensue.)
2025-06-14 10:26:37 -04:00
DRC
942ac87e47 Build: Allow disabling tests/command-line tools
This is useful for downstream projects that include libjpeg-turbo via
ExternalProject_Add().

Closes #818
2025-06-14 07:51:06 -04:00
DRC
91b3d4be42 CMakeLists.txt: Formatting tweak 2025-06-14 07:19:17 -04:00
DRC
51cee03629 Build: Use wrappers rather than CMake object libs
Some downstream projects need to adapt the libjpeg-turbo source code to
non-CMake build systems, and the use of CMake object libraries made that
difficult.  Referring to #754, the use of CMake object libraries also
caused the libjpeg-turbo libraries to contain duplicate object names,
which caused problems with certain development tools.  This commit
modifies the build system so that it uses wrappers, rather than CMake
object libraries, to compile source files for multiple data precisions.
For convenience, the wrappers are included in the source tree, but they
can be re-generated by building the "wrappers" target.

In addition to facilitating downstream integration, using wrappers
improves code readability, since multiple data precisions are now
handled at the source code level instead of at the build system level.

Since this will be pushed to a bug-fix release, the goal was to avoid
changing any existing source code.  A future major release of
libjpeg-turbo may restructure the libjpeg API source code so that only
the functions that need to be compiled for multiple data precisions are
wrapped.  (That is how the TurboJPEG API source code is structured.)

Closes #817
2025-06-13 17:27:57 -04:00
DRC
c889b1da56 TJBench: Require additional argument with -copy
(oversight from e4c67aff50)
2025-06-12 10:08:21 -04:00
DRC
d95f62f0df CI/Win: Deploy build log with pre-release packages 2025-06-11 16:04:09 -04:00
DRC
7723f50f3f Build: Don't modify CMAKE_C_FLAGS_* if specified
The build system originally force-enabled the maximum optimization level
(-O3) with GCC because it significantly improved the performance of the
C Huffman encoder on x86 platforms.  Since libjpeg-turbo 1.5.x, the
Huffman encoder has been SIMD-accelerated on x86 and Arm platforms, and
in my testing on various Intel CPUs, the difference between -O2 and -O3
is no longer statistically significant.  However, on certain Arm CPUs, I
observe that grayscale decompression slows down by 16-27% with -O2 vs.
-O3.  Although modern versions of CMake use -O3 as the default
optimization level for Release builds, -O2 is still the default
optimization level for RelWithDebInfo builds.  Thus, I am reluctant to
change the default behavior of our build system.  However, referring
to #815, some users observe better performance with -O2 vs. -O3 on other
Arm CPUs, so the build system needs to allow users to override the
default behavior.

Closes #815
3.1.1
2025-06-06 14:50:51 -04:00
DRC
d163c99bf0 CI/Win: Fix release signing
GitHub Actions automatically creates a zip file from artifacts, so we
don't need to create it ourselves.
2025-05-19 11:14:47 -04:00
DRC
085e0a7be9 CI/Win: Don't deploy tag builds to AWS
AWS is used for pre-releases, and tag builds are used for final
releases.
2025-05-19 10:35:02 -04:00
DRC
63a2fd8736 CI/Win: Fix caching of installers
The cache action needs to run before the build setup.
2025-05-18 10:58:19 -04:00
DRC
024e10f3c9 CI: Trigger Windows build when a tag is pushed
AppVeyor ran our CI build when both branches and tags were pushed.  This
is necessary to support signing with SignPath.io, since we only sign
releases and not pre-releases.  However, due to an oversight in
9af8cca75c, the global on: dictionary
excluded tag pushes.

To simulate the previous AppVeyor CI environment:
- Run all jobs regardless of whether a branch or a tag was pushed.
- Use the if: key to exclude all jobs except "windows" from tag pushes.
2025-05-18 10:57:53 -04:00
DRC
0bf816644a CI: Move strict MSVC comp. wrngs. to build scripts 2025-05-18 08:38:03 -04:00
DRC
9af8cca75c CI: Use GitHub Actions for Windows builds 2025-05-17 17:10:47 -04:00
DRC
4c72bb80c5 Build/CI: Officially support Windows/Arm
- Use Visual Studio 2022 for CI builds.
- Rename installers to clearly distinguish x86, x64, and Arm64 versions.

NOTE: The Windows/Arm installer uses the same internal name and install
directory as the Windows/x64 installer.  That is consistent with the
behavior of the Linux packages.  Because the installer places
turbojpeg.dll into C:\WINDOWS\System32, it would normally be impossible
to co-install the x64 and Arm64 versions anyhow.  (That can still be
accomplished.  You just have to use 7-Zip to extract one of the
installers into a non-default directory.)
2025-05-16 15:07:17 -04:00
DRC
6677122360 cjpeg: Free ICC profile if API error when fuzzing
Fixes #809
2025-05-13 10:33:15 -04:00
DRC
2a0c862782 Fuzz: Fix -Wsign-compare warnings 2025-04-03 13:05:01 -04:00
DRC
2f26b48f10 Mac pkg: Fix issues that prevent notarization
- Explicitly sign all binaries included in the package.

- Enable the hardened runtime.
2025-04-02 13:59:17 -04:00
DRC
adbb328159 GitHub: Use GCC 11 for linux-jpeg7 job
GCC 12 and later throw a false positive with -Wstringop-overflow=4.
2025-02-25 14:52:48 -05:00
DRC
f210df79ca GitHub: Don't test x32 ABI
The ubuntu-20.04 hosted runner image is going away on April 1, and newer
versions of Ubuntu can build but not run x32 binaries.  The x32 ABI
seems to be mostly dead, but we can still regression test x32 support
using a local Ubuntu 20.04 VM if necessary.  (That shouldn't be
necessary unless the x86-64 SIMD extensions change at some point in the
future.)
2025-02-25 14:26:48 -05:00
DRC
36ac5b8470 GitHub: Use Clang 17 rather than Clang 14
The ubuntu-latest runner image now runs Ubuntu 24.04 rather than 22.04.
2025-02-17 17:57:32 -05:00
DRC
e0e18dea54 Ensure methods called by global funcs are init'd
If a hypothetical calling application does something really stupid and
changes cinfo->data_precision after calling jpeg_start_*compress(), then
the precision-specific methods called by jpeg_write_scanlines(),
jpeg_write_raw_data(), jpeg_finish_compress(), jpeg_read_scanlines(),
jpeg_read_raw_data(), or jpeg_start_output() may not be initialized.

Ensure that the first precision-specific method (which will always be
cinfo->main->process_data*(), cinfo->coef->compress_data*(), or
cinfo->coef->decompress_data()) called by any global function that may
be called after jpeg_start_*compress() is initialized and non-NULL.
This increases the likelihood (but does not guarantee) that a
hypothetical stupid calling application will fail gracefully rather than
segfault if it changes cinfo->data_precision after calling
jpeg_start_*compress().  A hypothetical stupid calling application can
still bork itself by changing cinfo->data_precision after initializing
the source manager but before calling jpeg_start_compress(), or after
initializing the destination manager but before calling
jpeg_start_decompress().
2024-12-18 16:31:41 -05:00
DRC
cc095fee7b Build: Generate 32-bit supplementary ppc64 .deb
As with x86-64, the Power ISA basically implements 64-bit instructions
as extensions of their 32-bit counterparts.  Thus, 64-bit Power ISA CPUs
can natively execute legacy 32-bit PowerPC instructions when running in
big-endian mode.  Most Power ISA support has shifted (pun intended) to
little-endian mode, so there are few remaining operating systems that
support big-endian mode.  Debian is one of them, however (albeit
unofficially.)
2024-12-18 10:14:51 -05:00
DRC
20ade4dea9 Build: Fix float test errors with Xcode 14.2/Arm
Unlike other versions of Clang 14.0.0, AppleClang 14.0.0 in Xcode 14.2
retains the old -ffp-contract=off default.  Apple didn't adopt
-ffp-contract=on as the default until Xcode 14.3 (AppleClang 14.0.3.)
This has been confirmed in the Xcode 14.3 release notes.
3.1.0
2024-12-12 15:46:51 -05:00
DRC
c3446d64d7 Bump version to 3.1.0 2024-12-12 11:01:53 -05:00
DRC
84fa3bc093 tjTransform(): Fix false positive compiler warning 2024-12-11 19:35:44 -05:00
DRC
602f0592a9 AltiVec: Disable/Fix some strict compiler warnings
We use a standard set of strict compiler warnings with Clang and GCC to
continuously test and maintain C89 conformance in the libjpeg API code.
However, SIMD extensions need not comply with that.  The AltiVec code
specifically uses some C99isms, so disable -Wc99-extensions and
-Wpedantic in the scope of that code.  Also disable -Wshadow, because
I'm too lazy to fix the TRANSPOSE() macro.  Also
use #ifdef __BIG_ENDIAN__ and #if defined(__BIG_ENDIAN__) instead
of #if __BIG_ENDIAN__
2024-12-11 19:31:24 -05:00
DRC
ea4ee22932 Neon: Disable some strict compiler warnings
We use a standard set of strict compiler warnings with Clang and GCC to
continuously test and maintain C89 conformance in the libjpeg API code.
However, SIMD extensions need not comply with that.  The Neon code
specifically uses some C99isms, so disable
-Wdeclaration-after-statement, -Wc99-extensions, and -Wpedantic in the
scope of that code.  Also modify the Neon feature tests so that they
will succeed if any of the aforementioned compiler warnings are enabled.
2024-12-11 16:57:46 -05:00
DRC
be7a0c8bae Build: Make Mac packaging architecture-agnostic
Rename the ARMV8_BUILD CMake variable to SECONDARY_BUILD, and modify the
makemacpkg script so that it allows any architecture in a primary or
secondary build.  The idea is that Apple Silicon users can package an
arm64 primary build and a secondary x86_64 build, and Intel users can
package an x86_64 primary build and a secondary arm64 build, using the
same procedure.

Also simplify the iOS build instructions, using the
CMAKE_OSX_ARCHITECTURES variable rather than a toolchain.
2024-12-11 13:22:43 -05:00
DRC
9758c8a74c Exclude more code if !(C|D)_LOSSLESS_SUPPORTED 2024-11-18 13:40:08 -05:00
DRC
6bace81b1b Fix OSS-Fuzz decompress_yuv fuzzer MSan failure 2024-11-15 08:34:08 -05:00
DRC
d7932a2709 TJ doc: Density params require YCbCr or grayscale
Since libjpeg-turbo does not support Exif, the only way it can embed
density information in a JPEG image is by using the JFIF marker, which
is only written if the JPEG colorspace is YCbCr or grayscale.
(Referring to the conversation under #793, we may need to further
restrict that to 8-bit-per-sample JPEG images, because the JFIF spec
requires 8-bit data precision.)
2024-10-30 12:21:50 -04:00
DRC
6da05150ef Allow disabling prog/opt/lossless if prev. enabled
- Due to an oversight, a113506d17
  (libjpeg-turbo 1.4 beta1) effectively made the call to
  std_huff_tables() in jpeg_set_defaults() a no-op if the Huffman tables
  were previously defined, which made it impossible to disable Huffman
  table optimization or progressive mode if they were previously enabled
  in the same API instance.  std_huff_tables() retains its previous
  behavior for decompression instances, but it now force-enables the
  standard (baseline) Huffman tables for compression instances.

- Due to another oversight, there was no way to disable lossless mode
  if it was previously enabled in a particular API instance.
  jpeg_set_defaults() now accomplishes this, which makes
  TJ*PARAM_LOSSLESS behave as intended/documented.

- Due to yet another oversight, setCompDefaults() in the TurboJPEG API
  library permanently modified the value of TJ*PARAM_SUBSAMP when
  generating a lossless JPEG image, which affected subsequent lossy
  compression operations.  This issue was hidden by the issue above and
  thus does not need to be publicly documented.

Fixes #792
2024-10-24 18:02:13 -04:00
DRC
befabe2c8b GitHub: Use macos-13 runner image w/ Xcode 14.2
(macos-12 is deprecated.)
2024-10-23 18:54:01 -04:00
DRC
a927b489e2 LICENSE.md: Update copyright year 2024-09-24 10:46:40 -04:00
DRC
bfe77d319f ChangeLog: Document accidental fix from 9983840e
Closes #789
2024-09-23 15:49:41 -04:00
DRC
1b1356a565 TJComp: Explicitly specify data precision
This is just a code readability thing.  The logic effectively caused the
data precision to default to 8 if -precision was not specified, but that
was not obvious.

This commit also modifies tjcomptest so that it tests TJComp with no
-precision argument, to ensure that the data precision defaults to 8.
2024-09-23 15:24:48 -04:00