2770 Commits

Author SHA1 Message Date
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
DRC
ad9c02c6f5 tj3Set(): Allow TJPARAM_LOSSLESSPT vals from 0..15
The target data precision isn't necessarily known at the time that the
calling program sets TJPARAM_LOSSLESSPT, so tj3Set() needs to allow all
possible values (from 0 to 15.)  jpeg_enable_lossless(), which is called
within the body of tj3Compress*(), will throw an error if the point
transform value is greater than {data precision} - 1.
2024-09-23 14:58:36 -04:00
DRC
2351a2d558 Build: Support LLVM/Windows
Since LLVM/Windows emulates Visual Studio, CMake sets
CMAKE_C_SIMULATE_ID="MSVC" but does not set MSVC.  Thus, our build
system needs to enable most (but not all) of the Visual Studio features
when CMAKE_C_SIMLUATE_ID="MSVC".  Support for LLVM/Windows is currently
undocumented because it isn't a standalone build environment.  (It
requires the Visual Studio and Windows SDK headers and link libraries.)

Closes #786
2024-09-16 14:20:24 -04:00
DRC
a9f7490cda Build: Fix typo 3.0.90 2024-09-14 16:09:15 -04:00
DRC
9d76821f98 3.1 beta1 2024-09-14 16:00:53 -04:00
DRC
0d58f09997 TJTran: ICC profiles are now supported 2024-09-14 13:23:36 -04:00
DRC
6d02718d9a JNI: Guard against int. overflow w/ ICC profiles 2024-09-14 13:23:36 -04:00
DRC
9b01f5a057 TJ: Add func/method for computing xformed buf size 2024-09-14 13:23:32 -04:00
DRC
5b09958060 Merge branch 'main' into dev 2024-09-14 11:13:07 -04:00
DRC
f29eda6485 tj3Transform: Don't calc dst subsamp unless needed
This just improves code readability by emphasizing that we don't care
about the destination image's level of subsampling unless
TJPARAM_NOREALLOC is set or lossless cropping will be performed.
3.0.4
2024-09-14 11:10:59 -04:00
DRC
437a4993e8 Merge branch 'main' into dev 2024-09-12 21:11:00 -04:00
DRC
bcbca8b9bc Fuzz: Calc. xformed buf size based on dst. subsamp
(oversight from b3f0abe377)
2024-09-12 21:07:51 -04:00
DRC
6f1fe2d113 turbojpeg-jni.c: Fix int. conv. warnings w/ VC++ 2024-09-09 10:54:16 -04:00
DRC
e3e353fe05 tjunittest.c: Store/retrieve original buf size ...
... between iterations.

(oversight from c519d7b679)
2024-09-09 10:49:51 -04:00
DRC
a272858212 TurboJPEG: ICC profile support 2024-09-06 19:55:41 -04:00
DRC
c6de7d87ad tjdecomp.c: Remove extraneous #defines 2024-09-06 19:55:27 -04:00
DRC
c519d7b679 Don't ignore JPEG buf size with TJPARAM_NOREALLOC
Since the introduction of TJFLAG_NOREALLOC in libjpeg-turbo 1.2.x, the
TurboJPEG C API documentation has (confusingly) stated that:

- if the JPEG buffer pointer points to a pre-allocated buffer, then the
JPEG buffer size must be specified, and

- the JPEG buffer size should be specified if the JPEG buffer is
pre-allocated to an arbitrary size.

The documentation never explicitly stated that the JPEG buffer size
should be specified if the JPEG buffer is pre-allocated to a worst-case
size, but since focus does not imply exclusion, it also never explicitly
stated the reverse.  Furthermore, the documentation never stated that
this was contingent upon TJPARAM_NOREALLOC/TJFLAG_NOREALLOC.  However,
effectively the compression and lossless transformation functions
ignored the JPEG buffer size(s) passed to them, and assumed that the
JPEG buffer(s) had been allocated to a worst-case size, if
TJPARAM_NOREALLOC/TJFLAG_NOREALLOC was set.  This behavior was an
accidental and undocumented throwback to libjpeg-turbo 1.1.x, in which
the tjCompress() function provided no way to specify the JPEG buffer
size.  It was always a bad idea for applications to rely upon that
behavior (although our own TJBench application unfortunately did.)
However, if such applications exist in the wild, the new behavior would
constitute a breaking change, so it has been introduced only into
libjpeg-turbo 3.1.x and only into TurboJPEG 3 API functions.  The
previous behavior has been retained when calling functions from the
TurboJPEG 2.1.x API and prior versions.

Did I mention that APIs are hard?
2024-09-06 19:55:27 -04:00
DRC
5f05c75ac1 Merge branch 'main' into dev 2024-09-06 19:55:20 -04:00
DRC
b3f0abe377 TJ: Calc. xformed buf sizes based on dst. subsamp
With respect to tj3Transform(), this addresses an oversight from
bb1d540a80.

Note to self: A convenience function/method for computing the worst-case
transformed JPEG size for a particular transform would be nice.
2024-09-06 19:04:28 -04:00
DRC
6d9591703f Minor TurboJPEG doc tweaks
- When transforming, the worst-case JPEG buffer size depends on the
  subsampling level used in the destination image, since a grayscale
  transform might have been applied.

- Parentheses Police
2024-09-05 22:31:40 -04:00
DRC
e3dac18833 Merge branch 'main' into dev 2024-09-05 17:07:50 -04:00
DRC
2e40a6875d turbojpeg.c: Fix -Wsign-compare compiler warning
(introduced by previous commit)
2024-09-05 16:49:44 -04:00
DRC
8db41dad22 Merge branch 'main' into dev 2024-09-05 15:15:08 -04:00
DRC
758e8a8e9f Java: Use Java-style method nomenclature
:: is a C++ thing.
2024-09-05 14:57:15 -04:00
DRC
fe1e555a73 tjbenchtest.in: Grammar Police 2024-09-05 14:46:04 -04:00
DRC
bb1d540a80 TJ: Explicitly reject OOB lossless crop regions
tj*Transform() relied upon the underlying transupp API to check the
cropping region.  However, transupp uses unsigned integers for the
cropping region, whereas the tjregion structure uses signed integers.
Thus, casting negative values from a tjregion structure produced very
large unsigned values.  In the case of the left and upper boundary, this
was innocuous, because jtransform_request_workspace() rejected the
values as being out of bounds.  However, jtransform_request_workspace()
did not always reject very large width and height values, because it
supports expanding the destination image by specifying a cropping region
larger than the source image.  In certain cases, it allowed those
values, and the libjpeg memory manager subsequently ran out of memory.

NOTE: Prior to this commit, image expansion technically worked with
tj*Transform() as long as the cropping width and height were valid and
automatic JPEG buffer (re)allocation was used.  However, that behavior
is not a documented feature of the TurboJPEG API, nor do we have any way
of testing it at the moment.  Official support for image expansion can
be added later, if there is sufficient demand for it.

Similarly, this commit modifies tj3SetCroppingRegion() so that it
explicitly checks for left boundary values exactly equal to the scaled
image width and upper boundary values exactly equal to the scaled image
height.  If the specified cropping width or height was 0 (which is
interpreted as {scaled image width} - {left boundary} or
{scaled image height} - {upper boundary}), then such values caused a
cropping width or height of 0 to be passed to the libjpeg API.  In the
case of the width, this was innocuous, because jpeg_crop_scanline()
rejected the value.  In the case of the height, however, this caused
unexpected and hard-to-diagnose errors farther down the pipeline.
2024-09-05 14:37:12 -04:00
DRC
e4c67aff50 TJBench: More argument consistification
-copynone --> -copy none

Add '-copy all', even though it's the default.

-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb, -gray, -cmyk -->
-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|gray|cmyk}
(This is mainly so -gray won't interfere with -grayscale.)

Fix an ArrayIndexOutOfBoundsException that occurred when passing -dct
to the Java version without specifying the DCT algorithm (oversight from
24fbf64d31a0758c63bcc27cf5d92fc5611717d0.)
2024-09-04 12:41:15 -04:00
DRC
d43ed7a1ff Merge branch 'main' into dev 2024-09-04 08:38:13 -04:00
DRC
dd8b15ee82 tjbenchtest.in: Formatting tweak
(oversight from a5689cd45b)
2024-09-04 07:52:51 -04:00
DRC
e7e9344db1 TJ: Honor TJ*OPT_COPYNONE for individual xforms
jcopy_markers_execute() has historically ignored its option argument,
which is OK for jpegtran, but tj*Transform() needs to be able to save a
set of markers from the source image and write a subset of those markers
to each destination image.  Without that ability, the function
effectively behaved as if TJ*OPT_COPYNONE was not specified unless all
transforms specified it.
2024-09-04 07:34:42 -04:00