|
bf01ed2f
|
2022-11-04T13:08:08
|
|
Fix build when SIMD extensions are disabled
(Broken by previous commit)
|
|
e8b40f3c
|
2022-11-01T21:45:39
|
|
Vastly improve 12-bit JPEG integration
The Gordian knot that 7fec5074f962b20ed00b4f5da4533e1e8d4ed8ac attempted
to unravel was caused by the fact that there are several
data-precision-dependent (JSAMPLE-dependent) fields and methods in the
exposed libjpeg API structures, and if you change the exposed libjpeg
API structures, then you have to change the whole API. If you change
the whole API, then you have to provide a whole new library to support
the new API, and that makes it difficult to support multiple data
precisions in the same application. (It is not impossible, as example.c
demonstrated, but using data-precision-dependent libjpeg API structures
would have made the cjpeg, djpeg, and jpegtran source code hard to read,
so it made more sense to build, install, and package 12-bit-specific
versions of those applications.)
Unfortunately, the result of that initial integration effort was an
unreadable and unmaintainable mess, which is a problem for a library
that is an ISO/ITU-T reference implementation. Also, as I dug into the
problem of lossless JPEG support, I realized that 16-bit lossless JPEG
images are a thing, and supporting yet another version of the libjpeg
API just for those images is untenable.
In fact, however, the touch points for JSAMPLE in the exposed libjpeg
API structures are minimal:
- The colormap and sample_range_limit fields in jpeg_decompress_struct
- The alloc_sarray() and access_virt_sarray() methods in
jpeg_memory_mgr
- jpeg_write_scanlines() and jpeg_write_raw_data()
- jpeg_read_scanlines() and jpeg_read_raw_data()
- jpeg_skip_scanlines() and jpeg_crop_scanline()
(This is subtle, but both of those functions use JSAMPLE-dependent
opaque structures behind the scenes.)
It is much more readable and maintainable to provide 12-bit-specific
versions of those six top-level API functions and to document that the
aforementioned methods and fields must be type-cast when using 12-bit
samples. Since that eliminates the need to provide a 12-bit-specific
version of the exposed libjpeg API structures, we can:
- Compile only the precision-dependent libjpeg modules (the
coefficient buffer controllers, the colorspace converters, the
DCT/IDCT managers, the main buffer controllers, the preprocessing
and postprocessing controller, the downsampler and upsamplers, the
quantizers, the integer DCT methods, and the IDCT methods) for
multiple data precisions.
- Introduce 12-bit-specific methods into the various internal
structures defined in jpegint.h.
- Create precision-independent data type, macro, method, field, and
function names that are prefixed by an underscore, and use an
internal header to convert those into precision-dependent data
type, macro, method, field, and function names, based on the value
of BITS_IN_JSAMPLE, when compiling the precision-dependent libjpeg
modules.
- Expose precision-dependent jinit*() functions for each of the
precision-dependent libjpeg modules.
- Abstract the precision-dependent libjpeg modules by calling the
appropriate precision-dependent jinit*() function, based on the
value of cinfo->data_precision, from top-level libjpeg API
functions.
|
|
6c2bc901
|
2022-11-03T14:39:19
|
|
Don't allow disabling in-memory src/dest managers
By default, libjpeg-turbo 1.3.x and later have enabled the in-memory
source/destination manager functions from libjpeg v8 when emulating the
libjpeg v6b or v7 API/ABI, which has allowed operating system
distributors to provide those functions without adopting the
backward-incompatible libjpeg v8 API/ABI.
Prior to libjpeg-turbo 1.5.x, it made sense to allow users to disable
the in-memory source/destination manager functions at build time and
thus retain both backward and forward API/ABI compatibility relative to
libjpeg v6b or v7. Since then, however, we have introduced several new
libjpeg API functions that break forward API/ABI compatibility, so it no
longer makes sense to allow the in-memory source/destination managers to
be disabled. libjpeg-turbo only claims to be
backward-API/ABI-compatible, i.e. to allow applications built against
libjpeg or an older version of libjpeg-turbo to work properly with the
current version of libjpeg-turbo.
|
|
664b64a9
|
2022-11-03T14:25:35
|
|
Merge branch 'main' into dev
|
|
4f7a8afb
|
2022-11-03T13:37:55
|
|
Build: Fix issues w/ Ninja Multi-Config generator
- Fix an issue whereby a build with ENABLE_SHARED=0 could not be
installed when using the Ninja Multi-Config CMake generator.
- Fix an issue whereby a Windows installer could not be built when using
the Ninja Multi-Config CMake generator.
- Fix an issue whereby the Java regression tests failed when using the
Ninja Multi-Config CMake generator.
Based on:
https://github.com/stilllman/libjpeg-turbo/commit/4f169deeb092a0513472b04f05f57bfe42b31ceb
Closes #626
|
|
8c5e78ce
|
2022-11-03T11:22:50
|
|
Build: Document SO_AGE and TURBOJPEG_SO_AGE vars
|
|
8917c548
|
2022-11-03T14:20:22
|
|
ChangeLog.md: Add colons to sub-headers
For some reason, I failed to add a colon to the "Significant changes
relative to 2.1 beta1" sub-header, and the mistake propagated from
there.
|
|
cb3642cb
|
2022-11-03T12:22:51
|
|
Bump version to 2.1.5 to prepare for new commits
|
|
4d269d7c
|
2022-10-21T12:22:28
|
|
Merge branch 'main' into dev
|
|
51f1924e
|
2022-10-21T11:36:29
|
|
wizard.txt: Clarify scan script restrictions
The Wallace paper is not entirely clear on these restrictions, and the
spec itself requires some digging.
Closes #624
|
|
5acd9f20
|
2022-10-04T12:58:11
|
|
Merge branch 'main' into dev
|
|
eb0a024a
|
2022-10-04T12:51:38
|
|
Remove redundant jconfigint.h #includes
Because of 607b668ff96e40fdc749de9b1bb98e7f40c86d93, jconfigint.h is
included by jinclude.h.
|
|
543bfc25
|
2022-10-03T21:38:15
|
|
Merge branch 'main' into dev
|
|
f579cc11
|
2022-10-03T19:46:09
|
|
Make SIMD capability variables thread-local ...
... on platforms that support TLS, which should include all
currently-supported platforms
(https://libjpeg-turbo.org/Documentation/OfficialBinaries)
Addresses a concern raised in #87
Although it is still my opinion that the data race in init_simd() was
innocuous, we can now fix it for free thanks to
ae87a958613b69628b92088b313ded0d4f59a716, so why not?
|
|
2fd634b8
|
2022-09-12T23:36:34
|
|
Merge branch 'main' into dev
|
|
2cad2169
|
2022-09-12T21:54:35
|
|
BUILDING.md: Acknowledge RHEL 9
|
|
b3d3cbf4
|
2022-09-12T14:41:34
|
|
JNI: Remove deprecated methods
(oversight from 931884e78dc8777e6477451e984af8b263e450b1)
|
|
fdfba495
|
2022-09-02T15:11:25
|
|
Merge branch 'main' into dev
|
|
c5db99e1
|
2022-09-02T14:48:58
|
|
GitHub Actions: Specify Big Sur for macOS build
The Catalina hosted runner is now fully deprecated.
|
|
513f9e66
|
2022-08-09T04:27:33
|
|
Merge branch 'main' into dev
|
|
8162eddf
|
2022-08-08T16:02:34
|
|
Fix issues w/ partial img decompr + buf img mode
Fixes #611
|
|
931884e7
|
2022-08-08T15:41:01
|
|
Java: Remove deprecated fields, ctors, and methods
Most of these have been deprecated since libjpeg-turbo 1.4.x.
It's time.
|
|
280784f7
|
2022-08-08T15:07:45
|
|
Merge branch 'main' into dev
|
|
2e136a71
|
2022-08-08T14:17:51
|
|
Re-fix buf img mode decompr err w/short prog JPEGs
This commit reverts 4dbc293125b417f97e5b1ca9e7260c82ff199a06 and
9f8f683e745972720433406cff4b31e95bd6a33e (the previous two commits) and
fixes #613 the correct way. The crux of the issue wasn't the size of
the whole_image virtual array but rather that, since last_iMCU_row is
unsigned, (last_iMCU_row - 1) wrapped around to 0xFFFFFFFF when
last_iMCU_row was 0. This caused the interblock smoothing algorithm
introduced in 6d91e950c871103a11bac2f10c63bf998796c719 to erroneously
try to access the next two iMCU rows, neither of which existed. The
first attempt at a fix (4dbc293125b417f97e5b1ca9e7260c82ff199a06)
exposed a NULL dereference, detected by OSS-Fuzz, that occurred when
attempting to decompress a specially-crafted malformed JPEG image to a
YUV buffer using tjDecompressToYUV*() with 1/4 IDCT scaling.
Fixes #613 (again)
Also fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=49898
|
|
f6273192
|
2022-08-07T14:16:28
|
|
Merge branch 'main' into dev
|
|
9f8f683e
|
2022-08-07T14:15:03
|
|
jdcoefct.c: Fix signed/unsigned mismatch VC++ wrng
(introduced by previous commit)
|
|
9a60181b
|
2022-08-07T13:48:31
|
|
Merge branch 'main' into dev
|
|
4dbc2931
|
2022-08-07T09:24:57
|
|
Fix buf image mode decompr err w/ short prog JPEGs
Regression introduced by 6d91e950c871103a11bac2f10c63bf998796c719
Because we're now using a 5x5 smoothing window when decompressing
progressive JPEG images, we need to ensure that the whole_image virtual
array contains at least five rows. Previously that was not always the
case unless the progressive JPEG image being decompressed had at least
five iMCU rows. Since an iMCU has a height of (8 * the vertical
sampling factor), attempting to decompress 4:2:2 and 4:4:4 images <= 32
pixels in height or 4:2:0 images <= 64 pixels in height triggered a
JERR_BAD_VIRTUAL_ACCESS error in decompress_smooth_data(), because
access_rows exceeded the number of rows in the virtual array.
Fixes #613
|
|
fc224c48
|
2022-07-07T13:11:05
|
|
Merge branch 'main' into dev
|
|
59337a67
|
2022-07-06T12:11:50
|
|
PowerPC: Detect AltiVec support on OS X
libjpeg-turbo's AltiVec SIMD extensions previously assumed that AltiVec
instructions were available on all Power Macs that supported OS X 10.4
"Tiger" (the earliest version of OS X that libjpeg-turbo has ever
supported), but Tiger can actually run on PowerPC G3 processors, which
lack AltiVec instructions. This commit enables run-time detection of
AltiVec instructions on OS X/PowerPC systems if AltiVec instructions are
not force-enabled at compile time (using -maltivec). This allows the
same build of libjpeg-turbo to support G3, G4, and G5 Power Macs.
Closes #609
|
|
8a3b0f70
|
2022-06-24T15:21:51
|
|
Implement 12-bit-specific error/warn/trace macros
The macros in jerror.h refer to j_common_ptr, so it is unfortunately
necessary to introduce a 12-bit-specific version of that header file
(j12error.h) with 12-bit specific ERREXIT*(), WARNMS*(), and
TRACEMS*() macros. (The message table is still shared between 8-bit and
12-bit implementations.)
Fixes #607
|
|
aa5a3599
|
2022-06-24T14:21:33
|
|
Merge branch 'main' into dev
|
|
ba22c0f7
|
2022-06-24T14:03:03
|
|
tjDecompressHeader3(): Accept tables-only streams
Inspired by:
https://github.com/amyspark/libjpeg-turbo/commit/b3b15cfe74cf07914122e26cf1e408a9a9cf3135
Closes #604
Closes #605
|
|
225781af
|
2022-06-14T14:25:11
|
|
jchuff.c: Clean up aadd60ae + add code comments
Based on:
https://github.com/fhanau/libjpeg-turbo/commit/4d73f52032a608262f8b286dd4584836ddc73180
https://github.com/fhanau/libjpeg-turbo/commit/184f10703eeb214177b02f88939af237267a8d66
Refer to #602
|
|
faa7c74a
|
2022-05-31T13:07:00
|
|
ChangeLog.md: Acknowledge 2.1.4 release
|
|
aadd60ae
|
2022-05-25T19:51:52
|
|
Speed up computation of optimal Huffman tables
Closes #602
|
|
0000dadf
|
2022-05-27T12:15:04
|
|
Merge branch 'main' into dev
|
|
a405519e
|
2022-05-27T11:59:56
|
|
Fix build if UPSAMPLE_MERGING_SUPPORTED undefined
Although it is uncommon, some downstream implementations undefine one or
more of the *_SUPPORTED macros in jmorecfg.h in order to reduce the size
of the library. In the interest of maintaining backward compatibility
with libjpeg, this is still a supported use case.
Regression introduced by 9120a247436e84c0b4eea828cb11e8f665fcde30
Based on:
https://github.com/fhanau/libjpeg-turbo/commit/74c4d032f0448edb0c8898b6e096123ae1aa093f
Closes #601
|
|
fac83814
|
2022-05-14T14:34:43
|
|
Build: Don't enable Loongson MMI with MIPS R6+
MIPS R6 removed some instructions, so Loongson MMI cannot be built with
MIPS R6+ toolchains.
Closes #598
|
|
0f5d31e6
|
2022-04-28T20:04:53
|
|
Merge branch 'main' into dev
|
|
290ddbf7
|
2022-04-22T08:30:21
|
|
MinGW: Fix str*casecmp() macro redef. warning
MinGW defines strcasecmp() and strncasecmp() as macros in string.h if
__CRT__NO_INLINE is defined, which will be the case when including any
of the Win32 API headers.
Closes #594
|
|
b98dabac
|
2022-04-27T12:38:58
|
|
Merge branch 'main' into dev
|
|
9171fd4b
|
2022-04-26T10:42:35
|
|
OSS-Fuzz: '.' --> '_' in fuzzer suffix
Referring to https://github.com/google/oss-fuzz/issues/7575, if the
fuzzer suffix contains periods, it can cause ClusterFuzz to misinterpret
the file extension of the fuzzer executables and thus misidentify them.
|
|
d0e7c454
|
2022-04-18T11:34:07
|
|
Don't install libturbojpeg.pc if WITH_TURBOJPEG=0
Fixes #593
|
|
dfc63d42
|
2022-03-28T22:30:54
|
|
Fix non-SIMD alignment if void* bigger than double
When building without the SIMD extensions, memory allocations are
currently aligned to sizeof(double). However, this may be insufficient
on architectures such as Arm Morello or 64-bit CHERI-RISC-V where
pointers require 16-byte rather than 8-byte alignment. This patch
causes memory allocations to be aligned to
MAX(sizeof(void *), sizeof(double)) when building without the SIMD
extensions.
(NOTE: With C11 we could instead use alignof(max_align_t), but C89
compatibility is still necessary in libjpeg-turbo.)
Closes #587
|
|
82081337
|
2022-04-06T11:16:09
|
|
Merge branch 'main' into dev
|
|
67cb0590
|
2022-04-06T10:50:33
|
|
OSS-Fuzz: Allow fuzzer suffix to be specified
This facilitates fuzzing multiple branches of the code.
|
|
5c8cac97
|
2022-04-06T10:51:58
|
|
CI: Un-integrate CIFuzz
Referring to the conversation in
https://github.com/google/oss-fuzz/issues/7479 and #559, there was a
misunderstanding regarding how CIFuzz works. It cannot be used to fuzz
arbitrary PRs or code branches, and it has a 90-day delay in downloading
corpora from OSS-Fuzz. That makes it unsuitable for libjpeg-turbo.
|
|
89a369de
|
2022-03-31T10:33:26
|
|
Merge branch 'main' into dev
|
|
df3c3dcb
|
2022-03-31T10:22:06
|
|
BUILDING.md: Generify PowerTools repo advice
This advice applies to CentOS Stream as well as to popular CentOS 8
replacements, such as Rocky Linux and AlmaLinux.
|
|
1b9edb5c
|
2022-03-10T23:57:11
|
|
Build: Fix 12-bit FP tests w/ 32-bit builds
With x86-64 builds, the default value of FLOATTEST works with both the
8-bit-per-sample and 12-bit-per-sample flavors of the libjpeg API
library. However, that is not the case with x86 builds. Thus, we need
separate 8-bit-per-sample and 12-bit-per-sample FLOATTEST variables.
|
|
cb715fe1
|
2022-03-11T17:12:37
|
|
example.c: Fix compiler warning with GCC 4.4.7
|
|
ebd19302
|
2022-03-10T23:21:55
|
|
GitHub Actions: "linux-12bit" --> "linux-no12bit"
This job tests the non-default value of WITH_12BIT, which is now 0
instead of 1.
|
|
263386c2
|
2022-03-11T17:35:59
|
|
Merge branch 'main' into dev
|
|
2ee7264d
|
2022-03-11T17:28:36
|
|
Build: Don't set DEFAULT_FLOATTEST for x86 MSVC
Newer versions of the 32-bit x86 Visual Studio compiler produce results
compatible with FLOATTEST=no-fp-contract, so we can no longer
intelligently set a default FLOATTEST value for that platform.
|
|
30cba2a2
|
2022-03-11T11:49:34
|
|
Build/Win: Fix CMake warning when WITH_TURBOJPEG=0
When 12-bit-per-component JPEG support is enabled (WITH_12BIT=1) or the
TurboJPEG API library and associated test programs are disabled
(WITH_TURBOJPEG=0), the Windows installer target should not depend on
the turbojpeg, turbojpeg-static, and tjbench targets.
|
|
a0148454
|
2022-03-11T10:50:47
|
|
Win: Fix build with Visual Studio 2010
(broken by 607b668ff96e40fdc749de9b1bb98e7f40c86d93)
- Visual Studio 2010 apparently doesn't have the snprintf() inline
function, so restore the macro that emulates that function using
_snprintf_s().
- Explicitly include errno.h in strtest.c, since jinclude.h doesn't
include it when building with Visual Studio.
|
|
b3ae7779
|
2022-03-10T23:13:43
|
|
Fix in-tree builds
(oops)
|
|
a32038e3
|
2022-03-10T23:10:12
|
|
Fix formatting issues detected by checkstyle
|
|
7fec5074
|
2022-03-08T12:34:11
|
|
Support 8-bit & 12-bit JPEGs using the same build
Partially implements #199
This commit also implements a request from #178 (the ability to compile
the libjpeg example as a standalone program.)
|
|
fc562d11
|
2022-03-07T14:29:37
|
|
Bump version to 2.2 alpha1 ...
... to prepare for new features
|
|
f3c716a2
|
2022-03-10T22:31:20
|
|
Link Sponsor button to GitHub Sponsors ...
... instead of PayPal.
|
|
6f1534d6
|
2022-03-09T12:58:17
|
|
example.txt: Fix a typo
|
|
9abeff46
|
2022-03-09T11:48:30
|
|
Remove extraneous #include directives
jinclude.h already includes stdio.h, stdlib.h, and string.h.
|
|
932b5bb0
|
2022-03-09T10:50:51
|
|
IJG dox: Wordsmithing and formatting tweaks
- Remove the section in libjpeg.txt that advised against building
libjpeg as a shared library. We obviously do not follow that advice,
and libjpeg-turbo does guarantee backward ABI compatibility in our
libjpeg API library, even though libjpeg did not and does not.
(Future expansion of our libjpeg API library, if necessary, will be
accomplished using get/set functions that store the new parameters
in the opaque master structs. Refer to
https://github.com/mozilla/mozjpeg/commit/db2986c96fcebe10c8700081578e5305fd7bc7dc.)
- Unmention install.txt, which was never relevant to libjpeg-turbo and
was removed in v1.3 (6f96153c67e9a88775b457f998fc7fdd64c62cee).
- Remove extraneous spaces.
- Document the fact that TWO_FILE_COMMANDLINE must be defined in order
to use the two-file interface with cjpeg, djpeg, jpegtran, and
wrjpgcom. libjpeg-turbo never enables that interface by default.
|
|
fdab4a7a
|
2022-03-08T17:25:57
|
|
Progs: Eliminate obsolete Mac ccommand() interface
ccommand() was a 1990s-vintage hack for running console applications
without a console. It doesn't exist in any modern macOS compiler.
|
|
05655481
|
2022-02-28T20:41:56
|
|
BUILDING.md: Mention sub-project best practices
People keep trying to include libjpeg-turbo into downstream CMake-based
build systems by way of the add_subdirectory() function and requesting
upstream support when something inevitably breaks.
(Refer to: #122, #173, #176, #202, #241, #349, #353, #412, #504,
https://github.com/libjpeg-turbo/libjpeg-turbo/commit/a3d4aadd0d1597ad46edcbe3b964499ec785d40c#commitcomment-67575889).
libjpeg-turbo has never supported that method of sub-project
integration, because doing so would require that we (minimally):
1. avoid using certain CMake variables, such as CMAKE_SOURCE_DIR,
CMAKE_BINARY_DIR, and CMAKE_PROJECT_NAME;
2. avoid using implicit include directories and relative paths;
3. provide a way to optionally skip the installation of libjpeg-turbo
components in response to 'make install';
4. provide a way to optionally postfix target names, to avoid namespace
conflicts;
5. restructure the top-level CMakeLists.txt so that it properly sets
the PROJECT_VERSION variable; and
6. design automated CI tests to ensure that new commits don't break
any of the above.
Even if we did all of that, issues would still arise, because it is
impossible for one upstream build system to anticipate the widely
varying needs of every downstream build system. That's why the CMake
ExternalProject_Add() function exists, and it is my sincere hope that
adding a blurb to BUILDING.md mentioning the need to use that function
will head off future GitHub issues on this topic. If not, then I can at
least post a link to this commit and the blurb and avoid doing the same
song and dance over and over again.
|
|
c5f269eb
|
2021-09-03T11:52:40
|
|
Neon/AArch64: Explicitly unroll quant loop w/Clang
The loop in jsimd_quantize_neon() is only executed twice and should be
unrolled for AArch64 targets. GCC does that by default, but Clang 11
and later versions available at the time of this writing do not. This
patch adds an unroll pragma when targetting AArch64 with Clang. We do
not use the unroll pragma for AArch32 targets, because it causes the
Clang-generated assembly code to exhaust the available Neon registers
(32 x 64-bit) and spill to the stack. (DRC: Referring to the discussion
in #570, this is likely due to compiler confusion that results in poor
register allocation. It is possible to eliminate the spillage and
reduce the instruction count by loading the data on a just-in-time
basis, thus explicitly interleaving compute and I/O, but the performance
implications of that are currently unknown.)
The effects of unrolling the quantization loop are:
1) elimination of the loop control flow overhead and
2) enabling the use of LDP/STP instructions that work from a single
base pointer, instead of using double the number of LDR/STR
instructions, each requiring an address calculation.
Closes #570
|
|
98bc3eeb
|
2022-02-24T23:09:58
|
|
Neon/AArch64: Fix/suppress UBSan warnings
- Suppress a UBSan warning regarding storing a 64-bit value to a
non-64-bit-aligned address. That behavior is technically undefined
per the C spec but is supported in the context of the AArch64
architecture and compilers.
- Explicitly promote block_diff[i] to unsigned int prior to left
shifting it, in order to avoid a UBSan warning. This warning also
described behavior that is technically undefined per the C spec but is
supported in the context of the AArch64 architecture and compilers.
Changing the type cast order eliminated the warning without changing
the generated assembly code.
Closes #582
|
|
147548c0
|
2021-09-06T11:31:37
|
|
Neon/AArch64: Accelerate Huffman encoding
- Make better use of 128-bit vector registers, thus reducing the number
of Neon instructions required to construct the AC coefficient bitmap.
- Refactor the Neon computations of 'nbits' and 'diff' to use shorter
and higher-throughput instruction sequences.
DRC's notes:
This commit partially integrates #570. Arm reported a 1-4% speedup on
Cortex-A55 and Neoverse-N1 cores when using recent compilers but little
or no speedup with Clang 10. I observed no speedup with Clang 10 on my
Cortex-A53 and Cortex-A72 cores. Thus, referring to #582, the primary
purpose of this commit is to fix UBSan warnings regarding the shift
operations previously located at Line 253:
https://github.com/libjpeg-turbo/libjpeg-turbo/blob/d640a457305164417a60f30c6457d316f0b44a9d/simd/arm/aarch64/jchuff-neon.c#L253
|
|
d640a457
|
2022-02-11T14:12:25
|
|
AppVeyor: Test strict MSVC compiler warnings
|
|
eb21c023
|
2022-02-22T14:01:07
|
|
Eliminate incompatible pointer type warnings
(C4057 in MSVC and -Wincompatible-pointer-types in GCC/Clang)
|
|
13377e6b
|
2022-02-11T13:58:31
|
|
MSVC: Eliminate int conversion warnings (C4244)
|
|
607b668f
|
2022-02-10T11:33:49
|
|
MSVC: Eliminate C4996 warnings in API libs
The primary purpose of this is to encourage adoption of libjpeg-turbo in
downstream Windows projects that forbid the use of "deprecated"
functions. libjpeg-turbo's usage of those functions was not actually
unsafe, because:
- libjpeg-turbo always checks the return value of fopen() and ensures
that a NULL filename can never be passed to it.
- libjpeg-turbo always checks the return value of getenv() and never
passes a NULL argument to it.
- The sprintf() calls in format_message() (jerror.c) could never
overflow the destination string buffer or leave it unterminated as
long as the buffer was at least JMSG_LENGTH_MAX bytes in length, as
instructed. (Regardless, this commit replaces those calls with
snprintf() calls.)
- libjpeg-turbo never uses sscanf() to read strings or multi-byte
character arrays.
- Because of b7d6e84d6a9283dc2bc50ef9fcaadc0cdeb25c9f, wrjpgcom
explicitly checks the bounds of the source and destination strings
before calling strcat() and strcpy().
- libjpeg-turbo always ensures that the destination string is
terminated when using strncpy().
(548490fe5e2aa31cb00f6602d5a478b068b99682 made this explicit.)
Regarding thread safety:
Technically speaking, getenv() is not thread-safe, because the returned
pointer may be invalidated if another thread sets the same environment
variable between the time that the first thread calls getenv() and the
time that that thread uses the return value. In practice, however, this
could only occur with libjpeg-turbo if:
(1) A multithreaded calling application used the deprecated and
undocumented TJFLAG_FORCEMMX/TJFLAG_FORCESSE/TJFLAG_FORCESSE2 flags in
the TurboJPEG API or set one of the corresponding environment variables
(which are only intended for testing purposes.) Since the TurboJPEG API
library only ever passed string constants to putenv(), the only inherent
risk (i.e. the only risk introduced by the library and not the calling
application) was that the SIMD extensions may have read an incorrect
value from one of the aforementioned environment variables.
or
(2) A multithreaded calling application modified the value of the
JPEGMEM environment variable in one thread while another thread was
reading the value of that environment variable (in the body of
jpeg_create_compress() or jpeg_create_decompress().) Given that the
libjpeg API provides a thread-safe way for applications to modify the
default memory limit without using the JPEGMEM environment variable,
direct modification of that environment variable by calling applications
is not supported.
Microsoft's implementation of getenv_s() does not claim to be
thread-safe either, so this commit uses getenv_s() solely to mollify
Visual Studio. New inline functions and macros (GETENV_S() and
PUTENV_S) wrap getenv_s()/_putenv_s() when building for Visual Studio
and getenv()/setenv() otherwise, but GETENV_S()/PUTENV_S() provide no
advantages over getenv()/setenv() other than parameter validation. They
are implemented solely for convenience.
Technically speaking, strerror() is not thread-safe, because the
returned pointer may be invalidated if another thread changes the locale
and/or calls strerror() between the time that the first thread calls
strerror() and the time that that thread uses the return value. In
practice, however, this could only occur with libjpeg-turbo if a
multithreaded calling application encountered a file I/O error in
tjLoadImage() or tjSaveImage(). Since both of those functions
immediately copy the string returned from strerror() into a thread-local
buffer, the risk is minimal, and the worst case would involve an
incorrect error string being reported to the calling application.
Regardless, this commit uses strerror_s() in the TurboJPEG API library
when building for Visual Studio. Note that strerror_r() could have been
used on Un*x systems, but it would have been necessary to handle both
the POSIX and GNU implementations of that function and perform
widespread compatibility testing. Such is left as an exercise for
another day.
Fixes #568
|
|
ab6cae6f
|
2022-02-22T10:23:19
|
|
BUILDING.md: Clarify that Ninja works with Windows
|
|
3ccb6ead
|
2022-02-11T10:05:18
|
|
BUILDING.md: Remove NASM RPM rebuild instructions
All currently supported Linux platforms now provide a recent enough
version of either NASM or Yasm.
|
|
6441ad0f
|
2022-02-11T09:56:41
|
|
BUILDING.md: Document NASM/Yasm path variables
This was an oversight from the CMake build system overhaul in
libjpeg-turbo 2.0 (6abd39160c5a3762e9ebe024e75407665093e715).
Closes #580
|
|
6d2d6d3b
|
2022-02-11T09:34:01
|
|
"YASM" = "Yasm"
The assembler name was initially spelled "YASM", but it has been "Yasm"
for the entirety of libjpeg-turbo's existence.
|
|
e1588a2a
|
2022-02-10T22:23:26
|
|
Build: Fix Neon capability detection w/ MSVC
(broken by 57ba02a408a9a55ccff25aae8b164632a3a4f177)
Refer to #547
|
|
548490fe
|
2022-02-10T11:37:06
|
|
Ensure that strncpy() dest strings are terminated
- Since the ERREXITS() and TRACEMSS() macros are never used internally
(they are a relic of the legacy memory managers that libjpeg
provided), the only risk was that an external program might have
invoked one of those macros with a string longer than 79 characters
(JMSG_STR_PARM_MAX - 1).
- TJBench never invokes the THROW_TJ() macro with a string longer than
199 (JMSG_LENGTH_MAX - 1) characters, so there was no risk. However,
it's a good idea to explicitly terminate the destination strings so
that anyone looking at the code can immediately tell that it is safe.
|
|
b579fc11
|
2022-02-07T15:27:50
|
|
Eliminate unnecessary JFREAD()/JFWRITE() macros
|
|
a3d4aadd
|
2022-02-01T12:53:28
|
|
Build: Embed version/API/(C) info in MSVC DLLs
Based on:
https://github.com/TheDorkKnight/libjpeg-turbo/commit/da7a18801a5c305d3f8a71b065f179f1e22b73ae
Closes #576
|
|
d7d16df6
|
2022-02-01T09:11:19
|
|
Fix segv w/ h2v2 merged upsamp, jpeg_crop_scanline
The h2v2 (4:2:0) merged upsampler uses a spare row buffer so that it can
upsample two rows at a time but return only one row to the application,
if necessary. merged_2v_upsample() copies from this spare row buffer
into the application-supplied output buffer, using the out_row_width
field in the my_merged_upsampler struct to determine how many samples to
copy. out_row_width is set in jinit_merged_upsampler(), which is called
within the body of jpeg_start_decompress(). Since jpeg_crop_scanline()
must be called after jpeg_start_decompress(), jpeg_crop_scanline() must
modify the value of out_row_width if the h2v2 merged upsampler will be
used. Otherwise, merged_2v_upsample() can overflow the output buffer if
the number of bytes between the current output buffer position and the
end of the buffer is less than the number of bytes required to represent
an uncropped scanline of the output image. All of the destination
managers used by djpeg allocate either a whole image buffer or a
scanline buffer based on the uncropped output image width, so this issue
is not reproducible using djpeg.
Fixes #574
|
|
14ce28a9
|
2022-01-29T12:33:40
|
|
TJBench: Remove innocuous always-true condition
This was accidentally introduced into tjbench.c in
890f1e0413b54c40b663208779d4ea9dae20eaef and ported into the Java
version from there.
Based on
https://github.com/libjpeg-turbo/libjpeg-turbo/pull/571/commits/4be6d4e7bdd09a73ee8456aa07693afa31ef2148
Refer to #571
|
|
da41ab94
|
2022-01-06T12:57:26
|
|
GitHub Actions: Specify Catalina for macOS build
macos-latest now maps to the Big Sur image, which doesn't have Xcode
12.2 installed.
|
|
1f55ae7b
|
2022-01-06T12:08:46
|
|
Fix -Wpedantic compiler warnings
... and test for those warnings (and others) when performing CI builds.
|
|
17297239
|
2022-01-06T09:17:30
|
|
Eliminate non-ANSI C compatibility macros
libjpeg-turbo has never supported non-ANSI C compilers. Per the spec,
ANSI C compilers must have locale.h, stddef.h, stdlib.h, memset(),
memcpy(), unsigned char, and unsigned short. They must also handle
undefined structures.
|
|
a7f0244e
|
2022-01-06T02:21:10
|
|
turbojpeg.h: Parenthesize TJSCALED() dimension arg
This ensures that, for example,
TJSCALED(dim0 + dim1, sf)
will evaluate to
(((dim0 + dim1) * sf.num + sf.denom - 1) / sf.denom)
rather than
((dim0 + (dim1 * sf.num) + sf.denom - 1) / sf.denom)
|
|
a01857cf
|
2021-12-01T17:08:29
|
|
Build: Disallow NEON_INTRINSICS=0 if GAS is broken
If NEON_INTRINSICS=0, then run the GAS sanity check from libjpeg-turbo
2.0.x and force-enable NEON_INTRINSICS if the test fails. This fixes
the AArch32 build when using Clang 6.0 on Linux or the Clang toolchain
in the Android NDK r15*-r16*. It also prevents users from manually
disabling NEON_INTRINSICS if doing so would break the build (such as
with Xcode 5.)
|
|
57ba02a4
|
2021-10-01T16:28:54
|
|
Build: Improve Neon capability detection
- Use check_c_source_compiles() rather than check_symbol_exists() to
detect the presence of vld1_s16_x3(), vld1_u16_x2(), and
vld1q_u8_x4(). check_symbol_exists() is unreliable for detecting
intrinsics, and in practice, it did not detect the presence of the
aforementioned intrinsics in versions of GCC that support them.
- Set DEFAULT_NEON_INTRINSICS=0 for GCC < 12, even if the aforementioned
intrinsics are available. The AArch64 back end in GCC 10 and 11
supports the necessary intrinsics, but the GAS implementation is still
faster when using those compilers.
Fixes #547
|
|
8a9a6dd1
|
2021-12-01T09:02:36
|
|
Make incompatible feature errs more user-friendly
- Use JERR_NOTIMPL ("Not implemented yet") rather than JERR_NOT_COMPILED
("Requested feature was omitted at compile time") to indicate that
arithmetic coding is incompatible with Huffman table optimization.
This is more consistent with other parts of the libjpeg API code.
JERR_NOT_COMPILED is typically used to indicate that a major feature
was not compiled in, whereas JERR_NOTIMPL is typically used to
indicate that two features were compiled in but are incompatible with
each other (such as, for instance, two-pass color quantization and
partial image decompression.)
- Change the text of JERR_NOTIMPL to "Requested features are
incompatible". This is a more accurate description of the situation.
"Not implemented yet" implies that it may be possible to support the
requested combination of features in the future, but that is not true
in most of the cases where JERR_NOTIMPL is used.
Fixes #567
|
|
73eff6ef
|
2021-11-30T15:06:54
|
|
cjpeg: auto. compr. gray BMP/GIF-->grayscale JPEG
aa7459050d7a50e1d8a99488902d41fbc118a50f was supposed to enable this for
BMP input images but didn't, due to a similar oversight to the one fixed
in the previous commit.
|
|
2ce32e0f
|
2021-11-30T10:54:24
|
|
cjpeg: automatically compress PGM-->grayscale JPEG
(regression introduced by aa7459050d7a50e1d8a99488902d41fbc118a50f)
cjpeg sets cinfo.in_color_space to JCS_RGB as an "arbitrary guess."
Since tjLoadImage() never uses JCS_RGB, the PGM reader should treat
JCS_RGB the same as JCS_UNKNOWN.
Fixes #566
|
|
e869a81a
|
2021-11-23T09:54:23
|
|
jdarith.c: Require cinfo->Se == DCTSIZE2 - 1
This fixes an oversight from the integration of the arithmetic entropy
codec from libjpeg (66f97e6820e2cc9ef7429ea36285c80ffda87c8f). I chose
to integrate the latest implementation available at the time, which was
from jpeg-8b. However, I naively replaced cinfo->lim_Se with
DCTSIZE2 - 1, not realizing that-- because of SmartScale-- jpeg-8b
contains additional code
(https://github.com/libjpeg-turbo/libjpeg-turbo/blob/jpeg-8b/jdinput.c#L249-L334)
that guards against illegal values of cinfo->Se >= DCTSIZE2. Thus,
libjpeg-turbo's implementation of arithmetic decoding has never guarded
against such illegal values. This commit restores the relevant check
from the original jpeg-6b arithmetic entropy codec patch ("jpeg-ari",
1e247ac854f8e33682bcfea475f6bccc42377208).
Fixes #564
|
|
5446ff88
|
2021-11-19T13:43:36
|
|
CI: CIFuzz integration
CIFuzz runs the project's fuzzers for a limited period of time any time
a commit is pushed or a PR is submitted. This is not intended to
replace OSS-Fuzz but rather to allow us to more quickly catch some
fuzzing failures, including fuzzer build regressions like the one
introduced in ecf021bc0d6f435daacff7c35ccaeef0145df1b9.
Closes #559
|
|
0f88060b
|
2021-11-19T13:36:42
|
|
cjpeg.c: Fix fuzzer build failure
(caused by previous commit)
|
|
ecf021bc
|
2021-11-18T21:04:35
|
|
cjpeg: Add -strict arg to treat warnings as fatal
This adds fault tolerance to the LZW-compressed GIF reader, which is
the only compression-side code that can throw warnings.
|
|
4c5fa566
|
2021-11-17T16:09:50
|
|
CI: Halt immediately on all sanitizer errors
|
|
d401d625
|
2021-10-27T03:39:09
|
|
PowerPC: Detect AltiVec support on FreeBSD
Recent FreeBSD/PowerPC compilers, such as Clang 11.0.x on FreeBSD 13, do
the equivalent of passing -maltivec to the compiler by default, so
run-time AltiVec detection is unnecessary. However, it becomes
necessary when using other compilers or when passing -mno-altivec to the
compiler.
Closes #552
|
|
2fd4ae7b
|
2021-10-27T14:00:15
|
|
JNI: Fix warnings/errors reported by -Xcheck:jni
- Don't check for exceptions immediately after invoking the
GetPrimitiveArrayCritical() method. That method does not throw
exceptions, and checking for them caused -Xcheck:jni to warn about
calling other JNI functions in the scope of
Get/ReleasePrimitiveArrayCritical().
- Check for exceptions immediately after invoking the
CallStaticObjectMethod() method in the PROP2ENV() macro.
- Don't use the Get/ReleasePrimitiveArrayCritical() methods for small
arrays. -Xcheck:jni didn't complain about that, but there is no
performance advantage to using those methods rather than the
Get*ArrayRegion() methods for small arrays, and using
Get*ArrayRegion() makes the code less error-prone.
- Don't release the source/destination planes arrays in the YUV methods
until after the corresponding C TurboJPEG functions have returned.
|