From 762f8b4f21716648cfaf36d63bde6bcddf2f82fa Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 5 Jul 2023 10:55:07 -0400
Subject: [PATCH 001/135] Doc: Mention that we are a JPEG ref implementation
---
README.md | 4 +++-
release/ReadMe.txt | 2 +-
release/deb-control.in | 3 ++-
release/rpm.spec.in | 3 ++-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index a1eed3df..119213f5 100644
--- a/README.md
+++ b/README.md
@@ -21,11 +21,13 @@ derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
-broader range of users and developers.
+broader range of users and developers. libjpeg-turbo is an ISO/IEC and ITU-T
+reference implementation of the JPEG standard.
More information about libjpeg-turbo can be found at
.
+
License
=======
diff --git a/release/ReadMe.txt b/release/ReadMe.txt
index 446ce46c..a71d15c2 100644
--- a/release/ReadMe.txt
+++ b/release/ReadMe.txt
@@ -2,4 +2,4 @@ libjpeg-turbo is a JPEG image codec that uses SIMD instructions to accelerate ba
libjpeg-turbo implements both the traditional libjpeg API as well as the less powerful but more straightforward TurboJPEG API. libjpeg-turbo also features colorspace extensions that allow it to compress from/decompress to 32-bit and big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java interface.
-libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and VirtualGL projects made numerous enhancements to the codec in 2009, and in early 2010, libjpeg-turbo spun off into an independent project, with the goal of making high-speed JPEG compression/decompression technology available to a broader range of users and developers.
+libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and VirtualGL projects made numerous enhancements to the codec in 2009, and in early 2010, libjpeg-turbo spun off into an independent project, with the goal of making high-speed JPEG compression/decompression technology available to a broader range of users and developers. libjpeg-turbo is an ISO/IEC and ITU-T reference implementation of the JPEG standard.
diff --git a/release/deb-control.in b/release/deb-control.in
index 72bceec4..2c2ae381 100644
--- a/release/deb-control.in
+++ b/release/deb-control.in
@@ -28,4 +28,5 @@ Description: A SIMD-accelerated JPEG codec that provides both the libjpeg and Tu
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
- broader range of users and developers.
+ broader range of users and developers. libjpeg-turbo is an ISO/IEC and ITU-T
+ reference implementation of the JPEG standard.
diff --git a/release/rpm.spec.in b/release/rpm.spec.in
index 33a36518..24872dbc 100644
--- a/release/rpm.spec.in
+++ b/release/rpm.spec.in
@@ -77,7 +77,8 @@ derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
-broader range of users and developers.
+broader range of users and developers. libjpeg-turbo is an ISO/IEC and ITU-T
+reference implementation of the JPEG standard.
#-->%prep
#-->%setup -q -n @CMAKE_PROJECT_NAME@-%{version}
From 926f1f3daf41148caa090f4476760e68f6aa2a59 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 5 Jul 2023 12:41:32 -0400
Subject: [PATCH 002/135] README.md: Include GitHub Sponsors link/button
Closes #706
---
README.md | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/README.md b/README.md
index 119213f5..5e5416af 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,21 @@ More information about libjpeg-turbo can be found at
.
+Funding
+=======
+
+libjpeg-turbo is an independent open source project, but we rely on patronage
+and funded development in order to maintain that independence. The easiest way
+to ensure that libjpeg-turbo remains community-focused and free of any one
+organization's agenda is to
+[sponsor our project through GitHub](https://github.com/sponsors/libjpeg-turbo).
+All sponsorship money goes directly toward funding the labor necessary to
+maintain libjpeg-turbo, support the user community, and implement bug fixes and
+strategically important features.
+
+[](https://github.com/sponsors/libjpeg-turbo)
+
+
License
=======
From 30c21e559d61a5060a8c4d8e235457379088327b Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 5 Jul 2023 13:51:35 -0400
Subject: [PATCH 003/135] OSS-Fuzz: Ignore tj3DecompressHeader() return val
Unlike its predecessors, tj3DecompressHeader() does not fail if passed
a JPEG image with an unknown subsampling type. This led me to believe
that it was OK for the fuzzers to abort if tj3DecompressHeader()
returned an error. However, there are apparently some malformed JPEG
images that can expose issues in libjpeg-turbo while also causing
tj3DecompressHeader() to complain about header errors. Thus, it is best
to ignore the return value of tj3DecompressHeader(), as the fuzzers in
libjpeg-turbo 2.1.x and prior did.
---
fuzz/decompress.cc | 6 ++++--
fuzz/decompress_yuv.cc | 6 ++++--
fuzz/transform.cc | 6 ++++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/fuzz/decompress.cc b/fuzz/decompress.cc
index 3db99221..eadc7342 100644
--- a/fuzz/decompress.cc
+++ b/fuzz/decompress.cc
@@ -55,8 +55,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if ((handle = tj3Init(TJINIT_DECOMPRESS)) == NULL)
goto bailout;
- if (tj3DecompressHeader(handle, data, size) < 0)
- goto bailout;
+ /* We ignore the return value of tj3DecompressHeader(), because malformed
+ JPEG images that might expose issues in libjpeg-turbo might also have
+ header errors that cause tj3DecompressHeader() to fail. */
+ tj3DecompressHeader(handle, data, size);
width = tj3Get(handle, TJPARAM_JPEGWIDTH);
height = tj3Get(handle, TJPARAM_JPEGHEIGHT);
precision = tj3Get(handle, TJPARAM_PRECISION);
diff --git a/fuzz/decompress_yuv.cc b/fuzz/decompress_yuv.cc
index fc262efe..4e869df6 100644
--- a/fuzz/decompress_yuv.cc
+++ b/fuzz/decompress_yuv.cc
@@ -55,8 +55,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if ((handle = tj3Init(TJINIT_DECOMPRESS)) == NULL)
goto bailout;
- if (tj3DecompressHeader(handle, data, size) < 0)
- goto bailout;
+ /* We ignore the return value of tj3DecompressHeader(), because malformed
+ JPEG images that might expose issues in libjpeg-turbo might also have
+ header errors that cause tj3DecompressHeader() to fail. */
+ tj3DecompressHeader(handle, data, size);
width = tj3Get(handle, TJPARAM_JPEGWIDTH);
height = tj3Get(handle, TJPARAM_JPEGHEIGHT);
jpegSubsamp = tj3Get(handle, TJPARAM_SUBSAMP);
diff --git a/fuzz/transform.cc b/fuzz/transform.cc
index 06493883..4cb58500 100644
--- a/fuzz/transform.cc
+++ b/fuzz/transform.cc
@@ -50,8 +50,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if ((handle = tj3Init(TJINIT_TRANSFORM)) == NULL)
goto bailout;
- if (tj3DecompressHeader(handle, data, size) < 0)
- goto bailout;
+ /* We ignore the return value of tj3DecompressHeader(), because malformed
+ JPEG images that might expose issues in libjpeg-turbo might also have
+ header errors that cause tj3DecompressHeader() to fail. */
+ tj3DecompressHeader(handle, data, size);
width = tj3Get(handle, TJPARAM_JPEGWIDTH);
height = tj3Get(handle, TJPARAM_JPEGHEIGHT);
jpegSubsamp = tj3Get(handle, TJPARAM_SUBSAMP);
From 895287572db62318332a78395a0c07eb86137fd8 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 5 Jul 2023 15:35:21 -0400
Subject: [PATCH 004/135] xform fuzz: Use src subsamp to calc dst buf size
Referring to
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60379
there are some specially-crafted malformed JPEG images that, when
transformed to grayscale, will exceed the worst-case transformed
grayscale JPEG image size. This is similar in nature to the issue fixed
by c8d52f1c4c7480277b91420c27b2548d4c8e9043, except that in this case,
the issue occurs regardless of the amount of metadata in the source
image. Also, the tj3Transform() function, the
Java_org_libjpegturbo_turbojpeg_TJTransformer_transform() JNI function,
and TJBench were behaving correctly in this case, because the TurboJPEG
API documentation specifies that the source image's subsampling type
should be used when computing the worst-case transformed JPEG image
size. (However, only the Java API documentation specified that. Oops.
The C API documentation now does as well.) The documented usage
mitigates the issue, and only the transform fuzzer did not adhere to
that. Thus, this was an issue with the fuzzer itself rather than an
issue with the library.
---
doc/html/group___turbo_j_p_e_g.html | 2 +-
fuzz/transform.cc | 4 ++--
turbojpeg.h | 15 ++++++++-------
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index 696af8a9..04285c25 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -3149,7 +3149,7 @@ If you choose option 1, then *jpegSize should be set to the size of
dstBufs
pointer to an array of n byte buffers. dstBufs[i] will receive a JPEG image that has been transformed using the parameters in transforms[i]. TurboJPEG has the ability to reallocate the JPEG destination buffer to accommodate the size of the transformed JPEG image. Thus, you can choose to:
pre-allocate the JPEG destination buffer with an arbitrary size using tj3Alloc() and let TurboJPEG grow the buffer as needed,
set dstBufs[i] to NULL to tell TurboJPEG to allocate the buffer for you, or
-
pre-allocate the buffer to a "worst case" size determined by calling tj3JPEGBufSize() with the transformed or cropped width and height. Under normal circumstances, this should ensure that the buffer never has to be re-allocated. (Setting TJPARAM_NOREALLOC guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded EXIF or ICC profile data) in which the transformed JPEG image will be larger than the worst-case size, and TJPARAM_NOREALLOC cannot be used in those cases.
+
pre-allocate the buffer to a "worst case" size determined by calling tj3JPEGBufSize() with the transformed or cropped width and height and the level of subsampling used in the source image. Under normal circumstances, this should ensure that the buffer never has to be re-allocated. (Setting TJPARAM_NOREALLOC guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded EXIF or ICC profile data) in which the transformed JPEG image will be larger than the worst-case size, and TJPARAM_NOREALLOC cannot be used in those cases.
If you choose option 1, then dstSizes[i] should be set to the size of your pre-allocated buffer. In any case, unless you have set TJPARAM_NOREALLOC, you should always check dstBufs[i] upon return from this function, as it may have changed.
dstSizes
pointer to an array of n size_t variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If dstBufs[i] points to a pre-allocated buffer, then dstSizes[i] should be set to the size of the buffer. Upon return, dstSizes[i] will contain the size of the transformed JPEG image (in bytes.)
diff --git a/fuzz/transform.cc b/fuzz/transform.cc
index 4cb58500..65e24a42 100644
--- a/fuzz/transform.cc
+++ b/fuzz/transform.cc
@@ -108,11 +108,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
transforms[0].options = TJXOPT_GRAY | TJXOPT_CROP | TJXOPT_COPYNONE;
dstBufs[0] =
(unsigned char *)malloc(tj3JPEGBufSize((height + 1) / 2, (width + 1) / 2,
- TJSAMP_GRAY));
+ jpegSubsamp));
if (!dstBufs[0])
goto bailout;
- maxBufSize = tj3JPEGBufSize((height + 1) / 2, (width + 1) / 2, TJSAMP_GRAY);
+ maxBufSize = tj3JPEGBufSize((height + 1) / 2, (width + 1) / 2, jpegSubsamp);
if (tj3Transform(handle, data, size, 1, dstBufs, dstSizes,
transforms) == 0) {
diff --git a/turbojpeg.h b/turbojpeg.h
index 976b98b6..12efcbc7 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -1862,13 +1862,14 @@ DLLEXPORT int tj3DecodeYUVPlanes8(tjhandle handle,
* -# set `dstBufs[i]` to NULL to tell TurboJPEG to allocate the buffer for
* you, or
* -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tj3JPEGBufSize() with the transformed or cropped width and height. Under
- * normal circumstances, this should ensure that the buffer never has to be
- * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
- * Note, however, that there are some rare cases (such as transforming images
- * with a large amount of embedded EXIF or ICC profile data) in which the
- * transformed JPEG image will be larger than the worst-case size, and
- * #TJPARAM_NOREALLOC cannot be used in those cases.
+ * #tj3JPEGBufSize() with the transformed or cropped width and height and the
+ * level of subsampling used in the source image. Under normal circumstances,
+ * this should ensure that the buffer never has to be re-allocated. (Setting
+ * #TJPARAM_NOREALLOC guarantees that it won't be.) Note, however, that there
+ * are some rare cases (such as transforming images with a large amount of
+ * embedded EXIF or ICC profile data) in which the transformed JPEG image will
+ * be larger than the worst-case size, and #TJPARAM_NOREALLOC cannot be used in
+ * those cases.
* .
* If you choose option 1, then `dstSizes[i]` should be set to the size of your
* pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
From d011622f4b5b2c3f0141e93fc3e1da6169915c18 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 6 Jul 2023 10:29:27 -0400
Subject: [PATCH 005/135] Restore xform fuzzer behavior from before c8d52f1c
The intent was for the final transform operation to be the same as the
first transform operation but without TJXOPT_COPYNONE or
TJPARAM_NOREALLOC. Unrolling the transform operations in
c8d52f1c4c7480277b91420c27b2548d4c8e9043 accidentally changed that.
---
fuzz/transform.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fuzz/transform.cc b/fuzz/transform.cc
index 65e24a42..351fa9c3 100644
--- a/fuzz/transform.cc
+++ b/fuzz/transform.cc
@@ -151,6 +151,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
transforms[0].options |= TJXOPT_OPTIMIZE;
free(dstBufs[0]);
dstBufs[0] = NULL;
+
+ transforms[0].op = TJXOP_NONE;
+ transforms[0].options = TJXOPT_PROGRESSIVE;
dstSizes[0] = 0;
tj3Set(handle, TJPARAM_NOREALLOC, 0);
From 035ea386d1b6a99a8a1e2ab57cc1fc903569136c Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 6 Jul 2023 12:04:22 -0400
Subject: [PATCH 006/135] Build: Fix regression test concurrency issues
- The example-*bit-*-decompress test must run after the
example-*bit-*-compress test, since the latter generates
testout*-example.jpg.
- Add -static to the filenames of all output files generated by the
"static" regression tests, to avoid conflicts with the "shared"
regression tests.
- Add the PID to the filenames of all files generated by the tjunittest
packed-pixel image I/O tests.
- Check the return value of MD5File() in tjunittest to avoid a segfault
if the file doesn't exist. (Prior to the fix described above, that
could occur if two instances of tjunittest ran concurrently from the
same directory with the same -bmp and -precision arguments.)
Fixes #705
---
CMakeLists.txt | 10 ++++++----
tjunittest.c | 8 ++++++--
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index efd101a0..f0b9e937 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1004,7 +1004,7 @@ foreach(libtype ${TEST_LIBTYPES})
if(sample_bits EQUAL 12)
set(tjbench tjbench12)
- set(testout testout12)
+ set(testout testout12${suffix})
set(MD5_PPM_GRAY_TILE 2f799249148b1a9d0e61fa4408f6c397)
set(MD5_PPM_420_8x8_TILE b25684e1af37be504ee3fd137757353f)
@@ -1024,7 +1024,7 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_PPM_444_TILE 2f571a032e4dbc8ef40f75219d336b0b)
else()
set(tjbench tjbench)
- set(testout testout)
+ set(testout testout${suffix})
set(MD5_PPM_GRAY_TILE 2c3b567086e6ca0c5e6d34ad8d6f6fe8)
set(MD5_PPM_420_8x8_TILE efca1bdf0226df01777137778cf986ec)
@@ -1160,7 +1160,7 @@ foreach(libtype ${TEST_LIBTYPES})
set(cjpeg cjpeg12)
set(djpeg djpeg12)
set(jpegtran jpegtran12)
- set(testout testout12)
+ set(testout testout12${suffix})
set(TESTORIG testorig12.jpg)
set(MD5_JPEG_RGB_ISLOW 9d7369207c520d37f2c1cbfcb82b2964)
@@ -1222,7 +1222,7 @@ foreach(libtype ${TEST_LIBTYPES})
set(cjpeg cjpeg)
set(djpeg djpeg)
set(jpegtran jpegtran)
- set(testout testout)
+ set(testout testout${suffix})
set(TESTORIG testorig.jpg)
set(MD5_JPEG_RGB_ISLOW 1d44a406f61da743b5fd31c0a9abdca3)
@@ -1632,6 +1632,8 @@ foreach(libtype ${TEST_LIBTYPES})
add_test(example-${sample_bits}bit-${libtype}-decompress
${CMAKE_CROSSCOMPILING_EMULATOR} example${suffix} decompress
${EXAMPLE_12BIT_ARG} ${testout}-example.jpg ${testout}-example.ppm)
+ set_tests_properties(example-${sample_bits}bit-${libtype}-decompress
+ PROPERTIES DEPENDS example-${sample_bits}bit-${libtype}-compress)
add_test(example-${sample_bits}bit-${libtype}-decompress-cmp
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_EXAMPLE_DECOMPRESS}
${testout}-example.ppm)
diff --git a/tjunittest.c b/tjunittest.c
index bbe44bb1..b033c4f1 100644
--- a/tjunittest.c
+++ b/tjunittest.c
@@ -977,8 +977,8 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf,
THROW("Could not allocate memory");
initBitmap(buf, width, pitch, height, pf, bottomUp);
- SNPRINTF(filename, 80, "test_bmp%d_%s_%d_%s.%s", precision, pixFormatStr[pf],
- align, bottomUp ? "bu" : "td", ext);
+ SNPRINTF(filename, 80, "test_bmp%d_%s_%d_%s_%d.%s", precision, pixFormatStr[pf],
+ align, bottomUp ? "bu" : "td", getpid(), ext);
if (precision == 8) {
TRY_TJ(handle, tj3SaveImage8(handle, filename, (unsigned char *)buf, width,
pitch, height, pf));
@@ -990,6 +990,10 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf,
width, pitch, height, pf));
}
md5sum = MD5File(filename, md5buf);
+ if (!md5sum) {
+ printf("\n Could not determine MD5 sum of %s\n", filename);
+ retval = -1; goto bailout;
+ }
if (strcasecmp(md5sum, md5ref))
THROW_MD5(filename, md5sum, md5ref);
From e429e379b01dde9d1d92b5bbabd2a18ee75d7eaa Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 6 Jul 2023 16:58:20 -0400
Subject: [PATCH 007/135] tjunittest.c: Use _getpid() on Windows
---
tjunittest.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tjunittest.c b/tjunittest.c
index b033c4f1..dcd5006e 100644
--- a/tjunittest.c
+++ b/tjunittest.c
@@ -46,7 +46,9 @@
#include "jconfigint.h"
#ifdef _WIN32
#include
+#include
#define random() rand()
+#define getpid() _getpid()
#else
#include
#endif
From d6914b6b1eb9be1cb4af7f42a7ccc116cbe6d297 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 24 Jul 2023 16:41:18 -0400
Subject: [PATCH 008/135] CMakeLists.txt: Fix comment buglet
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0b9e937..2ddd0f1c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -895,7 +895,7 @@ if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
set(DEFAULT_FLOATTEST8 no-fp-contract)
# else we can't really set an intelligent default for i386. The appropriate
# value could be no-fp-contract, fp-contract, 387, or msvc, depending on the
- # compiler and compiler options. We leave it to the user to set FLOATTEST
+ # compiler and compiler options. We leave it to the user to set FLOATTEST8
# manually.
endif()
else()
From 63bd71885f566dc65db9c9481fc1445f720451a7 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 25 Jul 2023 10:01:42 -0400
Subject: [PATCH 009/135] Build: Unset FLOATTEST* by default for non-x86
Because libjpeg-turbo 3.0.x now supports multiple data precisions in the
same build, the regression test system can test the 8-bit and 12-bit
floating point DCT/IDCT algorithms separately. The expected MD5 sums
for those tests are communicated to the test system using the FLOATTEST8
and FLOATTEST12 CMake variables. Whereas it is possible to
intelligently set a default value for FLOATTEST8 when building for
x86[-64] and a default value for FLOATTEST12 when building for x86-64,
it is not possible with other architectures. (Refer to #705, #709,
and #710.) Clang 14, for example, now enables FMA (fused multiply-add)
instructions by default on architectures that support them, but with
AArch64 builds, the results are not the same as when using GCC/AArch64
with FMA instructions enabled. Thus, setting FLOATTEST12=fp-contract
doesn't make the tests pass. It was already impossible to intelligently
set a default for FLOATTEST8 with i386 builds, but referring to #710,
that appears to be the case with other non-x86-64 builds as well.
Back in 1991, when Tom Lane first released libjpeg, some CPUs had
floating point units and some didn't. It could take minutes to compress
or decompress a 1-megapixel JPEG image using the "slow" integer DCT/IDCT
algorithms, and the floating point algorithms were significantly faster
on systems that had an FPU. On systems without FPUs, floating point
math was emulated and really slow, so Tom also developed "fast" integer
DCT/IDCT algorithms to speed up JPEG performance, at the expense of
accuracy, on those systems. Because of libjpeg-turbo's SIMD extensions,
the floating point algorithms are now significantly slower than the
"slow" integer algorithms without being significantly more accurate, and
the "fast" integer algorithms fail the ISO/ITU-T conformance tests
without being any faster than the "slow" integer algorithms on x86
systems. Thus, the floating point and "fast" integer algorithms are
considered legacy features.
In order for the floating point regression tests to be useful, the
results of the tests must be validated against an independent metric.
(In other words, it wouldn't be useful to use the floating point
DCT/IDCT algorithms to determine the expected results of the floating
point DCT/IDCT algorithms.) In the past, I attempted without success to
develop a low-level floating point test that would run at configure time
and determine the appropriate default value of FLOATTEST*. Barring that
approach, the only other possibilities would be:
1. Develop a test framework that compares the floating point results
with a margin of error, as TJUnitTest does. However, that effort isn't
justified unless it could also benefit non-legacy features.
2. Compare the floating point results against an expected MD5 sum, as we
currently do. However, as previously described, it isn't possible in
most cases to determine an appropriate default value for the expected
MD5 sum.
For the moment, it makes the most sense to disable the 8-bit floating
point tests by default except with x86[-64] builds and to disable the
12-bit floating point tests by default except with x86-64 builds. That
means that the floating point algorithms will still be regression tested
when performing x86[-64] builds, but other types of builds will have to
opt in to the same regression tests. Since the floating point DCT/IDCT
algorithms are unlikely to change ever again (the only reason they still
exist at all is to maintain backward compatibility with libjpeg), this
seems like a reasonable tradeoff.
---
CMakeLists.txt | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ddd0f1c..c0f46375 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -893,18 +893,11 @@ if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
set(DEFAULT_FLOATTEST8 sse)
elseif(CPU_TYPE STREQUAL "x86_64")
set(DEFAULT_FLOATTEST8 no-fp-contract)
- # else we can't really set an intelligent default for i386. The appropriate
- # value could be no-fp-contract, fp-contract, 387, or msvc, depending on the
- # compiler and compiler options. We leave it to the user to set FLOATTEST8
- # manually.
- endif()
-else()
- if((CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64") AND
- NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT MSVC)
- set(DEFAULT_FLOATTEST8 fp-contract)
- else()
- set(DEFAULT_FLOATTEST8 no-fp-contract)
endif()
+# else we can't really set an intelligent default for FLOATTEST8. The
+# appropriate value could be no-fp-contract, fp-contract, 387, or msvc,
+# depending on the compiler and compiler options. We leave it to the user to
+# set FLOATTEST8 manually.
endif()
# This causes FLOATTEST8 to reset to the default value if WITH_SIMD has
@@ -932,13 +925,10 @@ endif()
if(CPU_TYPE STREQUAL "x86_64")
set(DEFAULT_FLOATTEST12 no-fp-contract)
-elseif(NOT CPU_TYPE STREQUAL "i386")
- if((CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64") AND
- NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT MSVC)
- set(DEFAULT_FLOATTEST12 fp-contract)
- else()
- set(DEFAULT_FLOATTEST12 no-fp-contract)
- endif()
+# else we can't really set an intelligent default for FLOATTEST12. The
+# appropriate value could be no-fp-contract, fp-contract, or something else,
+# depending on the compiler and compiler options. We leave it to the user to
+# set FLOATTEST12 manually.
endif()
set(FLOATTEST12 ${DEFAULT_FLOATTEST12} CACHE STRING
From ebca79d508d424687707462675a4a5f09ab4429c Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 25 Jul 2023 16:46:07 -0400
Subject: [PATCH 010/135] xform fuzz: Test optimized baseline entropy coding
Because of d011622f4b5b2c3f0141e93fc3e1da6169915c18, optimized baseline
entropy coding wasn't actually being tested.
---
fuzz/transform.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fuzz/transform.cc b/fuzz/transform.cc
index 351fa9c3..8d2e6aca 100644
--- a/fuzz/transform.cc
+++ b/fuzz/transform.cc
@@ -105,7 +105,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
transforms[0].r.w = (height + 1) / 2;
transforms[0].r.h = (width + 1) / 2;
transforms[0].op = TJXOP_TRANSPOSE;
- transforms[0].options = TJXOPT_GRAY | TJXOPT_CROP | TJXOPT_COPYNONE;
+ transforms[0].options = TJXOPT_GRAY | TJXOPT_CROP | TJXOPT_COPYNONE |
+ TJXOPT_OPTIMIZE;
dstBufs[0] =
(unsigned char *)malloc(tj3JPEGBufSize((height + 1) / 2, (width + 1) / 2,
jpegSubsamp));
@@ -148,7 +149,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
goto bailout;
}
- transforms[0].options |= TJXOPT_OPTIMIZE;
free(dstBufs[0]);
dstBufs[0] = NULL;
From 300a344d653d4a8779706e42828d945c6a53ff9d Mon Sep 17 00:00:00 2001
From: DRC
Date: Sun, 30 Jul 2023 11:02:29 -0400
Subject: [PATCH 011/135] tjexample.c: Fix error when recompressing
(regression introduced by fc01f4673b71c0b833c59c21e8c4478a9c4bcf21)
Because of the TurboJPEG 3 API overhaul, the pure compression code path
in tjexample.c now creates a TurboJPEG compression instance prior to
calling tj3LoadImage(). However, due to an oversight, a compression
instance was no longer created in the recompression code path. Thus,
that code path attempted to reuse the TurboJPEG decompression instance,
which caused an error ("tj3Set(): TJPARAM_QUALITY is not applicable to
decompression instances.") This commit modifies tjexample.c so that the
recompression code path creates a new TurboJPEG compression instance if
one has not already been created.
Fixes #716
---
tjexample.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tjexample.c b/tjexample.c
index 947ef2fe..579ebe53 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -350,6 +350,7 @@ int main(int argc, char **argv)
pixelFormat) < 0)
THROW_TJ("decompressing JPEG image");
tj3Free(jpegBuf); jpegBuf = NULL;
+ tj3Destroy(tjInstance); tjInstance = NULL;
} else {
/* Input image is not a JPEG image. Load it into memory. */
if ((tjInstance = tj3Init(TJINIT_COMPRESS)) == NULL)
@@ -379,6 +380,8 @@ int main(int argc, char **argv)
printf(", %s subsampling, quality = %d\n", subsampName[outSubsamp],
outQual);
+ if (!tjInstance && (tjInstance = tj3Init(TJINIT_COMPRESS)) == NULL)
+ THROW_TJ("initializing compressor");
if (tj3Set(tjInstance, TJPARAM_SUBSAMP, outSubsamp) < 0)
THROW_TJ("setting TJPARAM_SUBSAMP");
if (tj3Set(tjInstance, TJPARAM_QUALITY, outQual) < 0)
From dbae59281fdc6b3a6304a40134e8576d50d662c0 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 3 Aug 2023 14:42:30 -0400
Subject: [PATCH 012/135] Fix interblock smoothing with narrow prog. JPEGs
Due to an oversight, the assignment of DC05, DC10, DC15, DC20, and DC25
(the right edge coefficients in the 5x5 interblock smoothing window) in
decompress_smooth_data() was incorrect for images exactly two MCU blocks
wide. For such images, DC04, DC09, DC14, DC19, and DC24 were assigned
values based on the last MCU column, but DC05, DC10, DC15, DC20, and
DC25 were assigned values based on the first MCU column (because
block_num + 1 was never less than last_block_column.) This commit
modifies jdcoefct.c so that, for images at least two MCU blocks wide,
DC05, DC10, DC15, DC20, and DC25 are assigned the same values as DC04,
DC09, DC14, DC19, and DC24 (respectively.) DC05, DC10, DC15, DC20, and
DC25 are then immediately overwritten for images more than two MCU
blocks wide.
Since this issue was minor and not likely obvious to an end user, the
fix is undocumented.
Fixes #700
---
jdcoefct.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/jdcoefct.c b/jdcoefct.c
index 85cbcb79..e68f6845 100644
--- a/jdcoefct.c
+++ b/jdcoefct.c
@@ -584,11 +584,11 @@ decompress_smooth_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
/* Update DC values */
if (block_num == cinfo->master->first_MCU_col[ci] &&
block_num < last_block_column) {
- DC04 = (int)prev_prev_block_row[1][0];
- DC09 = (int)prev_block_row[1][0];
- DC14 = (int)buffer_ptr[1][0];
- DC19 = (int)next_block_row[1][0];
- DC24 = (int)next_next_block_row[1][0];
+ DC04 = DC05 = (int)prev_prev_block_row[1][0];
+ DC09 = DC10 = (int)prev_block_row[1][0];
+ DC14 = DC15 = (int)buffer_ptr[1][0];
+ DC19 = DC20 = (int)next_block_row[1][0];
+ DC24 = DC25 = (int)next_next_block_row[1][0];
}
if (block_num + 1 < last_block_column) {
DC05 = (int)prev_prev_block_row[2][0];
From e17fa3a271bfc0d8ab4687f02fabb7d2c3bebd20 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 27 Jul 2023 13:11:39 -0400
Subject: [PATCH 013/135] Bump version to 3.0.1 to prepare for new commits
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c0f46375..3c3b040c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ if(CMAKE_EXECUTABLE_SUFFIX)
endif()
project(libjpeg-turbo C)
-set(VERSION 3.0.0)
+set(VERSION 3.0.1)
set(COPYRIGHT_YEAR "1991-2023")
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
From 7b844bfda67f68b7bd61a6394815b5a1628ee096 Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 28 Jul 2023 11:46:10 -0400
Subject: [PATCH 014/135] x86-64 SIMD: Use std stack frame/prologue/epilogue
This allows debuggers and profilers to reliably capture backtraces from
within the x86-64 SIMD functions.
In places where rbp was previously used to access temporary variables
(after stack alignment), we now use r15 and save/restore it accordingly.
The total amount of work is approximately the same, because the previous
code pushed the pre-alignment stack pointer to the aligned stack. The
new prologue and epilogue actually have fewer instructions.
Also note that the {un}collect_args macros now use rbp instead of rax to
access arguments passed on the stack, so we save a few instructions
there as well.
Based on:
https://github.com/alk/libjpeg-turbo/commit/debcc7c3b436467aea8d02c66a514c5099d0ad37
Closes #707
Closes #708
---
ChangeLog.md | 10 +++++++
simd/nasm/jsimdext.inc | 5 ++--
simd/x86_64/jccolext-avx2.asm | 17 ++++++-----
simd/x86_64/jccolext-sse2.asm | 17 ++++++-----
simd/x86_64/jcgryext-avx2.asm | 17 ++++++-----
simd/x86_64/jcgryext-sse2.asm | 17 ++++++-----
simd/x86_64/jchuff-sse2.asm | 56 +++++++++++++++++------------------
simd/x86_64/jcphuff-sse2.asm | 31 +++++++------------
simd/x86_64/jcsample-avx2.asm | 2 --
simd/x86_64/jcsample-sse2.asm | 2 --
simd/x86_64/jdcolext-avx2.asm | 17 ++++++-----
simd/x86_64/jdcolext-sse2.asm | 17 ++++++-----
simd/x86_64/jdmrgext-avx2.asm | 18 +++++------
simd/x86_64/jdmrgext-sse2.asm | 18 +++++------
simd/x86_64/jdsample-avx2.asm | 22 +++++++-------
simd/x86_64/jdsample-sse2.asm | 20 ++++++-------
simd/x86_64/jfdctflt-sse.asm | 17 ++++++-----
simd/x86_64/jfdctfst-sse2.asm | 17 ++++++-----
simd/x86_64/jfdctint-avx2.asm | 1 -
simd/x86_64/jfdctint-sse2.asm | 17 ++++++-----
simd/x86_64/jidctflt-sse2.asm | 17 +++++------
simd/x86_64/jidctfst-sse2.asm | 19 ++++++------
simd/x86_64/jidctint-avx2.asm | 1 -
simd/x86_64/jidctint-sse2.asm | 19 ++++++------
simd/x86_64/jidctred-sse2.asm | 20 ++++++-------
simd/x86_64/jquantf-sse2.asm | 2 --
simd/x86_64/jquanti-avx2.asm | 2 --
simd/x86_64/jquanti-sse2.asm | 2 --
simd/x86_64/jsimdcpu.asm | 4 +++
29 files changed, 209 insertions(+), 215 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index e12b6178..8bccc1aa 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,13 @@
+3.0.1
+=====
+
+### Significant changes relative to 3.0.0:
+
+1. The x86-64 SIMD functions now use a standard stack frame, prologue, and
+epilogue so that debuggers and profilers can reliably capture backtraces from
+within the functions.
+
+
3.0.0
=====
diff --git a/simd/nasm/jsimdext.inc b/simd/nasm/jsimdext.inc
index e8d50b03..bebcb200 100644
--- a/simd/nasm/jsimdext.inc
+++ b/simd/nasm/jsimdext.inc
@@ -5,6 +5,7 @@
; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
; Copyright (C) 2018, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library - version 1.02
;
@@ -397,11 +398,11 @@ const_base:
%endif
%if %1 > 4
push r14
- mov r14, [rax+48]
+ mov r14, [rbp+48]
%endif
%if %1 > 5
push r15
- mov r15, [rax+56]
+ mov r15, [rbp+56]
%endif
push rsi
push rdi
diff --git a/simd/x86_64/jccolext-avx2.asm b/simd/x86_64/jccolext-avx2.asm
index ffb527db..dd7ea398 100644
--- a/simd/x86_64/jccolext-avx2.asm
+++ b/simd/x86_64/jccolext-avx2.asm
@@ -4,6 +4,7 @@
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -33,7 +34,7 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 8
align 32
@@ -41,12 +42,12 @@
EXTN(jsimd_rgb_ycc_convert_avx2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_YMMWORD * WK_NUM)
collect_args 5
push rbx
@@ -549,8 +550,8 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
pop rbx
vzeroupper
uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jccolext-sse2.asm b/simd/x86_64/jccolext-sse2.asm
index af70ed60..bc1e8175 100644
--- a/simd/x86_64/jccolext-sse2.asm
+++ b/simd/x86_64/jccolext-sse2.asm
@@ -3,6 +3,7 @@
;
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -32,7 +33,7 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 8
align 32
@@ -40,12 +41,12 @@
EXTN(jsimd_rgb_ycc_convert_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_XMMWORD * WK_NUM)
collect_args 5
push rbx
@@ -474,8 +475,8 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
.return:
pop rbx
uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jcgryext-avx2.asm b/simd/x86_64/jcgryext-avx2.asm
index ddcc2c0a..c8c8d12a 100644
--- a/simd/x86_64/jcgryext-avx2.asm
+++ b/simd/x86_64/jcgryext-avx2.asm
@@ -4,6 +4,7 @@
; Copyright (C) 2011, 2016, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -33,7 +34,7 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 2
align 32
@@ -41,12 +42,12 @@
EXTN(jsimd_rgb_gray_convert_avx2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_YMMWORD * WK_NUM)
collect_args 5
push rbx
@@ -428,8 +429,8 @@ EXTN(jsimd_rgb_gray_convert_avx2):
pop rbx
vzeroupper
uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jcgryext-sse2.asm b/simd/x86_64/jcgryext-sse2.asm
index f1d399a6..7e5a0f2c 100644
--- a/simd/x86_64/jcgryext-sse2.asm
+++ b/simd/x86_64/jcgryext-sse2.asm
@@ -3,6 +3,7 @@
;
; Copyright (C) 2011, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -32,7 +33,7 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
@@ -40,12 +41,12 @@
EXTN(jsimd_rgb_gray_convert_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 5
push rbx
@@ -353,8 +354,8 @@ EXTN(jsimd_rgb_gray_convert_sse2):
.return:
pop rbx
uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jchuff-sse2.asm b/simd/x86_64/jchuff-sse2.asm
index 9ea6df94..a0eb9ce2 100644
--- a/simd/x86_64/jchuff-sse2.asm
+++ b/simd/x86_64/jchuff-sse2.asm
@@ -1,9 +1,10 @@
;
; jchuff-sse2.asm - Huffman entropy encoding (64-bit SSE2)
;
-; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, 2023, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -208,15 +209,15 @@ times 1 << 15 db 16
; rax - buffer
; rbx - temp
; rcx - nbits
-; rdx - block --> free_bits
+; rdx - code
; rsi - nbits_base
; rdi - t
-; rbp - code
; r8 - dctbl --> code_temp
; r9 - actbl
; r10 - state
; r11 - index
; r12 - put_buffer
+; r15 - block --> free_bits
%define buffer rax
%ifdef WIN64
@@ -231,12 +232,11 @@ times 1 << 15 db 16
%define nbitsq rcx
%define nbits ecx
%define nbitsb cl
-%define block rdx
+%define codeq rdx
+%define code edx
%define nbits_base rsi
%define t rdi
%define td edi
-%define codeq rbp
-%define code ebp
%define dctbl r8
%define actbl r9
%define state r10
@@ -244,6 +244,7 @@ times 1 << 15 db 16
%define indexd r11d
%define put_buffer r12
%define put_bufferd r12d
+%define block r15
; Step 1: Re-arrange input data according to jpeg_natural_order
; xx 01 02 03 04 05 06 07 xx 01 08 16 09 02 03 10
@@ -259,6 +260,8 @@ times 1 << 15 db 16
GLOBAL_FUNCTION(jsimd_huff_encode_one_block_sse2)
EXTN(jsimd_huff_encode_one_block_sse2):
+ push rbp
+ mov rbp, rsp
%ifdef WIN64
@@ -266,15 +269,15 @@ EXTN(jsimd_huff_encode_one_block_sse2):
; rdx = JOCTET *buffer
; r8 = JCOEFPTR block
; r9 = int last_dc_val
-; [rax+48] = c_derived_tbl *dctbl
-; [rax+56] = c_derived_tbl *actbl
+; [rbp+48] = c_derived_tbl *dctbl
+; [rbp+56] = c_derived_tbl *actbl
;X: X = code stream
mov buffer, rdx
+ push r15
mov block, r8
movups xmm3, XMMWORD [block + 0 * SIZEOF_WORD] ;D: w3 = xx 01 02 03 04 05 06 07
push rbx
- push rbp
movdqa xmm0, xmm3 ;A: w0 = xx 01 02 03 04 05 06 07
push rsi
push rdi
@@ -284,12 +287,10 @@ EXTN(jsimd_huff_encode_one_block_sse2):
movsx code, word [block] ;Z: code = block[0];
pxor xmm4, xmm4 ;A: w4[i] = 0;
sub code, r9d ;Z: code -= last_dc_val;
- mov dctbl, POINTER [rsp+6*8+4*8]
- mov actbl, POINTER [rsp+6*8+5*8]
+ mov dctbl, POINTER [rbp+48]
+ mov actbl, POINTER [rbp+56]
punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
lea nbits_base, [rel jpeg_nbits_table]
- add rsp, -DCTSIZE2 * SIZEOF_WORD
- mov t, rsp
%else
@@ -301,9 +302,10 @@ EXTN(jsimd_huff_encode_one_block_sse2):
; r9 = c_derived_tbl *actbl
;X: X = code stream
+ push r15
+ mov block, rdx
movups xmm3, XMMWORD [block + 0 * SIZEOF_WORD] ;D: w3 = xx 01 02 03 04 05 06 07
push rbx
- push rbp
movdqa xmm0, xmm3 ;A: w0 = xx 01 02 03 04 05 06 07
push r12
mov state, rdi
@@ -314,10 +316,13 @@ EXTN(jsimd_huff_encode_one_block_sse2):
pxor xmm4, xmm4 ;A: w4[i] = 0;
sub codeq, rcx ;Z: code -= last_dc_val;
punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
- lea t, [rsp - DCTSIZE2 * SIZEOF_WORD] ; use red zone for t_
%endif
+ ; Allocate stack space for t array, and realign stack.
+ add rsp, -DCTSIZE2 * SIZEOF_WORD - 8
+ mov t, rsp
+
pshuflw xmm0, xmm0, 11001001b ;A: w0 = 01 08 xx 09 02 03 10 11
pinsrw xmm0, word [block + 16 * SIZEOF_WORD], 2 ;A: w0 = 01 08 16 09 02 03 10 11
punpckhdq xmm3, xmm1 ;D: w3 = 04 05 12 13 06 07 14 15
@@ -443,9 +448,9 @@ EXTN(jsimd_huff_encode_one_block_sse2):
pinsrw xmm5, word [block + 29 * SIZEOF_WORD], 7 ;E: w5 = 42 49 56 57 50 43 36 29
; (Row 4, offset 1)
%undef block
-%define free_bitsq rdx
-%define free_bitsd edx
-%define free_bitsb dl
+%define free_bitsq r15
+%define free_bitsd r15d
+%define free_bitsb r15b
pcmpeqw xmm1, xmm0 ;F: w1[i] = (w1[i] == 0 ? -1 : 0);
shl tempq, 48 ;Z: temp <<= 48;
pxor xmm2, xmm2 ;E: w2[i] = 0;
@@ -534,12 +539,8 @@ EXTN(jsimd_huff_encode_one_block_sse2):
test index, index
jnz .BLOOP ; } while (index != 0);
.ELOOP: ; } /* index != 0 */
- sub td, esp ; t -= (WIN64: &t_[0], UNIX: &t_[64]);
-%ifdef WIN64
+ sub td, esp ; t -= &t_[0];
cmp td, (DCTSIZE2 - 2) * SIZEOF_WORD ; if (t != 62)
-%else
- cmp td, -2 * SIZEOF_WORD ; if (t != -2)
-%endif
je .EFN ; {
movzx nbits, byte [actbl + c_derived_tbl.ehufsi + 0]
; nbits = actbl->ehufsi[0];
@@ -556,18 +557,17 @@ EXTN(jsimd_huff_encode_one_block_sse2):
; state->cur.put_buffer.simd = put_buffer;
mov byte [state + working_state.cur.free_bits], free_bitsb
; state->cur.free_bits = free_bits;
-%ifdef WIN64
- sub rsp, -DCTSIZE2 * SIZEOF_WORD
+ sub rsp, -DCTSIZE2 * SIZEOF_WORD - 8
pop r12
+%ifdef WIN64
pop rdi
pop rsi
- pop rbp
pop rbx
%else
- pop r12
- pop rbp
pop rbx
%endif
+ pop r15
+ pop rbp
ret
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/simd/x86_64/jcphuff-sse2.asm b/simd/x86_64/jcphuff-sse2.asm
index 01b5c023..11db4b2d 100644
--- a/simd/x86_64/jcphuff-sse2.asm
+++ b/simd/x86_64/jcphuff-sse2.asm
@@ -3,6 +3,7 @@
; (64-bit SSE2)
;
; Copyright (C) 2016, 2018, Matthieu Darbois
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -282,16 +283,12 @@
EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [rbp - 16]
+ sub rsp, SIZEOF_XMMWORD
+ movdqa XMMWORD [rsp], ZERO
collect_args 6
- movdqa XMMWORD [rbp - 16], ZERO
-
movd AL, r13d
pxor ZERO, ZERO
mov K, LEN
@@ -384,10 +381,9 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
REDUCE0
- movdqa ZERO, XMMWORD [rbp - 16]
uncollect_args 6
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ movdqa ZERO, XMMWORD [rsp]
+ mov rsp, rbp
pop rbp
ret
@@ -450,16 +446,12 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [rbp - 16]
+ sub rsp, SIZEOF_XMMWORD
+ movdqa XMMWORD [rsp], ZERO
collect_args 6
- movdqa XMMWORD [rbp - 16], ZERO
-
xor SIGN, SIGN
xor EOB, EOB
xor KK, KK
@@ -606,10 +598,9 @@ EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
REDUCE0
mov eax, EOB
- movdqa ZERO, XMMWORD [rbp - 16]
uncollect_args 6
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ movdqa ZERO, XMMWORD [rsp]
+ mov rsp, rbp
pop rbp
ret
diff --git a/simd/x86_64/jcsample-avx2.asm b/simd/x86_64/jcsample-avx2.asm
index b32527ae..589c52bd 100644
--- a/simd/x86_64/jcsample-avx2.asm
+++ b/simd/x86_64/jcsample-avx2.asm
@@ -45,7 +45,6 @@
EXTN(jsimd_h2v1_downsample_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 6
@@ -207,7 +206,6 @@ EXTN(jsimd_h2v1_downsample_avx2):
EXTN(jsimd_h2v2_downsample_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 6
diff --git a/simd/x86_64/jcsample-sse2.asm b/simd/x86_64/jcsample-sse2.asm
index 2fcfe456..7a4f1bc3 100644
--- a/simd/x86_64/jcsample-sse2.asm
+++ b/simd/x86_64/jcsample-sse2.asm
@@ -44,7 +44,6 @@
EXTN(jsimd_h2v1_downsample_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 6
@@ -189,7 +188,6 @@ EXTN(jsimd_h2v1_downsample_sse2):
EXTN(jsimd_h2v2_downsample_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 6
diff --git a/simd/x86_64/jdcolext-avx2.asm b/simd/x86_64/jdcolext-avx2.asm
index 2370fda6..070436c2 100644
--- a/simd/x86_64/jdcolext-avx2.asm
+++ b/simd/x86_64/jdcolext-avx2.asm
@@ -5,6 +5,7 @@
; Copyright (C) 2009, 2012, 2016, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -34,7 +35,7 @@
; r13 = JSAMPARRAY output_buf
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 2
align 32
@@ -42,12 +43,12 @@
EXTN(jsimd_ycc_rgb_convert_avx2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (WK_NUM * SIZEOF_YMMWORD)
collect_args 5
push rbx
@@ -486,8 +487,8 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
pop rbx
vzeroupper
uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jdcolext-sse2.asm b/simd/x86_64/jdcolext-sse2.asm
index e07c8d75..bba3a30c 100644
--- a/simd/x86_64/jdcolext-sse2.asm
+++ b/simd/x86_64/jdcolext-sse2.asm
@@ -4,6 +4,7 @@
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2012, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -33,7 +34,7 @@
; r13 = JSAMPARRAY output_buf
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
@@ -41,12 +42,12 @@
EXTN(jsimd_ycc_rgb_convert_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 5
push rbx
@@ -429,8 +430,8 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
.return:
pop rbx
uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jdmrgext-avx2.asm b/simd/x86_64/jdmrgext-avx2.asm
index 8b264b4f..11916455 100644
--- a/simd/x86_64/jdmrgext-avx2.asm
+++ b/simd/x86_64/jdmrgext-avx2.asm
@@ -5,6 +5,7 @@
; Copyright (C) 2009, 2012, 2016, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -34,7 +35,7 @@
; r12d = JDIMENSION in_row_group_ctr
; r13 = JSAMPARRAY output_buf
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 3
align 32
@@ -42,12 +43,12 @@
EXTN(jsimd_h2v1_merged_upsample_avx2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, SIZEOF_YMMWORD * WK_NUM
collect_args 4
push rbx
@@ -480,8 +481,8 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
pop rbx
vzeroupper
uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -506,7 +507,6 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
EXTN(jsimd_h2v2_merged_upsample_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
push rbx
diff --git a/simd/x86_64/jdmrgext-sse2.asm b/simd/x86_64/jdmrgext-sse2.asm
index eb3ab9db..8988dd0b 100644
--- a/simd/x86_64/jdmrgext-sse2.asm
+++ b/simd/x86_64/jdmrgext-sse2.asm
@@ -4,6 +4,7 @@
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2012, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -33,7 +34,7 @@
; r12d = JDIMENSION in_row_group_ctr
; r13 = JSAMPARRAY output_buf
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 3
align 32
@@ -41,12 +42,12 @@
EXTN(jsimd_h2v1_merged_upsample_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 4
push rbx
@@ -422,8 +423,8 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
.return:
pop rbx
uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -448,7 +449,6 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
EXTN(jsimd_h2v2_merged_upsample_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
push rbx
diff --git a/simd/x86_64/jdsample-avx2.asm b/simd/x86_64/jdsample-avx2.asm
index 1e4979f9..c6ddbb5e 100644
--- a/simd/x86_64/jdsample-avx2.asm
+++ b/simd/x86_64/jdsample-avx2.asm
@@ -5,6 +5,7 @@
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -62,7 +63,6 @@ PW_EIGHT times 16 dw 8
EXTN(jsimd_h2v1_fancy_upsample_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
push_xmm 3
collect_args 4
@@ -208,7 +208,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
; r12 = JSAMPARRAY input_data
; r13 = JSAMPARRAY *output_data_ptr
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 4
align 32
@@ -216,12 +216,12 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
EXTN(jsimd_h2v2_fancy_upsample_avx2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ mov rbp, rsp
+ push r15
+ and rsp, byte (-SIZEOF_YMMWORD) ; align to 128 bits
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_YMMWORD * WK_NUM)
push_xmm 3
collect_args 4
push rbx
@@ -500,8 +500,8 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vzeroupper
uncollect_args 4
pop_xmm 3
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -525,7 +525,6 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
EXTN(jsimd_h2v1_upsample_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
@@ -614,7 +613,6 @@ EXTN(jsimd_h2v1_upsample_avx2):
EXTN(jsimd_h2v2_upsample_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
push rbx
diff --git a/simd/x86_64/jdsample-sse2.asm b/simd/x86_64/jdsample-sse2.asm
index 38dbceec..24cd3896 100644
--- a/simd/x86_64/jdsample-sse2.asm
+++ b/simd/x86_64/jdsample-sse2.asm
@@ -4,6 +4,7 @@
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -61,7 +62,6 @@ PW_EIGHT times 8 dw 8
EXTN(jsimd_h2v1_fancy_upsample_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
@@ -195,7 +195,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
; r12 = JSAMPARRAY input_data
; r13 = JSAMPARRAY *output_data_ptr
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 4
align 32
@@ -203,12 +203,12 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
EXTN(jsimd_h2v2_fancy_upsample_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 4
push rbx
@@ -473,8 +473,8 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
.return:
pop rbx
uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -498,7 +498,6 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
EXTN(jsimd_h2v1_upsample_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
@@ -585,7 +584,6 @@ EXTN(jsimd_h2v1_upsample_sse2):
EXTN(jsimd_h2v2_upsample_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
push rbx
diff --git a/simd/x86_64/jfdctflt-sse.asm b/simd/x86_64/jfdctflt-sse.asm
index ef279664..35954964 100644
--- a/simd/x86_64/jfdctflt-sse.asm
+++ b/simd/x86_64/jfdctflt-sse.asm
@@ -3,6 +3,7 @@
;
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -58,7 +59,7 @@ PD_1_306 times 4 dd 1.306562964876376527856643
; r10 = FAST_FLOAT *data
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
@@ -66,12 +67,12 @@ PD_1_306 times 4 dd 1.306562964876376527856643
EXTN(jsimd_fdct_float_sse):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 1
; ---- Pass 1: process rows.
@@ -345,8 +346,8 @@ EXTN(jsimd_fdct_float_sse):
jnz near .columnloop
uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jfdctfst-sse2.asm b/simd/x86_64/jfdctfst-sse2.asm
index 2e1bfe6e..d33c58a4 100644
--- a/simd/x86_64/jfdctfst-sse2.asm
+++ b/simd/x86_64/jfdctfst-sse2.asm
@@ -3,6 +3,7 @@
;
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -73,7 +74,7 @@ PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
; r10 = DCTELEM *data
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
@@ -81,12 +82,12 @@ PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
EXTN(jsimd_fdct_ifast_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 1
; ---- Pass 1: process rows.
@@ -379,8 +380,8 @@ EXTN(jsimd_fdct_ifast_sse2):
movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm2
uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jfdctint-avx2.asm b/simd/x86_64/jfdctint-avx2.asm
index e56258b4..d0afe5e8 100644
--- a/simd/x86_64/jfdctint-avx2.asm
+++ b/simd/x86_64/jfdctint-avx2.asm
@@ -261,7 +261,6 @@ PW_1_NEG1 times 8 dw 1
EXTN(jsimd_fdct_islow_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 1
diff --git a/simd/x86_64/jfdctint-sse2.asm b/simd/x86_64/jfdctint-sse2.asm
index ec1f383c..024ce900 100644
--- a/simd/x86_64/jfdctint-sse2.asm
+++ b/simd/x86_64/jfdctint-sse2.asm
@@ -3,6 +3,7 @@
;
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, 2020, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -94,7 +95,7 @@ PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
; r10 = DCTELEM *data
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 6
align 32
@@ -102,12 +103,12 @@ PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
EXTN(jsimd_fdct_islow_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 1
; ---- Pass 1: process rows.
@@ -609,8 +610,8 @@ EXTN(jsimd_fdct_islow_sse2):
movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm3
uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jidctflt-sse2.asm b/simd/x86_64/jidctflt-sse2.asm
index 60bf9618..952fbe30 100644
--- a/simd/x86_64/jidctflt-sse2.asm
+++ b/simd/x86_64/jidctflt-sse2.asm
@@ -4,6 +4,7 @@
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -65,8 +66,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
%define workspace wk(0) - DCTSIZE2 * SIZEOF_FAST_FLOAT
@@ -77,11 +77,11 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
EXTN(jsimd_idct_float_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
lea rsp, [workspace]
collect_args 4
push rbx
@@ -322,7 +322,6 @@ EXTN(jsimd_idct_float_sse2):
; ---- Pass 2: process rows from work array, store into output array.
- mov rax, [original_rbp]
lea rsi, [workspace] ; FAST_FLOAT *wsptr
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -472,8 +471,8 @@ EXTN(jsimd_idct_float_sse2):
pop rbx
uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jidctfst-sse2.asm b/simd/x86_64/jidctfst-sse2.asm
index cb97fdfb..a3da8d87 100644
--- a/simd/x86_64/jidctfst-sse2.asm
+++ b/simd/x86_64/jidctfst-sse2.asm
@@ -4,6 +4,7 @@
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -86,8 +87,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
@@ -96,12 +96,12 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
EXTN(jsimd_idct_ifast_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 4
; ---- Pass 1: process columns from input.
@@ -320,7 +320,6 @@ EXTN(jsimd_idct_ifast_sse2):
; ---- Pass 2: process rows from work array, store into output array.
- mov rax, [original_rbp]
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -480,8 +479,8 @@ EXTN(jsimd_idct_ifast_sse2):
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2
uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
ret
diff --git a/simd/x86_64/jidctint-avx2.asm b/simd/x86_64/jidctint-avx2.asm
index ca7e317f..528da012 100644
--- a/simd/x86_64/jidctint-avx2.asm
+++ b/simd/x86_64/jidctint-avx2.asm
@@ -283,7 +283,6 @@ PW_1_NEG1 times 8 dw 1
EXTN(jsimd_idct_islow_avx2):
push rbp
- mov rax, rsp ; rax = original rbp
mov rbp, rsp ; rbp = aligned rbp
push_xmm 4
collect_args 4
diff --git a/simd/x86_64/jidctint-sse2.asm b/simd/x86_64/jidctint-sse2.asm
index 7aa869bc..92f633e9 100644
--- a/simd/x86_64/jidctint-sse2.asm
+++ b/simd/x86_64/jidctint-sse2.asm
@@ -4,6 +4,7 @@
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, 2020, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -99,8 +100,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 12
@@ -109,12 +109,12 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
EXTN(jsimd_idct_islow_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_XMMWORD * WK_NUM)
collect_args 4
; ---- Pass 1: process columns from input.
@@ -512,7 +512,6 @@ EXTN(jsimd_idct_islow_sse2):
; ---- Pass 2: process rows from work array, store into output array.
- mov rax, [original_rbp]
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -837,8 +836,8 @@ EXTN(jsimd_idct_islow_sse2):
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm5
uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/simd/x86_64/jidctred-sse2.asm b/simd/x86_64/jidctred-sse2.asm
index 4ece9d89..1ec500c9 100644
--- a/simd/x86_64/jidctred-sse2.asm
+++ b/simd/x86_64/jidctred-sse2.asm
@@ -4,6 +4,7 @@
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -107,8 +108,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
@@ -117,12 +117,12 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
EXTN(jsimd_idct_4x4_sse2):
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
collect_args 4
; ---- Pass 1: process columns from input.
@@ -309,7 +309,6 @@ EXTN(jsimd_idct_4x4_sse2):
; ---- Pass 2: process rows, store into output array.
- mov rax, [original_rbp]
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -390,8 +389,8 @@ EXTN(jsimd_idct_4x4_sse2):
movd XMM_DWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -415,7 +414,6 @@ EXTN(jsimd_idct_4x4_sse2):
EXTN(jsimd_idct_2x2_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 4
push rbx
diff --git a/simd/x86_64/jquantf-sse2.asm b/simd/x86_64/jquantf-sse2.asm
index ab2e3954..232bbb2d 100644
--- a/simd/x86_64/jquantf-sse2.asm
+++ b/simd/x86_64/jquantf-sse2.asm
@@ -38,7 +38,6 @@
EXTN(jsimd_convsamp_float_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 3
push rbx
@@ -111,7 +110,6 @@ EXTN(jsimd_convsamp_float_sse2):
EXTN(jsimd_quantize_float_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 3
diff --git a/simd/x86_64/jquanti-avx2.asm b/simd/x86_64/jquanti-avx2.asm
index 70fe8113..66104d7d 100644
--- a/simd/x86_64/jquanti-avx2.asm
+++ b/simd/x86_64/jquanti-avx2.asm
@@ -39,7 +39,6 @@
EXTN(jsimd_convsamp_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 3
@@ -117,7 +116,6 @@ EXTN(jsimd_convsamp_avx2):
EXTN(jsimd_quantize_avx2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 3
diff --git a/simd/x86_64/jquanti-sse2.asm b/simd/x86_64/jquanti-sse2.asm
index 3ee44202..11e9f4c4 100644
--- a/simd/x86_64/jquanti-sse2.asm
+++ b/simd/x86_64/jquanti-sse2.asm
@@ -38,7 +38,6 @@
EXTN(jsimd_convsamp_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 3
push rbx
@@ -117,7 +116,6 @@ EXTN(jsimd_convsamp_sse2):
EXTN(jsimd_quantize_sse2):
push rbp
- mov rax, rsp
mov rbp, rsp
collect_args 3
diff --git a/simd/x86_64/jsimdcpu.asm b/simd/x86_64/jsimdcpu.asm
index 705f813d..251bc4cd 100644
--- a/simd/x86_64/jsimdcpu.asm
+++ b/simd/x86_64/jsimdcpu.asm
@@ -3,6 +3,7 @@
;
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on
; x86 SIMD extension for IJG JPEG library
@@ -31,6 +32,8 @@
GLOBAL_FUNCTION(jpeg_simd_cpu_support)
EXTN(jpeg_simd_cpu_support):
+ push rbp
+ mov rbp, rsp
push rbx
push rdi
@@ -79,6 +82,7 @@ EXTN(jpeg_simd_cpu_support):
pop rdi
pop rbx
+ pop rbp
ret
; For some reason, the OS X linker does not honor the request to align the
From 9b704f96b2dccc54363ad7a2fe8e378fc1a2893b Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 15 Aug 2023 11:03:57 -0400
Subject: [PATCH 015/135] Fix block smoothing w/vert.-subsampled prog. JPEGs
The 5x5 interblock smoothing implementation, introduced in libjpeg-turbo
2.1, improperly extended the logic from the traditional 3x3 smoothing
implementation. Both implementations point prev_block_row and
next_block_row to the current block row when processing, respectively,
the first and the last block row in the image:
if (block_row > 0 || cinfo->output_iMCU_row > 0)
prev_block_row =
buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
else
prev_block_row = buffer_ptr;
if (block_row < block_rows - 1 ||
cinfo->output_iMCU_row < last_iMCU_row)
next_block_row =
buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
else
next_block_row = buffer_ptr;
6d91e950c871103a11bac2f10c63bf998796c719 naively extended that logic to
accommodate a 5x5 smoothing window:
if (block_row > 1 || cinfo->output_iMCU_row > 1)
prev_prev_block_row =
buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
else
prev_prev_block_row = prev_block_row;
if (block_row < block_rows - 2 ||
cinfo->output_iMCU_row + 1 < last_iMCU_row)
next_next_block_row =
buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
else
next_next_block_row = next_block_row;
However, this new logic was only correct if block_rows == 1, so the
values of prev_prev_block_row and next_next_block_row were incorrect
when processing, respectively, the second and second to last iMCU rows
in a vertically-subsampled progressive JPEG image.
The intent was to:
- point prev_block_row to the current block row when processing the
first block row in the image,
- point prev_prev_block_row to prev_block_row when processing the first
two block rows in the image,
- point next_block_row to the current block row when processing the
last block row in the image, and
- point next_next_block_row to next_block_row when processing the last
two block rows in the image.
This commit modifies decompress_smooth_data() so that it computes the
current block row's position relative to the whole image and sets
the block row pointers based on that value.
This commit also restores a line of code that was accidentally deleted
by 6d91e950c871103a11bac2f10c63bf998796c719:
access_rows += compptr->v_samp_factor; /* prior iMCU row too */
access_rows is merely a sanity check that tells the access_virt_barray()
method to generate an error if accessing the specified number of rows
would cause a buffer overrun. Essentially, it is a belt-and-suspenders
measure to ensure that j*init_d_coef_controller() allocated enough rows
for the full-image virtual array. Thus, excluding that line of code did
not cause an observable issue.
This commit also documents dbae59281fdc6b3a6304a40134e8576d50d662c0 in
the change log.
Fixes #721
---
ChangeLog.md | 5 +++++
jdcoefct.c | 17 ++++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 8bccc1aa..2f3ebd54 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -7,6 +7,11 @@
epilogue so that debuggers and profilers can reliably capture backtraces from
within the functions.
+2. Fixed two minor issues in the interblock smoothing algorithm that caused
+mathematical (but not necessarily perceptible) edge block errors when
+decompressing progressive JPEG images exactly two MCU blocks in width or that
+use vertical chrominance subsampling.
+
3.0.0
=====
diff --git a/jdcoefct.c b/jdcoefct.c
index e68f6845..40ce2725 100644
--- a/jdcoefct.c
+++ b/jdcoefct.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman for Cendio AB
- * Copyright (C) 2010, 2015-2016, 2019-2020, 2022, D. R. Commander.
+ * Copyright (C) 2010, 2015-2016, 2019-2020, 2022-2023, D. R. Commander.
* Copyright (C) 2015, 2020, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -431,7 +431,8 @@ decompress_smooth_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
JDIMENSION block_num, last_block_column;
- int ci, block_row, block_rows, access_rows;
+ int ci, block_row, block_rows, access_rows, image_block_row,
+ image_block_rows;
JBLOCKARRAY buffer;
JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
JBLOCKROW next_block_row, next_next_block_row;
@@ -497,6 +498,7 @@ decompress_smooth_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
(JDIMENSION)access_rows, FALSE);
buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
} else if (cinfo->output_iMCU_row > 0) {
+ access_rows += compptr->v_samp_factor; /* prior iMCU row too */
buffer = (*cinfo->mem->access_virt_barray)
((j_common_ptr)cinfo, coef->whole_image[ci],
(cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
@@ -539,29 +541,30 @@ decompress_smooth_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
inverse_DCT = cinfo->idct->_inverse_DCT[ci];
output_ptr = output_buf[ci];
/* Loop over all DCT blocks to be processed. */
+ image_block_rows = block_rows * cinfo->total_iMCU_rows;
for (block_row = 0; block_row < block_rows; block_row++) {
+ image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
- if (block_row > 0 || cinfo->output_iMCU_row > 0)
+ if (image_block_row > 0)
prev_block_row =
buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
else
prev_block_row = buffer_ptr;
- if (block_row > 1 || cinfo->output_iMCU_row > 1)
+ if (image_block_row > 1)
prev_prev_block_row =
buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
else
prev_prev_block_row = prev_block_row;
- if (block_row < block_rows - 1 || cinfo->output_iMCU_row < last_iMCU_row)
+ if (image_block_row < image_block_rows - 1)
next_block_row =
buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
else
next_block_row = buffer_ptr;
- if (block_row < block_rows - 2 ||
- cinfo->output_iMCU_row + 1 < last_iMCU_row)
+ if (image_block_row < image_block_rows - 2)
next_next_block_row =
buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
else
From f3c7116eaf3eed9af081150a4a3353f105c15389 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 11 Sep 2023 12:46:13 -0400
Subject: [PATCH 016/135] jpeglib.h: Document that JCS_RGB565 is decomp-only
Closes #723
---
jpeglib.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/jpeglib.h b/jpeglib.h
index 8c813097..a59e98c2 100644
--- a/jpeglib.h
+++ b/jpeglib.h
@@ -7,7 +7,8 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, 2022, D. R. Commander.
+ * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, 2022-2023,
+ D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -270,7 +271,8 @@ typedef enum {
JCS_EXT_BGRA, /* blue/green/red/alpha */
JCS_EXT_ABGR, /* alpha/blue/green/red */
JCS_EXT_ARGB, /* alpha/red/green/blue */
- JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
+ JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue
+ [decompression only] */
} J_COLOR_SPACE;
/* DCT/IDCT algorithm options. */
From c0412b56d66b287817009afca7c105feb674cd7c Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 14 Sep 2023 17:19:36 -0400
Subject: [PATCH 017/135] ChangeLog.md: List CVE ID fixed by ccaba5d7
Closes #724
---
ChangeLog.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 2f3ebd54..ad0dc95b 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -413,9 +413,9 @@ transform a specially-crafted malformed JPEG image.
### Significant changes relative to 2.1 beta1:
-1. Fixed a regression introduced by 2.1 beta1[6(b)] whereby attempting to
-decompress certain progressive JPEG images with one or more component planes of
-width 8 or less caused a buffer overrun.
+1. Fixed a regression (CVE-2021-29390) introduced by 2.1 beta1[6(b)] whereby
+attempting to decompress certain progressive JPEG images with one or more
+component planes of width 8 or less caused a buffer overrun.
2. Fixed a regression introduced by 2.1 beta1[6(b)] whereby attempting to
decompress a specially-crafted malformed progressive JPEG image caused the
From 47656a082091f9c9efda054674522513f4768c6c Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 2 Oct 2023 18:03:50 -0400
Subject: [PATCH 018/135] Test: Fix float test errors w/ Clang & fp-contract
The MD5 sums associated with FLOATTEST8=fp-contract and
FLOATTEST12=fp-contract are appropriate for GCC (tested v5 through v13)
with -ffp-contract=fast, which is the default when compiling for an
architecture that has fused multiply-add (FMA) instructions. However,
different MD5 sums are needed for Clang (tested v5 through v14) with
-ffp-contract=on, which is now the default in Clang 14 when compiling
for an architecture that has FMA instructions.
Refer to #705, #709, #710
---
CMakeLists.txt | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c3b040c..deb948fa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -874,14 +874,14 @@ endif()
# extensions
# no-fp-contract = validate against the expected results from the C code when
# floating point expression contraction is disabled (the
-# default with Clang, with GCC when building for platforms
-# that lack fused multiply-add [FMA] instructions, or when
-# passing -ffp-contract=off to the compiler)
+# default with Clang 13 and earlier, when building for
+# platforms that lack fused multiply-add [FMA] instructions,
+# or when passing -ffp-contract=off to GCC or Clang)
# fp-contract = validate against the expected results from the C code when
# floating point expression contraction is enabled (the default
-# with GCC when building for platforms that have fused multiply-
-# add [FMA] instructions or when passing -ffp-contract=fast to
-# the compiler)
+# with Clang 14 and later, with GCC when building for platforms
+# that have fused multiply-add [FMA] instructions, or when
+# passing -ffp-contract=fast to GCC or -ffp-contract=on to Clang)
# 387 = validate against the expected results from the C code when the 387 FPU
# is being used for floating point math (which is generally the default
# with x86 compilers)
@@ -1176,7 +1176,11 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_SSE})
set(MD5_JPEG_3x2_FLOAT_PROG_FP_CONTRACT
${MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT})
- set(MD5_PPM_3x2_FLOAT_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_SSE})
+ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set(MD5_PPM_3x2_FLOAT_FP_CONTRACT 2da9de6ae869e88b8372de815d366b03)
+ else()
+ set(MD5_PPM_3x2_FLOAT_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_SSE})
+ endif()
set(MD5_JPEG_3x2_FLOAT_PROG_387 bc6dbbefac2872f6b9d6c4a0ae60c3c0)
set(MD5_PPM_3x2_FLOAT_387 bcc5723c61560463ac60f772e742d092)
set(MD5_JPEG_3x2_FLOAT_PROG_MSVC e27840755870fa849872e58aa0cd1400)
@@ -1244,7 +1248,11 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT f6bfab038438ed8f5522fbd33595dcdc)
set(MD5_JPEG_3x2_FLOAT_PROG_FP_CONTRACT
${MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT})
- set(MD5_PPM_3x2_FLOAT_FP_CONTRACT 0e917a34193ef976b679a6b069b1be26)
+ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set(MD5_PPM_3x2_FLOAT_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT})
+ else()
+ set(MD5_PPM_3x2_FLOAT_FP_CONTRACT 0e917a34193ef976b679a6b069b1be26)
+ endif()
set(MD5_JPEG_3x2_FLOAT_PROG_387 1657664a410e0822c924b54f6f65e6e9)
set(MD5_PPM_3x2_FLOAT_387 cb0a1f027f3d2917c902b5640214e025)
set(MD5_JPEG_3x2_FLOAT_PROG_MSVC 7999ce9cd0ee9b6c7043b7351ab7639d)
From 2c97a1ff07ccffe7c4b6bc96c7a94afbc32c3575 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 3 Oct 2023 12:07:40 -0400
Subject: [PATCH 019/135] GitHub: Use Ubuntu 20.04 runner for x32 build/test
The Ubuntu 22.04 kernel no longer supports the x32 ABI.
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d0888706..5633792b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -110,7 +110,7 @@ jobs:
JSIMD_FORCENONE=1 make test
popd
linux-jpeg7-x32:
- runs-on: ubuntu-latest
+ runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
From 3d1d68cf967aec4aba34cd51e89a13fc2f0f3d9b Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 4 Oct 2023 13:20:38 -0400
Subject: [PATCH 020/135] README.md: Mention 4:4:0 math. incomp. vs. jpeg-6b
libjpeg-turbo implements 4:4:0 "fancy" (smooth) upsampling, which is
enabled by default when decompressing JPEG images that use 4:4:0
chrominance subsampling. libjpeg did not and does not implement fancy
4:4:0 upsampling.
---
README.md | 47 ++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/README.md b/README.md
index 5e5416af..923e61d2 100644
--- a/README.md
+++ b/README.md
@@ -283,30 +283,35 @@ Mathematical Compatibility
==========================
For the most part, libjpeg-turbo should produce identical output to libjpeg
-v6b. The one exception to this is when using the floating point DCT/IDCT, in
-which case the outputs of libjpeg v6b and libjpeg-turbo can differ for the
-following reasons:
+v6b. There are two exceptions:
-- The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever so
- slightly more accurate than the implementation in libjpeg v6b, but not by
- any amount perceptible to human vision (generally in the range of 0.01 to
- 0.08 dB gain in PNSR.)
+1. When decompressing a JPEG image that uses 4:4:0 chrominance subsampling, the
+outputs of libjpeg v6b and libjpeg-turbo can differ because libjpeg-turbo
+implements a "fancy" (smooth) 4:4:0 upsampling algorithm and libjpeg did not.
-- When not using the SIMD extensions, libjpeg-turbo uses the more accurate
- (and slightly faster) floating point IDCT algorithm introduced in libjpeg
- v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
- however, that this algorithm basically brings the accuracy of the floating
- point IDCT in line with the accuracy of the accurate integer IDCT. The
- floating point DCT/IDCT algorithms are mainly a legacy feature, and they do
- not produce significantly more accuracy than the accurate integer algorithms
- (to put numbers on this, the typical difference in PNSR between the two
- algorithms is less than 0.10 dB, whereas changing the quality level by 1 in
- the upper range of the quality scale is typically more like a 1.0 dB
- difference.)
+2. When using the floating point DCT/IDCT, the outputs of libjpeg v6b and
+libjpeg-turbo can differ for the following reasons:
-- If the floating point algorithms in libjpeg-turbo are not implemented using
- SIMD instructions on a particular platform, then the accuracy of the
- floating point DCT/IDCT can depend on the compiler settings.
+ - The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever
+ so slightly more accurate than the implementation in libjpeg v6b, but not
+ by any amount perceptible to human vision (generally in the range of 0.01
+ to 0.08 dB gain in PNSR.)
+
+ - When not using the SIMD extensions, libjpeg-turbo uses the more accurate
+ (and slightly faster) floating point IDCT algorithm introduced in libjpeg
+ v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
+ however, that this algorithm basically brings the accuracy of the
+ floating point IDCT in line with the accuracy of the accurate integer
+ IDCT. The floating point DCT/IDCT algorithms are mainly a legacy
+ feature, and they do not produce significantly more accuracy than the
+ accurate integer algorithms. (To put numbers on this, the typical
+ difference in PNSR between the two algorithms is less than 0.10 dB,
+ whereas changing the quality level by 1 in the upper range of the quality
+ scale is typically more like a 1.0 dB difference.)
+
+ - If the floating point algorithms in libjpeg-turbo are not implemented
+ using SIMD instructions on a particular platform, then the accuracy of
+ the floating point DCT/IDCT can depend on the compiler settings.
While libjpeg-turbo does emulate the libjpeg v8 API/ABI, under the hood it is
still using the same algorithms as libjpeg v6b, so there are several specific
From da48edfc49508574d844fa14f91de89b79e5a5ce Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 9 Oct 2023 14:13:55 -0400
Subject: [PATCH 021/135] jchuff.c: Fix uninit read w/ AArch64, WITH_SIMD=0
Because of bf01ed2fbc02c15e86f414ff4946b66b4e5a00f1, the simd field in
huff_entropy_encoder (and, by extension, the simd field in
savable_state) is only initialized if WITH_SIMD is defined. Due to an
oversight, the simd field in savable_state was queried in flush_bits()
regardless of whether WITH_SIMD was defined. In most cases, both
branches of the query have identical code, and the optimizer removes the
branch. However, because the legacy Neon GAS Huffman encoder uses the
older bit buffer logic from libjpeg-turbo 2.0.x and prior (refer to
087c29e07f7533ec82fd7eb1dafc84c29e7870ec), the branches do not have
identical code when building for AArch64 with NEON_INTRINSICS undefined
(which will be the case if WITH_SIMD is undefined.) Thus, if
libjpeg-turbo was built for AArch64 with the SIMD extensions disabled
at build time, it was possible for the Neon GAS branch in flush_bits()
to be taken, which would have set put_bits to a value that is incorrect
for the C Huffman encoder. Referring to #728, a user reported that this
issue sometimes caused libjpeg-turbo to generate bogus JPEG images if it
was built for AArch64 without SIMD extensions and subsequently used
through the Qt framework. (It should be noted, however, that disabling
the SIMD extensions in AArch64 builds of libjpeg-turbo is inadvisable
for performance reasons.)
I was unable to reproduce the issue on Linux/AArch64 using libjpeg-turbo
alone, despite testing various versions of GCC and Clang and various
optimization levels. However, the issue is reproducible using MSan with
-O0, so this commit also modifies the GitHub Actions workflow so that
compiler optimization is disabled in the linux-msan job. That should
prevent the issue or similar issues from re-emerging.
Fixes #728
---
.github/workflows/build.yml | 2 +-
ChangeLog.md | 6 ++++++
jchuff.c | 20 ++++++++++++++++++--
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5633792b..22b6607e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -169,7 +169,7 @@ jobs:
run: |
mkdir build
pushd build
- cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O3 -g -fsanitize=memory -fno-sanitize-recover=all -fPIE" -DWITH_SIMD=0 ..
+ cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O0 -g -fsanitize=memory -fno-sanitize-recover=all -fPIE" -DWITH_SIMD=0 ..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
make test
diff --git a/ChangeLog.md b/ChangeLog.md
index ad0dc95b..a4667851 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -12,6 +12,12 @@ mathematical (but not necessarily perceptible) edge block errors when
decompressing progressive JPEG images exactly two MCU blocks in width or that
use vertical chrominance subsampling.
+3. Fixed a regression introduced by 3.0 beta2[6] that, in rare cases, caused
+the C Huffman encoder (which is not used by default on x86 and Arm CPUs) to
+generate incorrect results if the Neon SIMD extensions were explicitly disabled
+at build time (by setting the `WITH_SIMD` CMake variable to `0`) in an AArch64
+build of libjpeg-turbo.
+
3.0.0
=====
diff --git a/jchuff.c b/jchuff.c
index b879506d..3fede05f 100644
--- a/jchuff.c
+++ b/jchuff.c
@@ -108,7 +108,9 @@ typedef bit_buf_type simd_bit_buf_type;
typedef struct {
union {
bit_buf_type c;
+#ifdef WITH_SIMD
simd_bit_buf_type simd;
+#endif
} put_buffer; /* current bit accumulation buffer */
int free_bits; /* # of bits available in it */
/* (Neon GAS: # of bits now in it) */
@@ -133,7 +135,9 @@ typedef struct {
long *ac_count_ptrs[NUM_HUFF_TBLS];
#endif
+#ifdef WITH_SIMD
int simd;
+#endif
} huff_entropy_encoder;
typedef huff_entropy_encoder *huff_entropy_ptr;
@@ -147,7 +151,9 @@ typedef struct {
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
savable_state cur; /* Current bit buffer & DC state */
j_compress_ptr cinfo; /* dump_buffer needs access to this */
+#ifdef WITH_SIMD
int simd;
+#endif
} working_state;
@@ -511,6 +517,7 @@ flush_bits(working_state *state)
simd_bit_buf_type put_buffer; int put_bits;
int localbuf = 0;
+#ifdef WITH_SIMD
if (state->simd) {
#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
put_bits = state->cur.free_bits;
@@ -518,7 +525,9 @@ flush_bits(working_state *state)
put_bits = SIMD_BIT_BUF_SIZE - state->cur.free_bits;
#endif
put_buffer = state->cur.put_buffer.simd;
- } else {
+ } else
+#endif
+ {
put_bits = BIT_BUF_SIZE - state->cur.free_bits;
put_buffer = state->cur.put_buffer.c;
}
@@ -536,6 +545,7 @@ flush_bits(working_state *state)
EMIT_BYTE(temp)
}
+#ifdef WITH_SIMD
if (state->simd) { /* and reset bit buffer to empty */
state->cur.put_buffer.simd = 0;
#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
@@ -543,7 +553,9 @@ flush_bits(working_state *state)
#else
state->cur.free_bits = SIMD_BIT_BUF_SIZE;
#endif
- } else {
+ } else
+#endif
+ {
state->cur.put_buffer.c = 0;
state->cur.free_bits = BIT_BUF_SIZE;
}
@@ -719,7 +731,9 @@ encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
state.free_in_buffer = cinfo->dest->free_in_buffer;
state.cur = entropy->saved;
state.cinfo = cinfo;
+#ifdef WITH_SIMD
state.simd = entropy->simd;
+#endif
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
@@ -792,7 +806,9 @@ finish_pass_huff(j_compress_ptr cinfo)
state.free_in_buffer = cinfo->dest->free_in_buffer;
state.cur = entropy->saved;
state.cinfo = cinfo;
+#ifdef WITH_SIMD
state.simd = entropy->simd;
+#endif
/* Flush out the last data */
if (!flush_bits(&state))
From 5b2beb4bc4f41dd9dd2a905cb931b8d5054d909b Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 10 Oct 2023 16:44:59 -0400
Subject: [PATCH 022/135] Build: Set FLOATTEST* by default for AArch64, PPC
Because of 47656a082091f9c9efda054674522513f4768c6c, we can now
reliably determine the correct default values for FLOATTEST8 and
FLOATTEST12 when using Clang or GCC to build for AArch64 or PowerPC
platforms. (Testing confirms that this is the case with GCC 5-13 and
Clang 5-14 on Ubuntu/AArch64, GCC 4 on CentOS 7/PPC, and GCC 8-10 and
Clang 6-12 on Ubuntu/PPCLE.) Other CPU architectures and compilers can
be added on a case-by-case basis as they are tested.
---
CMakeLists.txt | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index deb948fa..5ad07183 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -894,6 +894,17 @@ if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
elseif(CPU_TYPE STREQUAL "x86_64")
set(DEFAULT_FLOATTEST8 no-fp-contract)
endif()
+elseif(CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64")
+ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 14.0.0 OR
+ CMAKE_C_COMPILER_VERSION VERSION_GREATER 14.0.0)
+ set(DEFAULT_FLOATTEST8 fp-contract)
+ else()
+ set(DEFAULT_FLOATTEST8 no-fp-contract)
+ endif()
+ elseif(CMAKE_COMPILER_IS_GNUCC)
+ set(DEFAULT_FLOATTEST8 fp-contract)
+ endif()
# else we can't really set an intelligent default for FLOATTEST8. The
# appropriate value could be no-fp-contract, fp-contract, 387, or msvc,
# depending on the compiler and compiler options. We leave it to the user to
@@ -925,6 +936,17 @@ endif()
if(CPU_TYPE STREQUAL "x86_64")
set(DEFAULT_FLOATTEST12 no-fp-contract)
+elseif(CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64")
+ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 14.0.0 OR
+ CMAKE_C_COMPILER_VERSION VERSION_GREATER 14.0.0)
+ set(DEFAULT_FLOATTEST12 fp-contract)
+ else()
+ set(DEFAULT_FLOATTEST12 no-fp-contract)
+ endif()
+ elseif(CMAKE_COMPILER_IS_GNUCC)
+ set(DEFAULT_FLOATTEST12 fp-contract)
+ endif()
# else we can't really set an intelligent default for FLOATTEST12. The
# appropriate value could be no-fp-contract, fp-contract, or something else,
# depending on the compiler and compiler options. We leave it to the user to
From ec32420f6b5dfa4e86883d42b209e8371e55aeb5 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 11 Oct 2023 15:02:33 -0400
Subject: [PATCH 023/135] example.c: Fix 12-bit PPM write w/ big endian CPUs
---
example.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/example.c b/example.c
index 837254c2..4a826955 100644
--- a/example.c
+++ b/example.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software.
* Copyright (C) 1992-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2022, D. R. Commander.
+ * Copyright (C) 2017, 2019, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -398,6 +398,7 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
J12SAMPARRAY buffer12 = NULL; /* 12-bit output row buffer */
int col;
int row_stride; /* physical row width in output buffer */
+ int little_endian = 1;
/* In this example we want to open the input and output files before doing
* anything else, so that the setjmp() error recovery below can assume the
@@ -494,10 +495,12 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
* more than one scanline at a time if that's more convenient.
*/
(void)jpeg12_read_scanlines(cinfo, buffer12, 1);
- /* Swap MSB and LSB in each sample */
- for (col = 0; col < row_stride; col++)
- buffer12[0][col] = ((buffer12[0][col] & 0xFF) << 8) |
- ((buffer12[0][col] >> 8) & 0xFF);
+ if (*(char *)&little_endian == 1) {
+ /* Swap MSB and LSB in each sample */
+ for (col = 0; col < row_stride; col++)
+ buffer12[0][col] = ((buffer12[0][col] & 0xFF) << 8) |
+ ((buffer12[0][col] >> 8) & 0xFF);
+ }
fwrite(buffer12[0], 1, row_stride * sizeof(J12SAMPLE), outfile);
}
} else {
From 0e2d289fab2dd383cb55dec8156c7aacd71b3530 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 7 Nov 2023 12:38:05 -0500
Subject: [PATCH 024/135] Bump version to 3.0.2 to prepare for new commits
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ad07183..02709e9a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ if(CMAKE_EXECUTABLE_SUFFIX)
endif()
project(libjpeg-turbo C)
-set(VERSION 3.0.1)
+set(VERSION 3.0.2)
set(COPYRIGHT_YEAR "1991-2023")
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
From 78eaf0d46d30bb82ac1101e601567a3d1b5fa1d3 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 7 Nov 2023 13:44:40 -0500
Subject: [PATCH 025/135] tj3*YUV8(): Fix int overflow w/ huge row alignment
If the align parameter was set to an unreasonably large value, such as
0x2000000, strides[0] * ph0 and strides[1] * ph1 could have overflowed
the int datatype and wrapped around when computing (src|dst)Planes[1]
and (src|dst)Planes[2] (respectively.) This would have caused
(src|dst)Planes[1] and (src|dst)Planes[2] to point to lower addresses in
the YUV buffer than expected, so the worst case would have been a
visually incorrect output image, not a buffer overrun or other
exploitable issue.
---
ChangeLog.md | 13 +++++++++++++
turbojpeg.c | 20 ++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/ChangeLog.md b/ChangeLog.md
index a4667851..a93773fb 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,16 @@
+3.0.2
+=====
+
+### Significant changes relative to 3.0.1:
+
+1. Fixed a signed integer overflow in the `tj3CompressFromYUV8()`,
+`tj3DecodeYUV8()`, `tj3DecompressToYUV8()`, and `tj3EncodeYUV8()` functions,
+detected by the Clang and GCC undefined behavior sanitizers, that could be
+triggered by setting the `align` parameter to an unreasonably large value.
+This issue did not pose a security threat, but removing the warning made it
+easier to detect actual security issues, should they arise in the future.
+
+
3.0.1
=====
diff --git a/turbojpeg.c b/turbojpeg.c
index b75d4148..a764608f 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1407,6 +1407,11 @@ DLLEXPORT int tj3EncodeYUV8(tjhandle handle, const unsigned char *srcBuf,
int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
}
@@ -1661,6 +1666,11 @@ DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
int ph1 = tjPlaneHeight(1, height, this->subsamp);
strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
}
@@ -2242,6 +2252,11 @@ DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
}
@@ -2531,6 +2546,11 @@ DLLEXPORT int tj3DecompressToYUV8(tjhandle handle,
int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
}
From 7c61794faf5df01a51fe5c98ec2288c0e98bde68 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 8 Nov 2023 11:16:14 -0500
Subject: [PATCH 026/135] jmemsys.h: Remove unused MS-DOS/Mac mem. mgr. code
Those obsolete memory managers have never been included in
libjpeg-turbo, nor has libjpeg-turbo ever claimed to support MS-DOS
or Mac operating systems prior to OS X 10.4 "Tiger." Note that we
retain the ability to use temp files, even though libjpeg-turbo does
not use them. This allows downstream implementations to write their own
memory managers that use temp files, if necessary.
---
jmemsys.h | 31 -------------------------------
1 file changed, 31 deletions(-)
diff --git a/jmemsys.h b/jmemsys.h
index 9229550a..ac09ef4c 100644
--- a/jmemsys.h
+++ b/jmemsys.h
@@ -99,24 +99,6 @@ EXTERN(size_t) jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */
-#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */
-
-typedef unsigned short XMSH; /* type of extended-memory handles */
-typedef unsigned short EMSH; /* type of expanded-memory handles */
-
-typedef union {
- short file_handle; /* DOS file handle if it's a temp file */
- XMSH xms_handle; /* handle if it's a chunk of XMS */
- EMSH ems_handle; /* handle if it's a chunk of EMS */
-} handle_union;
-
-#endif /* USE_MSDOS_MEMMGR */
-
-#ifdef USE_MAC_MEMMGR /* Mac-specific junk */
-#include
-#endif /* USE_MAC_MEMMGR */
-
-
typedef struct backing_store_struct *backing_store_ptr;
typedef struct backing_store_struct {
@@ -130,22 +112,9 @@ typedef struct backing_store_struct {
void (*close_backing_store) (j_common_ptr cinfo, backing_store_ptr info);
/* Private fields for system-dependent backing-store management */
-#ifdef USE_MSDOS_MEMMGR
- /* For the MS-DOS manager (jmemdos.c), we need: */
- handle_union handle; /* reference to backing-store storage object */
- char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
-#else
-#ifdef USE_MAC_MEMMGR
- /* For the Mac manager (jmemmac.c), we need: */
- short temp_file; /* file reference number to temp file */
- FSSpec tempSpec; /* the FSSpec for the temp file */
- char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
-#else
/* For a typical implementation with temp files, we need: */
FILE *temp_file; /* stdio reference to temp file */
char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */
-#endif
-#endif
} backing_store_info;
From cbdc20fbf45b4595506331157c8e0a13bde0d401 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 8 Nov 2023 11:43:58 -0500
Subject: [PATCH 027/135] example.c: Remove comments regarding temp files
Those comments could be confusing to new libjpeg-turbo users, and the
same information already exists in libjpeg.txt and structure.txt.
---
example.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/example.c b/example.c
index 4a826955..78b658a0 100644
--- a/example.c
+++ b/example.c
@@ -271,13 +271,6 @@ write_JPEG_file(char *filename, int quality, int data_precision)
* destination module that can demand suspension of the compressor.
* (If you don't know what that's for, you don't need it.)
*
- * If the compressor requires full-image buffers (for entropy-coding
- * optimization or a multi-scan JPEG file), it will create temporary
- * files for anything that doesn't fit within the maximum-memory setting.
- * (Note that temp files are NOT needed if you use the default parameters.)
- * On some systems you may need to set up a signal handler to ensure that
- * temporary files are deleted if the program is interrupted. See libjpeg.txt.
- *
* Scanlines MUST be supplied in top-to-bottom order if you want your JPEG
* files to be compatible with everyone else's. If you cannot readily read
* your data in that order, you'll need an intermediate array to hold the
@@ -562,10 +555,6 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
* which is standardly top-to-bottom. If you must emit data bottom-to-top,
* you can use one of the virtual arrays provided by the JPEG memory manager
* to invert the data. See wrbmp.c for an example.
- *
- * As with compression, some operating modes may require temporary files.
- * On some systems you may need to set up a signal handler to ensure that
- * temporary files are deleted if the program is interrupted. See libjpeg.txt.
*/
From 220bd761888f7dae1e0d9d7258b364ede7d5ed7f Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 10 Nov 2023 11:06:16 -0500
Subject: [PATCH 028/135] turbojpeg.h: Fix broken refs in API documentation
"TJPARAM_DENSITYUNIT" should be "TJPARAM_DENSITYUNITS" (oops.)
---
doc/html/group___turbo_j_p_e_g.html | 8 ++++----
turbojpeg.h | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index 04285c25..77dcd5fc 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -978,15 +978,15 @@ YUV Image Format Notes
Value
The JPEG image has (decompression) or will have (compression) the specified horizontal pixel density [default for compression: 1].
-
This value is stored in or read from the JPEG header. It does not affect the contents of the JPEG image. Note that this parameter is set by tj3LoadImage8() when loading a Windows BMP file that contains pixel density information, and the value of this parameter is stored to a Windows BMP file by tj3SaveImage8() if the value of #TJPARAM_DENSITYUNIT is 2.
-
See also
TJPARAM_DENSITYUNIT
+
This value is stored in or read from the JPEG header. It does not affect the contents of the JPEG image. Note that this parameter is set by tj3LoadImage8() when loading a Windows BMP file that contains pixel density information, and the value of this parameter is stored to a Windows BMP file by tj3SaveImage8() if the value of TJPARAM_DENSITYUNITS is 2.
The JPEG image has (decompression) or will have (compression) the specified vertical pixel density [default for compression: 1].
-
This value is stored in or read from the JPEG header. It does not affect the contents of the JPEG image. Note that this parameter is set by tj3LoadImage8() when loading a Windows BMP file that contains pixel density information, and the value of this parameter is stored to a Windows BMP file by tj3SaveImage8() if the value of #TJPARAM_DENSITYUNIT is 2.
-
See also
TJPARAM_DENSITYUNIT
+
This value is stored in or read from the JPEG header. It does not affect the contents of the JPEG image. Note that this parameter is set by tj3LoadImage8() when loading a Windows BMP file that contains pixel density information, and the value of this parameter is stored to a Windows BMP file by tj3SaveImage8() if the value of TJPARAM_DENSITYUNITS is 2.
diff --git a/turbojpeg.h b/turbojpeg.h
index 12efcbc7..97469389 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -715,10 +715,10 @@ enum TJPARAM {
* the contents of the JPEG image. Note that this parameter is set by
* #tj3LoadImage8() when loading a Windows BMP file that contains pixel
* density information, and the value of this parameter is stored to a
- * Windows BMP file by #tj3SaveImage8() if the value of #TJPARAM_DENSITYUNIT
+ * Windows BMP file by #tj3SaveImage8() if the value of #TJPARAM_DENSITYUNITS
* is `2`.
*
- * @see TJPARAM_DENSITYUNIT
+ * @see TJPARAM_DENSITYUNITS
*/
TJPARAM_XDENSITY,
/**
@@ -732,10 +732,10 @@ enum TJPARAM {
* the contents of the JPEG image. Note that this parameter is set by
* #tj3LoadImage8() when loading a Windows BMP file that contains pixel
* density information, and the value of this parameter is stored to a
- * Windows BMP file by #tj3SaveImage8() if the value of #TJPARAM_DENSITYUNIT
+ * Windows BMP file by #tj3SaveImage8() if the value of #TJPARAM_DENSITYUNITS
* is `2`.
*
- * @see TJPARAM_DENSITYUNIT
+ * @see TJPARAM_DENSITYUNITS
*/
TJPARAM_YDENSITY,
/**
From bf248a5093009bc8cf6f11f09a4d3def6e26131e Mon Sep 17 00:00:00 2001
From: DRC
Date: Sat, 11 Nov 2023 15:14:07 -0500
Subject: [PATCH 029/135] tj3Compress*(): Free virt arrays if mem limit hit
This is very subtle, but if a user specifies a libjpeg virtual array
memory limit via the JPEGMEM environment variable and one of the
tj3Compress*() functions hits that limit, the libjpeg error handler
will be invoked in jpeg_start_compress() (more specifically in
realize_virt_arrays() in jinit_compress_master()) before the libjpeg
global compression state can be incremented. Thus,
jpeg_abort_compress() will not be called before the tj3Compress*()
function exits, the unrealized virtual arrays will not be freed, and if
the TurboJPEG compression instance is reused, those unrealized virtual
arrays will count against the specified memory limit. This could cause
subsequent compression operations that require smaller virtual arrays
(or even no virtual arrays at all) to fail when they would otherwise
succeed. In reality, the vast majority of calling programs would abort
and free the TurboJPEG compression instance if one of the tj3Compress*()
functions failed, but TJBench is a rare exception. This issue does not
bear documenting because of its subtlety and rarity and because JPEGMEM
is not a documented feature of the TurboJPEG API.
Note that the issue does not exist in the tj3Encode*() and tj3Decode*()
functions, because realize_virt_arrays() is never called in the body of
those functions. The issue also does not exist in the tj3Decompress*()
and tj3Transform() functions, because those functions ensure that the
JPEG header is read (and thus the libjpeg global decompression state is
incremented) prior to calling a function that calls
realize_virt_arrays() (i.e. jpeg_start_decompress() or
jpeg_read_coefficients().) If realize_virt_arrays() failed in the body
of jpeg_write_coefficients(), then tj3Transform() would abort without
calling jpeg_abort_compress(). However, since jpeg_start_compress() is
never called in the body of tj3Transform(), no virtual arrays are ever
requested from the compression object, so failing to call
jpeg_abort_compress() would be innocuous.
---
turbojpeg-mp.c | 6 +++---
turbojpeg.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/turbojpeg-mp.c b/turbojpeg-mp.c
index 5699869d..f58995e7 100644
--- a/turbojpeg-mp.c
+++ b/turbojpeg-mp.c
@@ -125,10 +125,10 @@ DLLEXPORT int GET_NAME(tj3Compress, BITS_IN_JSAMPLE)
jpeg_finish_compress(cinfo);
bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
+ if (cinfo->global_state > CSTATE_START && alloc)
+ (*cinfo->dest->term_destination) (cinfo);
+ if (cinfo->global_state > CSTATE_START || retval == -1)
jpeg_abort_compress(cinfo);
- }
free(row_pointer);
if (this->jerr.warning) retval = -1;
return retval;
diff --git a/turbojpeg.c b/turbojpeg.c
index a764608f..81bd6691 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1589,10 +1589,10 @@ DLLEXPORT int tj3CompressFromYUVPlanes8(tjhandle handle,
jpeg_finish_compress(cinfo);
bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
+ if (cinfo->global_state > CSTATE_START && alloc)
+ (*cinfo->dest->term_destination) (cinfo);
+ if (cinfo->global_state > CSTATE_START || retval == -1)
jpeg_abort_compress(cinfo);
- }
for (i = 0; i < MAX_COMPONENTS; i++) {
free(tmpbuf[i]);
free(inbuf[i]);
From df9dbff830820c3e0ab36b3c4a1649c614d7ccc5 Mon Sep 17 00:00:00 2001
From: DRC
Date: Sat, 11 Nov 2023 12:25:03 -0500
Subject: [PATCH 030/135] TurboJPEG: New param to limit virt array mem usage
This corresponds to max_memory_to_use in the jpeg_memory_mgr struct in
the libjpeg API, except that the TurboJPEG parameter is specified in
megabytes. Because this is 2023 and computers with less than 1 MB of
memory are not a thing (at least not within the scope of libjpeg-turbo
support), it isn't useful to allow a limit less than 1 MB to be
specified. Furthermore, because TurboJPEG parameters are signed
integers, if we allowed the memory limit to be specified in bytes, then
it would be impossible to specify a limit larger than 2 GB on 64-bit
machines. Because max_memory_to_use is a long signed integer,
effectively we can specify a limit of up to 2 petabytes on 64-bit
machines if the TurboJPEG parameter is specified in megabytes. (2 PB
should be enough for anybody, right?)
This commit also bumps the TurboJPEG API version to 3.0.1. Since the
TurboJPEG API version no longer tracks the libjpeg-turbo version, it
makes sense to increment the API revision number when adding constants,
to increment the minor version number when adding functions, and to
increment the major version number for a complete overhaul.
This commit also removes the vestigial TJ_NUMPARAM macro, which was
never defined because it proved unnecessary.
Partially implements #735
---
ChangeLog.md | 10 ++
doc/html/annotated.html | 2 +-
doc/html/classes.html | 2 +-
doc/html/functions.html | 2 +-
doc/html/functions_vars.html | 2 +-
doc/html/group___turbo_j_p_e_g.html | 29 ++----
doc/html/index.html | 2 +-
doc/html/modules.html | 2 +-
doc/html/search/all_6.js | 70 ++++++-------
doc/html/search/enumvalues_0.js | 83 +++++++--------
doc/html/search/groups_0.js | 2 +-
doc/html/structtjregion.html | 2 +-
doc/html/structtjscalingfactor.html | 2 +-
doc/html/structtjtransform.html | 2 +-
doxygen.config | 2 +-
java/TJBench.java | 23 ++++-
java/doc/allclasses-index.html | 2 +-
java/doc/allclasses.html | 2 +-
java/doc/allpackages-index.html | 2 +-
java/doc/constant-values.html | 69 +++++++------
java/doc/deprecated-list.html | 2 +-
java/doc/help-doc.html | 2 +-
java/doc/index-all.html | 6 +-
java/doc/jquery/jquery-3.6.0.min.js | 2 -
java/doc/jquery/jquery-3.6.1.min.js | 2 +
java/doc/member-search-index.js | 2 +-
java/doc/member-search-index.zip | Bin 1933 -> 1943 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 96 ++++++++++++------
.../libjpegturbo/turbojpeg/TJCompressor.html | 2 +-
.../turbojpeg/TJCustomFilter.html | 2 +-
.../turbojpeg/TJDecompressor.html | 2 +-
.../libjpegturbo/turbojpeg/TJException.html | 2 +-
.../turbojpeg/TJScalingFactor.html | 2 +-
.../libjpegturbo/turbojpeg/TJTransform.html | 2 +-
.../libjpegturbo/turbojpeg/TJTransformer.html | 2 +-
.../org/libjpegturbo/turbojpeg/YUVImage.html | 2 +-
.../turbojpeg/package-summary.html | 2 +-
.../libjpegturbo/turbojpeg/package-tree.html | 2 +-
java/doc/overview-tree.html | 2 +-
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/serialized-form.html | 2 +-
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 13 +++
java/org_libjpegturbo_turbojpeg_TJ.h | 2 +
jerror.h | 4 +-
tjbench.c | 22 +++-
turbojpeg-mp.c | 6 ++
turbojpeg.c | 15 +++
turbojpeg.h | 17 ++--
49 files changed, 320 insertions(+), 207 deletions(-)
delete mode 100644 java/doc/jquery/jquery-3.6.0.min.js
create mode 100644 java/doc/jquery/jquery-3.6.1.min.js
diff --git a/ChangeLog.md b/ChangeLog.md
index a93773fb..e2ecbf9c 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -10,6 +10,16 @@ triggered by setting the `align` parameter to an unreasonably large value.
This issue did not pose a security threat, but removing the warning made it
easier to detect actual security issues, should they arise in the future.
+2. Introduced a new parameter (`TJPARAM_MAXMEMORY` in the TurboJPEG C API and
+`TJ.PARAM_MAXMEMORY` in the TurboJPEG Java API) and a corresponding TJBench
+option (`-maxmemory`) for specifying the maximum amount of memory (in
+megabytes) that will be allocated for intermediate buffers, which are used with
+progressive JPEG compression and decompression, optimized baseline entropy
+coding, lossless JPEG compression, and lossless transformation. The new
+parameter and option serve the same purpose as the `max_memory_to_use` field in
+the `jpeg_memory_mgr` struct in the libjpeg API, the `JPEGMEM` environment
+variable, and the cjpeg/djpeg/jpegtran `-maxmemory` option.
+
3.0.1
=====
diff --git a/doc/html/annotated.html b/doc/html/annotated.html
index d7e29877..734fa849 100644
--- a/doc/html/annotated.html
+++ b/doc/html/annotated.html
@@ -23,7 +23,7 @@
This value is stored in or read from the JPEG header. It does not affect the contents of the JPEG image. Note that this parameter is set by tj3LoadImage8() when loading a Windows BMP file that contains pixel density information, and the value of this parameter is stored to a Windows BMP file by tj3SaveImage8() if the value is 2.
the maximum amount of memory (in megabytes) that will be allocated for intermediate buffers, which are used with progressive JPEG compression and decompression, optimized baseline entropy coding, lossless JPEG compression, and lossless transformation [default: 0 (no limit)]
the maximum amount of memory (in megabytes) that will be allocated
+ for intermediate buffers, which are used with progressive JPEG compression
+ and decompression, optimized baseline entropy coding, lossless JPEG
+ compression, and lossless transformation [default: 0 (no
+ limit)]
+
the maximum amount of memory (in megabytes) that will be allocated
+ * for intermediate buffers, which are used with progressive JPEG compression
+ * and decompression, optimized baseline entropy coding, lossless JPEG
+ * compression, and lossless transformation [default: 0 (no
+ * limit)]
+ *
+ */
+ public static final int PARAM_MAXMEMORY = 23;
/**
diff --git a/java/org_libjpegturbo_turbojpeg_TJ.h b/java/org_libjpegturbo_turbojpeg_TJ.h
index e27c3b5c..103e4782 100644
--- a/java/org_libjpegturbo_turbojpeg_TJ.h
+++ b/java/org_libjpegturbo_turbojpeg_TJ.h
@@ -107,6 +107,8 @@ extern "C" {
#define org_libjpegturbo_turbojpeg_TJ_PARAM_YDENSITY 21L
#undef org_libjpegturbo_turbojpeg_TJ_PARAM_DENSITYUNITS
#define org_libjpegturbo_turbojpeg_TJ_PARAM_DENSITYUNITS 22L
+#undef org_libjpegturbo_turbojpeg_TJ_PARAM_MAXMEMORY
+#define org_libjpegturbo_turbojpeg_TJ_PARAM_MAXMEMORY 23L
#undef org_libjpegturbo_turbojpeg_TJ_FLAG_BOTTOMUP
#define org_libjpegturbo_turbojpeg_TJ_FLAG_BOTTOMUP 2L
#undef org_libjpegturbo_turbojpeg_TJ_FLAG_FASTUPSAMPLE
diff --git a/jerror.h b/jerror.h
index 39362fdd..71ba03e2 100644
--- a/jerror.h
+++ b/jerror.h
@@ -7,7 +7,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2014, 2017, 2021-2022, D. R. Commander.
+ * Copyright (C) 2014, 2017, 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -111,7 +111,7 @@ JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
#if JPEG_LIB_VERSION >= 70
JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
#endif
-JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
+JMESSAGE(JERR_NO_BACKING_STORE, "Memory limit exceeded")
JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
diff --git a/tjbench.c b/tjbench.c
index e053dc6d..566fe8cf 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -89,8 +89,9 @@ int tjErrorLine = -1, tjErrorCode = -1;
TJSCALED(height, sf))
int stopOnWarning = 0, bottomUp = 0, noRealloc = 1, fastUpsample = 0,
- fastDCT = 0, optimize = 0, progressive = 0, limitScans = 0, arithmetic = 0,
- lossless = 0, restartIntervalBlocks = 0, restartIntervalRows = 0;
+ fastDCT = 0, optimize = 0, progressive = 0, limitScans = 0, maxMemory = 0,
+ arithmetic = 0, lossless = 0, restartIntervalBlocks = 0,
+ restartIntervalRows = 0;
int precision = 8, sampleSize, compOnly = 0, decompOnly = 0, doYUV = 0,
quiet = 0, doTile = 0, pf = TJPF_BGR, yuvAlign = 1, doWrite = 1;
char *ext = "ppm";
@@ -201,6 +202,8 @@ static int decomp(unsigned char **jpegBufs, size_t *jpegSizes, void *dstBuf,
THROW_TJ();
if (tj3Set(handle, TJPARAM_SCANLIMIT, limitScans ? 500 : 0) == -1)
THROW_TJ();
+ if (tj3Set(handle, TJPARAM_MAXMEMORY, maxMemory) == -1)
+ THROW_TJ();
if (IS_CROPPED(cr)) {
if (tj3DecompressHeader(handle, jpegBufs[0], jpegSizes[0]) == -1)
@@ -454,6 +457,8 @@ static int fullTest(tjhandle handle, void *srcBuf, int w, int h, int subsamp,
THROW_TJ();
if (tj3Set(handle, TJPARAM_RESTARTROWS, restartIntervalRows) == -1)
THROW_TJ();
+ if (tj3Set(handle, TJPARAM_MAXMEMORY, maxMemory) == -1)
+ THROW_TJ();
if (doYUV) {
yuvSize = tj3YUVBufSize(tilew, yuvAlign, tileh, subsamp);
@@ -652,6 +657,8 @@ static int decompTest(char *fileName)
THROW_TJ();
if (tj3Set(handle, TJPARAM_SCANLIMIT, limitScans ? 500 : 0) == -1)
THROW_TJ();
+ if (tj3Set(handle, TJPARAM_MAXMEMORY, maxMemory) == -1)
+ THROW_TJ();
if (tj3DecompressHeader(handle, srcBuf, srcSize) == -1)
THROW_TJ();
@@ -899,6 +906,10 @@ static void usage(char *progName)
printf("-componly = Stop after running compression tests. Do not test decompression.\n");
printf("-lossless = Generate lossless JPEG images when compressing (implies\n");
printf(" -subsamp 444). PSV is the predictor selection value (1-7).\n");
+ printf("-maxmemory = Memory limit (in megabytes) for intermediate buffers used with\n");
+ printf(" progressive JPEG compression and decompression, optimized baseline entropy\n");
+ printf(" coding, lossless JPEG compression, and lossless transformation\n");
+ printf(" [default = no limit]\n");
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
printf(" benchmark results)\n");
printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n");
@@ -1145,7 +1156,12 @@ int main(int argc, char *argv[])
doWrite = 0;
else if (!strcasecmp(argv[i], "-limitscans"))
limitScans = 1;
- else if (!strcasecmp(argv[i], "-restart") && i < argc - 1) {
+ else if (!strcasecmp(argv[i], "-maxmemory") && i < argc - 1) {
+ int tempi = atoi(argv[++i]);
+
+ if (tempi < 0) usage(argv[0]);
+ maxMemory = tempi;
+ } else if (!strcasecmp(argv[i], "-restart") && i < argc - 1) {
int tempi = -1, nscan; char tempc = 0;
if ((nscan = sscanf(argv[++i], "%d%c", &tempi, &tempc)) < 1 ||
diff --git a/turbojpeg-mp.c b/turbojpeg-mp.c
index f58995e7..f3b9d112 100644
--- a/turbojpeg-mp.c
+++ b/turbojpeg-mp.c
@@ -167,6 +167,8 @@ DLLEXPORT int GET_NAME(tj3Decompress, BITS_IN_JSAMPLE)
} else
dinfo->progress = NULL;
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
if (setjmp(this->jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error. */
retval = -1; goto bailout;
@@ -342,6 +344,8 @@ DLLEXPORT _JSAMPLE *GET_NAME(tj3LoadImage, BITS_IN_JSAMPLE)
} else
THROW("Unsupported file type");
+ cinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
src->input_file = file;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Refuse to load images larger than 1 Megapixel when fuzzing. */
@@ -480,6 +484,8 @@ DLLEXPORT int GET_NAME(tj3SaveImage, BITS_IN_JSAMPLE)
invert = this->bottomUp;
}
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
dst->output_file = file;
(*dst->start_output) (dinfo, dst);
(*dinfo->mem->realize_virt_arrays) ((j_common_ptr)dinfo);
diff --git a/turbojpeg.c b/turbojpeg.c
index 81bd6691..fd7b3584 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -136,6 +136,7 @@ typedef struct _tjinstance {
int densityUnits;
tjscalingfactor scalingFactor;
tjregion croppingRegion;
+ int maxMemory;
} tjinstance;
static tjhandle _tjInitCompress(tjinstance *this);
@@ -335,6 +336,7 @@ static void setCompDefaults(tjinstance *this, int pixelFormat)
this->cinfo.X_density = (UINT16)this->xDensity;
this->cinfo.Y_density = (UINT16)this->yDensity;
this->cinfo.density_unit = (UINT8)this->densityUnits;
+ this->cinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
if (this->lossless) {
#ifdef C_LOSSLESS_SUPPORTED
@@ -704,6 +706,9 @@ DLLEXPORT int tj3Set(tjhandle handle, int param, int value)
THROW("TJPARAM_DENSITYUNITS is read-only in decompression instances.");
SET_PARAM(densityUnits, 0, 2);
break;
+ case TJPARAM_MAXMEMORY:
+ SET_PARAM(maxMemory, 0, (int)(min(LONG_MAX / 1048576L, (long)INT_MAX)));
+ break;
default:
THROW("Invalid parameter");
}
@@ -766,6 +771,8 @@ DLLEXPORT int tj3Get(tjhandle handle, int param)
return this->yDensity;
case TJPARAM_DENSITYUNITS:
return this->densityUnits;
+ case TJPARAM_MAXMEMORY:
+ return this->maxMemory;
}
return -1;
@@ -2043,6 +2050,8 @@ static void setDecodeDefaults(tjinstance *this, int pixelFormat)
this->dinfo.quant_tbl_ptrs[i] =
jpeg_alloc_quant_table((j_common_ptr)&this->dinfo);
}
+
+ this->dinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
}
@@ -2329,6 +2338,8 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
} else
dinfo->progress = NULL;
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
if (setjmp(this->jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error. */
retval = -1; goto bailout;
@@ -2396,6 +2407,8 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
dinfo->dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
dinfo->raw_data_out = TRUE;
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
jpeg_start_decompress(dinfo);
for (row = 0; row < (int)dinfo->output_height;
row += dinfo->max_v_samp_factor * dinfo->_min_DCT_scaled_size) {
@@ -2658,6 +2671,8 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
} else
dinfo->progress = NULL;
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
if ((xinfo =
(jpeg_transform_info *)malloc(sizeof(jpeg_transform_info) * n)) == NULL)
THROW("Memory allocation failure");
diff --git a/turbojpeg.h b/turbojpeg.h
index 97469389..3058199a 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -425,11 +425,6 @@ enum TJCS {
};
-/**
- * The number of parameters
- */
-#define TJ_NUMPARAM
-
/**
* Parameters
*/
@@ -758,7 +753,17 @@ enum TJPARAM {
*
* @see TJPARAM_XDENSITY, TJPARAM_YDENSITY
*/
- TJPARAM_DENSITYUNITS
+ TJPARAM_DENSITYUNITS,
+ /**
+ * Memory limit for intermediate buffers
+ *
+ * **Value**
+ * - the maximum amount of memory (in megabytes) that will be allocated for
+ * intermediate buffers, which are used with progressive JPEG compression and
+ * decompression, optimized baseline entropy coding, lossless JPEG
+ * compression, and lossless transformation *[default: `0` (no limit)]*
+ */
+ TJPARAM_MAXMEMORY
};
From 837e471a90e79b37cb4f7ef9950321f48c7c5f41 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 14 Nov 2023 11:17:25 -0500
Subject: [PATCH 031/135] tjexample.c: Fix error when decompressing
(regression introduced by 300a344d653d4a8779706e42828d945c6a53ff9d)
300a344d653d4a8779706e42828d945c6a53ff9d fixed the recompression code
path but also broke the pure decompression code path, because the fix
caused the TurboJPEG decompression instance to be destroyed before
tj3SaveImage() could use it. Furthermore, the fix in
300a344d653d4a8779706e42828d945c6a53ff9d prevented pixel density
information from being transferred from the input image to the output
image when recompressing. This commit does the following:
- Modify tjexample.c so that a single TurboJPEG instance is initialized
for lossless transformation and shared by all code paths. In addition
to fixing both of the aforementioned issues, this makes the code more
readable.
- Extend tjexampletest to test the recompression code path, thus
ensuring that the issues fixed by this commit and
300a344d653d4a8779706e42828d945c6a53ff9d are not reintroduced.
- Modify tjexample.c to remove redundant fclose(), tj3Destroy(), and
tj3Free() calls.
---
tjexample.c | 18 +++---------------
tjexampletest.in | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/tjexample.c b/tjexample.c
index 579ebe53..1edf30f7 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -252,6 +252,9 @@ int main(int argc, char **argv)
inFormat = &inFormat[1];
outFormat = &outFormat[1];
+ if ((tjInstance = tj3Init(TJINIT_TRANSFORM)) == NULL)
+ THROW_TJ("creating TurboJPEG instance");
+
if (!strcasecmp(inFormat, "jpg")) {
/* Input image is a JPEG image. Decompress and/or transform it. */
long size;
@@ -280,8 +283,6 @@ int main(int argc, char **argv)
unsigned char *dstBuf = NULL; /* Dynamically allocate the JPEG buffer */
size_t dstSize = 0;
- if ((tjInstance = tj3Init(TJINIT_TRANSFORM)) == NULL)
- THROW_TJ("initializing transformer");
xform.options |= TJXOPT_TRIM;
if (tj3Transform(tjInstance, jpegBuf, jpegSize, 1, &dstBuf, &dstSize,
&xform) < 0) {
@@ -291,9 +292,6 @@ int main(int argc, char **argv)
tj3Free(jpegBuf);
jpegBuf = dstBuf;
jpegSize = dstSize;
- } else {
- if ((tjInstance = tj3Init(TJINIT_DECOMPRESS)) == NULL)
- THROW_TJ("initializing decompressor");
}
if (tj3Set(tjInstance, TJPARAM_FASTUPSAMPLE, fastUpsample) < 0)
THROW_TJ("setting TJPARAM_FASTUPSAMPLE");
@@ -323,7 +321,6 @@ int main(int argc, char **argv)
THROW_UNIX("opening output file");
if (fwrite(jpegBuf, jpegSize, 1, jpegFile) < 1)
THROW_UNIX("writing output file");
- fclose(jpegFile); jpegFile = NULL;
goto bailout;
}
@@ -350,11 +347,8 @@ int main(int argc, char **argv)
pixelFormat) < 0)
THROW_TJ("decompressing JPEG image");
tj3Free(jpegBuf); jpegBuf = NULL;
- tj3Destroy(tjInstance); tjInstance = NULL;
} else {
/* Input image is not a JPEG image. Load it into memory. */
- if ((tjInstance = tj3Init(TJINIT_COMPRESS)) == NULL)
- THROW_TJ("initializing compressor");
if ((imgBuf = tj3LoadImage8(tjInstance, argv[1], &width, 1, &height,
&pixelFormat)) == NULL)
THROW_TJ("loading input image");
@@ -380,8 +374,6 @@ int main(int argc, char **argv)
printf(", %s subsampling, quality = %d\n", subsampName[outSubsamp],
outQual);
- if (!tjInstance && (tjInstance = tj3Init(TJINIT_COMPRESS)) == NULL)
- THROW_TJ("initializing compressor");
if (tj3Set(tjInstance, TJPARAM_SUBSAMP, outSubsamp) < 0)
THROW_TJ("setting TJPARAM_SUBSAMP");
if (tj3Set(tjInstance, TJPARAM_QUALITY, outQual) < 0)
@@ -391,16 +383,12 @@ int main(int argc, char **argv)
if (tj3Compress8(tjInstance, imgBuf, width, 0, height, pixelFormat,
&jpegBuf, &jpegSize) < 0)
THROW_TJ("compressing image");
- tj3Destroy(tjInstance); tjInstance = NULL;
/* Write the JPEG image to disk. */
if ((jpegFile = fopen(argv[2], "wb")) == NULL)
THROW_UNIX("opening output file");
if (fwrite(jpegBuf, jpegSize, 1, jpegFile) < 1)
THROW_UNIX("writing output file");
- tj3Destroy(tjInstance); tjInstance = NULL;
- fclose(jpegFile); jpegFile = NULL;
- tj3Free(jpegBuf); jpegBuf = NULL;
} else {
/* Output image format is not JPEG. Save the uncompressed image
directly to disk. */
diff --git a/tjexampletest.in b/tjexampletest.in
index c56fc429..a852c55d 100755
--- a/tjexampletest.in
+++ b/tjexampletest.in
@@ -68,6 +68,14 @@ for image in $IMAGES; do
runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg2.jpg $OUTDIR/${basename}_GRAY_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg2.jpg $OUTDIR/${basename}_420_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg2.jpg $OUTDIR/${basename}_422_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg2.jpg $OUTDIR/${basename}_444_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg2.jpg $OUTDIR/${basename}_GRAY_accurate_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg2.jpg $OUTDIR/${basename}_420_accurate_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg2.jpg $OUTDIR/${basename}_422_accurate_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg2.jpg $OUTDIR/${basename}_444_accurate_djpeg.bmp
# Compression
for dct in fast accurate; do
@@ -81,6 +89,18 @@ for image in $IMAGES; do
done
done
+ # Recompression
+ for dct in fast accurate; do
+ dctarg=
+ if [ "${dct}" = "fast" ]; then
+ dctarg=-fastdct
+ fi
+ for samp in GRAY 420 422 444; do
+ runme $TJEXAMPLE $OUTDIR/${basename}_${samp}_${dct}.jpg $OUTDIR/${basename}_${samp}_${dct}_recomp.jpg -q 95 -subsamp ${samp} ${dctarg}
+ runme cmp $OUTDIR/${basename}_${samp}_${dct}_recomp.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg2.jpg
+ done
+ done
+
# Decompression
for dct in fast accurate; do
dctarg=
From a27bad655220c6cd99084588da4b322bc3d1277b Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 14 Nov 2023 14:47:40 -0500
Subject: [PATCH 032/135] tj3Transform(): Ensure JPEG hdr successfully read
Because of the TurboJPEG 3 API overhaul, the legacy decompression and
lossless transformation functions now wrap the new TurboJPEG 3
functions. For performance reasons, we don't want to read the JPEG
header more than once during the same operation, so the wrapped
functions do not read the header if it has already been read by a
wrapper function. Initially the TurboJPEG 3 functions used a state
variable to track whether the header had already been read, but
b94041390c477a02b3cab79d0cc0ef321dc889e8 made this more robust by using
the libjpeg global decompression state instead. If a wrapper function
has already read the JPEG header successfully, then the global
decompression state will be DSTATE_READY, and the logic introduced in
b94041390c477a02b3cab79d0cc0ef321dc889e8 will prevent the header from
being read again.
A subtle issue arises because tj3DecompressHeader() does not call
jpeg_abort_decompress() if jpeg_read_header() fails. (That is arguably
a bug, but it has existed since the very first implementation of the
function.) Depending on the nature of the failure, this can cause
tj3DecompressHeader() to return an error code and leave the libjpeg
global decompression state set to DSTATE_INHEADER. If a misbehaved
application ignored the error and subsequently called a TurboJPEG
decompression or lossless transformation function, then the function
would fail to read the JPEG header because the global decompression
state was greater than DSTATE_START. In the case of the decompression
functions, this was innocuous, because jpeg_calc_output_dimensions()
and jpeg_start_decompress() both sanity check the global decompression
state. However, it was possible for a misbehaved application to call
tj3DecompressHeader() with junk data, ignore the return value, and pass
the same junk data into tj3Transform(). Because tj3DecompressHeader()
left the global decompression state set to DSTATE_INHEADER,
tj3Transform() failed to detect the junk data (because it didn't try to
read the JPEG header), and it called jtransform_request_workspace() with
dinfo->image_width and dinfo->image_height still initialized to 0.
Because jtransform_request_workspace() does not sanity check the
decompression state, a division-by-zero error occurred with certain
combinations of transform options in which TJXOPT_TRIM or TJXOPT_CROP
was specified. However, it should be noted that TJXOPT_TRIM and
TJXOPT_CROP cannot be expected to work properly without foreknowledge of
the JPEG source image dimensions, which cannot be gained except by
calling tj3DecompressHeader() successfully. Thus, a calling application
is inviting trouble if it does not check the return value of
tj3DecompressHeader() and sanity check the JPEG source image dimensions
before calling tj3Transform(). This commit softens the failure, but the
failure is still due to improper API usage.
---
turbojpeg-mp.c | 2 +-
turbojpeg.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/turbojpeg-mp.c b/turbojpeg-mp.c
index f3b9d112..2ca23aa7 100644
--- a/turbojpeg-mp.c
+++ b/turbojpeg-mp.c
@@ -174,7 +174,7 @@ DLLEXPORT int GET_NAME(tj3Decompress, BITS_IN_JSAMPLE)
retval = -1; goto bailout;
}
- if (dinfo->global_state <= DSTATE_START) {
+ if (dinfo->global_state <= DSTATE_INHEADER) {
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
jpeg_read_header(dinfo, TRUE);
}
diff --git a/turbojpeg.c b/turbojpeg.c
index fd7b3584..f4e6446c 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -2345,7 +2345,7 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
retval = -1; goto bailout;
}
- if (dinfo->global_state <= DSTATE_START) {
+ if (dinfo->global_state <= DSTATE_INHEADER) {
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
jpeg_read_header(dinfo, TRUE);
}
@@ -2536,7 +2536,7 @@ DLLEXPORT int tj3DecompressToYUV8(tjhandle handle,
retval = -1; goto bailout;
}
- if (dinfo->global_state <= DSTATE_START) {
+ if (dinfo->global_state <= DSTATE_INHEADER) {
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
jpeg_read_header(dinfo, TRUE);
}
@@ -2683,7 +2683,7 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
retval = -1; goto bailout;
}
- if (dinfo->global_state <= DSTATE_START)
+ if (dinfo->global_state <= DSTATE_INHEADER)
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
for (i = 0; i < n; i++) {
@@ -2711,7 +2711,7 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
}
jcopy_markers_setup(dinfo, saveMarkers ? JCOPYOPT_ALL : JCOPYOPT_NONE);
- if (dinfo->global_state <= DSTATE_START)
+ if (dinfo->global_state <= DSTATE_INHEADER)
jpeg_read_header(dinfo, TRUE);
this->subsamp = getSubsamp(&this->dinfo);
From 8a4ce73c923b8c8a7f6f27b7c6cc27879255c62e Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 15 Nov 2023 10:54:58 -0500
Subject: [PATCH 033/135] tj3Transform(): Range check transform operations
---
turbojpeg.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/turbojpeg.c b/turbojpeg.c
index f4e6446c..519a868e 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -2687,6 +2687,8 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
for (i = 0; i < n; i++) {
+ if (t[i].op < 0 || t[i].op >= TJ_NUMXOP)
+ THROW("Invalid transform operation");
xinfo[i].transform = xformtypes[t[i].op];
xinfo[i].perfect = (t[i].options & TJXOPT_PERFECT) ? 1 : 0;
xinfo[i].trim = (t[i].options & TJXOPT_TRIM) ? 1 : 0;
From d51830473a76304112756852723b81b10899a582 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 15 Nov 2023 11:06:23 -0500
Subject: [PATCH 034/135] tjexampletest.in: Fix code formatting issue
(introduced by 837e471a90e79b37cb4f7ef9950321f48c7c5f41)
---
tjexampletest.in | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tjexampletest.in b/tjexampletest.in
index a852c55d..81c46601 100755
--- a/tjexampletest.in
+++ b/tjexampletest.in
@@ -68,14 +68,14 @@ for image in $IMAGES; do
runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done
- runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg2.jpg $OUTDIR/${basename}_GRAY_fast_djpeg.bmp
- runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg2.jpg $OUTDIR/${basename}_420_fast_djpeg.bmp
- runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg2.jpg $OUTDIR/${basename}_422_fast_djpeg.bmp
- runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg2.jpg $OUTDIR/${basename}_444_fast_djpeg.bmp
- runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg2.jpg $OUTDIR/${basename}_GRAY_accurate_djpeg.bmp
- runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg2.jpg $OUTDIR/${basename}_420_accurate_djpeg.bmp
- runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg2.jpg $OUTDIR/${basename}_422_accurate_djpeg.bmp
- runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg2.jpg $OUTDIR/${basename}_444_accurate_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg2.jpg $OUTDIR/${basename}_GRAY_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg2.jpg $OUTDIR/${basename}_420_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg2.jpg $OUTDIR/${basename}_422_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg2.jpg $OUTDIR/${basename}_444_fast_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg2.jpg $OUTDIR/${basename}_GRAY_accurate_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg2.jpg $OUTDIR/${basename}_420_accurate_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg2.jpg $OUTDIR/${basename}_422_accurate_djpeg.bmp
+ runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg2.jpg $OUTDIR/${basename}_444_accurate_djpeg.bmp
# Compression
for dct in fast accurate; do
From 45f018cb22adaa4dadd0ab420d3a45d5d9d8de4e Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 15 Nov 2023 13:04:12 -0500
Subject: [PATCH 035/135] SECURITY.md: Clarify security advisories policy
Unfortunately, most of the GitHub security advisories filed against
libjpeg-turbo thus far have been the result of non-exploitable API
abuses triggered by randomly-generated test programs and accompanied by
wild claims of denials of service with no demonstrable or even probable
exploit that might cause such a DoS (assuming a service even existed
that used the API in question.) Security advisories remain private
unless accepted, and I cannot accept them if they do not describe an
actual security issue. Thus, it's best to steer most users toward
regular bug reports.
---
.github/SECURITY.md | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
index 0b8fc6b7..01a70973 100644
--- a/.github/SECURITY.md
+++ b/.github/SECURITY.md
@@ -14,6 +14,19 @@ Vulnerabilities can be reported in one of the following ways:
optionally encrypt the e-mail using the provided public GPG key.
- Open a
[GitHub draft security advisory](https://github.com/libjpeg-turbo/libjpeg-turbo/security/advisories/new).
+ Note that security advisories are reserved for security researchers who fully
+ understand the Common Vulnerability Scoring System (CVSS), Common Weakness
+ Enumeration (CWE), and Common Vulnerabilities and Exposures (CVE) Program and
+ who are prepared to demonstrate a known or probable exploit for an issue.
+ For example, if a buffer overrun, an uninitialized read, or undefined
+ behavior can be triggered by malformed data passed to a public libjpeg-turbo
+ API function from an otherwise well-behaved calling program, then it merits
+ investigation as a potential security issue. If, however, the calling
+ program itself is malformed and could not work properly with any image, then
+ its inevitable failure is not a security issue. Such failures can be
+ reported using a
+ [GitHub bug report](https://github.com/libjpeg-turbo/libjpeg-turbo/issues/new/choose),
+ and they will be investigated as potential opportunities for user proofing.
- [Alpha/Evolving, Beta, and Post-Beta release series](https://libjpeg-turbo.org/DeveloperInfo/Versioning)
are not expected to be free of bugs, so vulnerabilities that affect only
those release series (for example, vulnerabilities introduced by a new
From 40419472fa9a67049d8d03d6cb05c8db4258bb53 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 15 Nov 2023 13:42:34 -0500
Subject: [PATCH 036/135] SECURITY.md: Further clarify security adv. policy
Security advisories should only be filed against official releases.
---
.github/SECURITY.md | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
index 01a70973..895a4a26 100644
--- a/.github/SECURITY.md
+++ b/.github/SECURITY.md
@@ -17,19 +17,23 @@ Vulnerabilities can be reported in one of the following ways:
Note that security advisories are reserved for security researchers who fully
understand the Common Vulnerability Scoring System (CVSS), Common Weakness
Enumeration (CWE), and Common Vulnerabilities and Exposures (CVE) Program and
- who are prepared to demonstrate a known or probable exploit for an issue.
- For example, if a buffer overrun, an uninitialized read, or undefined
- behavior can be triggered by malformed data passed to a public libjpeg-turbo
- API function from an otherwise well-behaved calling program, then it merits
- investigation as a potential security issue. If, however, the calling
- program itself is malformed and could not work properly with any image, then
- its inevitable failure is not a security issue. Such failures can be
- reported using a
+ who are prepared to demonstrate a known or probable exploit for an issue that
+ exists in an official release of libjpeg-turbo. For example, if a buffer
+ overrun, an uninitialized read, or undefined behavior can be triggered by
+ malformed data passed to a public libjpeg-turbo API function from an
+ otherwise well-behaved calling program, then it merits investigation as a
+ potential security issue. If, however, the calling program itself is
+ malformed and could not work properly with any image, then its inevitable
+ failure is not a security issue. Such failures can be reported using a
[GitHub bug report](https://github.com/libjpeg-turbo/libjpeg-turbo/issues/new/choose),
and they will be investigated as potential opportunities for user proofing.
-- [Alpha/Evolving, Beta, and Post-Beta release series](https://libjpeg-turbo.org/DeveloperInfo/Versioning)
+- [Beta and Post-Beta release series](https://libjpeg-turbo.org/DeveloperInfo/Versioning)
are not expected to be free of bugs, so vulnerabilities that affect only
those release series (for example, vulnerabilities introduced by a new
feature that is not present in a Stable release series) can optionally be
reported using a
[GitHub bug report](https://github.com/libjpeg-turbo/libjpeg-turbo/issues/new/choose).
+ Vulnerabilities that affect only
+ [Alpha/Evolving release series](https://libjpeg-turbo.org/DeveloperInfo/Versioning)
+ should always be reported using a
+ [GitHub bug report](https://github.com/libjpeg-turbo/libjpeg-turbo/issues/new/choose).
From 6136a9e285905c7069fa29d59b4e3b67ac1b32c2 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 16 Nov 2023 14:12:28 -0500
Subject: [PATCH 037/135] Java doc: Terminology tweaks
- "function" = "method"
- "decompression and transform functions" = "decompression and transform
operations" (for consistency with the 2.1.x documentation)
- "return an error" = "throw an error"
- "ceil()" = "Math.ceil()"
---
java/doc/index-all.html | 2 +-
java/doc/member-search-index.zip | Bin 1943 -> 1943 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 4 ++--
.../turbojpeg/TJCustomFilter.html | 10 +++++-----
.../turbojpeg/TJScalingFactor.html | 6 +++---
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 4 ++--
.../turbojpeg/TJCustomFilter.java | 8 ++++----
.../turbojpeg/TJScalingFactor.java | 8 ++++----
10 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/java/doc/index-all.html b/java/doc/index-all.html
index 9be6d809..12d5cc2f 100644
--- a/java/doc/index-all.html
+++ b/java/doc/index-all.html
@@ -170,7 +170,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
A callback function that can be used to modify the DCT coefficients after
+
A callback method that can be used to modify the DCT coefficients after
they are losslessly transformed but before they are transcoded to a new
JPEG image.
Setting this parameter will cause the decompression and transform
- functions to return an error if the number of scans in a progressive JPEG
+ operations to throw an error if the number of scans in a progressive JPEG
image exceeds the specified limit. The primary purpose of this is to
allow security-critical applications to guard against an exploit of the
progressive JPEG format described in
@@ -1576,7 +1576,7 @@ extends java.lang.Object
Value
maximum number of progressive JPEG scans that the decompression and
- transform functions will process [default: 0 (no
+ transform operations will process [default: 0 (no
limit)]
A callback function that can be used to modify the DCT coefficients after
+
A callback method that can be used to modify the DCT coefficients after
they are losslessly transformed but before they are transcoded to a new
JPEG image.
A callback function that can be used to modify the DCT coefficients after
+
A callback method that can be used to modify the DCT coefficients after
they are losslessly transformed but before they are transcoded to a new
JPEG image. This allows for custom filters or other transformations to be
applied in the frequency domain.
coeffBuffer - a buffer containing transformed DCT coefficients.
(NOTE: this buffer is not guaranteed to be valid once the callback
returns, so applications wishing to hand off the DCT coefficients to
- another function or library should make a copy of them within the body of
- the callback.)
+ another method should make a copy of them within the body of the
+ callback.)
bufferRegion - rectangle containing the width and height of
coeffBuffer as well as its offset relative to the component
plane. TurboJPEG implementations may choose to split each component plane
- into multiple DCT coefficient buffers and call the callback function once
+ into multiple DCT coefficient buffers and call the callback method once
for each buffer.
planeRegion - rectangle containing the width and height of the
component plane to which coeffBuffer belongs
Returns the scaled value of dimension. This function
- performs the integer equivalent of
- ceil(dimension * scalingFactor).
+
Returns the scaled value of dimension. This method performs
+ the integer equivalent of
+ Math.ceil(dimension * scalingFactor).
Parameters:
dimension - width or height to multiply by this scaling factor
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index 68c0b503a86743c8aebeaf7be85f5d0cb1fcfea0..70a04c09e457119035d9778f0044c15e80b7dd32 100644
GIT binary patch
delta 28
hcmaFM_?D43z?+#xgn@&DgQ29TU?OinGl-h+2LNeY2oeAQ
delta 28
hcmaFM_?D43z?+#xgn@&DgQ0du?nK^xW)L;s4*+g}2&w=8
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index 10d2f39ad497761dfdf783cb5e6b27e2cd3888a9..fca9ab2821a489175dbc62802d51350e8dfd0915 100644
GIT binary patch
delta 28
hcmdnaw4I4Jz?+#xgn@&DgQ29TU?T4wW)Stp8vtP|2tNP-
delta 28
hcmdnaw4I4Jz?+#xgn@&DgQ0du?nK@@%pmHGHvnc&2-g4r
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index 7c90b6ff..8f96438e 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -581,7 +581,7 @@ public final class TJ {
* transformation]
*
*
Setting this parameter will cause the decompression and transform
- * functions to return an error if the number of scans in a progressive JPEG
+ * operations to throw an error if the number of scans in a progressive JPEG
* image exceeds the specified limit. The primary purpose of this is to
* allow security-critical applications to guard against an exploit of the
* progressive JPEG format described in
@@ -590,7 +590,7 @@ public final class TJ {
*
Value
*
*
maximum number of progressive JPEG scans that the decompression and
- * transform functions will process [default: 0 (no
+ * transform operations will process [default: 0 (no
* limit)]
*
*
diff --git a/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java b/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
index 78e6e4e1..0444eb7f 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
@@ -37,7 +37,7 @@ import java.nio.*;
public interface TJCustomFilter {
/**
- * A callback function that can be used to modify the DCT coefficients after
+ * A callback method that can be used to modify the DCT coefficients after
* they are losslessly transformed but before they are transcoded to a new
* JPEG image. This allows for custom filters or other transformations to be
* applied in the frequency domain.
@@ -45,13 +45,13 @@ public interface TJCustomFilter {
* @param coeffBuffer a buffer containing transformed DCT coefficients.
* (NOTE: this buffer is not guaranteed to be valid once the callback
* returns, so applications wishing to hand off the DCT coefficients to
- * another function or library should make a copy of them within the body of
- * the callback.)
+ * another method should make a copy of them within the body of the
+ * callback.)
*
* @param bufferRegion rectangle containing the width and height of
* coeffBuffer as well as its offset relative to the component
* plane. TurboJPEG implementations may choose to split each component plane
- * into multiple DCT coefficient buffers and call the callback function once
+ * into multiple DCT coefficient buffers and call the callback method once
* for each buffer.
*
* @param planeRegion rectangle containing the width and height of the
diff --git a/java/org/libjpegturbo/turbojpeg/TJScalingFactor.java b/java/org/libjpegturbo/turbojpeg/TJScalingFactor.java
index ccf91797..294c5c18 100644
--- a/java/org/libjpegturbo/turbojpeg/TJScalingFactor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJScalingFactor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011, 2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011, 2018, 2023 D. R. Commander. All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,9 +67,9 @@ public class TJScalingFactor {
}
/**
- * Returns the scaled value of dimension. This function
- * performs the integer equivalent of
- * ceil(dimension * scalingFactor).
+ * Returns the scaled value of dimension. This method performs
+ * the integer equivalent of
+ * Math.ceil(dimension * scalingFactor).
*
* @param dimension width or height to multiply by this scaling factor
*
From 55d342c788b6eb6188789a52e24da44bbeb6fc60 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 16 Nov 2023 15:36:47 -0500
Subject: [PATCH 038/135] TurboJPEG: Expose/extend hidden "max pixels" param
TJPARAM_MAXPIXELS was previously hidden and used only for fuzz testing,
but it is potentially useful for calling applications as well,
particularly if they want to guard against excessive memory consumption
by the tj3LoadImage*() functions. The parameter has also been extended
to decompression and lossless transformation functions/methods, mainly
as a convenience. (It was already possible for calling applications to
impose their own JPEG image size limits by reading the JPEG header prior
to decompressing or transforming the image.)
---
ChangeLog.md | 6 +
cdjpeg.h | 2 -
doc/html/group___turbo_j_p_e_g.html | 10 +-
doc/html/search/all_6.js | 125 +++++++++----------
doc/html/search/all_7.js | 2 +-
doc/html/search/all_8.js | 2 +-
doc/html/search/all_9.js | 2 +-
doc/html/search/classes_0.js | 6 +-
doc/html/search/enums_0.js | 14 +--
doc/html/search/enumvalues_0.js | 127 ++++++++++----------
doc/html/search/functions_0.js | 76 ++++++------
doc/html/search/groups_0.js | 2 +-
doc/html/search/typedefs_0.js | 4 +-
doc/html/search/variables_0.js | 2 +-
doc/html/search/variables_1.js | 4 +-
doc/html/search/variables_2.js | 2 +-
doc/html/search/variables_3.js | 2 +-
doc/html/search/variables_4.js | 4 +-
doc/html/search/variables_5.js | 2 +-
doc/html/search/variables_6.js | 18 +--
doc/html/search/variables_7.js | 2 +-
doc/html/search/variables_8.js | 2 +-
doc/html/search/variables_9.js | 2 +-
java/TJBench.java | 19 ++-
java/doc/constant-values.html | 67 ++++++-----
java/doc/index-all.html | 4 +
java/doc/member-search-index.js | 2 +-
java/doc/member-search-index.zip | Bin 1943 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 96 ++++++++++-----
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 15 +++
java/org_libjpegturbo_turbojpeg_TJ.h | 2 +
rdbmp.c | 8 +-
rdgif.c | 12 +-
rdppm.c | 6 +-
rdtarga.c | 8 +-
tjbench.c | 14 ++-
turbojpeg-mp.c | 7 +-
turbojpeg.c | 21 ++--
turbojpeg.h | 19 ++-
41 files changed, 409 insertions(+), 309 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index e2ecbf9c..16ec04cd 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -20,6 +20,12 @@ parameter and option serve the same purpose as the `max_memory_to_use` field in
the `jpeg_memory_mgr` struct in the libjpeg API, the `JPEGMEM` environment
variable, and the cjpeg/djpeg/jpegtran `-maxmemory` option.
+3. Introduced a new parameter (`TJPARAM_MAXPIXELS` in the TurboJPEG C API and
+`TJ.PARAM_MAXPIXELS` in the TurboJPEG Java API) and a corresponding TJBench
+option (`-maxpixels`) for specifying the maximum number of pixels that the
+decompression, lossless transformation, and packed-pixel image loading
+functions/methods will process.
+
3.0.1
=====
diff --git a/cdjpeg.h b/cdjpeg.h
index 471b9a3f..f4da2388 100644
--- a/cdjpeg.h
+++ b/cdjpeg.h
@@ -40,9 +40,7 @@ struct cjpeg_source_struct {
J16SAMPARRAY buffer16;
#endif
JDIMENSION buffer_height;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
JDIMENSION max_pixels;
-#endif
};
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index 8fdae045..5ee50a48 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -233,7 +233,9 @@ Enumerations
the maximum amount of memory (in megabytes) that will be allocated for intermediate buffers, which are used with progressive JPEG compression and decompression, optimized baseline entropy coding, lossless JPEG compression, and lossless transformation [default: 0 (no limit)]
Setting this parameter will cause the decompression, transform, and image loading functions to return an error if the number of pixels in the source image exceeds the specified limit. This allows security-critical applications to guard against excessive memory consumption.
+
Value
+
maximum number of pixels that the decompression, transform, and image loading functions will process [default: 0 (no limit)]
Setting this parameter will cause the decompression and transform
+ operations to throw an error if the number of pixels in the JPEG source
+ image exceeds the specified limit. This allows security-critical
+ applications to guard against excessive memory consumption.
+
+
Value
+
+
maximum number of pixels that the decompression and transform
+ operations will process [default: 0 (no limit)]
+
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index 70a04c09e457119035d9778f0044c15e80b7dd32..c5f302c2e34b9db0461ad508cbb6ffb0090d6b75 100644
GIT binary patch
delta 26
gcmaFM_?D3;z?+#xgn@&DgTc9GBF_XSAUV$;09M!r;s5{u
delta 26
gcmaFM_?D3;z?+#xgn@&DgQ28oBF_XSAUV$;09jlIFaQ7m
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index fca9ab2821a489175dbc62802d51350e8dfd0915..295927d540ee37d1193ccbe111f479a8ab4570aa 100644
GIT binary patch
delta 26
gcmdnaw4I43z?+#xgn@&DgTc9GBF|kWAot<8
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index 8f96438e..23b1c653 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -787,6 +787,21 @@ public final class TJ {
*
*/
public static final int PARAM_MAXMEMORY = 23;
+ /**
+ * Image size limit [decompression, lossless transformation]
+ *
+ *
Setting this parameter will cause the decompression and transform
+ * operations to throw an error if the number of pixels in the JPEG source
+ * image exceeds the specified limit. This allows security-critical
+ * applications to guard against excessive memory consumption.
+ *
+ *
Value
+ *
+ *
maximum number of pixels that the decompression and transform
+ * operations will process [default: 0 (no limit)]
+ *
+ */
+ public static final int PARAM_MAXPIXELS = 24;
/**
diff --git a/java/org_libjpegturbo_turbojpeg_TJ.h b/java/org_libjpegturbo_turbojpeg_TJ.h
index 103e4782..38505f73 100644
--- a/java/org_libjpegturbo_turbojpeg_TJ.h
+++ b/java/org_libjpegturbo_turbojpeg_TJ.h
@@ -109,6 +109,8 @@ extern "C" {
#define org_libjpegturbo_turbojpeg_TJ_PARAM_DENSITYUNITS 22L
#undef org_libjpegturbo_turbojpeg_TJ_PARAM_MAXMEMORY
#define org_libjpegturbo_turbojpeg_TJ_PARAM_MAXMEMORY 23L
+#undef org_libjpegturbo_turbojpeg_TJ_PARAM_MAXPIXELS
+#define org_libjpegturbo_turbojpeg_TJ_PARAM_MAXPIXELS 24L
#undef org_libjpegturbo_turbojpeg_TJ_FLAG_BOTTOMUP
#define org_libjpegturbo_turbojpeg_TJ_FLAG_BOTTOMUP 2L
#undef org_libjpegturbo_turbojpeg_TJ_FLAG_FASTUPSAMPLE
diff --git a/rdbmp.c b/rdbmp.c
index 88ee7512..c2c06fd0 100644
--- a/rdbmp.c
+++ b/rdbmp.c
@@ -6,7 +6,7 @@
* Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Modified 2011 by Siarhei Siamashka.
- * Copyright (C) 2015, 2017-2018, 2021-2022, D. R. Commander.
+ * Copyright (C) 2015, 2017-2018, 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -523,11 +523,9 @@ start_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (biWidth <= 0 || biHeight <= 0)
ERREXIT(cinfo, JERR_BMP_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)biWidth * biHeight > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
if (biPlanes != 1)
ERREXIT(cinfo, JERR_BMP_BADPLANES);
@@ -681,9 +679,7 @@ jinit_read_bmp(j_compress_ptr cinfo, boolean use_inversion_array)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_bmp;
source->pub.finish_input = finish_input_bmp;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
source->use_inversion_array = use_inversion_array;
diff --git a/rdgif.c b/rdgif.c
index 0cbd2796..23e8b9e1 100644
--- a/rdgif.c
+++ b/rdgif.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2021-2022, D. R. Commander.
+ * Copyright (C) 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -418,11 +418,9 @@ start_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
height = LM_to_uint(hdrbuf, 2);
if (width == 0 || height == 0)
ERREXIT(cinfo, JERR_GIF_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
/* we ignore the color resolution, sort flag, and background color index */
aspectRatio = UCH(hdrbuf[6]);
if (aspectRatio != 0 && aspectRatio != 49)
@@ -467,11 +465,9 @@ start_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
height = LM_to_uint(hdrbuf, 6);
if (width == 0 || height == 0)
ERREXIT(cinfo, JERR_GIF_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
source->is_interlaced = (BitSet(hdrbuf[8], INTERLACE) != 0);
/* Read local colormap if header indicates it is present */
@@ -715,9 +711,7 @@ _jinit_read_gif(j_compress_ptr cinfo)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_gif;
source->pub.finish_input = finish_input_gif;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
return (cjpeg_source_ptr)source;
}
diff --git a/rdppm.c b/rdppm.c
index 57058069..84e26f7b 100644
--- a/rdppm.c
+++ b/rdppm.c
@@ -689,10 +689,8 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
ERREXIT(cinfo, JERR_PPM_NOT);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */
cinfo->image_width = (JDIMENSION)w;
@@ -883,9 +881,7 @@ _jinit_read_ppm(j_compress_ptr cinfo)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_ppm;
source->pub.finish_input = finish_input_ppm;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
return (cjpeg_source_ptr)source;
}
diff --git a/rdtarga.c b/rdtarga.c
index dae0b58d..b78a1653 100644
--- a/rdtarga.c
+++ b/rdtarga.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2018, 2021-2022, D. R. Commander.
+ * Copyright (C) 2018, 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -363,11 +363,9 @@ start_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
interlace_type != 0 || /* currently don't allow interlaced image */
width == 0 || height == 0) /* image width/height must be non-zero */
ERREXIT(cinfo, JERR_TGA_BADPARMS);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
if (subtype > 8) {
/* It's an RLE-coded file */
@@ -501,9 +499,7 @@ jinit_read_targa(j_compress_ptr cinfo)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_tga;
source->pub.finish_input = finish_input_tga;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
return (cjpeg_source_ptr)source;
}
diff --git a/tjbench.c b/tjbench.c
index 566fe8cf..bedc94b4 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -90,7 +90,7 @@ int tjErrorLine = -1, tjErrorCode = -1;
int stopOnWarning = 0, bottomUp = 0, noRealloc = 1, fastUpsample = 0,
fastDCT = 0, optimize = 0, progressive = 0, limitScans = 0, maxMemory = 0,
- arithmetic = 0, lossless = 0, restartIntervalBlocks = 0,
+ maxPixels = 0, arithmetic = 0, lossless = 0, restartIntervalBlocks = 0,
restartIntervalRows = 0;
int precision = 8, sampleSize, compOnly = 0, decompOnly = 0, doYUV = 0,
quiet = 0, doTile = 0, pf = TJPF_BGR, yuvAlign = 1, doWrite = 1;
@@ -204,6 +204,8 @@ static int decomp(unsigned char **jpegBufs, size_t *jpegSizes, void *dstBuf,
THROW_TJ();
if (tj3Set(handle, TJPARAM_MAXMEMORY, maxMemory) == -1)
THROW_TJ();
+ if (tj3Set(handle, TJPARAM_MAXPIXELS, maxPixels) == -1)
+ THROW_TJ();
if (IS_CROPPED(cr)) {
if (tj3DecompressHeader(handle, jpegBufs[0], jpegSizes[0]) == -1)
@@ -659,6 +661,8 @@ static int decompTest(char *fileName)
THROW_TJ();
if (tj3Set(handle, TJPARAM_MAXMEMORY, maxMemory) == -1)
THROW_TJ();
+ if (tj3Set(handle, TJPARAM_MAXPIXELS, maxPixels) == -1)
+ THROW_TJ();
if (tj3DecompressHeader(handle, srcBuf, srcSize) == -1)
THROW_TJ();
@@ -910,6 +914,7 @@ static void usage(char *progName)
printf(" progressive JPEG compression and decompression, optimized baseline entropy\n");
printf(" coding, lossless JPEG compression, and lossless transformation\n");
printf(" [default = no limit]\n");
+ printf("-maxpixels = Input image size limit (in pixels) [default = no limit]\n");
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
printf(" benchmark results)\n");
printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n");
@@ -1161,6 +1166,11 @@ int main(int argc, char *argv[])
if (tempi < 0) usage(argv[0]);
maxMemory = tempi;
+ } else if (!strcasecmp(argv[i], "-maxpixels") && i < argc - 1) {
+ int tempi = atoi(argv[++i]);
+
+ if (tempi < 0) usage(argv[0]);
+ maxPixels = tempi;
} else if (!strcasecmp(argv[i], "-restart") && i < argc - 1) {
int tempi = -1, nscan; char tempc = 0;
@@ -1228,6 +1238,8 @@ int main(int argc, char *argv[])
THROW_TJ();
if (tj3Set(handle, TJPARAM_BOTTOMUP, bottomUp) == -1)
THROW_TJ();
+ if (tj3Set(handle, TJPARAM_MAXPIXELS, maxPixels) == -1)
+ THROW_TJ();
if (precision == 8) {
if ((srcBuf = tj3LoadImage8(handle, argv[1], &w, 1, &h, &pf)) == NULL)
diff --git a/turbojpeg-mp.c b/turbojpeg-mp.c
index 2ca23aa7..9bf346b4 100644
--- a/turbojpeg-mp.c
+++ b/turbojpeg-mp.c
@@ -179,6 +179,9 @@ DLLEXPORT int GET_NAME(tj3Decompress, BITS_IN_JSAMPLE)
jpeg_read_header(dinfo, TRUE);
}
setDecompParameters(this);
+ if (this->maxPixels &&
+ (unsigned long long)this->jpegWidth * this->jpegHeight > this->maxPixels)
+ THROW("Image is too large");
this->dinfo.out_color_space = pf2cs[pixelFormat];
#if BITS_IN_JSAMPLE != 16
scaledWidth = TJSCALED(dinfo->image_width, this->scalingFactor);
@@ -347,10 +350,8 @@ DLLEXPORT _JSAMPLE *GET_NAME(tj3LoadImage, BITS_IN_JSAMPLE)
cinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
src->input_file = file;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- /* Refuse to load images larger than 1 Megapixel when fuzzing. */
+ /* Refuse to load images larger than the specified size. */
src->max_pixels = this->maxPixels;
-#endif
(*src->start_input) (cinfo, src);
if (tempc == 'B') {
if (cinfo->X_density && cinfo->Y_density) {
diff --git a/turbojpeg.c b/turbojpeg.c
index 519a868e..b9fe6e9f 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -109,9 +109,6 @@ typedef struct _tjinstance {
char errStr[JMSG_LENGTH_MAX];
boolean isInstanceError;
/* Parameters */
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- int maxPixels;
-#endif
boolean bottomUp;
boolean noRealloc;
int quality;
@@ -137,6 +134,7 @@ typedef struct _tjinstance {
tjscalingfactor scalingFactor;
tjregion croppingRegion;
int maxMemory;
+ int maxPixels;
} tjinstance;
static tjhandle _tjInitCompress(tjinstance *this);
@@ -592,11 +590,6 @@ DLLEXPORT int tj3Set(tjhandle handle, int param, int value)
GET_TJINSTANCE(handle, -1);
switch (param) {
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- case TJPARAM_MAXPIXELS:
- SET_PARAM(maxPixels, 0, -1);
- break;
-#endif
case TJPARAM_STOPONWARNING:
SET_BOOL_PARAM(jerr.stopOnWarning);
break;
@@ -709,6 +702,9 @@ DLLEXPORT int tj3Set(tjhandle handle, int param, int value)
case TJPARAM_MAXMEMORY:
SET_PARAM(maxMemory, 0, (int)(min(LONG_MAX / 1048576L, (long)INT_MAX)));
break;
+ case TJPARAM_MAXPIXELS:
+ SET_PARAM(maxPixels, 0, -1);
+ break;
default:
THROW("Invalid parameter");
}
@@ -773,6 +769,8 @@ DLLEXPORT int tj3Get(tjhandle handle, int param)
return this->densityUnits;
case TJPARAM_MAXMEMORY:
return this->maxMemory;
+ case TJPARAM_MAXPIXELS:
+ return this->maxPixels;
}
return -1;
@@ -2350,6 +2348,9 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
jpeg_read_header(dinfo, TRUE);
}
setDecompParameters(this);
+ if (this->maxPixels &&
+ (unsigned long long)this->jpegWidth * this->jpegHeight > this->maxPixels)
+ THROW("Image is too large");
if (this->subsamp == TJSAMP_UNKNOWN)
THROW("Could not determine subsampling level of JPEG image");
@@ -2715,6 +2716,10 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
jcopy_markers_setup(dinfo, saveMarkers ? JCOPYOPT_ALL : JCOPYOPT_NONE);
if (dinfo->global_state <= DSTATE_INHEADER)
jpeg_read_header(dinfo, TRUE);
+ if (this->maxPixels &&
+ (unsigned long long)dinfo->image_width * dinfo->image_height >
+ this->maxPixels)
+ THROW("Image is too large");
this->subsamp = getSubsamp(&this->dinfo);
for (i = 0; i < n; i++) {
diff --git a/turbojpeg.h b/turbojpeg.h
index 3058199a..4a09c64d 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -429,9 +429,6 @@ enum TJCS {
* Parameters
*/
enum TJPARAM {
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- TJPARAM_MAXPIXELS = -1,
-#endif
/**
* Error handling behavior
*
@@ -763,7 +760,21 @@ enum TJPARAM {
* decompression, optimized baseline entropy coding, lossless JPEG
* compression, and lossless transformation *[default: `0` (no limit)]*
*/
- TJPARAM_MAXMEMORY
+ TJPARAM_MAXMEMORY,
+ /**
+ * Image size limit [decompression, lossless transformation, packed-pixel
+ * image loading]
+ *
+ * Setting this parameter will cause the decompression, transform, and image
+ * loading functions to return an error if the number of pixels in the source
+ * image exceeds the specified limit. This allows security-critical
+ * applications to guard against excessive memory consumption.
+ *
+ * **Value**
+ * - maximum number of pixels that the decompression, transform, and image
+ * loading functions will process *[default: `0` (no limit)]*
+ */
+ TJPARAM_MAXPIXELS
};
From 3eee0dd747d30ce3db23d21592920978206ae9ec Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 29 Nov 2023 10:03:49 -0500
Subject: [PATCH 039/135] ChangeLog.md: "since" = "relative to"
---
ChangeLog.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 16ec04cd..6ed5aeea 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -2175,7 +2175,7 @@ and unit tests now work on those architectures.
0.0.93
======
-### Significant changes since 0.0.91:
+### Significant changes relative to 0.0.91:
1. 2982659: Fixed x86-64 build on FreeBSD systems
From abeca1f0cc638a6492d81f4c3b956c2dec817c3e Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 30 Nov 2023 09:35:11 -0500
Subject: [PATCH 040/135] Move official releases to GitHub
---
release/rpm.spec.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/release/rpm.spec.in b/release/rpm.spec.in
index 24872dbc..7db85c24 100644
--- a/release/rpm.spec.in
+++ b/release/rpm.spec.in
@@ -45,7 +45,7 @@ Version: @VERSION@
Vendor: @PKGVENDOR@
URL: @PKGURL@
Group: System Environment/Libraries
-#-->Source0: http://prdownloads.sourceforge.net/@CMAKE_PROJECT_NAME@/@CMAKE_PROJECT_NAME@-%{version}.tar.gz
+#-->Source0: https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/%{version}/libjpeg-turbo-%{version}.tar.gz
Release: @BUILD@
License: BSD-style
BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release}
From be96fa0a403e5d084719757f7b8241d20393246d Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 14 Dec 2023 13:18:20 -0500
Subject: [PATCH 041/135] Doc: Lossless JPEG clarifications
- Clarify that lossless JPEG is slower than and doesn't compress as well
as lossy JPEG. (That should be obvious, because "lossy" literally
means that data is thrown away.)
- Re-generate TurboJPEG C API documentation using Doxygen 1.9.8.
- Clarify that setting the data_precision field in jpeg_compress_struct
to 16 requires lossless mode.
- Explain what the predictor selection value actually does. (Refer to
Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994, Section
H.1.2.1.)
---
cjpeg.1 | 9 +-
doc/html/annotated.html | 44 +-
doc/html/bc_sd.png | Bin 0 -> 635 bytes
doc/html/bdwn.png | Bin 147 -> 0 bytes
doc/html/classes.html | 61 +-
doc/html/doc.png | Bin 746 -> 0 bytes
doc/html/doc.svg | 12 +
doc/html/docd.svg | 12 +
doc/html/doxygen-extra.css | 4 +
doc/html/doxygen.css | 1163 ++++++++++++-------
doc/html/doxygen.svg | 4 +-
doc/html/dynsections.js | 71 ++
doc/html/folderclosed.png | Bin 616 -> 0 bytes
doc/html/folderclosed.svg | 11 +
doc/html/folderclosedd.svg | 11 +
doc/html/folderopen.png | Bin 597 -> 0 bytes
doc/html/folderopen.svg | 17 +
doc/html/folderopend.svg | 12 +
doc/html/functions.html | 83 +-
doc/html/functions_vars.html | 85 +-
doc/html/group___turbo_j_p_e_g.html | 1015 ++++++++--------
doc/html/index.html | 42 +-
doc/html/jquery.js | 11 +-
doc/html/menu.js | 97 +-
doc/html/menudata.js | 2 +-
doc/html/minus.svg | 8 +
doc/html/minusd.svg | 8 +
doc/html/nav_fd.png | Bin 0 -> 169 bytes
doc/html/nav_hd.png | Bin 0 -> 114 bytes
doc/html/plus.svg | 9 +
doc/html/plusd.svg | 9 +
doc/html/search/all_0.html | 36 -
doc/html/search/all_1.html | 36 -
doc/html/search/all_1.js | 4 +-
doc/html/search/all_2.html | 36 -
doc/html/search/all_2.js | 2 +-
doc/html/search/all_3.html | 36 -
doc/html/search/all_3.js | 2 +-
doc/html/search/all_4.html | 36 -
doc/html/search/all_4.js | 3 +-
doc/html/search/all_5.html | 36 -
doc/html/search/all_5.js | 3 +-
doc/html/search/all_6.html | 36 -
doc/html/search/all_6.js | 141 +--
doc/html/search/all_7.html | 36 -
doc/html/search/all_7.js | 2 +-
doc/html/search/all_8.html | 36 -
doc/html/search/all_8.js | 140 ++-
doc/html/search/all_9.html | 36 -
doc/html/search/all_9.js | 2 +-
doc/html/search/all_a.js | 4 +
doc/html/search/all_b.js | 5 +
doc/html/search/classes_0.html | 36 -
doc/html/search/classes_0.js | 6 +-
doc/html/search/close.svg | 19 +-
doc/html/search/enums_0.html | 36 -
doc/html/search/enums_0.js | 14 +-
doc/html/search/enumvalues_0.html | 36 -
doc/html/search/enumvalues_0.js | 128 +-
doc/html/search/functions_0.html | 36 -
doc/html/search/functions_0.js | 76 +-
doc/html/search/groups_0.html | 36 -
doc/html/search/groups_0.js | 2 +-
doc/html/search/mag.svg | 24 +
doc/html/search/mag_d.svg | 24 +
doc/html/search/mag_sel.svg | 53 +-
doc/html/search/mag_seld.svg | 31 +
doc/html/search/nomatches.html | 12 -
doc/html/search/search.css | 122 +-
doc/html/search/search.js | 196 ++--
doc/html/search/search_l.png | Bin 567 -> 0 bytes
doc/html/search/search_m.png | Bin 158 -> 0 bytes
doc/html/search/search_r.png | Bin 553 -> 0 bytes
doc/html/search/searchdata.js | 2 +-
doc/html/search/typedefs_0.html | 36 -
doc/html/search/typedefs_0.js | 4 +-
doc/html/search/variables_0.html | 36 -
doc/html/search/variables_0.js | 2 +-
doc/html/search/variables_1.html | 36 -
doc/html/search/variables_1.js | 4 +-
doc/html/search/variables_2.html | 36 -
doc/html/search/variables_2.js | 2 +-
doc/html/search/variables_3.html | 36 -
doc/html/search/variables_3.js | 2 +-
doc/html/search/variables_4.html | 36 -
doc/html/search/variables_4.js | 4 +-
doc/html/search/variables_5.html | 36 -
doc/html/search/variables_5.js | 2 +-
doc/html/search/variables_6.html | 36 -
doc/html/search/variables_6.js | 18 +-
doc/html/search/variables_7.html | 36 -
doc/html/search/variables_7.js | 2 +-
doc/html/search/variables_8.html | 36 -
doc/html/search/variables_8.js | 2 +-
doc/html/search/variables_9.html | 36 -
doc/html/search/variables_9.js | 2 +-
doc/html/splitbard.png | Bin 0 -> 282 bytes
doc/html/structtjregion.html | 78 +-
doc/html/structtjscalingfactor.html | 62 +-
doc/html/structtjtransform.html | 86 +-
doc/html/tab_ad.png | Bin 0 -> 135 bytes
doc/html/tab_bd.png | Bin 0 -> 173 bytes
doc/html/tab_hd.png | Bin 0 -> 180 bytes
doc/html/tab_sd.png | Bin 0 -> 188 bytes
doc/html/tabs.css | 2 +-
doc/html/{modules.html => topics.html} | 46 +-
doxygen-extra.css | 4 +
java/doc/jquery/jquery-ui.min.css | 2 +-
java/doc/jquery/jquery-ui.min.js | 4 +-
java/doc/legal/ADDITIONAL_LICENSE_INFO | 37 +
java/doc/legal/ASSEMBLY_EXCEPTION | 27 +
java/doc/legal/LICENSE | 347 ++++++
java/doc/legal/jquery.md | 72 ++
java/doc/legal/jqueryUI.md | 49 +
java/doc/legal/jszip.md | 653 +++++++++++
java/doc/legal/pako.md | 45 +
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 36 +-
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 34 +-
libjpeg.txt | 35 +-
turbojpeg.h | 32 +-
usage.txt | 6 +-
124 files changed, 3775 insertions(+), 2679 deletions(-)
create mode 100644 doc/html/bc_sd.png
delete mode 100644 doc/html/bdwn.png
delete mode 100644 doc/html/doc.png
create mode 100644 doc/html/doc.svg
create mode 100644 doc/html/docd.svg
delete mode 100644 doc/html/folderclosed.png
create mode 100644 doc/html/folderclosed.svg
create mode 100644 doc/html/folderclosedd.svg
delete mode 100644 doc/html/folderopen.png
create mode 100644 doc/html/folderopen.svg
create mode 100644 doc/html/folderopend.svg
create mode 100644 doc/html/minus.svg
create mode 100644 doc/html/minusd.svg
create mode 100644 doc/html/nav_fd.png
create mode 100644 doc/html/nav_hd.png
create mode 100644 doc/html/plus.svg
create mode 100644 doc/html/plusd.svg
delete mode 100644 doc/html/search/all_0.html
delete mode 100644 doc/html/search/all_1.html
delete mode 100644 doc/html/search/all_2.html
delete mode 100644 doc/html/search/all_3.html
delete mode 100644 doc/html/search/all_4.html
delete mode 100644 doc/html/search/all_5.html
delete mode 100644 doc/html/search/all_6.html
delete mode 100644 doc/html/search/all_7.html
delete mode 100644 doc/html/search/all_8.html
delete mode 100644 doc/html/search/all_9.html
create mode 100644 doc/html/search/all_a.js
create mode 100644 doc/html/search/all_b.js
delete mode 100644 doc/html/search/classes_0.html
delete mode 100644 doc/html/search/enums_0.html
delete mode 100644 doc/html/search/enumvalues_0.html
delete mode 100644 doc/html/search/functions_0.html
delete mode 100644 doc/html/search/groups_0.html
create mode 100644 doc/html/search/mag.svg
create mode 100644 doc/html/search/mag_d.svg
create mode 100644 doc/html/search/mag_seld.svg
delete mode 100644 doc/html/search/nomatches.html
delete mode 100644 doc/html/search/search_l.png
delete mode 100644 doc/html/search/search_m.png
delete mode 100644 doc/html/search/search_r.png
delete mode 100644 doc/html/search/typedefs_0.html
delete mode 100644 doc/html/search/variables_0.html
delete mode 100644 doc/html/search/variables_1.html
delete mode 100644 doc/html/search/variables_2.html
delete mode 100644 doc/html/search/variables_3.html
delete mode 100644 doc/html/search/variables_4.html
delete mode 100644 doc/html/search/variables_5.html
delete mode 100644 doc/html/search/variables_6.html
delete mode 100644 doc/html/search/variables_7.html
delete mode 100644 doc/html/search/variables_8.html
delete mode 100644 doc/html/search/variables_9.html
create mode 100644 doc/html/splitbard.png
create mode 100644 doc/html/tab_ad.png
create mode 100644 doc/html/tab_bd.png
create mode 100644 doc/html/tab_hd.png
create mode 100644 doc/html/tab_sd.png
rename doc/html/{modules.html => topics.html} (64%)
create mode 100644 java/doc/legal/ADDITIONAL_LICENSE_INFO
create mode 100644 java/doc/legal/ASSEMBLY_EXCEPTION
create mode 100644 java/doc/legal/LICENSE
create mode 100644 java/doc/legal/jquery.md
create mode 100644 java/doc/legal/jqueryUI.md
create mode 100644 java/doc/legal/jszip.md
create mode 100644 java/doc/legal/pako.md
diff --git a/cjpeg.1 b/cjpeg.1
index 0815ca0c..f88714d6 100644
--- a/cjpeg.1
+++ b/cjpeg.1
@@ -1,4 +1,4 @@
-.TH CJPEG 1 "29 June 2023"
+.TH CJPEG 1 "14 Dec 2023"
.SH NAME
cjpeg \- compress an image file to a JPEG file
.SH SYNOPSIS
@@ -174,8 +174,11 @@ non-zero point transform value right-shifts the input samples by the specified
number of bits, which is effectively a form of lossy color quantization.)
.B Caution:
lossless JPEG is not yet widely implemented, so many decoders will be unable to
-view a lossless JPEG file at all. Note that the following features will be
-unavailable when compressing or decompressing a lossless JPEG file:
+view a lossless JPEG file at all. In most cases, compressing and decompressing
+a lossless JPEG file is considerably slower than compressing and decompressing
+a lossy JPEG file, and lossless JPEG files are much larger than lossy JPEG
+files. Also note that the following features will be unavailable when
+compressing or decompressing a lossless JPEG file:
.IP
- Quality/quantization table selection
.IP
diff --git a/doc/html/annotated.html b/doc/html/annotated.html
index 734fa849..1e5b5622 100644
--- a/doc/html/annotated.html
+++ b/doc/html/annotated.html
@@ -1,9 +1,9 @@
-
+
-
-
+
+
TurboJPEG: Data Structures
@@ -20,10 +20,9 @@
A callback function that can be used to modify the DCT coefficients after they are losslessly transformed but before they are transcoded to a new JPEG image. More...
A callback function that can be used to modify the DCT coefficients after they are losslessly transformed but before they are transcoded to a new JPEG image.
The documentation for this struct was generated from the following file:
-
turbojpeg.h
+
turbojpeg.h
-Generated by 1.8.20
+Generated by 1.9.8
diff --git a/doc/html/tab_ad.png b/doc/html/tab_ad.png
new file mode 100644
index 0000000000000000000000000000000000000000..e34850acfc24be58da6d2fd1ccc6b29cc84fe34d
GIT binary patch
literal 135
zcmeAS@N?(olHy`uVBq!ia0vp^j6kfy!2~3aiye;!QhuH;jv*C{Z|5d*H3V=pKi{In
zd2jxLclDRPylmD}^l7{QOtL{vUjO{-WqItb5sQp2h-99b8^^Scr-=2mblCdZuUm?4
jzOJvgvt3{(cjKLW5(A@0qPS@<&}0TrS3j3^P6y&q2{!U5bk+Tso_B!YCpDh>v
z{CM*1U8YvQRyBUHt^Ju0W_sq-?;9@_4equ-bavTs=gk796zopr0EBT&m;e9(
literal 0
HcmV?d00001
diff --git a/doc/html/tab_sd.png b/doc/html/tab_sd.png
new file mode 100644
index 0000000000000000000000000000000000000000..757a565ced4730f85c833fb2547d8e199ae68f19
GIT binary patch
literal 188
zcmeAS@N?(olHy`uVBq!ia0vp^j6kfy!2~3aiye;!Qq7(&jv*C{Z|_!fH5o7*c=%9%
zcILh!EA=pAQKdx-Cdiev=v{eg{8Ht<{e8_NAN~b=)%W>-WDCE0PyDHGemi$BoXwcK
z{>e9^za6*c1ilttWw&V+U;WCPlV9{LdC~Ey%_H(qj`xgfES(4Yz5jSTZfCt`4E$0YRsR*S^mTCR^;V&sxC8{l_Cp7w8-YPgg&ebxsLQ00$vXK>z>%
literal 0
HcmV?d00001
diff --git a/doc/html/tabs.css b/doc/html/tabs.css
index 85a0cd5b..71c8a470 100644
--- a/doc/html/tabs.css
+++ b/doc/html/tabs.css
@@ -1 +1 @@
-.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0 1px 1px rgba(255,255,255,0.9);color:#283a5d;outline:0}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace!important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283a5d transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;-moz-border-radius:0!important;-webkit-border-radius:0;border-radius:0!important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a:hover span.sub-arrow{border-color:white transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;-moz-border-radius:5px!important;-webkit-border-radius:5px;border-radius:5px!important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0!important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent white}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px!important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}}
\ No newline at end of file
+.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.main-menu-btn{position:relative;display:inline-block;width:36px;height:36px;text-indent:36px;margin-left:8px;white-space:nowrap;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.main-menu-btn-icon,.main-menu-btn-icon:before,.main-menu-btn-icon:after{position:absolute;top:50%;left:2px;height:2px;width:24px;background:var(--nav-menu-button-color);-webkit-transition:all .25s;transition:all .25s}.main-menu-btn-icon:before{content:'';top:-7px;left:0}.main-menu-btn-icon:after{content:'';top:7px;left:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon{height:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:before{top:0;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:after{top:0;-webkit-transform:rotate(45deg);transform:rotate(45deg)}#main-menu-state{position:absolute;width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden;clip:rect(1px,1px,1px,1px)}#main-menu-state:not(:checked) ~ #main-menu{display:none}#main-menu-state:checked ~ #main-menu{display:block}@media(min-width:768px){.main-menu-btn{position:absolute;top:-99999px}#main-menu-state:not(:checked) ~ #main-menu{display:block}}.sm-dox{background-image:var(--nav-gradient-image)}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:var(--font-family-nav);font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:var(--nav-text-normal-shadow);color:var(--nav-text-normal-color);outline:0}.sm-dox a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:var(--nav-text-hover-shadow)}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace !important;text-align:center;text-shadow:none;background:var(--nav-menu-toggle-color);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a span.sub-arrow:before{display:block;content:'+'}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:var(--nav-menu-background-color)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:var(--nav-menu-background-color);background-image:none}.sm-dox ul a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:var(--nav-gradient-image);line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:var(--nav-text-normal-color) transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:var(--nav-separator-image);background-repeat:no-repeat;background-position:right;-moz-border-radius:0 !important;-webkit-border-radius:0;border-radius:0 !important}.sm-dox a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:var(--nav-text-hover-shadow)}.sm-dox a:hover span.sub-arrow{border-color:var(--nav-text-hover-color) transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent var(--nav-menu-background-color) transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:var(--nav-menu-background-color);-moz-border-radius:5px !important;-webkit-border-radius:5px;border-radius:5px !important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent var(--nav-menu-foreground-color);border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:var(--nav-menu-foreground-color);background-image:none;border:0 !important;color:var(--nav-menu-foreground-color);background-image:none}.sm-dox ul a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:var(--nav-text-hover-shadow)}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent var(--nav-text-hover-color)}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:var(--nav-menu-background-color);height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent var(--nav-menu-foreground-color) transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:var(--nav-menu-foreground-color) transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px !important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:var(--nav-gradient-image)}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:var(--nav-menu-background-color)}}
\ No newline at end of file
diff --git a/doc/html/modules.html b/doc/html/topics.html
similarity index 64%
rename from doc/html/modules.html
rename to doc/html/topics.html
index 6dbbbf94..5b4a88ff 100644
--- a/doc/html/modules.html
+++ b/doc/html/topics.html
@@ -1,11 +1,11 @@
-
+
-
-
+
+
-TurboJPEG: Modules
+TurboJPEG: Topics
@@ -20,10 +20,9 @@
").text(e.label)).appendTo(t)},_move:function(t,e){if(this.menu.element.is(":visible"))return this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this.isMultiLine||this._value(this.term),void this.menu.blur()):void this.menu[t](e);this.search(null,e)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){this.isMultiLine&&!this.menu.element.is(":visible")||(this._move(t,e),e.preventDefault())},_isContentEditable:function(t){if(!t.length)return!1;var e=t.prop("contentEditable");return"inherit"===e?this._isContentEditable(t.parent()):"true"===e}}),x.extend(x.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,e){var i=new RegExp(x.ui.autocomplete.escapeRegex(e),"i");return x.grep(t,function(t){return i.test(t.label||t.value||t)})}}),x.widget("ui.autocomplete",x.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(1").text(e))},100))}});x.ui.autocomplete});
\ No newline at end of file
diff --git a/java/doc/legal/ADDITIONAL_LICENSE_INFO b/java/doc/legal/ADDITIONAL_LICENSE_INFO
new file mode 100644
index 00000000..ff700cd0
--- /dev/null
+++ b/java/doc/legal/ADDITIONAL_LICENSE_INFO
@@ -0,0 +1,37 @@
+ ADDITIONAL INFORMATION ABOUT LICENSING
+
+Certain files distributed by Oracle America, Inc. and/or its affiliates are
+subject to the following clarification and special exception to the GPLv2,
+based on the GNU Project exception for its Classpath libraries, known as the
+GNU Classpath Exception.
+
+Note that Oracle includes multiple, independent programs in this software
+package. Some of those programs are provided under licenses deemed
+incompatible with the GPLv2 by the Free Software Foundation and others.
+For example, the package includes programs licensed under the Apache
+License, Version 2.0 and may include FreeType. Such programs are licensed
+to you under their original licenses.
+
+Oracle facilitates your further distribution of this package by adding the
+Classpath Exception to the necessary parts of its GPLv2 code, which permits
+you to use that code in combination with other independent modules not
+licensed under the GPLv2. However, note that this would not permit you to
+commingle code under an incompatible license with Oracle's GPLv2 licensed
+code by, for example, cutting and pasting such code into a file also
+containing Oracle's GPLv2 licensed code and then distributing the result.
+
+Additionally, if you were to remove the Classpath Exception from any of the
+files to which it applies and distribute the result, you would likely be
+required to license some or all of the other code in that distribution under
+the GPLv2 as well, and since the GPLv2 is incompatible with the license terms
+of some items included in the distribution by Oracle, removing the Classpath
+Exception could therefore effectively compromise your ability to further
+distribute the package.
+
+Failing to distribute notices associated with some files may also create
+unexpected legal consequences.
+
+Proceed with caution and we recommend that you obtain the advice of a lawyer
+skilled in open source matters before removing the Classpath Exception or
+making modifications to this package which may subsequently be redistributed
+and/or involve the use of third party software.
diff --git a/java/doc/legal/ASSEMBLY_EXCEPTION b/java/doc/legal/ASSEMBLY_EXCEPTION
new file mode 100644
index 00000000..065b8d90
--- /dev/null
+++ b/java/doc/legal/ASSEMBLY_EXCEPTION
@@ -0,0 +1,27 @@
+
+OPENJDK ASSEMBLY EXCEPTION
+
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License version 2
+only ("GPL2"), with the following clarification and special exception.
+
+ Linking this OpenJDK Code statically or dynamically with other code
+ is making a combined work based on this library. Thus, the terms
+ and conditions of GPL2 cover the whole combination.
+
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
+ http://openjdk.java.net/legal/exception-modules-2007-05-08.html
+ ("Designated Exception Modules") to produce an executable,
+ regardless of the license terms of the Designated Exception Modules,
+ and to copy and distribute the resulting executable under GPL2,
+ provided that the Designated Exception Modules continue to be
+ governed by the licenses under which they were offered by Oracle.
+
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
diff --git a/java/doc/legal/LICENSE b/java/doc/legal/LICENSE
new file mode 100644
index 00000000..8b400c7a
--- /dev/null
+++ b/java/doc/legal/LICENSE
@@ -0,0 +1,347 @@
+The GNU General Public License (GPL)
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license
+document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share
+and change it. By contrast, the GNU General Public License is intended to
+guarantee your freedom to share and change free software--to make sure the
+software is free for all its users. This General Public License applies to
+most of the Free Software Foundation's software and to any other program whose
+authors commit to using it. (Some other Free Software Foundation software is
+covered by the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the freedom to
+distribute copies of free software (and charge for this service if you wish),
+that you receive source code or can get it if you want it, that you can change
+the software or use pieces of it in new free programs; and that you know you
+can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny
+you these rights or to ask you to surrender the rights. These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have. You must
+make sure that they, too, receive or can get the source code. And you must
+show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients to
+know that what they have is not the original, so that any problems introduced
+by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program proprietary.
+To prevent this, we have made it clear that any patent must be licensed for
+everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms of
+this General Public License. The "Program", below, refers to any such program
+or work, and a "work based on the Program" means either the Program or any
+derivative work under copyright law: that is to say, a work containing the
+Program or a portion of it, either verbatim or with modifications and/or
+translated into another language. (Hereinafter, translation is included
+without limitation in the term "modification".) Each licensee is addressed as
+"you".
+
+Activities other than copying, distribution and modification are not covered by
+this License; they are outside its scope. The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made by
+running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as
+you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may
+at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus
+forming a work based on the Program, and copy and distribute such modifications
+or work under the terms of Section 1 above, provided that you also meet all of
+these conditions:
+
+ a) You must cause the modified files to carry prominent notices stating
+ that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in whole or
+ in part contains or is derived from the Program or any part thereof, to be
+ licensed as a whole at no charge to all third parties under the terms of
+ this License.
+
+ c) If the modified program normally reads commands interactively when run,
+ you must cause it, when started running for such interactive use in the
+ most ordinary way, to print or display an announcement including an
+ appropriate copyright notice and a notice that there is no warranty (or
+ else, saying that you provide a warranty) and that users may redistribute
+ the program under these conditions, and telling the user how to view a copy
+ of this License. (Exception: if the Program itself is interactive but does
+ not normally print such an announcement, your work based on the Program is
+ not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be reasonably
+considered independent and separate works in themselves, then this License, and
+its terms, do not apply to those sections when you distribute them as separate
+works. But when you distribute the same sections as part of a whole which is a
+work based on the Program, the distribution of the whole must be on the terms
+of this License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your
+rights to work written entirely by you; rather, the intent is to exercise the
+right to control the distribution of derivative or collective works based on
+the Program.
+
+In addition, mere aggregation of another work not based on the Program with the
+Program (or with a work based on the Program) on a volume of a storage or
+distribution medium does not bring the other work under the scope of this
+License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1 and
+2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable source
+ code, which must be distributed under the terms of Sections 1 and 2 above
+ on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three years, to
+ give any third party, for a charge no more than your cost of physically
+ performing source distribution, a complete machine-readable copy of the
+ corresponding source code, to be distributed under the terms of Sections 1
+ and 2 above on a medium customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer to
+ distribute corresponding source code. (This alternative is allowed only
+ for noncommercial distribution and only if you received the program in
+ object code or executable form with such an offer, in accord with
+ Subsection b above.)
+
+The source code for a work means the preferred form of the work for making
+modifications to it. For an executable work, complete source code means all
+the source code for all modules it contains, plus any associated interface
+definition files, plus the scripts used to control compilation and installation
+of the executable. However, as a special exception, the source code
+distributed need not include anything that is normally distributed (in either
+source or binary form) with the major components (compiler, kernel, and so on)
+of the operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the source
+code from the same place counts as distribution of the source code, even though
+third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy, modify,
+sublicense or distribute the Program is void, and will automatically terminate
+your rights under this License. However, parties who have received copies, or
+rights, from you under this License will not have their licenses terminated so
+long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the Program
+or its derivative works. These actions are prohibited by law if you do not
+accept this License. Therefore, by modifying or distributing the Program (or
+any work based on the Program), you indicate your acceptance of this License to
+do so, and all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program),
+the recipient automatically receives a license from the original licensor to
+copy, distribute or modify the Program subject to these terms and conditions.
+You may not impose any further restrictions on the recipients' exercise of the
+rights granted herein. You are not responsible for enforcing compliance by
+third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose that
+choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original
+copyright holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In
+such case, this License incorporates the limitation as if written in the body
+of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the
+General Public License from time to time. Such new versions will be similar in
+spirit to the present version, but may differ in detail to address new problems
+or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any later
+version", you have the option of following the terms and conditions either of
+that version or of any later version published by the Free Software Foundation.
+If the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software Foundation,
+write to the Free Software Foundation; we sometimes make exceptions for this.
+Our decision will be guided by the two goals of preserving the free status of
+all derivatives of our free software and of promoting the sharing and reuse of
+software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
+PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
+YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
+ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
+PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
+BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
+OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible
+use to the public, the best way to achieve this is to make it free software
+which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach
+them to the start of each source file to most effectively convey the exclusion
+of warranty; and each file should have at least the "copyright" line and a
+pointer to where the full notice is found.
+
+ One line to give the program's name and a brief idea of what it does.
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it
+starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
+ with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free
+ software, and you are welcome to redistribute it under certain conditions;
+ type 'show c' for details.
+
+The hypothetical commands 'show w' and 'show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may be
+called something other than 'show w' and 'show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school,
+if any, to sign a "copyright disclaimer" for the program, if necessary. Here
+is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ 'Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ signature of Ty Coon, 1 April 1989
+
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General Public
+License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL
+
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
+
+ Linking this library statically or dynamically with other modules is making
+ a combined work based on this library. Thus, the terms and conditions of
+ the GNU General Public License cover the whole combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent modules,
+ and to copy and distribute the resulting executable under terms of your
+ choice, provided that you also meet, for each linked independent module,
+ the terms and conditions of the license of that module. An independent
+ module is a module which is not derived from or based on this library. If
+ you modify this library, you may extend this exception to your version of
+ the library, but you are not obligated to do so. If you do not wish to do
+ so, delete this exception statement from your version.
diff --git a/java/doc/legal/jquery.md b/java/doc/legal/jquery.md
new file mode 100644
index 00000000..d468b318
--- /dev/null
+++ b/java/doc/legal/jquery.md
@@ -0,0 +1,72 @@
+## jQuery v3.6.1
+
+### jQuery License
+```
+jQuery v 3.6.1
+Copyright OpenJS Foundation and other contributors, https://openjsf.org/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************
+
+The jQuery JavaScript Library v3.6.1 also includes Sizzle.js
+
+Sizzle.js includes the following license:
+
+Copyright JS Foundation and other contributors, https://js.foundation/
+
+This software consists of voluntary contributions made by many
+individuals. For exact contribution history, see the revision history
+available at https://github.com/jquery/sizzle
+
+The following license applies to all parts of this software except as
+documented below:
+
+====
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+====
+
+All files located in the node_modules and external directories are
+externally maintained libraries used by this software which have their
+own licenses; we recommend you read them, as their terms may differ from
+the terms above.
+
+*********************
+
+```
diff --git a/java/doc/legal/jqueryUI.md b/java/doc/legal/jqueryUI.md
new file mode 100644
index 00000000..8bda9d7a
--- /dev/null
+++ b/java/doc/legal/jqueryUI.md
@@ -0,0 +1,49 @@
+## jQuery UI v1.13.2
+
+### jQuery UI License
+```
+Copyright jQuery Foundation and other contributors, https://jquery.org/
+
+This software consists of voluntary contributions made by many
+individuals. For exact contribution history, see the revision history
+available at https://github.com/jquery/jquery-ui
+
+The following license applies to all parts of this software except as
+documented below:
+
+====
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+====
+
+Copyright and related rights for sample code are waived via CC0. Sample
+code is defined as all source code contained within the demos directory.
+
+CC0: http://creativecommons.org/publicdomain/zero/1.0/
+
+====
+
+All files located in the node_modules and external directories are
+externally maintained libraries used by this software which have their
+own licenses; we recommend you read them, as their terms may differ from
+the terms above.
+
+```
diff --git a/java/doc/legal/jszip.md b/java/doc/legal/jszip.md
new file mode 100644
index 00000000..fad2cb15
--- /dev/null
+++ b/java/doc/legal/jszip.md
@@ -0,0 +1,653 @@
+## JSZip v3.7.1
+
+JSZip is dual licensed. You may use it under the MIT license *or* the GPLv3
+license.
+
+### The MIT License
+```
+Copyright (c) 2009-2016 Stuart Knightley, David Duponchel, Franz Buchinger, António Afonso
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+```
+
+### GPL version 3
+```
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+```
diff --git a/java/doc/legal/pako.md b/java/doc/legal/pako.md
new file mode 100644
index 00000000..de339d89
--- /dev/null
+++ b/java/doc/legal/pako.md
@@ -0,0 +1,45 @@
+## Pako v1.0
+
+### Pako License
+
+Copyright (C) 2014-2017 by Vitaly Puzrin and Andrei Tuputcyn
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+(C) 1995-2013 Jean-loup Gailly and Mark Adler
+(C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software
+in a product, an acknowledgment in the product documentation would be
+appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+
In most cases, compressing and decompressing lossless JPEG images is
- considerably slower than compressing and decompressing lossy JPEG images.
- Also note that the following features are not available with lossless JPEG
- images:
+ considerably slower than compressing and decompressing lossy JPEG images,
+ and lossless JPEG images are much larger than lossy JPEG images. Thus,
+ lossless JPEG images are typically used only for applications that require
+ mathematically lossless compression. Also note that the following
+ features are not available with lossless JPEG images:
Colorspace conversion (lossless JPEG images always use
CS_RGB, CS_GRAY, or CS_CMYK, depending on the
@@ -1679,7 +1681,33 @@ extends java.lang.Object
1-7[default for compression:
1]
-
+
+
+
Lossless JPEG compression shares no algorithms with lossy JPEG
+ compression. Instead, it uses differential pulse-code modulation (DPCM),
+ an algorithm whereby each sample is encoded as the difference between the
+ sample's value and a "predictor", which is based on the values of
+ neighboring samples. If Ra is the sample immediately to the left of the
+ current sample, Rb is the sample immediately above the current sample, and
+ Rc is the sample diagonally to the left and above the current sample, then
+ the relationship between the predictor selection value and the predictor
+ is as follows:
+
+
+
+
PSV
Predictor
+
1
Ra
+
2
Rb
+
3
Rc
+
4
Ra + Rb – Rc
+
5
Ra + (Rb – Rc) / 2
+
6
Rb + (Ra – Rc) / 2
+
7
(Ra + Rb) / 2
+
+
+
Predictors 1-3 are 1-dimensional predictors, whereas Predictors 4-7 are
+ 2-dimensional predictors. The best predictor for a particular image
+ depends on the image.
In most cases, compressing and decompressing lossless JPEG images is
- * considerably slower than compressing and decompressing lossy JPEG images.
- * Also note that the following features are not available with lossless JPEG
- * images:
+ * considerably slower than compressing and decompressing lossy JPEG images,
+ * and lossless JPEG images are much larger than lossy JPEG images. Thus,
+ * lossless JPEG images are typically used only for applications that require
+ * mathematically lossless compression. Also note that the following
+ * features are not available with lossless JPEG images:
*
*
Colorspace conversion (lossless JPEG images always use
* {@link #CS_RGB}, {@link #CS_GRAY}, or {@link #CS_CMYK}, depending on the
@@ -660,6 +662,32 @@ public final class TJ {
* 1]
*
*
+ *
Lossless JPEG compression shares no algorithms with lossy JPEG
+ * compression. Instead, it uses differential pulse-code modulation (DPCM),
+ * an algorithm whereby each sample is encoded as the difference between the
+ * sample's value and a "predictor", which is based on the values of
+ * neighboring samples. If Ra is the sample immediately to the left of the
+ * current sample, Rb is the sample immediately above the current sample, and
+ * Rc is the sample diagonally to the left and above the current sample, then
+ * the relationship between the predictor selection value and the predictor
+ * is as follows:
+ *
+ *
+ *
+ *
PSV
Predictor
+ *
1
Ra
+ *
2
Rb
+ *
3
Rc
+ *
4
Ra + Rb – Rc
+ *
5
Ra + (Rb – Rc) / 2
+ *
6
Rb + (Ra – Rc) / 2
+ *
7
(Ra + Rb) / 2
+ *
+ *
+ *
Predictors 1-3 are 1-dimensional predictors, whereas Predictors 4-7 are
+ * 2-dimensional predictors. The best predictor for a particular image
+ * depends on the image.
+ *
* @see #PARAM_LOSSLESS
*/
public static final int PARAM_LOSSLESSPSV = 16;
diff --git a/libjpeg.txt b/libjpeg.txt
index 2dae2d20..0fe95bb6 100644
--- a/libjpeg.txt
+++ b/libjpeg.txt
@@ -1028,8 +1028,11 @@ jpeg_enable_lossless (j_compress_ptr cinfo, int predictor_selection_value,
is necessary in order to create a fully lossless JPEG image. (A
non-zero point transform value right-shifts the input samples by the
specified number of bits, which is effectively a form of lossy color
- quantization.) Note that the following features will be unavailable
- when compressing or decompressing lossless JPEG images:
+ quantization.) In most cases, lossless mode is considerably slower
+ than, and does not compress as effectively as, lossy mode. Thus, it is
+ typically used only for applications that require mathematically
+ lossless compression. Note that the following features will be
+ unavailable when compressing or decompressing lossless JPEG images:
* Partial image decompression
* Quality/quantization table selection
* DCT/IDCT algorithm selection
@@ -1044,6 +1047,30 @@ jpeg_enable_lossless (j_compress_ptr cinfo, int predictor_selection_value,
Any parameters used to enable or configure those features will be
ignored.
+ Lossless mode shares no algorithms with lossy mode. Instead, it uses
+ differential pulse-code modulation (DPCM), an algorithm whereby each
+ sample is encoded as the difference between the sample's value and a
+ "predictor", which is based on the values of neighboring samples. If
+ Ra is the sample immediately to the left of the current sample, Rb is
+ the sample immediately above the current sample, and Rc is the sample
+ diagonally to the left and above the current sample, then the
+ relationship between the predictor selection value and the predictor is
+ as follows:
+
+ PSV Predictor
+ --------------
+ 1 Ra
+ 2 Rb
+ 3 Rc
+ 4 Ra + Rb – Rc
+ 5 Ra + (Rb – Rc) / 2
+ 6 Rb + (Ra – Rc) / 2
+ 7 (Ra + Rb) / 2
+
+ Predictors 1-3 are 1-dimensional predictors, whereas Predictors 4-7 are
+ 2-dimensional predictors. The best predictor for a particular image
+ depends on the image.
+
Compression parameters (cinfo fields) include:
@@ -1058,7 +1085,9 @@ int data_precision
jpeg_write_scanlines() or jpeg_write_raw_data(). To create a
16-bit-per-component lossless JPEG file, set data_precision to 16 prior
to calling jpeg_start_compress() or using the memory manager, then use
- jpeg16_write_scanlines() instead of jpeg_write_scanlines().
+ jpeg16_write_scanlines() instead of jpeg_write_scanlines(). Note that
+ 16-bit data precision requires lossless mode. (See
+ jpeg_enable_lossless().)
J_DCT_METHOD dct_method
Selects the algorithm used for the DCT step. Choices are:
diff --git a/turbojpeg.h b/turbojpeg.h
index 4a09c64d..68b88a41 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -621,9 +621,11 @@ enum TJPARAM {
* lossless/predictive.
*
* In most cases, compressing and decompressing lossless JPEG images is
- * considerably slower than compressing and decompressing lossy JPEG images.
- * Also note that the following features are not available with lossless JPEG
- * images:
+ * considerably slower than compressing and decompressing lossy JPEG images,
+ * and lossless JPEG images are much larger than lossy JPEG images. Thus,
+ * lossless JPEG images are typically used only for applications that require
+ * mathematically lossless compression. Also note that the following
+ * features are not available with lossless JPEG images:
* - Colorspace conversion (lossless JPEG images always use #TJCS_RGB,
* #TJCS_GRAY, or #TJCS_CMYK, depending on the pixel format of the source
* image)
@@ -645,6 +647,30 @@ enum TJPARAM {
* **Value**
* - `1`-`7` *[default for compression: `1`]*
*
+ * Lossless JPEG compression shares no algorithms with lossy JPEG
+ * compression. Instead, it uses differential pulse-code modulation (DPCM),
+ * an algorithm whereby each sample is encoded as the difference between the
+ * sample's value and a "predictor", which is based on the values of
+ * neighboring samples. If Ra is the sample immediately to the left of the
+ * current sample, Rb is the sample immediately above the current sample, and
+ * Rc is the sample diagonally to the left and above the current sample, then
+ * the relationship between the predictor selection value and the predictor
+ * is as follows:
+ *
+ * PSV | Predictor
+ * ----|----------
+ * 1 | Ra
+ * 2 | Rb
+ * 3 | Rc
+ * 4 | Ra + Rb – Rc
+ * 5 | Ra + (Rb – Rc) / 2
+ * 6 | Rb + (Ra – Rc) / 2
+ * 7 | (Ra + Rb) / 2
+ *
+ * Predictors 1-3 are 1-dimensional predictors, whereas Predictors 4-7 are
+ * 2-dimensional predictors. The best predictor for a particular image
+ * depends on the image.
+ *
* @see #TJPARAM_LOSSLESS
*/
TJPARAM_LOSSLESSPSV,
diff --git a/usage.txt b/usage.txt
index c1bba4ae..2497ce08 100644
--- a/usage.txt
+++ b/usage.txt
@@ -177,7 +177,11 @@ Switches for advanced users:
number of bits, which is effectively a form of lossy
color quantization.) CAUTION: lossless JPEG is not yet
widely implemented, so many decoders will be unable to
- view a lossless JPEG file at all. Note that the
+ view a lossless JPEG file at all. In most cases,
+ compressing and decompressing a lossless JPEG file is
+ considerably slower than compressing and decompressing
+ a lossy JPEG file, and lossless JPEG files are much
+ larger than lossy JPEG files. Also note that the
following features will be unavailable when compressing
or decompressing a lossless JPEG file:
* Quality/quantization table selection
From fa2b6ea09253ce06152bc31591f6b84a3286502d Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 12 Jan 2024 18:21:41 -0500
Subject: [PATCH 042/135] Eliminate duplicate copies of jpeg_nbits_table
ef9a4e05ba919494cbebe50e15f332de5ab97e82 (libjpeg-turbo 1.4.x), which
was based on
https://bug815473.bmoattachments.org/attachment.cgi?id=692126
(https://bugzilla.mozilla.org/show_bug.cgi?id=815473), modified the C
baseline Huffman encoder so that it precomputes jpeg_nbits_table, in
order to facilitate sharing the table among multiple processes.
However, libjpeg-turbo never shared the table, and because the table was
implemented as a static array, f3a8684cd1c28e557d394470962a7a224c76ddbc
(libjpeg-turbo 1.5.x) and 37bae1a0e977ee1ba769e6f0aa27e519ab6e58c6
(libjpeg-turbo 2.0.x) each introduced a duplicate copy of the table for
(respectively) the SSE2 baseline Huffman encoder and the C progressive
Huffman encoder.
This commit does the following:
- Move the duplicated code in jchuff.c and jcphuff.c, originally
introduced in 0cfc4c17b740cb2cbb11f9d85c8ab3745d5b913a and
37bae1a0e977ee1ba769e6f0aa27e519ab6e58c6, into a header
(jpeg_nbits.h).
- Credit the co-author of 0cfc4c17b740cb2cbb11f9d85c8ab3745d5b913a.
(Refer to https://sourceforge.net/p/libjpeg-turbo/patches/57).
- Modify the SSE2 baseline Huffman encoder so that the C Huffman
encoders can share its definition of jpeg_nbits_table.
- Move the definition of jpeg_nbits_table into a C source file
(jpeg_nbits.c) rather than a header, and define the table only if
USE_CLZ_INTRINSIC is undefined and the SSE2 baseline Huffman encoder
will not be built.
- Apply hidden symbol visibility to the shared definition of
jpeg_nbits_table, if the compiler supports the necessary attribute.
(In practice, only Visual C++ doesn't.)
Closes #114
See also:
https://bugzilla.mozilla.org/show_bug.cgi?id=1501523
---
CMakeLists.txt | 11 +++++++-
jchuff.c | 38 ++------------------------
jconfigint.h.in | 3 +++
jcphuff.c | 37 ++-----------------------
jpeg_nbits_table.h => jpeg_nbits.c | 38 +++++++++++++++++++++++++-
jpeg_nbits.h | 43 ++++++++++++++++++++++++++++++
simd/i386/jchuff-sse2.asm | 11 ++++----
simd/x86_64/jchuff-sse2.asm | 11 ++++----
8 files changed, 109 insertions(+), 83 deletions(-)
rename jpeg_nbits_table.h => jpeg_nbits.c (99%)
create mode 100644 jpeg_nbits.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02709e9a..66e077ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -468,6 +468,15 @@ if(UNIX)
endif()
endif()
+if(NOT MSVC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ check_c_source_compiles("const int __attribute__((visibility(\"hidden\"))) table[1] = { 0 }; int main(void) { return table[0]; }"
+ HIDDEN_WORKS)
+ if(HIDDEN_WORKS)
+ set(HIDDEN "__attribute__((visibility(\"hidden\")))")
+ message(STATUS "HIDDEN = ${HIDDEN}")
+ endif()
+endif()
+
if(MSVC)
set(INLINE_OPTIONS "__inline;inline")
else()
@@ -572,7 +581,7 @@ set(JPEG_SOURCES ${JPEG12_SOURCES} jcapimin.c jchuff.c jcicc.c jcinit.c
jclhuff.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c jctrans.c
jdapimin.c jdatadst.c jdatasrc.c jdhuff.c jdicc.c jdinput.c jdlhuff.c
jdmarker.c jdmaster.c jdphuff.c jdtrans.c jerror.c jfdctflt.c jmemmgr.c
- jmemnobs.c)
+ jmemnobs.c jpeg_nbits.c)
if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
diff --git a/jchuff.c b/jchuff.c
index 3fede05f..488c9b5c 100644
--- a/jchuff.c
+++ b/jchuff.c
@@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2014-2016, 2018-2023, D. R. Commander.
+ * Copyright (C) 2009-2011, 2014-2016, 2018-2024, D. R. Commander.
* Copyright (C) 2015, Matthieu Darbois.
* Copyright (C) 2018, Matthias Räncker.
* Copyright (C) 2020, Arm Limited.
@@ -35,41 +35,7 @@
#include "jchuff.h" /* Declarations shared with jc*huff.c */
#endif
#include
-
-/*
- * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
- * used for bit counting rather than the lookup table. This will reduce the
- * memory footprint by 64k, which is important for some mobile applications
- * that create many isolated instances of libjpeg-turbo (web browsers, for
- * instance.) This may improve performance on some mobile platforms as well.
- * This feature is enabled by default only on Arm processors, because some x86
- * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
- * shown to have a significant performance impact even on the x86 chips that
- * have a fast implementation of it. When building for Armv6, you can
- * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
- * flags (this defines __thumb__).
- */
-
-/* NOTE: Both GCC and Clang define __GNUC__ */
-#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
- defined(_M_ARM) || defined(_M_ARM64)
-#if !defined(__thumb__) || defined(__thumb2__)
-#define USE_CLZ_INTRINSIC
-#endif
-#endif
-
-#ifdef USE_CLZ_INTRINSIC
-#if defined(_MSC_VER) && !defined(__clang__)
-#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
-#else
-#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
-#endif
-#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
-#else
-#include "jpeg_nbits_table.h"
-#define JPEG_NBITS(x) (jpeg_nbits_table[x])
-#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
-#endif
+#include "jpeg_nbits.h"
/* Expanded entropy encoder object for Huffman encoding.
diff --git a/jconfigint.h.in b/jconfigint.h.in
index e7e66e74..5c14e32a 100644
--- a/jconfigint.h.in
+++ b/jconfigint.h.in
@@ -1,6 +1,9 @@
/* libjpeg-turbo build number */
#define BUILD "@BUILD@"
+/* How to hide global symbols. */
+#define HIDDEN @HIDDEN@
+
/* Compiler's inline keyword */
#undef inline
diff --git a/jcphuff.c b/jcphuff.c
index 56e63bd6..484e2d85 100644
--- a/jcphuff.c
+++ b/jcphuff.c
@@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2018, 2021-2022, D. R. Commander.
+ * Copyright (C) 2011, 2015, 2018, 2021-2022, 2024, D. R. Commander.
* Copyright (C) 2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
* Copyright (C) 2021, Alex Richardson.
@@ -44,40 +44,7 @@
#ifdef C_PROGRESSIVE_SUPPORTED
-/*
- * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
- * used for bit counting rather than the lookup table. This will reduce the
- * memory footprint by 64k, which is important for some mobile applications
- * that create many isolated instances of libjpeg-turbo (web browsers, for
- * instance.) This may improve performance on some mobile platforms as well.
- * This feature is enabled by default only on Arm processors, because some x86
- * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
- * shown to have a significant performance impact even on the x86 chips that
- * have a fast implementation of it. When building for Armv6, you can
- * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
- * flags (this defines __thumb__).
- */
-
-/* NOTE: Both GCC and Clang define __GNUC__ */
-#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
- defined(_M_ARM) || defined(_M_ARM64)
-#if !defined(__thumb__) || defined(__thumb2__)
-#define USE_CLZ_INTRINSIC
-#endif
-#endif
-
-#ifdef USE_CLZ_INTRINSIC
-#if defined(_MSC_VER) && !defined(__clang__)
-#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
-#else
-#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
-#endif
-#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
-#else
-#include "jpeg_nbits_table.h"
-#define JPEG_NBITS(x) (jpeg_nbits_table[x])
-#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
-#endif
+#include "jpeg_nbits.h"
/* Expanded entropy encoder object for progressive Huffman encoding. */
diff --git a/jpeg_nbits_table.h b/jpeg_nbits.c
similarity index 99%
rename from jpeg_nbits_table.h
rename to jpeg_nbits.c
index fcf73878..c8ee6b05 100644
--- a/jpeg_nbits_table.h
+++ b/jpeg_nbits.c
@@ -1,4 +1,32 @@
-static const unsigned char jpeg_nbits_table[65536] = {
+/*
+ * Copyright (C) 2024, D. R. Commander.
+ *
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ */
+
+#include "jpeg_nbits.h"
+#include "jconfigint.h"
+
+
+#ifndef USE_CLZ_INTRINSIC
+
+#define INCLUDE_JPEG_NBITS_TABLE
+
+/* When building for x86[-64] with the SIMD extensions enabled, the C Huffman
+ * encoders can reuse jpeg_nbits_table from the SSE2 baseline Huffman encoder.
+ */
+#if (defined(__x86_64__) || defined(__i386__) || defined(_M_IX86) || \
+ defined(_M_X64)) && defined(WITH_SIMD)
+#undef INCLUDE_JPEG_NBITS_TABLE
+#endif
+
+#endif
+
+
+#ifdef INCLUDE_JPEG_NBITS_TABLE
+
+const unsigned char HIDDEN jpeg_nbits_table[65536] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
@@ -4096,3 +4124,11 @@ static const unsigned char jpeg_nbits_table[65536] = {
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
};
+
+#else
+
+/* Suppress compiler warnings about empty translation unit. */
+
+typedef int dummy_jpeg_nbits_table;
+
+#endif
diff --git a/jpeg_nbits.h b/jpeg_nbits.h
new file mode 100644
index 00000000..6481a122
--- /dev/null
+++ b/jpeg_nbits.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014, 2021, 2024, D. R. Commander.
+ * Copyright (C) 2014, Olle Liljenzin.
+ * Copyright (C) 2020, Arm Limited.
+ *
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ */
+
+/*
+ * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
+ * used for bit counting rather than the lookup table. This will reduce the
+ * memory footprint by 64k, which is important for some mobile applications
+ * that create many isolated instances of libjpeg-turbo (web browsers, for
+ * instance.) This may improve performance on some mobile platforms as well.
+ * This feature is enabled by default only on Arm processors, because some x86
+ * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
+ * shown to have a significant performance impact even on the x86 chips that
+ * have a fast implementation of it. When building for Armv6, you can
+ * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
+ * flags (this defines __thumb__).
+ */
+
+/* NOTE: Both GCC and Clang define __GNUC__ */
+#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
+ defined(_M_ARM) || defined(_M_ARM64)
+#if !defined(__thumb__) || defined(__thumb2__)
+#define USE_CLZ_INTRINSIC
+#endif
+#endif
+
+#ifdef USE_CLZ_INTRINSIC
+#if defined(_MSC_VER) && !defined(__clang__)
+#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
+#else
+#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
+#endif
+#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
+#else
+extern const unsigned char jpeg_nbits_table[65536];
+#define JPEG_NBITS(x) (jpeg_nbits_table[x])
+#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
+#endif
diff --git a/simd/i386/jchuff-sse2.asm b/simd/i386/jchuff-sse2.asm
index 278cf5e8..76cc85f6 100644
--- a/simd/i386/jchuff-sse2.asm
+++ b/simd/i386/jchuff-sse2.asm
@@ -1,7 +1,7 @@
;
; jchuff-sse2.asm - Huffman entropy encoding (SSE2)
;
-; Copyright (C) 2009-2011, 2014-2017, 2019, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2017, 2019, 2024, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
;
@@ -65,7 +65,8 @@ times 1 << 2 db 3
times 1 << 1 db 2
times 1 << 0 db 1
times 1 db 0
-jpeg_nbits_table:
+GLOBAL_DATA(jpeg_nbits_table)
+EXTN(jpeg_nbits_table):
times 1 db 0
times 1 << 0 db 1
times 1 << 1 db 2
@@ -88,9 +89,9 @@ times 1 << 14 db 15
%ifdef PIC
%define NBITS(x) nbits_base + x
%else
-%define NBITS(x) jpeg_nbits_table + x
+%define NBITS(x) EXTN(jpeg_nbits_table) + x
%endif
-%define MASK_BITS(x) NBITS((x) * 8) + (jpeg_mask_bits - jpeg_nbits_table)
+%define MASK_BITS(x) NBITS((x) * 8) + (jpeg_mask_bits - EXTN(jpeg_nbits_table))
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -469,7 +470,7 @@ EXTN(jsimd_huff_encode_one_block_sse2):
pcmpeqw mm_all_0xff, mm_all_0xff ;Z: all_0xff[i] = 0xFF;
%endmacro
- GET_SYM nbits_base, jpeg_nbits_table, GET_SYM_BEFORE, GET_SYM_AFTER
+ GET_SYM nbits_base, EXTN(jpeg_nbits_table), GET_SYM_BEFORE, GET_SYM_AFTER
psrldq xmm4, 1 * SIZEOF_WORD ;G: w4 = 37 44 45 38 39 46 47 --
shufpd xmm1, xmm5, 10b ;F: w1 = 36 37 44 45 50 51 58 59
diff --git a/simd/x86_64/jchuff-sse2.asm b/simd/x86_64/jchuff-sse2.asm
index a0eb9ce2..0c2cdd64 100644
--- a/simd/x86_64/jchuff-sse2.asm
+++ b/simd/x86_64/jchuff-sse2.asm
@@ -1,7 +1,7 @@
;
; jchuff-sse2.asm - Huffman entropy encoding (64-bit SSE2)
;
-; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, 2023, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, 2023-2024, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
@@ -67,7 +67,8 @@ times 1 << 2 db 3
times 1 << 1 db 2
times 1 << 0 db 1
times 1 db 0
-jpeg_nbits_table:
+GLOBAL_DATA(jpeg_nbits_table)
+EXTN(jpeg_nbits_table):
times 1 db 0
times 1 << 0 db 1
times 1 << 1 db 2
@@ -89,7 +90,7 @@ times 1 << 15 db 16
alignz 32
%define NBITS(x) nbits_base + x
-%define MASK_BITS(x) NBITS((x) * 4) + (jpeg_mask_bits - jpeg_nbits_table)
+%define MASK_BITS(x) NBITS((x) * 4) + (jpeg_mask_bits - EXTN(jpeg_nbits_table))
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -290,7 +291,7 @@ EXTN(jsimd_huff_encode_one_block_sse2):
mov dctbl, POINTER [rbp+48]
mov actbl, POINTER [rbp+56]
punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
- lea nbits_base, [rel jpeg_nbits_table]
+ lea nbits_base, [rel EXTN(jpeg_nbits_table)]
%else
@@ -312,7 +313,7 @@ EXTN(jsimd_huff_encode_one_block_sse2):
mov buffer, rsi
movups xmm1, XMMWORD [block + 8 * SIZEOF_WORD] ;B: w1 = 08 09 10 11 12 13 14 15
movsx codeq, word [block] ;Z: code = block[0];
- lea nbits_base, [rel jpeg_nbits_table]
+ lea nbits_base, [rel EXTN(jpeg_nbits_table)]
pxor xmm4, xmm4 ;A: w4[i] = 0;
sub codeq, rcx ;Z: code -= last_dc_val;
punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
From 335ed793f92370edbb425d56fe9c07aab5a93d9a Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 19 Jan 2024 12:58:13 -0500
Subject: [PATCH 043/135] Assume 3-comp lossls JPEG w/o Adobe marker is RGB
libjpeg-turbo always includes Adobe APP14 markers in the lossless JPEG
images that it generates, but some compressors (e.g. accusoft PICTools
Medical) do not.
Fixes #743
---
ChangeLog.md | 6 ++++++
jdapimin.c | 11 +++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 6ed5aeea..a929b62a 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -26,6 +26,12 @@ option (`-maxpixels`) for specifying the maximum number of pixels that the
decompression, lossless transformation, and packed-pixel image loading
functions/methods will process.
+4. Fixed an error ("Unsupported color conversion request") that occurred when
+attempting to decompress a 3-component lossless JPEG image without an Adobe
+APP14 marker. The decompressor now assumes that a 3-component lossless JPEG
+image without an Adobe APP14 marker uses the RGB colorspace if its component
+IDs are 1, 2, and 3.
+
3.0.1
=====
diff --git a/jdapimin.c b/jdapimin.c
index 51ca552d..30d92841 100644
--- a/jdapimin.c
+++ b/jdapimin.c
@@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2022, D. R. Commander.
+ * Copyright (C) 2016, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -160,9 +160,12 @@ default_decompress_parms(j_decompress_ptr cinfo)
int cid1 = cinfo->comp_info[1].component_id;
int cid2 = cinfo->comp_info[2].component_id;
- if (cid0 == 1 && cid1 == 2 && cid2 == 3)
- cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
- else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
+ if (cid0 == 1 && cid1 == 2 && cid2 == 3) {
+ if (cinfo->master->lossless)
+ cinfo->jpeg_color_space = JCS_RGB; /* assume RGB w/out marker */
+ else
+ cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
+ } else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
else {
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
From 5a2353c2dad951af3f823ca4f9bdee293876cea1 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 22 Jan 2024 14:07:55 -0500
Subject: [PATCH 044/135] GNUInstallDirs.cmake: Various improvements
- Integrate
https://github.com/Kitware/CMake/commit/c07bba27302960fc2f35b6a9e00eab8b32ca9a49#diff-1e2deb5301e9481203102fcddd1b2d0d2bf0ddc1cbb445c7f4b6414a3b869ce8
so that the default man directory is /share/man
on FreeBSD systems.
- For good measure, integrate
https://github.com/Kitware/CMake/commit/f835f189aeb38a791ad09ba5c2d89300a3fd16f1
so that the default info directory is
/share/info on FreeBSD systems, even though we
don't use that directory.
- Automatically set the CMake variable type to PATH for any
user-specified CMAKE_INSTALL_*DIR variables.
Addresses concerns raised in #326, #346, #648
Closes #648
---
BUILDING.md | 9 ---------
cmakescripts/GNUInstallDirs.cmake | 13 +++++++++----
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/BUILDING.md b/BUILDING.md
index 6b484a12..f6ec42e1 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -605,15 +605,6 @@ 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**.
-NOTE: If setting one of these directory variables to a relative path using the
-CMake command line, you must specify that the variable is of type `PATH`.
-For example:
-
- cmake -G"{generator type}" -DCMAKE_INSTALL_LIBDIR:PATH=lib {source_directory}
-
-Otherwise, CMake will assume that the path is relative to the build directory
-rather than the install directory.
-
Creating Distribution Packages
==============================
diff --git a/cmakescripts/GNUInstallDirs.cmake b/cmakescripts/GNUInstallDirs.cmake
index 6408fca7..d3e5b471 100644
--- a/cmakescripts/GNUInstallDirs.cmake
+++ b/cmakescripts/GNUInstallDirs.cmake
@@ -118,9 +118,10 @@
# absolute paths where necessary, using the same logic.
#=============================================================================
+# Copyright 2018 Tobias C. Berner
# Copyright 2018 Matthias Räncker
-# Copyright 2016, 2019 D. R. Commander
-# Copyright 2016 Dmitry Marakasov
+# Copyright 2016, 2019, 2024 D. R. Commander
+# Copyright 2016, 2021 Dmitry Marakasov
# Copyright 2016 Roger Leigh
# Copyright 2015 Alex Turbov
# Copyright 2014 Rolf Eike Beer
@@ -181,6 +182,10 @@ macro(GNUInstallDirs_set_install_dir var docstring)
set(_GNUInstallDirs_CMAKE_INSTALL_FORCE_${var} "FORCE")
endif()
+ if(DEFINED CMAKE_INSTALL_${var} AND NOT CMAKE_INSTALL_${var} MATCHES "^/")
+ set_property(CACHE CMAKE_INSTALL_${var} PROPERTY TYPE PATH)
+ endif()
+
set(CMAKE_INSTALL_${var} "${CMAKE_INSTALL_DEFAULT_${var}}" CACHE PATH
"${docstring} (Default: ${CMAKE_INSTALL_DEFAULT_${var}})"
${_GNUInstallDirs_CMAKE_INSTALL_FORCE_${var}})
@@ -300,7 +305,7 @@ GNUInstallDirs_set_install_dir(DATADIR
"The directory under which read-only architecture-independent data files should be installed")
if(NOT DEFINED CMAKE_INSTALL_DEFAULT_INFODIR)
- if(CMAKE_SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$")
+ if(CMAKE_SYSTEM_NAME MATCHES "^(([^kF].*)?BSD|DragonFly)$")
set(CMAKE_INSTALL_DEFAULT_INFODIR "info")
else()
set(CMAKE_INSTALL_DEFAULT_INFODIR "/info")
@@ -310,7 +315,7 @@ GNUInstallDirs_set_install_dir(INFODIR
"The directory into which info documentation files should be installed")
if(NOT DEFINED CMAKE_INSTALL_DEFAULT_MANDIR)
- if(CMAKE_SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$")
+ if(CMAKE_SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$" AND NOT CMAKE_SYSTEM_NAME MATCHES "^(FreeBSD)$")
set(CMAKE_INSTALL_DEFAULT_MANDIR "man")
else()
set(CMAKE_INSTALL_DEFAULT_MANDIR "/man")
From 1644bdb7d2fac66cd0ce25adef7754e008b5bc1e Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 22 Jan 2024 14:33:31 -0500
Subject: [PATCH 045/135] BUILD: Silence CMake 3.28.x deprecation warning
Closes #740
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66e077ca..3c7feb6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 2.8.12...3.28)
# When using CMake 3.4 and later, don't export symbols from executables unless
# the CMAKE_ENABLE_EXPORTS variable is set.
if(POLICY CMP0065)
From 0ef07927c3e816f49539fa6d5a845faf7cbc305d Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 23 Jan 2024 10:46:04 -0500
Subject: [PATCH 046/135] Bump copyright year to 2024
---
CMakeLists.txt | 2 +-
jversion.h.in | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c7feb6b..f802d6d2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ endif()
project(libjpeg-turbo C)
set(VERSION 3.0.2)
-set(COPYRIGHT_YEAR "1991-2023")
+set(COPYRIGHT_YEAR "1991-2024")
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
diff --git a/jversion.h.in b/jversion.h.in
index 42a4e736..0f68fe63 100644
--- a/jversion.h.in
+++ b/jversion.h.in
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2012-2023, D. R. Commander.
+ * Copyright (C) 2010, 2012-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -37,7 +37,7 @@
*/
#define JCOPYRIGHT \
- "Copyright (C) 2009-2023 D. R. Commander\n" \
+ "Copyright (C) 2009-2024 D. R. Commander\n" \
"Copyright (C) 2015, 2020 Google, Inc.\n" \
"Copyright (C) 2019-2020 Arm Limited\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
From 289df647c0f208dad7db63f24830361257812b1b Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 23 Jan 2024 17:35:53 -0500
Subject: [PATCH 047/135] Build: Add tjdoc target for building TurboJPEG dox
---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f802d6d2..adb0ca45 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -710,6 +710,9 @@ if(WITH_TURBOJPEG)
add_executable(tjexample tjexample.c)
target_link_libraries(tjexample turbojpeg)
+
+ add_custom_target(tjdoc COMMAND doxygen -s doxygen.config
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
if(ENABLE_STATIC)
From 17df25f92c38cfff4d8cbc618dd7c016b5594eea Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 25 Jan 2024 13:52:58 -0500
Subject: [PATCH 048/135] Build/Win: Eliminate MSVC run-time DLL dependency
(regression introduced by 1644bdb7d2fac66cd0ce25adef7754e008b5bc1e)
Setting a maximum version in cmake_minimum_required() effectively sets
the behavior to NEW for all policies introduced in all CMake versions up
to and including that maximum version. The NEW behavior for CMP0091,
introduced in CMake 3.15, uses CMake variables to specify the MSVC
runtime library against which to link, rather than placing the relevant
flags in CMAKE_C_FLAGS*. Thus, replacing /MD with /MT in CMAKE_C_FLAGS*
no longer has any effect when using CMake 3.15+.
---
CMakeLists.txt | 25 +++++++++++++++++--------
ChangeLog.md | 11 +++++++++++
sharedlib/CMakeLists.txt | 19 ++++++++++++++-----
3 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index adb0ca45..d423c563 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ if(CMAKE_EXECUTABLE_SUFFIX)
endif()
project(libjpeg-turbo C)
-set(VERSION 3.0.2)
+set(VERSION 3.0.3)
set(COPYRIGHT_YEAR "1991-2024")
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
@@ -379,18 +379,29 @@ set(TURBOJPEG_SO_VERSION 0.${TURBOJPEG_SO_AGE}.0)
# COMPILER SETTINGS
###############################################################################
+string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
+
if(MSVC)
option(WITH_CRT_DLL
"Link all ${CMAKE_PROJECT_NAME} libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.) The default is to use the C run-time DLL only with the libraries and executables that need it."
FALSE)
if(NOT WITH_CRT_DLL)
# Use the static C library for all build types
- foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
- CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
- if(${var} MATCHES "/MD")
- string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
+ if(CMAKE_VERSION VERSION_EQUAL "3.15" OR
+ CMAKE_VERSION VERSION_GREATER "3.15")
+ if(CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
+ else()
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif()
- endforeach()
+ else()
+ foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
+ if(${var} MATCHES "/MD")
+ string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
+ endif()
+ endforeach()
+ endif()
endif()
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
endif()
@@ -418,8 +429,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
endif()
endif()
-string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
-
set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}")
diff --git a/ChangeLog.md b/ChangeLog.md
index a929b62a..3982dcd8 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,14 @@
+3.0.3
+=====
+
+### Significant changes relative to 3.0.2:
+
+1. Fixed an issue in the build system, introduced in 3.0.2, that caused all
+libjpeg-turbo components to depend on the Visual C++ run-time DLL when built
+with Visual C++ and CMake 3.15 or later, regardless of value of the
+`WITH_CRT_DLL` CMake variable.
+
+
3.0.2
=====
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index 8e942569..d10b8ac8 100644
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -11,12 +11,21 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
if(MSVC)
# Build all configurations against shared C library
- foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
- CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
- if(${var} MATCHES "/MT")
- string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}")
+ if(CMAKE_VERSION VERSION_EQUAL "3.15" OR
+ CMAKE_VERSION VERSION_GREATER "3.15")
+ if(CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
+ else()
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
endif()
- endforeach()
+ else()
+ foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
+ if(${var} MATCHES "/MT")
+ string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}")
+ endif()
+ endforeach()
+ endif()
endif()
foreach(src ${JPEG_SOURCES})
From 7d67c3495f5b6e8893c06f6949ce3b59266ca33e Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 26 Jan 2024 10:34:04 -0500
Subject: [PATCH 049/135] Build/Win: Report CMAKE_MSVC_RUNTIME_LIBRARY value
... when using CMake 3.15+
---
CMakeLists.txt | 2 ++
sharedlib/CMakeLists.txt | 1 +
2 files changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d423c563..3c5607b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -385,6 +385,7 @@ if(MSVC)
option(WITH_CRT_DLL
"Link all ${CMAKE_PROJECT_NAME} libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.) The default is to use the C run-time DLL only with the libraries and executables that need it."
FALSE)
+ boolean_number(WITH_CRT_DLL)
if(NOT WITH_CRT_DLL)
# Use the static C library for all build types
if(CMAKE_VERSION VERSION_EQUAL "3.15" OR
@@ -394,6 +395,7 @@ if(MSVC)
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif()
+ message(STATUS "Visual C++ run-time library: ${CMAKE_MSVC_RUNTIME_LIBRARY} (WITH_CRT_DLL = ${WITH_CRT_DLL})")
else()
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index d10b8ac8..449b1848 100644
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -18,6 +18,7 @@ if(MSVC)
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
endif()
+ message(STATUS "Visual C++ run-time library for libjpeg API DLL: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
else()
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
From 9ef0d03e1e5f0140636215afe627954b81602c38 Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 26 Jan 2024 10:50:26 -0500
Subject: [PATCH 050/135] LICENSE.md: zlib License clarifications
Disclaimer: I am not a lawyer, nor do I play one on TV.
Referring to #744, mentioning the zlib License as a license that applies
to libjpeg-turbo is confusing, and it isn't actually necessary, since
the IJG License subsumes the terms of the zlib License in the context of
the libjpeg API library and associated programs. This was presumably
understood to be the case by Miyasaka-san when he chose the zlib License
for the first libjpeg SIMD extensions. The libjpeg/SIMD web site
(https://cetus.sakura.ne.jp/softlab/jpeg-x86simd/jpegsimd.html) states
(translated from Japanese): "The terms of use of this SIMD enhanced
version of IJG JPEG software are subject to the terms of use of the
original version of IJG JPEG software."
Detailed analysis of the zlib License terms:
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
This text is an almost literal subset of the warranty disclaimer text in
the IJG License. The IJG License states everything above with only
slight differences in wording, and it further clarifies that the user
assumes all risk as to the software's quality and accuracy and that
vendors of commercial products based on the software must assume all
warranty and liability claims.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
This is semantically the same as the permission text in the IJG License,
since "use, copy, modify, and distribute this software (or portions
thereof) for any purpose, without fee" covers "use" for "any purpose,
including commercial applications" as well as alteration and
redistribution.
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
The IJG License requirement that "If any part of the source code for
this software is distributed, then this README file must be included,
with this copyright and no-warranty notice unaltered; and any additions,
deletions, or changes to the original files must be clearly indicated in
accompanying documentation" (Clause 1), as well as the requirement that
"If only executable code is distributed, then the accompanying
documentation must state that 'this software is based in part on the
work of the Independent JPEG Group'" (Clause 2), satisfies the
requirement of Clause 1 of the zlib License.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
Since Clause 1 of the IJG License applies only to the distribution of
source code, the copyright headers in the source code are effectively
"accompanying documentation" in that case. This is why we ensure that
the copyright headers of individual source files indicate the year(s) in
which modifications were made by each contributor. Doing so satisfies
the requirements of both Clause 2 of the zlib License and Clause 1 of
the IJG License.
3. This notice may not be removed or altered from any source
distribution.
Clauses 2 and 3 of the zlib License apply only to the source code that
bears that license. Thus, as applied to the software as a whole, those
requirements of the inbound zlib License are compatible with the
outbound IJG License as long as the IJG License does not contradict
them (which it doesn't.)
NOTE: To be clear, existing source code that bears the zlib License
cannot literally be re-licensed under the IJG License, since that would
violate Clause 3 of the zlib License. However, when considering the
terms under which the overall library is made available, the IJG License
effectively subsumes the terms of the zlib License.
https://www.gnu.org/licenses/license-compatibility.en.html is a
thorough, albeit somewhat GPL-biased, discussion of license
compatibility.
---
LICENSE.md | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/LICENSE.md b/LICENSE.md
index bf8a7fda..2204864f 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,30 +1,33 @@
libjpeg-turbo Licenses
======================
-libjpeg-turbo is covered by three compatible BSD-style open source licenses:
+libjpeg-turbo is covered by two compatible BSD-style open source licenses:
- The IJG (Independent JPEG Group) License, which is listed in
[README.ijg](README.ijg)
- This license applies to the libjpeg API library and associated programs
- (any code inherited from libjpeg, and any modifications to that code.)
+ This license applies to the libjpeg API library and associated programs,
+ including any code inherited from libjpeg and any modifications to that
+ code. Note that the libjpeg-turbo SIMD source code bears the
+ [zlib License](https://opensource.org/licenses/Zlib), but in the context of
+ the overall libjpeg API library, the terms of the zlib License are subsumed
+ by the terms of the IJG License.
- The Modified (3-clause) BSD License, which is listed below
- This license covers the TurboJPEG API library and associated programs, as
- well as the build system.
-
-- The [zlib License](https://opensource.org/licenses/Zlib)
-
- This license is a subset of the other two, and it covers the libjpeg-turbo
- SIMD extensions.
+ This license applies to the TurboJPEG API library and associated programs, as
+ well as the build system. Note that the TurboJPEG API library wraps the
+ libjpeg API library, so in the context of the overall TurboJPEG API library,
+ both the terms of the IJG License and the terms of the Modified (3-clause)
+ BSD License apply.
Complying with the libjpeg-turbo Licenses
=========================================
This section provides a roll-up of the libjpeg-turbo licensing terms, to the
-best of our understanding.
+best of our understanding. This is not a license in and of itself. It is
+intended solely for clarification.
1. If you are distributing a modified version of the libjpeg-turbo source,
then:
@@ -38,7 +41,7 @@ best of our understanding.
- Clauses 1 and 3 of the zlib License
2. You must add your own copyright notice to the header of each source
- file you modified, so others can tell that you modified that file (if
+ file you modified, so others can tell that you modified that file. (If
there is not an existing copyright header in that file, then you can
simply add a notice stating that you modified the file.)
@@ -119,8 +122,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-Why Three Licenses?
-===================
+Why Two Licenses?
+=================
The zlib License could have been used instead of the Modified (3-clause) BSD
License, and since the IJG License effectively subsumes the distribution
From 36c51dd3eb60ebde3ca77d3cfa7df3422f1aaaf1 Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 26 Jan 2024 15:55:19 -0500
Subject: [PATCH 051/135] GitHub: Update checkout, AWS credentials actions
... to silence deprecation warning regarding Node.js 12 and 16 actions.
---
.github/workflows/build.yml | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 22b6607e..542635a4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,7 +17,7 @@ jobs:
run: |
echo "BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" >$GITHUB_ENV
- name: Check out code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up build
run: |
mkdir -p $HOME/src/ljt.nightly
@@ -41,7 +41,7 @@ jobs:
mv $HOME/src/ljt.nightly/latest/log-${{github.job}}.txt $HOME/src/ljt.nightly/latest/files/
- name: Configure AWS
if: ${{github.event_name != 'pull_request'}}
- uses: aws-actions/configure-aws-credentials@v1
+ uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
@@ -57,7 +57,7 @@ jobs:
run: |
echo "BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" >$GITHUB_ENV
- name: Check out code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up build
run: |
brew install yasm md5sha1sum
@@ -77,7 +77,7 @@ jobs:
mv $HOME/src/ljt.nightly/latest/log-${{github.job}}.txt $HOME/src/ljt.nightly/latest/files/
- name: Configure AWS
if: ${{github.event_name != 'pull_request'}}
- uses: aws-actions/configure-aws-credentials@v1
+ uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
@@ -90,7 +90,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up build
run: |
sudo apt install -y nasm
@@ -113,7 +113,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Check out code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up build
run: |
sudo apt update
@@ -138,7 +138,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up build
run: |
sudo apt -y install nasm
@@ -162,7 +162,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Build
env:
CTEST_OUTPUT_ON_FAILURE: 1
From d59b1a3bcec3b238d330f2f97655e5d55a2ebfe3 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 30 Jan 2024 15:40:51 -0500
Subject: [PATCH 052/135] Build: Reformat lines longer than 80 columns ...
... to ensure that no function argument starts beyond the 80th column.
---
CMakeLists.txt | 34 ++++++++++++++++++++++++----------
java/CMakeLists.txt | 15 ++++++++++-----
2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c5607b9..0839b90a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -222,25 +222,38 @@ option(ENABLE_SHARED "Build shared libraries" TRUE)
boolean_number(ENABLE_SHARED)
option(ENABLE_STATIC "Build static libraries" TRUE)
boolean_number(ENABLE_STATIC)
-option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE)
+option(REQUIRE_SIMD
+ "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)"
+ FALSE)
boolean_number(REQUIRE_SIMD)
-option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE)
+option(WITH_ARITH_DEC
+ "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI"
+ TRUE)
boolean_number(WITH_ARITH_DEC)
-option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE)
+option(WITH_ARITH_ENC
+ "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI"
+ TRUE)
boolean_number(WITH_ARITH_ENC)
if(CMAKE_C_COMPILER_ABI MATCHES "ELF X32")
set(WITH_JAVA 0)
else()
- option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE)
+ option(WITH_JAVA
+ "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)"
+ FALSE)
boolean_number(WITH_JAVA)
endif()
-option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
+option(WITH_JPEG7
+ "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)"
+ FALSE)
boolean_number(WITH_JPEG7)
-option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
+option(WITH_JPEG8
+ "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)"
+ FALSE)
boolean_number(WITH_JPEG8)
option(WITH_SIMD "Include SIMD extensions, if available for this platform" TRUE)
boolean_number(WITH_SIMD)
-option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" TRUE)
+option(WITH_TURBOJPEG
+ "Include the TurboJPEG API library and associated test programs" TRUE)
boolean_number(WITH_TURBOJPEG)
option(WITH_FUZZ "Build fuzz targets" FALSE)
@@ -521,7 +534,8 @@ if(MSVC)
else()
set(THREAD_LOCAL "__thread")
endif()
-check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }" HAVE_THREAD_LOCAL)
+check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }"
+ HAVE_THREAD_LOCAL)
if(HAVE_THREAD_LOCAL)
message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}")
else()
@@ -1079,8 +1093,8 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_PPM_444_TILE 87bd58005eec73f0f313c8e38d0d793c)
endif()
- # Test compressing from/decompressing to an arbitrary subregion of a larger
- # image buffer
+ # Test compressing from/decompressing to an arbitrary subregion of a
+ # larger image buffer
add_test(${tjbench}-${libtype}-tile-cp
${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
${testout}_tile.ppm)
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index 3d863bdd..cff93e7d 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -56,7 +56,8 @@ if(MSYS)
endif()
add_custom_target(javadoc COMMAND
- javadoc -notimestamp -d ${CMAKE_CURRENT_SOURCE_DIR}/doc -sourcepath ${CMAKE_CURRENT_SOURCE_DIR} org.libjpegturbo.turbojpeg)
+ javadoc -notimestamp -d ${CMAKE_CURRENT_SOURCE_DIR}/doc
+ -sourcepath ${CMAKE_CURRENT_SOURCE_DIR} org.libjpegturbo.turbojpeg)
set(JAVACLASSPATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/turbojpeg-java.dir)
if(Java_VERSION_MAJOR GREATER 9)
add_custom_target(javah
@@ -68,10 +69,14 @@ if(Java_VERSION_MAJOR GREATER 9)
${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJTransformer.java)
else()
add_custom_target(javah
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJ
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJCompressor
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJDecompressor
- COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJTransformer)
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH}
+ org.libjpegturbo.turbojpeg.TJ
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH}
+ org.libjpegturbo.turbojpeg.TJCompressor
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH}
+ org.libjpegturbo.turbojpeg.TJDecompressor
+ COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH}
+ org.libjpegturbo.turbojpeg.TJTransformer)
endif()
if(NOT DEFINED CMAKE_INSTALL_DEFAULT_JAVADIR)
From b6ee1016abbc55116304ad396cf88aa19391e10a Mon Sep 17 00:00:00 2001
From: Alyssa Ross
Date: Mon, 29 Jan 2024 17:18:38 +0100
Subject: [PATCH 053/135] Build: Fix tests w/ emulators that don't check CWD
While QEMU will run executables from the current working directory,
other emulators may not. It is more reliable to pass the full
executable path to the emulator. The add_test(NAME ... COMMAND ...)
syntax automatically invokes the emulator (e.g. the command specified
in CMAKE_CROSSCOMPILING_EMULATOR) and passes the full executable path to
it, as long as the first COMMAND argument is the name of a target. This
cleans up the CMake code somewhat as well, since it is no longer
necessary to manually invoke CMAKE_CROSSCOMPILING_EMULATOR.
Closes #747
---
CMakeLists.txt | 185 +++++++++++++++++++++++--------------------------
1 file changed, 86 insertions(+), 99 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0839b90a..26bb189c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -896,10 +896,8 @@ if(ENABLE_STATIC)
endif()
set(TESTIMAGES ${CMAKE_CURRENT_SOURCE_DIR}/testimages)
-set(MD5CMP ${CMAKE_CURRENT_BINARY_DIR}/md5/md5cmp)
if(CMAKE_CROSSCOMPILING)
file(RELATIVE_PATH TESTIMAGES ${CMAKE_CURRENT_BINARY_DIR} ${TESTIMAGES})
- file(RELATIVE_PATH MD5CMP ${CMAKE_CURRENT_BINARY_DIR} ${MD5CMP})
endif()
# The output of the floating point DCT/IDCT algorithms differs depending on the
@@ -1012,42 +1010,38 @@ foreach(libtype ${TEST_LIBTYPES})
set(suffix -static)
endif()
if(WITH_TURBOJPEG)
- add_test(tjunittest-${libtype}
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix})
- add_test(tjunittest-${libtype}-alloc
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -alloc)
- add_test(tjunittest-${libtype}-yuv
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv)
- add_test(tjunittest-${libtype}-yuv-alloc
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -alloc)
- add_test(tjunittest-${libtype}-yuv-nopad
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -noyuvpad)
- add_test(tjunittest-${libtype}-lossless
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -lossless)
- add_test(tjunittest-${libtype}-lossless-alloc
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -lossless -alloc)
- add_test(tjunittest-${libtype}-bmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -bmp)
- add_test(tjunittest12-${libtype}
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 12)
- add_test(tjunittest12-${libtype}-alloc
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 12
- -alloc)
- add_test(tjunittest12-${libtype}-lossless
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 12
- -lossless)
- add_test(tjunittest12-${libtype}-lossless-alloc
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 12
- -lossless -alloc)
- add_test(tjunittest12-${libtype}-bmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 12 -bmp)
- add_test(tjunittest16-${libtype}-lossless
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 16)
- add_test(tjunittest16-${libtype}-lossless-alloc
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 16
- -alloc)
- add_test(tjunittest16-${libtype}-bmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -precision 16 -bmp)
+ add_test(NAME tjunittest-${libtype}
+ COMMAND tjunittest${suffix})
+ add_test(NAME tjunittest-${libtype}-alloc
+ COMMAND tjunittest${suffix} -alloc)
+ add_test(NAME tjunittest-${libtype}-yuv
+ COMMAND tjunittest${suffix} -yuv)
+ add_test(NAME tjunittest-${libtype}-yuv-alloc
+ COMMAND tjunittest${suffix} -yuv -alloc)
+ add_test(NAME tjunittest-${libtype}-yuv-nopad
+ COMMAND tjunittest${suffix} -yuv -noyuvpad)
+ add_test(NAME tjunittest-${libtype}-lossless
+ COMMAND tjunittest${suffix} -lossless)
+ add_test(NAME tjunittest-${libtype}-lossless-alloc
+ COMMAND tjunittest${suffix} -lossless -alloc)
+ add_test(NAME tjunittest-${libtype}-bmp
+ COMMAND tjunittest${suffix} -bmp)
+ add_test(NAME tjunittest12-${libtype}
+ COMMAND tjunittest${suffix} -precision 12)
+ add_test(NAME tjunittest12-${libtype}-alloc
+ COMMAND tjunittest${suffix} -precision 12 -alloc)
+ add_test(NAME tjunittest12-${libtype}-lossless
+ COMMAND tjunittest${suffix} -precision 12 -lossless)
+ add_test(NAME tjunittest12-${libtype}-lossless-alloc
+ COMMAND tjunittest${suffix} -precision 12 -lossless -alloc)
+ add_test(NAME tjunittest12-${libtype}-bmp
+ COMMAND tjunittest${suffix} -precision 12 -bmp)
+ add_test(NAME tjunittest16-${libtype}-lossless
+ COMMAND tjunittest${suffix} -precision 16)
+ add_test(NAME tjunittest16-${libtype}-lossless-alloc
+ COMMAND tjunittest${suffix} -precision 16 -alloc)
+ add_test(NAME tjunittest16-${libtype}-bmp
+ COMMAND tjunittest${suffix} -precision 16 -bmp)
foreach(sample_bits 8 12)
@@ -1095,28 +1089,27 @@ foreach(libtype ${TEST_LIBTYPES})
# Test compressing from/decompressing to an arbitrary subregion of a
# larger image buffer
- add_test(${tjbench}-${libtype}-tile-cp
- ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
- ${testout}_tile.ppm)
- add_test(${tjbench}-${libtype}-tile
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} ${testout}_tile.ppm
- 95 -precision ${sample_bits} -rgb -quiet -tile -benchtime 0.01
+ add_test(NAME ${tjbench}-${libtype}-tile-cp
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${TESTIMAGES}/testorig.ppm ${testout}_tile.ppm)
+ add_test(NAME ${tjbench}-${libtype}-tile
+ COMMAND tjbench${suffix} ${testout}_tile.ppm 95
+ -precision ${sample_bits} -rgb -quiet -tile -benchtime 0.01
-warmup 0)
set_tests_properties(${tjbench}-${libtype}-tile
PROPERTIES DEPENDS ${tjbench}-${libtype}-tile-cp)
foreach(tile 8 16 32 64 128)
- add_test(${tjbench}-${libtype}-tile-gray-${tile}x${tile}-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_GRAY_TILE}
+ add_test(NAME ${tjbench}-${libtype}-tile-gray-${tile}x${tile}-cmp
+ COMMAND md5cmp ${MD5_PPM_GRAY_TILE}
${testout}_tile_GRAY_Q95_${tile}x${tile}.ppm)
foreach(subsamp 420 422)
- add_test(${tjbench}-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
- ${MD5_PPM_${subsamp}_${tile}x${tile}_TILE}
+ add_test(NAME ${tjbench}-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
+ COMMAND md5cmp ${MD5_PPM_${subsamp}_${tile}x${tile}_TILE}
${testout}_tile_${subsamp}_Q95_${tile}x${tile}.ppm)
endforeach()
- add_test(${tjbench}-${libtype}-tile-444-${tile}x${tile}-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_444_TILE}
+ add_test(NAME ${tjbench}-${libtype}-tile-444-${tile}x${tile}-cmp
+ COMMAND md5cmp ${MD5_PPM_444_TILE}
${testout}_tile_444_Q95_${tile}x${tile}.ppm)
foreach(subsamp gray 420 422 444)
set_tests_properties(
@@ -1125,27 +1118,26 @@ foreach(libtype ${TEST_LIBTYPES})
endforeach()
endforeach()
- add_test(${tjbench}-${libtype}-tilem-cp
- ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
- ${testout}_tilem.ppm)
- add_test(${tjbench}-${libtype}-tilem
- ${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} ${testout}_tilem.ppm
- 95 -precision ${sample_bits} -rgb -fastupsample -quiet -tile
+ add_test(NAME ${tjbench}-${libtype}-tilem-cp
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${TESTIMAGES}/testorig.ppm ${testout}_tilem.ppm)
+ add_test(NAME ${tjbench}-${libtype}-tilem
+ COMMAND tjbench${suffix} ${testout}_tilem.ppm 95
+ -precision ${sample_bits} -rgb -fastupsample -quiet -tile
-benchtime 0.01 -warmup 0)
set_tests_properties(${tjbench}-${libtype}-tilem
PROPERTIES DEPENDS ${tjbench}-${libtype}-tilem-cp)
- add_test(${tjbench}-${libtype}-tile-420m-8x8-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_420M_8x8_TILE}
+ add_test(NAME ${tjbench}-${libtype}-tile-420m-8x8-cmp
+ COMMAND md5cmp ${MD5_PPM_420M_8x8_TILE}
${testout}_tilem_420_Q95_8x8.ppm)
- add_test(${tjbench}-${libtype}-tile-422m-8x8-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_422M_8x8_TILE}
+ add_test(NAME ${tjbench}-${libtype}-tile-422m-8x8-cmp
+ COMMAND md5cmp ${MD5_PPM_422M_8x8_TILE}
${testout}_tilem_422_Q95_8x8.ppm)
foreach(tile 16 32 64 128)
foreach(subsamp 420 422)
- add_test(${tjbench}-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
- ${MD5_PPM_${subsamp}M_TILE}
+ add_test(NAME ${tjbench}-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
+ COMMAND md5cmp ${MD5_PPM_${subsamp}M_TILE}
${testout}_tilem_${subsamp}_Q95_${tile}x${tile}.ppm)
endforeach()
endforeach()
@@ -1175,11 +1167,11 @@ foreach(libtype ${TEST_LIBTYPES})
endif()
string(REGEX REPLACE "16" "" ACTUAL_PROG ${PROG})
string(REGEX REPLACE "12" "" ACTUAL_PROG ${ACTUAL_PROG})
- add_test(${PROG}-${libtype}-${NAME}
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${ACTUAL_PROG}${suffix} ${ACTUAL_ARGS}
- -outfile ${OUTFILE} ${INFILE})
- add_test(${PROG}-${libtype}-${NAME}-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5SUM} ${OUTFILE})
+ add_test(NAME ${PROG}-${libtype}-${NAME}
+ COMMAND ${ACTUAL_PROG}${suffix} ${ACTUAL_ARGS} -outfile ${OUTFILE}
+ ${INFILE})
+ add_test(NAME ${PROG}-${libtype}-${NAME}-cmp
+ COMMAND md5cmp ${MD5SUM} ${OUTFILE})
set_tests_properties(${PROG}-${libtype}-${NAME}-cmp PROPERTIES
DEPENDS ${PROG}-${libtype}-${NAME})
if(${ARGC} GREATER 6)
@@ -1368,9 +1360,8 @@ foreach(libtype ${TEST_LIBTYPES})
${testout}_rgb_islow.ppm ${testout}_rgb_islow.jpg
${MD5_PPM_RGB_ISLOW} ${cjpeg}-${libtype}-rgb-islow)
- add_test(${djpeg}-${libtype}-rgb-islow-icc-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
- b06a39d730129122e85c1363ed1bbc9e ${testout}_rgb_islow.icc)
+ add_test(NAME ${djpeg}-${libtype}-rgb-islow-icc-cmp
+ COMMAND md5cmp b06a39d730129122e85c1363ed1bbc9e ${testout}_rgb_islow.icc)
set_tests_properties(${djpeg}-${libtype}-rgb-islow-icc-cmp PROPERTIES
DEPENDS ${djpeg}-${libtype}-rgb-islow)
@@ -1614,10 +1605,9 @@ foreach(libtype ${TEST_LIBTYPES})
# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No
# ENT: prog huff
- add_test(${cjpeg}-${libtype}-420-islow-prog
- ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog
- -precision ${sample_bits} -outfile ${testout}_420_islow_prog.jpg
- ${TESTIMAGES}/testorig.ppm)
+ add_test(NAME ${cjpeg}-${libtype}-420-islow-prog
+ COMMAND cjpeg${suffix} -dct int -prog -precision ${sample_bits}
+ -outfile ${testout}_420_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
add_bittest(${djpeg} 420-islow-prog-crop62x62_71_71
"-dct;int;-crop;62x62+71+71;-ppm"
${testout}_420_islow_prog_crop62x62,71,71.ppm
@@ -1634,19 +1624,18 @@ foreach(libtype ${TEST_LIBTYPES})
endif()
# Context rows: No Intra-iMCU row: Yes ENT: huff
- add_test(${cjpeg}-${libtype}-444-islow
- ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -sample 1x1
- -precision ${sample_bits} -outfile ${testout}_444_islow.jpg
- ${TESTIMAGES}/testorig.ppm)
+ add_test(NAME ${cjpeg}-${libtype}-444-islow
+ COMMAND cjpeg${suffix} -dct int -sample 1x1 -precision ${sample_bits}
+ -outfile ${testout}_444_islow.jpg ${TESTIMAGES}/testorig.ppm)
add_bittest(${djpeg} 444-islow-skip1_6 "-dct;int;-skip;1,6;-ppm"
${testout}_444_islow_skip1,6.ppm ${testout}_444_islow.jpg
${MD5_PPM_444_ISLOW_SKIP1_6} ${cjpeg}-${libtype}-444-islow)
# Context rows: No Intra-iMCU row: No ENT: prog huff
- add_test(${cjpeg}-${libtype}-444-islow-prog
- ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog
- -precision ${sample_bits} -sample 1x1
- -outfile ${testout}_444_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
+ add_test(NAME ${cjpeg}-${libtype}-444-islow-prog
+ COMMAND cjpeg${suffix} -dct int -prog -precision ${sample_bits}
+ -sample 1x1 -outfile ${testout}_444_islow_prog.jpg
+ ${TESTIMAGES}/testorig.ppm)
add_bittest(${djpeg} 444-islow-prog-crop98x98_13_13
"-dct;int;-crop;98x98+13+13;-ppm"
${testout}_444_islow_prog_crop98x98,13,13.ppm
@@ -1655,10 +1644,10 @@ foreach(libtype ${TEST_LIBTYPES})
# Context rows: No Intra-iMCU row: No ENT: arith
if(WITH_ARITH_ENC AND sample_bits EQUAL 8)
- add_test(${cjpeg}-${libtype}-444-islow-ari
- ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -arithmetic
- -sample 1x1 -precision ${sample_bits}
- -outfile ${testout}_444_islow_ari.jpg ${TESTIMAGES}/testorig.ppm)
+ add_test(NAME ${cjpeg}-${libtype}-444-islow-ari
+ COMMAND cjpeg${suffix} -dct int -arithmetic -sample 1x1
+ -precision ${sample_bits} -outfile ${testout}_444_islow_ari.jpg
+ ${TESTIMAGES}/testorig.ppm)
if(WITH_ARITH_DEC)
add_bittest(${djpeg} 444-islow-ari-crop37x37_0_0
"-dct;int;-crop;37x37+0+0;-ppm"
@@ -1677,23 +1666,21 @@ foreach(libtype ${TEST_LIBTYPES})
set(EXAMPLE_12BIT_ARG "-precision;12")
endif()
- add_test(example-${sample_bits}bit-${libtype}-compress
- ${CMAKE_CROSSCOMPILING_EMULATOR} example${suffix} compress -q 95
- ${EXAMPLE_12BIT_ARG} ${testout}-example.jpg)
- add_test(example-${sample_bits}bit-${libtype}-compress-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_JPEG_EXAMPLE_COMPRESS}
+ add_test(NAME example-${sample_bits}bit-${libtype}-compress
+ COMMAND example${suffix} compress -q 95 ${EXAMPLE_12BIT_ARG}
${testout}-example.jpg)
+ add_test(NAME example-${sample_bits}bit-${libtype}-compress-cmp
+ COMMAND md5cmp ${MD5_JPEG_EXAMPLE_COMPRESS} ${testout}-example.jpg)
set_tests_properties(example-${sample_bits}bit-${libtype}-compress-cmp
PROPERTIES DEPENDS example-${sample_bits}bit-${libtype}-compress)
- add_test(example-${sample_bits}bit-${libtype}-decompress
- ${CMAKE_CROSSCOMPILING_EMULATOR} example${suffix} decompress
- ${EXAMPLE_12BIT_ARG} ${testout}-example.jpg ${testout}-example.ppm)
+ add_test(NAME example-${sample_bits}bit-${libtype}-decompress
+ COMMAND example${suffix} decompress ${EXAMPLE_12BIT_ARG}
+ ${testout}-example.jpg ${testout}-example.ppm)
set_tests_properties(example-${sample_bits}bit-${libtype}-decompress
PROPERTIES DEPENDS example-${sample_bits}bit-${libtype}-compress)
- add_test(example-${sample_bits}bit-${libtype}-decompress-cmp
- ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_EXAMPLE_DECOMPRESS}
- ${testout}-example.ppm)
+ add_test(NAME example-${sample_bits}bit-${libtype}-decompress-cmp
+ COMMAND md5cmp ${MD5_PPM_EXAMPLE_DECOMPRESS} ${testout}-example.ppm)
set_tests_properties(example-${sample_bits}bit-${libtype}-decompress-cmp
PROPERTIES DEPENDS example-${sample_bits}bit-${libtype}-decompress)
From 26fc07c8d12cc02cf95a5ec745178f9d1916556a Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 8 Feb 2024 12:03:37 -0500
Subject: [PATCH 054/135] Build: Set MSVC run-time lib based on IDE config
---
CMakeLists.txt | 2 ++
sharedlib/CMakeLists.txt | 2 ++
2 files changed, 4 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 26bb189c..03cb1d64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -405,6 +405,8 @@ if(MSVC)
CMAKE_VERSION VERSION_GREATER "3.15")
if(CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
+ elseif(MSVC_IDE)
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif()
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index 449b1848..5ca8a8b8 100644
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -15,6 +15,8 @@ if(MSVC)
CMAKE_VERSION VERSION_GREATER "3.15")
if(CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
+ elseif(MSVC_IDE)
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
endif()
From 1335547558d75ccff5f141ec5e078ea4694a2c9e Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 29 Feb 2024 12:18:49 -0500
Subject: [PATCH 055/135] x86 SIMD: Capitalize all instruction-like macros
(to improve code readability)
---
simd/i386/jccolext-avx2.asm | 22 ++++++-------
simd/i386/jccolext-mmx.asm | 22 ++++++-------
simd/i386/jccolext-sse2.asm | 22 ++++++-------
simd/i386/jccolor-avx2.asm | 6 ++--
simd/i386/jccolor-mmx.asm | 6 ++--
simd/i386/jccolor-sse2.asm | 6 ++--
simd/i386/jcgray-avx2.asm | 6 ++--
simd/i386/jcgray-mmx.asm | 6 ++--
simd/i386/jcgray-sse2.asm | 6 ++--
simd/i386/jcgryext-avx2.asm | 22 ++++++-------
simd/i386/jcgryext-mmx.asm | 22 ++++++-------
simd/i386/jcgryext-sse2.asm | 22 ++++++-------
simd/i386/jchuff-sse2.asm | 6 ++--
simd/i386/jcsample-avx2.asm | 18 +++++------
simd/i386/jcsample-mmx.asm | 14 ++++-----
simd/i386/jcsample-sse2.asm | 18 +++++------
simd/i386/jdcolext-avx2.asm | 20 ++++++------
simd/i386/jdcolext-mmx.asm | 20 ++++++------
simd/i386/jdcolext-sse2.asm | 20 ++++++------
simd/i386/jdcolor-avx2.asm | 6 ++--
simd/i386/jdcolor-mmx.asm | 6 ++--
simd/i386/jdcolor-sse2.asm | 6 ++--
simd/i386/jdmerge-avx2.asm | 6 ++--
simd/i386/jdmerge-mmx.asm | 6 ++--
simd/i386/jdmerge-sse2.asm | 6 ++--
simd/i386/jdmrgext-avx2.asm | 20 ++++++------
simd/i386/jdmrgext-mmx.asm | 20 ++++++------
simd/i386/jdmrgext-sse2.asm | 20 ++++++------
simd/i386/jdsample-avx2.asm | 58 +++++++++++++++++------------------
simd/i386/jdsample-mmx.asm | 58 +++++++++++++++++------------------
simd/i386/jdsample-sse2.asm | 58 +++++++++++++++++------------------
simd/i386/jfdctflt-3dn.asm | 16 +++++-----
simd/i386/jfdctflt-sse.asm | 16 +++++-----
simd/i386/jfdctfst-mmx.asm | 16 +++++-----
simd/i386/jfdctfst-sse2.asm | 12 ++++----
simd/i386/jfdctint-avx2.asm | 24 +++++++--------
simd/i386/jfdctint-mmx.asm | 16 +++++-----
simd/i386/jfdctint-sse2.asm | 12 ++++----
simd/i386/jidctflt-3dn.asm | 22 ++++++-------
simd/i386/jidctflt-sse.asm | 38 +++++++++++------------
simd/i386/jidctflt-sse2.asm | 38 +++++++++++------------
simd/i386/jidctfst-mmx.asm | 18 +++++------
simd/i386/jidctfst-sse2.asm | 14 ++++-----
simd/i386/jidctint-avx2.asm | 26 ++++++++--------
simd/i386/jidctint-mmx.asm | 18 +++++------
simd/i386/jidctint-sse2.asm | 14 ++++-----
simd/i386/jidctred-mmx.asm | 18 +++++------
simd/i386/jidctred-sse2.asm | 16 +++++-----
simd/i386/jquant-3dn.asm | 6 ++--
simd/i386/jquant-mmx.asm | 8 ++---
simd/i386/jquant-sse.asm | 6 ++--
simd/i386/jquantf-sse2.asm | 6 ++--
simd/i386/jquanti-sse2.asm | 6 ++--
simd/nasm/jsimdext.inc | 40 ++++++++++++------------
simd/x86_64/jccolext-avx2.asm | 6 ++--
simd/x86_64/jccolext-sse2.asm | 6 ++--
simd/x86_64/jccolor-avx2.asm | 6 ++--
simd/x86_64/jccolor-sse2.asm | 6 ++--
simd/x86_64/jcgray-avx2.asm | 6 ++--
simd/x86_64/jcgray-sse2.asm | 6 ++--
simd/x86_64/jcgryext-avx2.asm | 6 ++--
simd/x86_64/jcgryext-sse2.asm | 6 ++--
simd/x86_64/jchuff-sse2.asm | 6 ++--
simd/x86_64/jcphuff-sse2.asm | 9 +++---
simd/x86_64/jcsample-avx2.asm | 10 +++---
simd/x86_64/jcsample-sse2.asm | 10 +++---
simd/x86_64/jdcolext-avx2.asm | 6 ++--
simd/x86_64/jdcolext-sse2.asm | 6 ++--
simd/x86_64/jdcolor-avx2.asm | 6 ++--
simd/x86_64/jdcolor-sse2.asm | 6 ++--
simd/x86_64/jdmerge-avx2.asm | 6 ++--
simd/x86_64/jdmerge-sse2.asm | 6 ++--
simd/x86_64/jdmrgext-avx2.asm | 10 +++---
simd/x86_64/jdmrgext-sse2.asm | 10 +++---
simd/x86_64/jdsample-avx2.asm | 30 +++++++++---------
simd/x86_64/jdsample-sse2.asm | 22 ++++++-------
simd/x86_64/jfdctflt-sse.asm | 10 +++---
simd/x86_64/jfdctfst-sse2.asm | 10 +++---
simd/x86_64/jfdctint-avx2.asm | 22 ++++++-------
simd/x86_64/jfdctint-sse2.asm | 10 +++---
simd/x86_64/jidctflt-sse2.asm | 30 +++++++++---------
simd/x86_64/jidctfst-sse2.asm | 10 +++---
simd/x86_64/jidctint-avx2.asm | 26 ++++++++--------
simd/x86_64/jidctint-sse2.asm | 10 +++---
simd/x86_64/jidctred-sse2.asm | 14 ++++-----
simd/x86_64/jquantf-sse2.asm | 10 +++---
simd/x86_64/jquanti-avx2.asm | 10 +++---
simd/x86_64/jquanti-sse2.asm | 10 +++---
88 files changed, 662 insertions(+), 661 deletions(-)
diff --git a/simd/i386/jccolext-avx2.asm b/simd/i386/jccolext-avx2.asm
index c46d6844..af6418f0 100644
--- a/simd/i386/jccolext-avx2.asm
+++ b/simd/i386/jccolext-avx2.asm
@@ -2,7 +2,7 @@
; jccolext.asm - colorspace conversion (AVX2)
;
; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,15 +49,15 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [img_width(eax)]
test ecx, ecx
@@ -80,9 +80,9 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
- pushpic eax
+ PUSHPIC eax
push edx
push ebx
push edi
@@ -93,11 +93,11 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
mov edi, JSAMPROW [edi] ; outptr0
mov ebx, JSAMPROW [ebx] ; outptr1
mov edx, JSAMPROW [edx] ; outptr2
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
cmp ecx, byte SIZEOF_YMMWORD
jae near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
%if RGB_PIXELSIZE == 3 ; ---------------
@@ -154,7 +154,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_ycc_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -278,7 +278,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_ycc_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -552,7 +552,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
pop edi
pop ebx
pop edx
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/simd/i386/jccolext-mmx.asm b/simd/i386/jccolext-mmx.asm
index 6357a42b..dbec80e7 100644
--- a/simd/i386/jccolext-mmx.asm
+++ b/simd/i386/jccolext-mmx.asm
@@ -2,7 +2,7 @@
; jccolext.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,15 +49,15 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [img_width(eax)] ; num_cols
test ecx, ecx
@@ -80,9 +80,9 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
- pushpic eax
+ PUSHPIC eax
push edx
push ebx
push edi
@@ -93,11 +93,11 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
mov edi, JSAMPROW [edi] ; outptr0
mov ebx, JSAMPROW [ebx] ; outptr1
mov edx, JSAMPROW [edx] ; outptr2
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
cmp ecx, byte SIZEOF_MMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
%if RGB_PIXELSIZE == 3 ; ---------------
@@ -143,7 +143,7 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_ycc_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -211,7 +211,7 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_ycc_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -449,7 +449,7 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
pop edi
pop ebx
pop edx
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/simd/i386/jccolext-sse2.asm b/simd/i386/jccolext-sse2.asm
index c6c80852..8d411451 100644
--- a/simd/i386/jccolext-sse2.asm
+++ b/simd/i386/jccolext-sse2.asm
@@ -1,7 +1,7 @@
;
; jccolext.asm - colorspace conversion (SSE2)
;
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -48,15 +48,15 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [img_width(eax)]
test ecx, ecx
@@ -79,9 +79,9 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
- pushpic eax
+ PUSHPIC eax
push edx
push ebx
push edi
@@ -92,11 +92,11 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
mov edi, JSAMPROW [edi] ; outptr0
mov ebx, JSAMPROW [ebx] ; outptr1
mov edx, JSAMPROW [edx] ; outptr2
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
cmp ecx, byte SIZEOF_XMMWORD
jae near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
%if RGB_PIXELSIZE == 3 ; ---------------
@@ -147,7 +147,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_ycc_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -232,7 +232,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_ycc_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -478,7 +478,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
pop edi
pop ebx
pop edx
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/simd/i386/jccolor-avx2.asm b/simd/i386/jccolor-avx2.asm
index 14944e95..3d6dfa6f 100644
--- a/simd/i386/jccolor-avx2.asm
+++ b/simd/i386/jccolor-avx2.asm
@@ -1,7 +1,7 @@
;
; jccolor.asm - colorspace conversion (AVX2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -33,7 +33,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_avx2)
EXTN(jconst_rgb_ycc_convert_avx2):
@@ -46,7 +46,7 @@ PD_ONEHALFM1_CJ times 8 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jccolor-mmx.asm b/simd/i386/jccolor-mmx.asm
index 8cb399bd..05274885 100644
--- a/simd/i386/jccolor-mmx.asm
+++ b/simd/i386/jccolor-mmx.asm
@@ -2,7 +2,7 @@
; jccolor.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -33,7 +33,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_mmx)
EXTN(jconst_rgb_ycc_convert_mmx):
@@ -46,7 +46,7 @@ PD_ONEHALFM1_CJ times 2 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 2 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jccolor-sse2.asm b/simd/i386/jccolor-sse2.asm
index 686d222f..ff6a2ecd 100644
--- a/simd/i386/jccolor-sse2.asm
+++ b/simd/i386/jccolor-sse2.asm
@@ -1,7 +1,7 @@
;
; jccolor.asm - colorspace conversion (SSE2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -32,7 +32,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_sse2)
EXTN(jconst_rgb_ycc_convert_sse2):
@@ -45,7 +45,7 @@ PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jcgray-avx2.asm b/simd/i386/jcgray-avx2.asm
index 560ee0c7..564974f8 100644
--- a/simd/i386/jcgray-avx2.asm
+++ b/simd/i386/jcgray-avx2.asm
@@ -1,7 +1,7 @@
;
; jcgray.asm - grayscale colorspace conversion (AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -29,7 +29,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_gray_convert_avx2)
EXTN(jconst_rgb_gray_convert_avx2):
@@ -38,7 +38,7 @@ PW_F0299_F0337 times 8 dw F_0_299, F_0_337
PW_F0114_F0250 times 8 dw F_0_114, F_0_250
PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jcgray-mmx.asm b/simd/i386/jcgray-mmx.asm
index 79fdf082..e791ea4a 100644
--- a/simd/i386/jcgray-mmx.asm
+++ b/simd/i386/jcgray-mmx.asm
@@ -2,7 +2,7 @@
; jcgray.asm - grayscale colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -29,7 +29,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_gray_convert_mmx)
EXTN(jconst_rgb_gray_convert_mmx):
@@ -38,7 +38,7 @@ PW_F0299_F0337 times 2 dw F_0_299, F_0_337
PW_F0114_F0250 times 2 dw F_0_114, F_0_250
PD_ONEHALF times 2 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jcgray-sse2.asm b/simd/i386/jcgray-sse2.asm
index cb4b28e8..70c0177d 100644
--- a/simd/i386/jcgray-sse2.asm
+++ b/simd/i386/jcgray-sse2.asm
@@ -1,7 +1,7 @@
;
; jcgray.asm - grayscale colorspace conversion (SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -28,7 +28,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_gray_convert_sse2)
EXTN(jconst_rgb_gray_convert_sse2):
@@ -37,7 +37,7 @@ PW_F0299_F0337 times 4 dw F_0_299, F_0_337
PW_F0114_F0250 times 4 dw F_0_114, F_0_250
PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jcgryext-avx2.asm b/simd/i386/jcgryext-avx2.asm
index 3fa7973d..0fb284aa 100644
--- a/simd/i386/jcgryext-avx2.asm
+++ b/simd/i386/jcgryext-avx2.asm
@@ -1,7 +1,7 @@
;
; jcgryext.asm - grayscale colorspace conversion (AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -49,15 +49,15 @@ EXTN(jsimd_rgb_gray_convert_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [img_width(eax)]
test ecx, ecx
@@ -76,20 +76,20 @@ EXTN(jsimd_rgb_gray_convert_avx2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
- pushpic eax
+ PUSHPIC eax
push edi
push esi
push ecx ; col
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr0
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
cmp ecx, byte SIZEOF_YMMWORD
jae near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
%if RGB_PIXELSIZE == 3 ; ---------------
@@ -146,7 +146,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -270,7 +270,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -433,7 +433,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
pop ecx ; col
pop esi
pop edi
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/simd/i386/jcgryext-mmx.asm b/simd/i386/jcgryext-mmx.asm
index 8af42e5a..1c69d382 100644
--- a/simd/i386/jcgryext-mmx.asm
+++ b/simd/i386/jcgryext-mmx.asm
@@ -2,7 +2,7 @@
; jcgryext.asm - grayscale colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,15 +49,15 @@ EXTN(jsimd_rgb_gray_convert_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [img_width(eax)] ; num_cols
test ecx, ecx
@@ -76,20 +76,20 @@ EXTN(jsimd_rgb_gray_convert_mmx):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
- pushpic eax
+ PUSHPIC eax
push edi
push esi
push ecx ; col
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr0
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
cmp ecx, byte SIZEOF_MMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
%if RGB_PIXELSIZE == 3 ; ---------------
@@ -135,7 +135,7 @@ EXTN(jsimd_rgb_gray_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -203,7 +203,7 @@ EXTN(jsimd_rgb_gray_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -330,7 +330,7 @@ EXTN(jsimd_rgb_gray_convert_mmx):
pop ecx ; col
pop esi
pop edi
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/simd/i386/jcgryext-sse2.asm b/simd/i386/jcgryext-sse2.asm
index c9d6ff1e..f710816a 100644
--- a/simd/i386/jcgryext-sse2.asm
+++ b/simd/i386/jcgryext-sse2.asm
@@ -1,7 +1,7 @@
;
; jcgryext.asm - grayscale colorspace conversion (SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -48,15 +48,15 @@ EXTN(jsimd_rgb_gray_convert_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [img_width(eax)]
test ecx, ecx
@@ -75,20 +75,20 @@ EXTN(jsimd_rgb_gray_convert_sse2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
- pushpic eax
+ PUSHPIC eax
push edi
push esi
push ecx ; col
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr0
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
cmp ecx, byte SIZEOF_XMMWORD
jae near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
%if RGB_PIXELSIZE == 3 ; ---------------
@@ -139,7 +139,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -224,7 +224,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -359,7 +359,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
pop ecx ; col
pop esi
pop edi
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/simd/i386/jchuff-sse2.asm b/simd/i386/jchuff-sse2.asm
index 76cc85f6..4adf5eb5 100644
--- a/simd/i386/jchuff-sse2.asm
+++ b/simd/i386/jchuff-sse2.asm
@@ -42,7 +42,7 @@ endstruc
EXTN(jconst_huff_encode_one_block):
- alignz 32
+ ALIGNZ 32
jpeg_mask_bits dq 0x0000, 0x0001, 0x0003, 0x0007
dq 0x000f, 0x001f, 0x003f, 0x007f
@@ -84,7 +84,7 @@ times 1 << 12 db 13
times 1 << 13 db 14
times 1 << 14 db 15
- alignz 32
+ ALIGNZ 32
%ifdef PIC
%define NBITS(x) nbits_base + x
@@ -236,7 +236,7 @@ times 1 << 14 db 15
; If PIC is defined, load the address of a symbol defined in this file into a
; register. Equivalent to
-; get_GOT %1
+; GET_GOT %1
; lea %1, [GOTOFF(%1, %2)]
; without using the GOT.
;
diff --git a/simd/i386/jcsample-avx2.asm b/simd/i386/jcsample-avx2.asm
index 0a20802d..3d40f1d9 100644
--- a/simd/i386/jcsample-avx2.asm
+++ b/simd/i386/jcsample-avx2.asm
@@ -3,7 +3,7 @@
;
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -70,7 +70,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -106,7 +106,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -117,7 +117,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
cmp ecx, byte SIZEOF_YMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r24:
; ecx can possibly be 8, 16, 24
@@ -141,7 +141,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
vpxor ymm1, ymm1, ymm1
mov ecx, SIZEOF_YMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -243,7 +243,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -279,7 +279,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -291,7 +291,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
cmp ecx, byte SIZEOF_YMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r24:
cmp ecx, 24
@@ -320,7 +320,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
vpxor ymm3, ymm3, ymm3
mov ecx, SIZEOF_YMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
diff --git a/simd/i386/jcsample-mmx.asm b/simd/i386/jcsample-mmx.asm
index 2c223eeb..38d5b322 100644
--- a/simd/i386/jcsample-mmx.asm
+++ b/simd/i386/jcsample-mmx.asm
@@ -2,7 +2,7 @@
; jcsample.asm - downsampling (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -69,7 +69,7 @@ EXTN(jsimd_h2v1_downsample_mmx):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -104,7 +104,7 @@ EXTN(jsimd_h2v1_downsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -112,7 +112,7 @@ EXTN(jsimd_h2v1_downsample_mmx):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -212,7 +212,7 @@ EXTN(jsimd_h2v2_downsample_mmx):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -247,7 +247,7 @@ EXTN(jsimd_h2v2_downsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -256,7 +256,7 @@ EXTN(jsimd_h2v2_downsample_mmx):
mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
mov edi, JSAMPROW [edi] ; outptr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [edx+0*SIZEOF_MMWORD]
diff --git a/simd/i386/jcsample-sse2.asm b/simd/i386/jcsample-sse2.asm
index 4fea60d2..26c5d740 100644
--- a/simd/i386/jcsample-sse2.asm
+++ b/simd/i386/jcsample-sse2.asm
@@ -2,7 +2,7 @@
; jcsample.asm - downsampling (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -69,7 +69,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -104,7 +104,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -115,14 +115,14 @@ EXTN(jsimd_h2v1_downsample_sse2):
cmp ecx, byte SIZEOF_XMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r8:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
pxor xmm1, xmm1
mov ecx, SIZEOF_XMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -225,7 +225,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -260,7 +260,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -272,7 +272,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
cmp ecx, byte SIZEOF_XMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r8:
movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
@@ -281,7 +281,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
pxor xmm3, xmm3
mov ecx, SIZEOF_XMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
diff --git a/simd/i386/jdcolext-avx2.asm b/simd/i386/jdcolext-avx2.asm
index 015be041..53ea3128 100644
--- a/simd/i386/jdcolext-avx2.asm
+++ b/simd/i386/jdcolext-avx2.asm
@@ -2,7 +2,7 @@
; jdcolext.asm - colorspace conversion (AVX2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -50,15 +50,15 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [out_width(eax)] ; num_cols
test ecx, ecx
@@ -81,7 +81,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax
push edi
@@ -94,8 +94,8 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
mov ebx, JSAMPROW [ebx] ; inptr1
mov edx, JSAMPROW [edx] ; inptr2
mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm5, YMMWORD [ebx] ; ymm5=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
@@ -295,7 +295,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -436,7 +436,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
cmp ecx, byte SIZEOF_YMMWORD/2
@@ -479,7 +479,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
%endif ; RGB_PIXELSIZE ; ---------------
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop ecx
diff --git a/simd/i386/jdcolext-mmx.asm b/simd/i386/jdcolext-mmx.asm
index 5813cfcb..d97faee0 100644
--- a/simd/i386/jdcolext-mmx.asm
+++ b/simd/i386/jdcolext-mmx.asm
@@ -2,7 +2,7 @@
; jdcolext.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,15 +49,15 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [out_width(eax)] ; num_cols
test ecx, ecx
@@ -80,7 +80,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax
push edi
@@ -93,8 +93,8 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
mov ebx, JSAMPROW [ebx] ; inptr1
mov edx, JSAMPROW [edx] ; inptr2
mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
+ ALIGNX 16, 7
.columnloop:
movq mm5, MMWORD [ebx] ; mm5=Cb(01234567)
@@ -255,7 +255,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
add edx, byte SIZEOF_MMWORD ; inptr2
add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -344,7 +344,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
add edx, byte SIZEOF_MMWORD ; inptr2
add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
cmp ecx, byte SIZEOF_MMWORD/2
@@ -369,7 +369,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
%endif ; RGB_PIXELSIZE ; ---------------
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop ecx
diff --git a/simd/i386/jdcolext-sse2.asm b/simd/i386/jdcolext-sse2.asm
index d5572b32..682efc73 100644
--- a/simd/i386/jdcolext-sse2.asm
+++ b/simd/i386/jdcolext-sse2.asm
@@ -2,7 +2,7 @@
; jdcolext.asm - colorspace conversion (SSE2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,15 +49,15 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [out_width(eax)] ; num_cols
test ecx, ecx
@@ -80,7 +80,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax
push edi
@@ -93,8 +93,8 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
mov ebx, JSAMPROW [ebx] ; inptr1
mov edx, JSAMPROW [edx] ; inptr2
mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
+ ALIGNX 16, 7
.columnloop:
movdqa xmm5, XMMWORD [ebx] ; xmm5=Cb(0123456789ABCDEF)
@@ -275,7 +275,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -387,7 +387,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
cmp ecx, byte SIZEOF_XMMWORD/2
@@ -423,7 +423,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
%endif ; RGB_PIXELSIZE ; ---------------
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop ecx
diff --git a/simd/i386/jdcolor-avx2.asm b/simd/i386/jdcolor-avx2.asm
index e05b60d0..0f9baf84 100644
--- a/simd/i386/jdcolor-avx2.asm
+++ b/simd/i386/jdcolor-avx2.asm
@@ -3,7 +3,7 @@
;
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -32,7 +32,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_avx2)
EXTN(jconst_ycc_rgb_convert_avx2):
@@ -43,7 +43,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jdcolor-mmx.asm b/simd/i386/jdcolor-mmx.asm
index fb7e7bcc..21e83329 100644
--- a/simd/i386/jdcolor-mmx.asm
+++ b/simd/i386/jdcolor-mmx.asm
@@ -2,7 +2,7 @@
; jdcolor.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -31,7 +31,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_mmx)
EXTN(jconst_ycc_rgb_convert_mmx):
@@ -42,7 +42,7 @@ PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285
PW_ONE times 4 dw 1
PD_ONEHALF times 2 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jdcolor-sse2.asm b/simd/i386/jdcolor-sse2.asm
index b7362553..481d0e4c 100644
--- a/simd/i386/jdcolor-sse2.asm
+++ b/simd/i386/jdcolor-sse2.asm
@@ -2,7 +2,7 @@
; jdcolor.asm - colorspace conversion (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -31,7 +31,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_sse2)
EXTN(jconst_ycc_rgb_convert_sse2):
@@ -42,7 +42,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jdmerge-avx2.asm b/simd/i386/jdmerge-avx2.asm
index 711e6792..00201dc4 100644
--- a/simd/i386/jdmerge-avx2.asm
+++ b/simd/i386/jdmerge-avx2.asm
@@ -2,7 +2,7 @@
; jdmerge.asm - merged upsampling/color conversion (AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -32,7 +32,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_avx2)
EXTN(jconst_merged_upsample_avx2):
@@ -43,7 +43,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jdmerge-mmx.asm b/simd/i386/jdmerge-mmx.asm
index 6e8311d4..be28c63f 100644
--- a/simd/i386/jdmerge-mmx.asm
+++ b/simd/i386/jdmerge-mmx.asm
@@ -2,7 +2,7 @@
; jdmerge.asm - merged upsampling/color conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -31,7 +31,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_mmx)
EXTN(jconst_merged_upsample_mmx):
@@ -42,7 +42,7 @@ PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285
PW_ONE times 4 dw 1
PD_ONEHALF times 2 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jdmerge-sse2.asm b/simd/i386/jdmerge-sse2.asm
index e32f90aa..9b40a67d 100644
--- a/simd/i386/jdmerge-sse2.asm
+++ b/simd/i386/jdmerge-sse2.asm
@@ -2,7 +2,7 @@
; jdmerge.asm - merged upsampling/color conversion (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -31,7 +31,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_sse2)
EXTN(jconst_merged_upsample_sse2):
@@ -42,7 +42,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/i386/jdmrgext-avx2.asm b/simd/i386/jdmrgext-avx2.asm
index e35f7282..97988eb6 100644
--- a/simd/i386/jdmrgext-avx2.asm
+++ b/simd/i386/jdmrgext-avx2.asm
@@ -2,7 +2,7 @@
; jdmrgext.asm - merged upsampling/color conversion (AVX2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -50,15 +50,15 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [output_width(eax)] ; col
test ecx, ecx
@@ -79,9 +79,9 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
pop ecx ; col
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
vmovdqu ymm6, YMMWORD [ebx] ; ymm6=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
vmovdqu ymm7, YMMWORD [edx] ; ymm7=Cr(0123456789ABCDEFGHIJKLMNOPQRSTUV)
@@ -168,13 +168,13 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
mov al, 2 ; Yctr
jmp short .Yloop_1st
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_2nd:
vmovdqa ymm0, YMMWORD [wk(1)] ; ymm0=(R-Y)H
vmovdqa ymm2, YMMWORD [wk(2)] ; ymm2=(G-Y)H
vmovdqa ymm4, YMMWORD [wk(0)] ; ymm4=(B-Y)H
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_1st:
vmovdqu ymm7, YMMWORD [esi] ; ymm7=Y(0123456789ABCDEFGHIJKLMNOPQRSTUV)
@@ -301,7 +301,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -445,7 +445,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
cmp ecx, byte SIZEOF_YMMWORD/2
diff --git a/simd/i386/jdmrgext-mmx.asm b/simd/i386/jdmrgext-mmx.asm
index eb3e36b4..79cee73d 100644
--- a/simd/i386/jdmrgext-mmx.asm
+++ b/simd/i386/jdmrgext-mmx.asm
@@ -2,7 +2,7 @@
; jdmrgext.asm - merged upsampling/color conversion (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -47,15 +47,15 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [output_width(eax)] ; col
test ecx, ecx
@@ -76,9 +76,9 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
pop ecx ; col
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
movq mm6, MMWORD [ebx] ; mm6=Cb(01234567)
movq mm7, MMWORD [edx] ; mm7=Cr(01234567)
@@ -171,13 +171,13 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
mov al, 2 ; Yctr
jmp short .Yloop_1st
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_2nd:
movq mm0, MMWORD [wk(1)] ; mm0=(R-Y)H
movq mm2, MMWORD [wk(2)] ; mm2=(G-Y)H
movq mm4, MMWORD [wk(0)] ; mm4=(B-Y)H
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_1st:
movq mm7, MMWORD [esi] ; mm7=Y(01234567)
@@ -258,7 +258,7 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
add ebx, byte SIZEOF_MMWORD ; inptr1
add edx, byte SIZEOF_MMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -350,7 +350,7 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
add ebx, byte SIZEOF_MMWORD ; inptr1
add edx, byte SIZEOF_MMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
cmp ecx, byte SIZEOF_MMWORD/2
diff --git a/simd/i386/jdmrgext-sse2.asm b/simd/i386/jdmrgext-sse2.asm
index c113dc4d..33134435 100644
--- a/simd/i386/jdmrgext-sse2.asm
+++ b/simd/i386/jdmrgext-sse2.asm
@@ -2,7 +2,7 @@
; jdmrgext.asm - merged upsampling/color conversion (SSE2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,15 +49,15 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov ecx, JDIMENSION [output_width(eax)] ; col
test ecx, ecx
@@ -78,9 +78,9 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
pop ecx ; col
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
movdqa xmm6, XMMWORD [ebx] ; xmm6=Cb(0123456789ABCDEF)
movdqa xmm7, XMMWORD [edx] ; xmm7=Cr(0123456789ABCDEF)
@@ -173,13 +173,13 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
mov al, 2 ; Yctr
jmp short .Yloop_1st
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_2nd:
movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H
movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H
movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_1st:
movdqa xmm7, XMMWORD [esi] ; xmm7=Y(0123456789ABCDEF)
@@ -280,7 +280,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -395,7 +395,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
cmp ecx, byte SIZEOF_XMMWORD/2
diff --git a/simd/i386/jdsample-avx2.asm b/simd/i386/jdsample-avx2.asm
index a800c35e..b0507aa5 100644
--- a/simd/i386/jdsample-avx2.asm
+++ b/simd/i386/jdsample-avx2.asm
@@ -3,7 +3,7 @@
;
; Copyright 2009 Pierre Ossman for Cendio AB
; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -20,7 +20,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_avx2)
EXTN(jconst_fancy_upsample_avx2):
@@ -31,7 +31,7 @@ PW_THREE times 16 dw 3
PW_SEVEN times 16 dw 7
PW_EIGHT times 16 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -62,13 +62,13 @@ PW_EIGHT times 16 dw 8
EXTN(jsimd_h2v1_fancy_upsample_avx2):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
test eax, eax
@@ -81,7 +81,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push edi
@@ -104,7 +104,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
and eax, byte -SIZEOF_YMMWORD
cmp eax, byte SIZEOF_YMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
vpcmpeqb xmm6, xmm6, xmm6
@@ -112,7 +112,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
vperm2i128 ymm6, ymm6, ymm6, 1 ; (---- ---- ... ---- ---- ff) MSB is ff
vpand ymm6, ymm6, YMMWORD [esi+0*SIZEOF_YMMWORD]
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm6, YMMWORD [esi+1*SIZEOF_YMMWORD]
@@ -196,7 +196,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
pop ebp
ret
@@ -234,15 +234,15 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov edx, eax ; edx = original ebp
mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
@@ -256,7 +256,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
mov esi, JSAMPARRAY [input_data(edx)] ; input_data
mov edi, POINTER [output_data_ptr(edx)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push ecx
@@ -286,8 +286,8 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqu ymm1, YMMWORD [ecx+0*SIZEOF_YMMWORD] ; ymm1=row[-1][0]
vmovdqu ymm2, YMMWORD [esi+0*SIZEOF_YMMWORD] ; ymm2=row[+1][0]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
vpxor ymm3, ymm3, ymm3 ; ymm3=(all 0's)
@@ -328,19 +328,19 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqa YMMWORD [wk(0)], ymm1
vmovdqa YMMWORD [wk(1)], ymm2
- poppic ebx
+ POPPIC ebx
add eax, byte SIZEOF_YMMWORD-1
and eax, byte -SIZEOF_YMMWORD
cmp eax, byte SIZEOF_YMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
; -- process the last column block
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
vpcmpeqb xmm1, xmm1, xmm1
vpslldq xmm1, xmm1, (SIZEOF_XMMWORD-2)
@@ -353,7 +353,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqa YMMWORD [wk(3)], ymm2 ; ymm2=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 31)
jmp near .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
; -- process the next column block
@@ -362,8 +362,8 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqu ymm1, YMMWORD [ecx+1*SIZEOF_YMMWORD] ; ymm1=row[-1][1]
vmovdqu ymm2, YMMWORD [esi+1*SIZEOF_YMMWORD] ; ymm2=row[+1][1]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
vpxor ymm3, ymm3, ymm3 ; ymm3=(all 0's)
@@ -516,7 +516,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm1
vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymm0
- poppic ebx
+ POPPIC ebx
sub eax, byte SIZEOF_YMMWORD
add ecx, byte 1*SIZEOF_YMMWORD ; inptr1(above)
@@ -590,7 +590,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -598,7 +598,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
cmp eax, byte SIZEOF_YMMWORD
@@ -629,7 +629,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
add esi, byte SIZEOF_YMMWORD ; inptr
add edi, byte 2*SIZEOF_YMMWORD ; outptr
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
@@ -689,7 +689,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -698,7 +698,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
cmp eax, byte SIZEOF_YMMWORD
@@ -734,7 +734,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
add ebx, 2*SIZEOF_YMMWORD ; outptr0
add edi, 2*SIZEOF_YMMWORD ; outptr1
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
diff --git a/simd/i386/jdsample-mmx.asm b/simd/i386/jdsample-mmx.asm
index 12c49f0e..6f70499c 100644
--- a/simd/i386/jdsample-mmx.asm
+++ b/simd/i386/jdsample-mmx.asm
@@ -2,7 +2,7 @@
; jdsample.asm - upsampling (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -19,7 +19,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_mmx)
EXTN(jconst_fancy_upsample_mmx):
@@ -30,7 +30,7 @@ PW_THREE times 4 dw 3
PW_SEVEN times 4 dw 7
PW_EIGHT times 4 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -61,13 +61,13 @@ PW_EIGHT times 4 dw 8
EXTN(jsimd_h2v1_fancy_upsample_mmx):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
test eax, eax
@@ -80,7 +80,7 @@ EXTN(jsimd_h2v1_fancy_upsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push edi
@@ -103,14 +103,14 @@ EXTN(jsimd_h2v1_fancy_upsample_mmx):
and eax, byte -SIZEOF_MMWORD
cmp eax, byte SIZEOF_MMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
pcmpeqb mm6, mm6
psllq mm6, (SIZEOF_MMWORD-1)*BYTE_BIT
pand mm6, MMWORD [esi+0*SIZEOF_MMWORD]
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm6, MMWORD [esi+1*SIZEOF_MMWORD]
@@ -187,7 +187,7 @@ EXTN(jsimd_h2v1_fancy_upsample_mmx):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
pop ebp
ret
@@ -224,15 +224,15 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov edx, eax ; edx = original ebp
mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
@@ -246,7 +246,7 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
mov esi, JSAMPARRAY [input_data(edx)] ; input_data
mov edi, POINTER [output_data_ptr(edx)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push ecx
@@ -276,8 +276,8 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq mm1, MMWORD [ecx+0*SIZEOF_MMWORD] ; mm1=row[-1][0]
movq mm2, MMWORD [esi+0*SIZEOF_MMWORD] ; mm2=row[+1][0]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor mm3, mm3 ; mm3=(all 0's)
movq mm4, mm0
@@ -312,19 +312,19 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq MMWORD [wk(0)], mm1
movq MMWORD [wk(1)], mm2
- poppic ebx
+ POPPIC ebx
add eax, byte SIZEOF_MMWORD-1
and eax, byte -SIZEOF_MMWORD
cmp eax, byte SIZEOF_MMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
; -- process the last column block
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pcmpeqb mm1, mm1
psllq mm1, (SIZEOF_MMWORD-2)*BYTE_BIT
@@ -337,7 +337,7 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq MMWORD [wk(3)], mm2
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
; -- process the next column block
@@ -346,8 +346,8 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq mm1, MMWORD [ecx+1*SIZEOF_MMWORD] ; mm1=row[-1][1]
movq mm2, MMWORD [esi+1*SIZEOF_MMWORD] ; mm2=row[+1][1]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor mm3, mm3 ; mm3=(all 0's)
movq mm4, mm0
@@ -486,7 +486,7 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq MMWORD [edi+0*SIZEOF_MMWORD], mm1
movq MMWORD [edi+1*SIZEOF_MMWORD], mm0
- poppic ebx
+ POPPIC ebx
sub eax, byte SIZEOF_MMWORD
add ecx, byte 1*SIZEOF_MMWORD ; inptr1(above)
@@ -561,7 +561,7 @@ EXTN(jsimd_h2v1_upsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -569,7 +569,7 @@ EXTN(jsimd_h2v1_upsample_mmx):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -599,7 +599,7 @@ EXTN(jsimd_h2v1_upsample_mmx):
add esi, byte 2*SIZEOF_MMWORD ; inptr
add edi, byte 4*SIZEOF_MMWORD ; outptr
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
@@ -660,7 +660,7 @@ EXTN(jsimd_h2v2_upsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -669,7 +669,7 @@ EXTN(jsimd_h2v2_upsample_mmx):
mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -704,7 +704,7 @@ EXTN(jsimd_h2v2_upsample_mmx):
add ebx, byte 4*SIZEOF_MMWORD ; outptr0
add edi, byte 4*SIZEOF_MMWORD ; outptr1
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
diff --git a/simd/i386/jdsample-sse2.asm b/simd/i386/jdsample-sse2.asm
index 4e28d2f4..f68c5ea5 100644
--- a/simd/i386/jdsample-sse2.asm
+++ b/simd/i386/jdsample-sse2.asm
@@ -2,7 +2,7 @@
; jdsample.asm - upsampling (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -19,7 +19,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_sse2)
EXTN(jconst_fancy_upsample_sse2):
@@ -30,7 +30,7 @@ PW_THREE times 8 dw 3
PW_SEVEN times 8 dw 7
PW_EIGHT times 8 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -61,13 +61,13 @@ PW_EIGHT times 8 dw 8
EXTN(jsimd_h2v1_fancy_upsample_sse2):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
test eax, eax
@@ -80,7 +80,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push edi
@@ -103,14 +103,14 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
and eax, byte -SIZEOF_XMMWORD
cmp eax, byte SIZEOF_XMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
pcmpeqb xmm6, xmm6
pslldq xmm6, (SIZEOF_XMMWORD-1)
pand xmm6, XMMWORD [esi+0*SIZEOF_XMMWORD]
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm6, XMMWORD [esi+1*SIZEOF_XMMWORD]
@@ -185,7 +185,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
pop ebp
ret
@@ -223,15 +223,15 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic eax ; make a room for GOT address
+ PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
- movpic POINTER [gotptr], ebx ; save GOT address
+ GET_GOT ebx ; get GOT address
+ MOVPIC POINTER [gotptr], ebx ; save GOT address
mov edx, eax ; edx = original ebp
mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
@@ -245,7 +245,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
mov esi, JSAMPARRAY [input_data(edx)] ; input_data
mov edi, POINTER [output_data_ptr(edx)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push ecx
@@ -275,8 +275,8 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa xmm1, XMMWORD [ecx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0]
movdqa xmm2, XMMWORD [esi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor xmm3, xmm3 ; xmm3=(all 0's)
movdqa xmm4, xmm0
@@ -311,19 +311,19 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa XMMWORD [wk(0)], xmm1
movdqa XMMWORD [wk(1)], xmm2
- poppic ebx
+ POPPIC ebx
add eax, byte SIZEOF_XMMWORD-1
and eax, byte -SIZEOF_XMMWORD
cmp eax, byte SIZEOF_XMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
; -- process the last column block
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pcmpeqb xmm1, xmm1
pslldq xmm1, (SIZEOF_XMMWORD-2)
@@ -336,7 +336,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15)
jmp near .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
; -- process the next column block
@@ -345,8 +345,8 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa xmm1, XMMWORD [ecx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1]
movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor xmm3, xmm3 ; xmm3=(all 0's)
movdqa xmm4, xmm0
@@ -485,7 +485,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm1
movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm0
- poppic ebx
+ POPPIC ebx
sub eax, byte SIZEOF_XMMWORD
add ecx, byte 1*SIZEOF_XMMWORD ; inptr1(above)
@@ -558,7 +558,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -566,7 +566,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -596,7 +596,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
add esi, byte 2*SIZEOF_XMMWORD ; inptr
add edi, byte 4*SIZEOF_XMMWORD ; outptr
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
@@ -655,7 +655,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -664,7 +664,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -699,7 +699,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
add ebx, byte 4*SIZEOF_XMMWORD ; outptr0
add edi, byte 4*SIZEOF_XMMWORD ; outptr1
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
diff --git a/simd/i386/jfdctflt-3dn.asm b/simd/i386/jfdctflt-3dn.asm
index 322ab163..34af2bf0 100644
--- a/simd/i386/jfdctflt-3dn.asm
+++ b/simd/i386/jfdctflt-3dn.asm
@@ -2,7 +2,7 @@
; jfdctflt.asm - floating-point FDCT (3DNow!)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -24,7 +24,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_float_3dnow)
EXTN(jconst_fdct_float_3dnow):
@@ -34,7 +34,7 @@ PD_0_707 times 2 dd 0.707106781186547524400844
PD_0_541 times 2 dd 0.541196100146196984399723
PD_1_306 times 2 dd 1.306562964876376527856643
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -63,19 +63,19 @@ EXTN(jsimd_fdct_float_3dnow):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
@@ -190,7 +190,7 @@ EXTN(jsimd_fdct_float_3dnow):
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
@@ -307,7 +307,7 @@ EXTN(jsimd_fdct_float_3dnow):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jfdctflt-sse.asm b/simd/i386/jfdctflt-sse.asm
index 86952c64..d247094b 100644
--- a/simd/i386/jfdctflt-sse.asm
+++ b/simd/i386/jfdctflt-sse.asm
@@ -2,7 +2,7 @@
; jfdctflt.asm - floating-point FDCT (SSE)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -34,7 +34,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_float_sse)
EXTN(jconst_fdct_float_sse):
@@ -44,7 +44,7 @@ PD_0_707 times 4 dd 0.707106781186547524400844
PD_0_541 times 4 dd 0.541196100146196984399723
PD_1_306 times 4 dd 1.306562964876376527856643
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -74,19 +74,19 @@ EXTN(jsimd_fdct_float_sse):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
@@ -222,7 +222,7 @@ EXTN(jsimd_fdct_float_sse):
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
@@ -358,7 +358,7 @@ EXTN(jsimd_fdct_float_sse):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jfdctfst-mmx.asm b/simd/i386/jfdctfst-mmx.asm
index 80645a50..8c55a987 100644
--- a/simd/i386/jfdctfst-mmx.asm
+++ b/simd/i386/jfdctfst-mmx.asm
@@ -2,7 +2,7 @@
; jfdctfst.asm - fast integer FDCT (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,7 +49,7 @@ F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_ifast_mmx)
EXTN(jconst_fdct_ifast_mmx):
@@ -59,7 +59,7 @@ PW_F0382 times 4 dw F_0_382 << CONST_SHIFT
PW_F0541 times 4 dw F_0_541 << CONST_SHIFT
PW_F1306 times 4 dw F_1_306 << CONST_SHIFT
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -88,19 +88,19 @@ EXTN(jsimd_fdct_ifast_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -241,7 +241,7 @@ EXTN(jsimd_fdct_ifast_mmx):
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -384,7 +384,7 @@ EXTN(jsimd_fdct_ifast_mmx):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jfdctfst-sse2.asm b/simd/i386/jfdctfst-sse2.asm
index 446fa7a6..c1ba533d 100644
--- a/simd/i386/jfdctfst-sse2.asm
+++ b/simd/i386/jfdctfst-sse2.asm
@@ -2,7 +2,7 @@
; jfdctfst.asm - fast integer FDCT (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -49,7 +49,7 @@ F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_ifast_sse2)
EXTN(jconst_fdct_ifast_sse2):
@@ -59,7 +59,7 @@ PW_F0382 times 8 dw F_0_382 << CONST_SHIFT
PW_F0541 times 8 dw F_0_541 << CONST_SHIFT
PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -89,13 +89,13 @@ EXTN(jsimd_fdct_ifast_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
@@ -392,7 +392,7 @@ EXTN(jsimd_fdct_ifast_sse2):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jfdctint-avx2.asm b/simd/i386/jfdctint-avx2.asm
index 23cf7331..21c3d5b2 100644
--- a/simd/i386/jfdctint-avx2.asm
+++ b/simd/i386/jfdctint-avx2.asm
@@ -2,7 +2,7 @@
; jfdctint.asm - accurate integer FDCT (AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -65,7 +65,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
@@ -108,7 +108,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%8: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 9
+%macro DODCT 9
vpsubw %5, %1, %4 ; %5=data1_0-data6_7=tmp6_7
vpaddw %6, %1, %4 ; %6=data1_0+data6_7=tmp1_0
vpaddw %7, %2, %3 ; %7=data3_2+data4_5=tmp3_2
@@ -223,7 +223,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_avx2)
EXTN(jconst_fdct_islow_avx2):
@@ -242,7 +242,7 @@ PW_DESCALE_P2X times 16 dw 1 << (PASS1_BITS - 1)
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -262,13 +262,13 @@ PW_1_NEG1 times 8 dw 1
EXTN(jsimd_fdct_islow_avx2):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
@@ -292,9 +292,9 @@ EXTN(jsimd_fdct_islow_avx2):
; ymm2=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
; ymm3=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm3=data7_5
; ---- Pass 2: process columns.
@@ -302,9 +302,9 @@ EXTN(jsimd_fdct_islow_avx2):
vperm2i128 ymm4, ymm1, ymm3, 0x20 ; ymm4=data3_7
vperm2i128 ymm1, ymm1, ymm3, 0x31 ; ymm1=data1_5
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm4=data7_5
vperm2i128 ymm3, ymm0, ymm1, 0x30 ; ymm3=data0_1
@@ -322,7 +322,7 @@ EXTN(jsimd_fdct_islow_avx2):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
pop ebp
ret
diff --git a/simd/i386/jfdctint-mmx.asm b/simd/i386/jfdctint-mmx.asm
index 34a43b9e..c2f308ed 100644
--- a/simd/i386/jfdctint-mmx.asm
+++ b/simd/i386/jfdctint-mmx.asm
@@ -2,7 +2,7 @@
; jfdctint.asm - accurate integer FDCT (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -63,7 +63,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_mmx)
EXTN(jconst_fdct_islow_mmx):
@@ -80,7 +80,7 @@ PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2 - 1)
PW_DESCALE_P2X times 4 dw 1 << (PASS1_BITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -109,19 +109,19 @@ EXTN(jsimd_fdct_islow_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -363,7 +363,7 @@ EXTN(jsimd_fdct_islow_mmx):
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -609,7 +609,7 @@ EXTN(jsimd_fdct_islow_mmx):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jfdctint-sse2.asm b/simd/i386/jfdctint-sse2.asm
index 6f8e18cb..b6e67991 100644
--- a/simd/i386/jfdctint-sse2.asm
+++ b/simd/i386/jfdctint-sse2.asm
@@ -2,7 +2,7 @@
; jfdctint.asm - accurate integer FDCT (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -63,7 +63,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_sse2)
EXTN(jconst_fdct_islow_sse2):
@@ -80,7 +80,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -110,13 +110,13 @@ EXTN(jsimd_fdct_islow_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
@@ -622,7 +622,7 @@ EXTN(jsimd_fdct_islow_sse2):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jidctflt-3dn.asm b/simd/i386/jidctflt-3dn.asm
index 87951910..1f696cb5 100644
--- a/simd/i386/jidctflt-3dn.asm
+++ b/simd/i386/jidctflt-3dn.asm
@@ -2,7 +2,7 @@
; jidctflt.asm - floating-point IDCT (3DNow! & MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -24,7 +24,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_3dnow)
EXTN(jconst_idct_float_3dnow):
@@ -36,7 +36,7 @@ PD_2_613 times 2 dd 2.613125929752753055713286
PD_RNDINT_MAGIC times 2 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -78,7 +78,7 @@ EXTN(jsimd_idct_float_3dnow):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -87,21 +87,21 @@ EXTN(jsimd_idct_float_3dnow):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; FAST_FLOAT *wsptr
mov ecx, DCTSIZE/2 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_3DNOW
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
jnz short .columnDCT
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov ebx, dword [DWBLOCK(3,0,esi,SIZEOF_JCOEF)]
mov eax, dword [DWBLOCK(4,0,esi,SIZEOF_JCOEF)]
or ebx, dword [DWBLOCK(5,0,esi,SIZEOF_JCOEF)]
or eax, dword [DWBLOCK(6,0,esi,SIZEOF_JCOEF)]
or ebx, dword [DWBLOCK(7,0,esi,SIZEOF_JCOEF)]
or eax, ebx
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
jnz short .columnDCT
; -- AC terms all zero
@@ -127,7 +127,7 @@ EXTN(jsimd_idct_float_3dnow):
movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm1
movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -293,7 +293,7 @@ EXTN(jsimd_idct_float_3dnow):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/2 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -420,14 +420,14 @@ EXTN(jsimd_idct_float_3dnow):
punpckldq mm6, mm4 ; mm6=(00 01 02 03 04 05 06 07)
punpckhdq mm7, mm4 ; mm7=(10 11 12 13 14 15 16 17)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 2*SIZEOF_FAST_FLOAT ; wsptr
add edi, byte 2*SIZEOF_JSAMPROW
diff --git a/simd/i386/jidctflt-sse.asm b/simd/i386/jidctflt-sse.asm
index b27ecfdf..daeef22a 100644
--- a/simd/i386/jidctflt-sse.asm
+++ b/simd/i386/jidctflt-sse.asm
@@ -2,7 +2,7 @@
; jidctflt.asm - floating-point IDCT (SSE & MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -23,18 +23,18 @@
; --------------------------------------------------------------------------
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
+%macro UNPCKLPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1, %2, 0x44
%endmacro
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
+%macro UNPCKHPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1, %2, 0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_sse)
EXTN(jconst_idct_float_sse):
@@ -46,7 +46,7 @@ PD_M2_613 times 4 dd -2.613125929752753055713286
PD_0_125 times 4 dd 0.125 ; 1/8
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -88,7 +88,7 @@ EXTN(jsimd_idct_float_sse):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -97,7 +97,7 @@ EXTN(jsimd_idct_float_sse):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; FAST_FLOAT *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -149,7 +149,7 @@ EXTN(jsimd_idct_float_sse):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -325,11 +325,11 @@ EXTN(jsimd_idct_float_sse):
unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
+ UNPCKLPS2 xmm6, xmm7 ; xmm6=(00 10 20 30)
+ UNPCKHPS2 xmm3, xmm7 ; xmm3=(01 11 21 31)
movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
+ UNPCKLPS2 xmm1, xmm2 ; xmm1=(02 12 22 32)
+ UNPCKHPS2 xmm0, xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
@@ -340,11 +340,11 @@ EXTN(jsimd_idct_float_sse):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
+ UNPCKLPS2 xmm5, xmm7 ; xmm5=(40 50 60 70)
+ UNPCKHPS2 xmm6, xmm7 ; xmm6=(41 51 61 71)
movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
+ UNPCKLPS2 xmm4, xmm2 ; xmm4=(42 52 62 72)
+ UNPCKHPS2 xmm3, xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
@@ -372,7 +372,7 @@ EXTN(jsimd_idct_float_sse):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -536,7 +536,7 @@ EXTN(jsimd_idct_float_sse):
punpckldq mm5, mm6 ; mm5=(20 21 22 23 24 25 26 27)
punpckhdq mm4, mm6 ; mm4=(30 31 32 33 34 35 36 37)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
@@ -547,7 +547,7 @@ EXTN(jsimd_idct_float_sse):
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/simd/i386/jidctflt-sse2.asm b/simd/i386/jidctflt-sse2.asm
index c646eaef..c39ffbe7 100644
--- a/simd/i386/jidctflt-sse2.asm
+++ b/simd/i386/jidctflt-sse2.asm
@@ -2,7 +2,7 @@
; jidctflt.asm - floating-point IDCT (SSE & SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -23,18 +23,18 @@
; --------------------------------------------------------------------------
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
+%macro UNPCKLPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1, %2, 0x44
%endmacro
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
+%macro UNPCKHPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1, %2, 0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_sse2)
EXTN(jconst_idct_float_sse2):
@@ -46,7 +46,7 @@ PD_M2_613 times 4 dd -2.613125929752753055713286
PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -88,7 +88,7 @@ EXTN(jsimd_idct_float_sse2):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -97,7 +97,7 @@ EXTN(jsimd_idct_float_sse2):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; FAST_FLOAT *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -150,7 +150,7 @@ EXTN(jsimd_idct_float_sse2):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -287,11 +287,11 @@ EXTN(jsimd_idct_float_sse2):
unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
+ UNPCKLPS2 xmm6, xmm7 ; xmm6=(00 10 20 30)
+ UNPCKHPS2 xmm3, xmm7 ; xmm3=(01 11 21 31)
movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
+ UNPCKLPS2 xmm1, xmm2 ; xmm1=(02 12 22 32)
+ UNPCKHPS2 xmm0, xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
@@ -302,11 +302,11 @@ EXTN(jsimd_idct_float_sse2):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
+ UNPCKLPS2 xmm5, xmm7 ; xmm5=(40 50 60 70)
+ UNPCKHPS2 xmm6, xmm7 ; xmm6=(41 51 61 71)
movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
+ UNPCKLPS2 xmm4, xmm2 ; xmm4=(42 52 62 72)
+ UNPCKHPS2 xmm3, xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
@@ -334,7 +334,7 @@ EXTN(jsimd_idct_float_sse2):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -464,7 +464,7 @@ EXTN(jsimd_idct_float_sse2):
pshufd xmm5, xmm6, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
pshufd xmm3, xmm7, 0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
@@ -475,7 +475,7 @@ EXTN(jsimd_idct_float_sse2):
movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5
movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm3
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/simd/i386/jidctfst-mmx.asm b/simd/i386/jidctfst-mmx.asm
index 24622d43..19de457f 100644
--- a/simd/i386/jidctfst-mmx.asm
+++ b/simd/i386/jidctfst-mmx.asm
@@ -2,7 +2,7 @@
; jidctfst.asm - fast integer IDCT (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -56,7 +56,7 @@ F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_ifast_mmx)
EXTN(jconst_idct_ifast_mmx):
@@ -67,7 +67,7 @@ PW_MF1613 times 4 dw -F_1_613 << CONST_SHIFT
PW_F1082 times 4 dw F_1_082 << CONST_SHIFT
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -109,7 +109,7 @@ EXTN(jsimd_idct_ifast_mmx):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -118,7 +118,7 @@ EXTN(jsimd_idct_ifast_mmx):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; JCOEF *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_IFAST_MMX
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -163,7 +163,7 @@ EXTN(jsimd_idct_ifast_mmx):
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -326,7 +326,7 @@ EXTN(jsimd_idct_ifast_mmx):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -464,7 +464,7 @@ EXTN(jsimd_idct_ifast_mmx):
punpckldq mm5, mm4 ; mm5=(20 21 22 23 24 25 26 27)
punpckhdq mm1, mm4 ; mm1=(30 31 32 33 34 35 36 37)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
@@ -475,7 +475,7 @@ EXTN(jsimd_idct_ifast_mmx):
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_JCOEF ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/simd/i386/jidctfst-sse2.asm b/simd/i386/jidctfst-sse2.asm
index 19704ffa..966311ed 100644
--- a/simd/i386/jidctfst-sse2.asm
+++ b/simd/i386/jidctfst-sse2.asm
@@ -2,7 +2,7 @@
; jidctfst.asm - fast integer IDCT (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -56,7 +56,7 @@ F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_ifast_sse2)
EXTN(jconst_idct_ifast_sse2):
@@ -67,7 +67,7 @@ PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -101,13 +101,13 @@ EXTN(jsimd_idct_ifast_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
@@ -155,7 +155,7 @@ EXTN(jsimd_idct_ifast_sse2):
movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1
movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -490,7 +490,7 @@ EXTN(jsimd_idct_ifast_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jidctint-avx2.asm b/simd/i386/jidctint-avx2.asm
index 199c7df3..dd4a3d5e 100644
--- a/simd/i386/jidctint-avx2.asm
+++ b/simd/i386/jidctint-avx2.asm
@@ -2,7 +2,7 @@
; jidctint.asm - accurate integer IDCT (AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -65,7 +65,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %5=(00 10 20 30 40 50 60 70 01 11 21 31 41 51 61 71)
; %6=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
; %7=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
@@ -118,7 +118,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%12: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 13
+%macro DODCT 13
; -- Even part
; (Original)
@@ -250,7 +250,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_avx2)
EXTN(jconst_idct_islow_avx2):
@@ -269,7 +269,7 @@ PB_CENTERJSAMP times 32 db CENTERJSAMPLE
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -303,13 +303,13 @@ EXTN(jsimd_idct_islow_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns.
@@ -353,7 +353,7 @@ EXTN(jsimd_idct_islow_avx2):
vpshufd ymm3, ymm4, 0xFF ; ymm3=col3_7=(03 03 03 03 03 03 03 03 07 07 07 07 07 07 07 07)
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -371,10 +371,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm2, ymm5, ymm7, 0x20 ; ymm2=in2_6
vperm2i128 ymm3, ymm7, ymm6, 0x31 ; ymm3=in7_5
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 1
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm3=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm3=data3_7
.column_end:
@@ -395,10 +395,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm4, ymm3, ymm1, 0x31 ; ymm3=in7_5
vperm2i128 ymm1, ymm3, ymm1, 0x20 ; ymm1=in3_1
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 2
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm4=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm4=data3_7
vpacksswb ymm0, ymm0, ymm1 ; ymm0=data01_45
@@ -442,7 +442,7 @@ EXTN(jsimd_idct_islow_avx2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jidctint-mmx.asm b/simd/i386/jidctint-mmx.asm
index f15c8d34..e2e1b3ff 100644
--- a/simd/i386/jidctint-mmx.asm
+++ b/simd/i386/jidctint-mmx.asm
@@ -2,7 +2,7 @@
; jidctint.asm - accurate integer IDCT (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -63,7 +63,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_mmx)
EXTN(jconst_idct_islow_mmx):
@@ -80,7 +80,7 @@ PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2 - 1)
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -122,7 +122,7 @@ EXTN(jsimd_idct_islow_mmx):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -131,7 +131,7 @@ EXTN(jsimd_idct_islow_mmx):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; JCOEF *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_ISLOW_MMX
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -178,7 +178,7 @@ EXTN(jsimd_idct_islow_mmx):
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -513,7 +513,7 @@ EXTN(jsimd_idct_islow_mmx):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -816,7 +816,7 @@ EXTN(jsimd_idct_islow_mmx):
punpckldq mm7, mm5 ; mm7=(20 21 22 23 24 25 26 27)
punpckhdq mm4, mm5 ; mm4=(30 31 32 33 34 35 36 37)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
@@ -827,7 +827,7 @@ EXTN(jsimd_idct_islow_mmx):
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm7
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_JCOEF ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/simd/i386/jidctint-sse2.asm b/simd/i386/jidctint-sse2.asm
index 43e32018..42be940d 100644
--- a/simd/i386/jidctint-sse2.asm
+++ b/simd/i386/jidctint-sse2.asm
@@ -2,7 +2,7 @@
; jidctint.asm - accurate integer IDCT (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -63,7 +63,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_sse2)
EXTN(jconst_idct_islow_sse2):
@@ -80,7 +80,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -114,13 +114,13 @@ EXTN(jsimd_idct_islow_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
@@ -172,7 +172,7 @@ EXTN(jsimd_idct_islow_sse2):
movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -847,7 +847,7 @@ EXTN(jsimd_idct_islow_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/simd/i386/jidctred-mmx.asm b/simd/i386/jidctred-mmx.asm
index e2307e1c..920dad90 100644
--- a/simd/i386/jidctred-mmx.asm
+++ b/simd/i386/jidctred-mmx.asm
@@ -2,7 +2,7 @@
; jidctred.asm - reduced-size IDCT (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -69,7 +69,7 @@ F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_red_mmx)
EXTN(jconst_idct_red_mmx):
@@ -87,7 +87,7 @@ PD_DESCALE_P1_2 times 2 dd 1 << (DESCALE_P1_2 - 1)
PD_DESCALE_P2_2 times 2 dd 1 << (DESCALE_P2_2 - 1)
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -124,13 +124,13 @@ EXTN(jsimd_idct_4x4_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [workspace]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -139,7 +139,7 @@ EXTN(jsimd_idct_4x4_mmx):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; JCOEF *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_4X4_MMX
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -181,7 +181,7 @@ EXTN(jsimd_idct_4x4_mmx):
movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -479,7 +479,7 @@ EXTN(jsimd_idct_4x4_mmx):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
@@ -512,7 +512,7 @@ EXTN(jsimd_idct_2x2_mmx):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
diff --git a/simd/i386/jidctred-sse2.asm b/simd/i386/jidctred-sse2.asm
index 6e56494e..9a6f9946 100644
--- a/simd/i386/jidctred-sse2.asm
+++ b/simd/i386/jidctred-sse2.asm
@@ -2,7 +2,7 @@
; jidctred.asm - reduced-size IDCT (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -69,7 +69,7 @@ F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_red_sse2)
EXTN(jconst_idct_red_sse2):
@@ -87,7 +87,7 @@ PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2 - 1)
PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -122,13 +122,13 @@ EXTN(jsimd_idct_4x4_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
@@ -171,7 +171,7 @@ EXTN(jsimd_idct_4x4_sse2):
pshufd xmm3, xmm3, 0xFA ; xmm3=[col6 col7]=(06 06 06 06 07 07 07 07)
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -400,7 +400,7 @@ EXTN(jsimd_idct_4x4_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
@@ -433,7 +433,7 @@ EXTN(jsimd_idct_2x2_sse2):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
diff --git a/simd/i386/jquant-3dn.asm b/simd/i386/jquant-3dn.asm
index 5cb60caa..6436bad1 100644
--- a/simd/i386/jquant-3dn.asm
+++ b/simd/i386/jquant-3dn.asm
@@ -2,7 +2,7 @@
; jquant.asm - sample data conversion and quantization (3DNow! & MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -52,7 +52,7 @@ EXTN(jsimd_convsamp_float_3dnow):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -154,7 +154,7 @@ EXTN(jsimd_quantize_float_3dnow):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/16
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
movq mm1, MMWORD [MMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
diff --git a/simd/i386/jquant-mmx.asm b/simd/i386/jquant-mmx.asm
index 61305c62..e525ba9e 100644
--- a/simd/i386/jquant-mmx.asm
+++ b/simd/i386/jquant-mmx.asm
@@ -2,7 +2,7 @@
; jquant.asm - sample data conversion and quantization (MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -52,7 +52,7 @@ EXTN(jsimd_convsamp_mmx):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -157,10 +157,10 @@ EXTN(jsimd_quantize_mmx):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov ah, 2
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop1:
mov al, DCTSIZE2/8/2
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop2:
movq mm2, MMWORD [MMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
movq mm3, MMWORD [MMBLOCK(0,1,esi,SIZEOF_DCTELEM)]
diff --git a/simd/i386/jquant-sse.asm b/simd/i386/jquant-sse.asm
index 218adc97..1cf2cc0c 100644
--- a/simd/i386/jquant-sse.asm
+++ b/simd/i386/jquant-sse.asm
@@ -2,7 +2,7 @@
; jquant.asm - sample data conversion and quantization (SSE & MMX)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -52,7 +52,7 @@ EXTN(jsimd_convsamp_float_sse):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -150,7 +150,7 @@ EXTN(jsimd_quantize_float_sse):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/16
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
diff --git a/simd/i386/jquantf-sse2.asm b/simd/i386/jquantf-sse2.asm
index a881ab50..66efd3ee 100644
--- a/simd/i386/jquantf-sse2.asm
+++ b/simd/i386/jquantf-sse2.asm
@@ -2,7 +2,7 @@
; jquantf.asm - sample data conversion and quantization (SSE & SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -52,7 +52,7 @@ EXTN(jsimd_convsamp_float_sse2):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -127,7 +127,7 @@ EXTN(jsimd_quantize_float_sse2):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/16
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
diff --git a/simd/i386/jquanti-sse2.asm b/simd/i386/jquanti-sse2.asm
index 0a509408..2a69af9c 100644
--- a/simd/i386/jquanti-sse2.asm
+++ b/simd/i386/jquanti-sse2.asm
@@ -2,7 +2,7 @@
; jquanti.asm - sample data conversion and quantization (SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -52,7 +52,7 @@ EXTN(jsimd_convsamp_sse2):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -133,7 +133,7 @@ EXTN(jsimd_quantize_sse2):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/32
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movdqa xmm4, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
movdqa xmm5, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_DCTELEM)]
diff --git a/simd/nasm/jsimdext.inc b/simd/nasm/jsimdext.inc
index bebcb200..2da5017e 100644
--- a/simd/nasm/jsimdext.inc
+++ b/simd/nasm/jsimdext.inc
@@ -2,7 +2,7 @@
; jsimdext.inc - common declarations
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
+; Copyright (C) 2010, 2016, 2018-2019, 2024, D. R. Commander.
; Copyright (C) 2018, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
@@ -272,7 +272,7 @@ const_base:
%define GOTOFF(got, sym) (got) + (sym) - const_base
-%imacro get_GOT 1
+%imacro GET_GOT 1
; NOTE: this macro destroys ecx resister.
call %%geteip
add ecx, byte (%%ref - $)
@@ -304,7 +304,7 @@ const_base:
%define GOTOFF(got, sym) (got) + (sym) wrt ..gotoff
-%imacro get_GOT 1
+%imacro GET_GOT 1
extern GOT_SYMBOL
call %%geteip
add %1, GOT_SYMBOL + $$ - $ wrt ..gotpc
@@ -317,13 +317,13 @@ const_base:
%endif ; GOT_SYMBOL == _MACHO_PIC_ ----------------
-%imacro pushpic 1.nolist
+%imacro PUSHPIC 1.nolist
push %1
%endmacro
-%imacro poppic 1.nolist
+%imacro POPPIC 1.nolist
pop %1
%endmacro
-%imacro movpic 2.nolist
+%imacro MOVPIC 2.nolist
mov %1, %2
%endmacro
@@ -331,13 +331,13 @@ const_base:
%define GOTOFF(got, sym) (sym)
-%imacro get_GOT 1.nolist
+%imacro GET_GOT 1.nolist
%endmacro
-%imacro pushpic 1.nolist
+%imacro PUSHPIC 1.nolist
%endmacro
-%imacro poppic 1.nolist
+%imacro POPPIC 1.nolist
%endmacro
-%imacro movpic 2.nolist
+%imacro MOVPIC 2.nolist
%endmacro
%endif ; PIC -----------------------------------------
@@ -349,7 +349,7 @@ const_base:
%define MSKLE(x, y) (~(((y) & 0xFFFF) - ((x) & 0xFFFF)) >> 16)
%define FILLB(b, n) (($$-(b)) & ((n)-1))
-%imacro alignx 1-2.nolist 0xFFFF
+%imacro ALIGNX 1-2.nolist 0xFFFF
%%bs: \
times MSKLE(FILLB(%%bs, %1), %2) & MSKLE(16, FILLB($, %1)) & FILLB($, %1) \
db 0x90 ; nop
@@ -371,7 +371,7 @@ const_base:
; Align the next data on {2,4,8,16,..}-byte boundary.
;
-%imacro alignz 1.nolist
+%imacro ALIGNZ 1.nolist
align %1, db 0 ; filling zeros
%endmacro
@@ -379,7 +379,7 @@ const_base:
%ifdef WIN64
-%imacro collect_args 1
+%imacro COLLECT_ARGS 1
sub rsp, SIZEOF_XMMWORD
movaps XMMWORD [rsp], xmm6
sub rsp, SIZEOF_XMMWORD
@@ -408,7 +408,7 @@ const_base:
push rdi
%endmacro
-%imacro uncollect_args 1
+%imacro UNCOLLECT_ARGS 1
pop rdi
pop rsi
%if %1 > 5
@@ -429,7 +429,7 @@ const_base:
add rsp, SIZEOF_XMMWORD
%endmacro
-%imacro push_xmm 1
+%imacro PUSH_XMM 1
sub rsp, %1 * SIZEOF_XMMWORD
movaps XMMWORD [rsp+0*SIZEOF_XMMWORD], xmm8
%if %1 > 1
@@ -443,7 +443,7 @@ const_base:
%endif
%endmacro
-%imacro pop_xmm 1
+%imacro POP_XMM 1
movaps xmm8, XMMWORD [rsp+0*SIZEOF_XMMWORD]
%if %1 > 1
movaps xmm9, XMMWORD [rsp+1*SIZEOF_XMMWORD]
@@ -459,7 +459,7 @@ const_base:
%else
-%imacro collect_args 1
+%imacro COLLECT_ARGS 1
push r10
mov r10, rdi
%if %1 > 1
@@ -484,7 +484,7 @@ const_base:
%endif
%endmacro
-%imacro uncollect_args 1
+%imacro UNCOLLECT_ARGS 1
%if %1 > 5
pop r15
%endif
@@ -503,10 +503,10 @@ const_base:
pop r10
%endmacro
-%imacro push_xmm 1
+%imacro PUSH_XMM 1
%endmacro
-%imacro pop_xmm 1
+%imacro POP_XMM 1
%endmacro
%endif
diff --git a/simd/x86_64/jccolext-avx2.asm b/simd/x86_64/jccolext-avx2.asm
index dd7ea398..2b29add4 100644
--- a/simd/x86_64/jccolext-avx2.asm
+++ b/simd/x86_64/jccolext-avx2.asm
@@ -1,7 +1,7 @@
;
; jccolext.asm - colorspace conversion (64-bit AVX2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
@@ -48,7 +48,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, (SIZEOF_YMMWORD * WK_NUM)
- collect_args 5
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -549,7 +549,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 5
+ UNCOLLECT_ARGS 5
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jccolext-sse2.asm b/simd/x86_64/jccolext-sse2.asm
index bc1e8175..18b367eb 100644
--- a/simd/x86_64/jccolext-sse2.asm
+++ b/simd/x86_64/jccolext-sse2.asm
@@ -1,7 +1,7 @@
;
; jccolext.asm - colorspace conversion (64-bit SSE2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -47,7 +47,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, (SIZEOF_XMMWORD * WK_NUM)
- collect_args 5
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -474,7 +474,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
.return:
pop rbx
- uncollect_args 5
+ UNCOLLECT_ARGS 5
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jccolor-avx2.asm b/simd/x86_64/jccolor-avx2.asm
index 16b78298..1f069caa 100644
--- a/simd/x86_64/jccolor-avx2.asm
+++ b/simd/x86_64/jccolor-avx2.asm
@@ -1,7 +1,7 @@
;
; jccolor.asm - colorspace conversion (64-bit AVX2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -33,7 +33,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_avx2)
EXTN(jconst_rgb_ycc_convert_avx2):
@@ -46,7 +46,7 @@ PD_ONEHALFM1_CJ times 8 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jccolor-sse2.asm b/simd/x86_64/jccolor-sse2.asm
index e2955c21..c0c1526d 100644
--- a/simd/x86_64/jccolor-sse2.asm
+++ b/simd/x86_64/jccolor-sse2.asm
@@ -1,7 +1,7 @@
;
; jccolor.asm - colorspace conversion (64-bit SSE2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -32,7 +32,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_sse2)
EXTN(jconst_rgb_ycc_convert_sse2):
@@ -45,7 +45,7 @@ PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jcgray-avx2.asm b/simd/x86_64/jcgray-avx2.asm
index 591255bb..354683ca 100644
--- a/simd/x86_64/jcgray-avx2.asm
+++ b/simd/x86_64/jcgray-avx2.asm
@@ -1,7 +1,7 @@
;
; jcgray.asm - grayscale colorspace conversion (64-bit AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -29,7 +29,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_gray_convert_avx2)
EXTN(jconst_rgb_gray_convert_avx2):
@@ -38,7 +38,7 @@ PW_F0299_F0337 times 8 dw F_0_299, F_0_337
PW_F0114_F0250 times 8 dw F_0_114, F_0_250
PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jcgray-sse2.asm b/simd/x86_64/jcgray-sse2.asm
index e389904f..d27c4b9a 100644
--- a/simd/x86_64/jcgray-sse2.asm
+++ b/simd/x86_64/jcgray-sse2.asm
@@ -1,7 +1,7 @@
;
; jcgray.asm - grayscale colorspace conversion (64-bit SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -28,7 +28,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_rgb_gray_convert_sse2)
EXTN(jconst_rgb_gray_convert_sse2):
@@ -37,7 +37,7 @@ PW_F0299_F0337 times 4 dw F_0_299, F_0_337
PW_F0114_F0250 times 4 dw F_0_114, F_0_250
PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jcgryext-avx2.asm b/simd/x86_64/jcgryext-avx2.asm
index c8c8d12a..d780336d 100644
--- a/simd/x86_64/jcgryext-avx2.asm
+++ b/simd/x86_64/jcgryext-avx2.asm
@@ -1,7 +1,7 @@
;
; jcgryext.asm - grayscale colorspace conversion (64-bit AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
@@ -48,7 +48,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_YMMWORD * WK_NUM)
- collect_args 5
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -428,7 +428,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 5
+ UNCOLLECT_ARGS 5
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jcgryext-sse2.asm b/simd/x86_64/jcgryext-sse2.asm
index 7e5a0f2c..4789fccf 100644
--- a/simd/x86_64/jcgryext-sse2.asm
+++ b/simd/x86_64/jcgryext-sse2.asm
@@ -1,7 +1,7 @@
;
; jcgryext.asm - grayscale colorspace conversion (64-bit SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -47,7 +47,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 5
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -353,7 +353,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
.return:
pop rbx
- uncollect_args 5
+ UNCOLLECT_ARGS 5
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jchuff-sse2.asm b/simd/x86_64/jchuff-sse2.asm
index 0c2cdd64..fca3e94d 100644
--- a/simd/x86_64/jchuff-sse2.asm
+++ b/simd/x86_64/jchuff-sse2.asm
@@ -39,7 +39,7 @@ endstruc
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_huff_encode_one_block)
EXTN(jconst_huff_encode_one_block):
@@ -49,7 +49,7 @@ jpeg_mask_bits dd 0x0000, 0x0001, 0x0003, 0x0007
dd 0x00ff, 0x01ff, 0x03ff, 0x07ff
dd 0x0fff, 0x1fff, 0x3fff, 0x7fff
- alignz 32
+ ALIGNZ 32
times 1 << 14 db 15
times 1 << 13 db 14
@@ -87,7 +87,7 @@ times 1 << 13 db 14
times 1 << 14 db 15
times 1 << 15 db 16
- alignz 32
+ ALIGNZ 32
%define NBITS(x) nbits_base + x
%define MASK_BITS(x) NBITS((x) * 4) + (jpeg_mask_bits - EXTN(jpeg_nbits_table))
diff --git a/simd/x86_64/jcphuff-sse2.asm b/simd/x86_64/jcphuff-sse2.asm
index 11db4b2d..1d47b9a1 100644
--- a/simd/x86_64/jcphuff-sse2.asm
+++ b/simd/x86_64/jcphuff-sse2.asm
@@ -4,6 +4,7 @@
;
; Copyright (C) 2016, 2018, Matthieu Darbois
; Copyright (C) 2023, Aliaksiej Kandracienka.
+; Copyright (C) 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -287,7 +288,7 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
sub rsp, SIZEOF_XMMWORD
movdqa XMMWORD [rsp], ZERO
- collect_args 6
+ COLLECT_ARGS 6
movd AL, r13d
pxor ZERO, ZERO
@@ -381,7 +382,7 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
REDUCE0
- uncollect_args 6
+ UNCOLLECT_ARGS 6
movdqa ZERO, XMMWORD [rsp]
mov rsp, rbp
pop rbp
@@ -450,7 +451,7 @@ EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
sub rsp, SIZEOF_XMMWORD
movdqa XMMWORD [rsp], ZERO
- collect_args 6
+ COLLECT_ARGS 6
xor SIGN, SIGN
xor EOB, EOB
@@ -598,7 +599,7 @@ EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
REDUCE0
mov eax, EOB
- uncollect_args 6
+ UNCOLLECT_ARGS 6
movdqa ZERO, XMMWORD [rsp]
mov rsp, rbp
pop rbp
diff --git a/simd/x86_64/jcsample-avx2.asm b/simd/x86_64/jcsample-avx2.asm
index 589c52bd..ff13862b 100644
--- a/simd/x86_64/jcsample-avx2.asm
+++ b/simd/x86_64/jcsample-avx2.asm
@@ -2,7 +2,7 @@
; jcsample.asm - downsampling (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
;
@@ -46,7 +46,7 @@
EXTN(jsimd_h2v1_downsample_avx2):
push rbp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -177,7 +177,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
.return:
vzeroupper
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
@@ -207,7 +207,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
EXTN(jsimd_h2v2_downsample_avx2):
push rbp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -356,7 +356,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
.return:
vzeroupper
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
diff --git a/simd/x86_64/jcsample-sse2.asm b/simd/x86_64/jcsample-sse2.asm
index 7a4f1bc3..44384466 100644
--- a/simd/x86_64/jcsample-sse2.asm
+++ b/simd/x86_64/jcsample-sse2.asm
@@ -2,7 +2,7 @@
; jcsample.asm - downsampling (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -45,7 +45,7 @@
EXTN(jsimd_h2v1_downsample_sse2):
push rbp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -159,7 +159,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
jg near .rowloop
.return:
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
@@ -189,7 +189,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
EXTN(jsimd_h2v2_downsample_sse2):
push rbp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -319,7 +319,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
jg near .rowloop
.return:
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
diff --git a/simd/x86_64/jdcolext-avx2.asm b/simd/x86_64/jdcolext-avx2.asm
index 070436c2..5b9d60ad 100644
--- a/simd/x86_64/jdcolext-avx2.asm
+++ b/simd/x86_64/jdcolext-avx2.asm
@@ -2,7 +2,7 @@
; jdcolext.asm - colorspace conversion (64-bit AVX2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
@@ -49,7 +49,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (WK_NUM * SIZEOF_YMMWORD)
- collect_args 5
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d ; num_cols
@@ -486,7 +486,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 5
+ UNCOLLECT_ARGS 5
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jdcolext-sse2.asm b/simd/x86_64/jdcolext-sse2.asm
index bba3a30c..33eb7abd 100644
--- a/simd/x86_64/jdcolext-sse2.asm
+++ b/simd/x86_64/jdcolext-sse2.asm
@@ -2,7 +2,7 @@
; jdcolext.asm - colorspace conversion (64-bit SSE2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -48,7 +48,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 5
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d ; num_cols
@@ -429,7 +429,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
.return:
pop rbx
- uncollect_args 5
+ UNCOLLECT_ARGS 5
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jdcolor-avx2.asm b/simd/x86_64/jdcolor-avx2.asm
index 43de9db0..4d52a0f1 100644
--- a/simd/x86_64/jdcolor-avx2.asm
+++ b/simd/x86_64/jdcolor-avx2.asm
@@ -2,7 +2,7 @@
; jdcolor.asm - colorspace conversion (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -32,7 +32,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_avx2)
EXTN(jconst_ycc_rgb_convert_avx2):
@@ -43,7 +43,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jdcolor-sse2.asm b/simd/x86_64/jdcolor-sse2.asm
index b3f1fec0..93d3c8dd 100644
--- a/simd/x86_64/jdcolor-sse2.asm
+++ b/simd/x86_64/jdcolor-sse2.asm
@@ -2,7 +2,7 @@
; jdcolor.asm - colorspace conversion (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -31,7 +31,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_sse2)
EXTN(jconst_ycc_rgb_convert_sse2):
@@ -42,7 +42,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jdmerge-avx2.asm b/simd/x86_64/jdmerge-avx2.asm
index 9515a170..4be43562 100644
--- a/simd/x86_64/jdmerge-avx2.asm
+++ b/simd/x86_64/jdmerge-avx2.asm
@@ -2,7 +2,7 @@
; jdmerge.asm - merged upsampling/color conversion (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -32,7 +32,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_avx2)
EXTN(jconst_merged_upsample_avx2):
@@ -43,7 +43,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jdmerge-sse2.asm b/simd/x86_64/jdmerge-sse2.asm
index aedccc20..a22f6ac7 100644
--- a/simd/x86_64/jdmerge-sse2.asm
+++ b/simd/x86_64/jdmerge-sse2.asm
@@ -2,7 +2,7 @@
; jdmerge.asm - merged upsampling/color conversion (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -31,7 +31,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_sse2)
EXTN(jconst_merged_upsample_sse2):
@@ -42,7 +42,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/simd/x86_64/jdmrgext-avx2.asm b/simd/x86_64/jdmrgext-avx2.asm
index 11916455..d19c5f4b 100644
--- a/simd/x86_64/jdmrgext-avx2.asm
+++ b/simd/x86_64/jdmrgext-avx2.asm
@@ -2,7 +2,7 @@
; jdmrgext.asm - merged upsampling/color conversion (64-bit AVX2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
@@ -49,7 +49,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, SIZEOF_YMMWORD * WK_NUM
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov ecx, r10d ; col
@@ -480,7 +480,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 4
+ UNCOLLECT_ARGS 4
lea rsp, [rbp-8]
pop r15
pop rbp
@@ -508,7 +508,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
EXTN(jsimd_h2v2_merged_upsample_avx2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov eax, r10d
@@ -587,7 +587,7 @@ EXTN(jsimd_h2v2_merged_upsample_avx2):
add rsp, SIZEOF_JSAMPARRAY*4
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/simd/x86_64/jdmrgext-sse2.asm b/simd/x86_64/jdmrgext-sse2.asm
index 8988dd0b..db934201 100644
--- a/simd/x86_64/jdmrgext-sse2.asm
+++ b/simd/x86_64/jdmrgext-sse2.asm
@@ -2,7 +2,7 @@
; jdmrgext.asm - merged upsampling/color conversion (64-bit SSE2)
;
; Copyright 2009, 2012 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -48,7 +48,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov ecx, r10d ; col
@@ -422,7 +422,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
.return:
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
lea rsp, [rbp-8]
pop r15
pop rbp
@@ -450,7 +450,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
EXTN(jsimd_h2v2_merged_upsample_sse2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov eax, r10d
@@ -529,7 +529,7 @@ EXTN(jsimd_h2v2_merged_upsample_sse2):
add rsp, SIZEOF_JSAMPARRAY*4
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/simd/x86_64/jdsample-avx2.asm b/simd/x86_64/jdsample-avx2.asm
index c6ddbb5e..e88778e2 100644
--- a/simd/x86_64/jdsample-avx2.asm
+++ b/simd/x86_64/jdsample-avx2.asm
@@ -2,7 +2,7 @@
; jdsample.asm - upsampling (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
@@ -22,7 +22,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_avx2)
EXTN(jconst_fancy_upsample_avx2):
@@ -33,7 +33,7 @@ PW_THREE times 16 dw 3
PW_SEVEN times 16 dw 7
PW_EIGHT times 16 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -64,8 +64,8 @@ PW_EIGHT times 16 dw 8
EXTN(jsimd_h2v1_fancy_upsample_avx2):
push rbp
mov rbp, rsp
- push_xmm 3
- collect_args 4
+ PUSH_XMM 3
+ COLLECT_ARGS 4
mov eax, r11d ; colctr
test rax, rax
@@ -186,8 +186,8 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
.return:
vzeroupper
- uncollect_args 4
- pop_xmm 3
+ UNCOLLECT_ARGS 4
+ POP_XMM 3
pop rbp
ret
@@ -222,8 +222,8 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, (SIZEOF_YMMWORD * WK_NUM)
- push_xmm 3
- collect_args 4
+ PUSH_XMM 3
+ COLLECT_ARGS 4
push rbx
mov eax, r11d ; colctr
@@ -498,8 +498,8 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 4
- pop_xmm 3
+ UNCOLLECT_ARGS 4
+ POP_XMM 3
lea rsp, [rbp-8]
pop r15
pop rbp
@@ -526,7 +526,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
EXTN(jsimd_h2v1_upsample_avx2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
mov edx, r11d
add rdx, byte (SIZEOF_YMMWORD-1)
@@ -589,7 +589,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
.return:
vzeroupper
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
@@ -614,7 +614,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
EXTN(jsimd_h2v2_upsample_avx2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov edx, r11d
@@ -685,7 +685,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/simd/x86_64/jdsample-sse2.asm b/simd/x86_64/jdsample-sse2.asm
index 24cd3896..d590b0cd 100644
--- a/simd/x86_64/jdsample-sse2.asm
+++ b/simd/x86_64/jdsample-sse2.asm
@@ -2,7 +2,7 @@
; jdsample.asm - upsampling (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -21,7 +21,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_sse2)
EXTN(jconst_fancy_upsample_sse2):
@@ -32,7 +32,7 @@ PW_THREE times 8 dw 3
PW_SEVEN times 8 dw 7
PW_EIGHT times 8 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -63,7 +63,7 @@ PW_EIGHT times 8 dw 8
EXTN(jsimd_h2v1_fancy_upsample_sse2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
mov eax, r11d ; colctr
test rax, rax
@@ -174,7 +174,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
jg near .rowloop
.return:
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
@@ -209,7 +209,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov eax, r11d ; colctr
@@ -472,7 +472,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
.return:
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
lea rsp, [rbp-8]
pop r15
pop rbp
@@ -499,7 +499,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
EXTN(jsimd_h2v1_upsample_sse2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
mov edx, r11d
add rdx, byte (2*SIZEOF_XMMWORD)-1
@@ -560,7 +560,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
jg short .rowloop
.return:
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
@@ -585,7 +585,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
EXTN(jsimd_h2v2_upsample_sse2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov edx, r11d
@@ -654,7 +654,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
.return:
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/simd/x86_64/jfdctflt-sse.asm b/simd/x86_64/jfdctflt-sse.asm
index 35954964..d80610c0 100644
--- a/simd/x86_64/jfdctflt-sse.asm
+++ b/simd/x86_64/jfdctflt-sse.asm
@@ -2,7 +2,7 @@
; jfdctflt.asm - floating-point FDCT (64-bit SSE)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -35,7 +35,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_float_sse)
EXTN(jconst_fdct_float_sse):
@@ -45,7 +45,7 @@ PD_0_707 times 4 dd 0.707106781186547524400844
PD_0_541 times 4 dd 0.541196100146196984399723
PD_1_306 times 4 dd 1.306562964876376527856643
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -73,7 +73,7 @@ EXTN(jsimd_fdct_float_sse):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 1
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -345,7 +345,7 @@ EXTN(jsimd_fdct_float_sse):
dec rcx
jnz near .columnloop
- uncollect_args 1
+ UNCOLLECT_ARGS 1
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jfdctfst-sse2.asm b/simd/x86_64/jfdctfst-sse2.asm
index d33c58a4..fa6e4e5e 100644
--- a/simd/x86_64/jfdctfst-sse2.asm
+++ b/simd/x86_64/jfdctfst-sse2.asm
@@ -2,7 +2,7 @@
; jfdctfst.asm - fast integer FDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -50,7 +50,7 @@ F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_ifast_sse2)
EXTN(jconst_fdct_ifast_sse2):
@@ -60,7 +60,7 @@ PW_F0382 times 8 dw F_0_382 << CONST_SHIFT
PW_F0541 times 8 dw F_0_541 << CONST_SHIFT
PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -88,7 +88,7 @@ EXTN(jsimd_fdct_ifast_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 1
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -379,7 +379,7 @@ EXTN(jsimd_fdct_ifast_sse2):
movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm6
movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm2
- uncollect_args 1
+ UNCOLLECT_ARGS 1
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jfdctint-avx2.asm b/simd/x86_64/jfdctint-avx2.asm
index d0afe5e8..22c5fa9b 100644
--- a/simd/x86_64/jfdctint-avx2.asm
+++ b/simd/x86_64/jfdctint-avx2.asm
@@ -2,7 +2,7 @@
; jfdctint.asm - accurate integer FDCT (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -65,7 +65,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
@@ -108,7 +108,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%8: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 9
+%macro DODCT 9
vpsubw %5, %1, %4 ; %5=data1_0-data6_7=tmp6_7
vpaddw %6, %1, %4 ; %6=data1_0+data6_7=tmp1_0
vpaddw %7, %2, %3 ; %7=data3_2+data4_5=tmp3_2
@@ -223,7 +223,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_avx2)
EXTN(jconst_fdct_islow_avx2):
@@ -242,7 +242,7 @@ PW_DESCALE_P2X times 16 dw 1 << (PASS1_BITS - 1)
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -262,7 +262,7 @@ PW_1_NEG1 times 8 dw 1
EXTN(jsimd_fdct_islow_avx2):
push rbp
mov rbp, rsp
- collect_args 1
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -284,9 +284,9 @@ EXTN(jsimd_fdct_islow_avx2):
; ymm2=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
; ymm3=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm3=data7_5
; ---- Pass 2: process columns.
@@ -294,9 +294,9 @@ EXTN(jsimd_fdct_islow_avx2):
vperm2i128 ymm4, ymm1, ymm3, 0x20 ; ymm4=data3_7
vperm2i128 ymm1, ymm1, ymm3, 0x31 ; ymm1=data1_5
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm4=data7_5
vperm2i128 ymm3, ymm0, ymm1, 0x30 ; ymm3=data0_1
@@ -310,7 +310,7 @@ EXTN(jsimd_fdct_islow_avx2):
vmovdqu YMMWORD [YMMBLOCK(6,0,r10,SIZEOF_DCTELEM)], ymm7
vzeroupper
- uncollect_args 1
+ UNCOLLECT_ARGS 1
pop rbp
ret
diff --git a/simd/x86_64/jfdctint-sse2.asm b/simd/x86_64/jfdctint-sse2.asm
index 024ce900..4b2e0f2f 100644
--- a/simd/x86_64/jfdctint-sse2.asm
+++ b/simd/x86_64/jfdctint-sse2.asm
@@ -2,7 +2,7 @@
; jfdctint.asm - accurate integer FDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2020, 2024, D. R. Commander.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -64,7 +64,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_sse2)
EXTN(jconst_fdct_islow_sse2):
@@ -81,7 +81,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -109,7 +109,7 @@ EXTN(jsimd_fdct_islow_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 1
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -609,7 +609,7 @@ EXTN(jsimd_fdct_islow_sse2):
movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm1
movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm3
- uncollect_args 1
+ UNCOLLECT_ARGS 1
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jidctflt-sse2.asm b/simd/x86_64/jidctflt-sse2.asm
index 952fbe30..fd448ceb 100644
--- a/simd/x86_64/jidctflt-sse2.asm
+++ b/simd/x86_64/jidctflt-sse2.asm
@@ -2,7 +2,7 @@
; jidctflt.asm - floating-point IDCT (64-bit SSE & SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -25,18 +25,18 @@
; --------------------------------------------------------------------------
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
+%macro UNPCKLPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1, %2, 0x44
%endmacro
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
+%macro UNPCKHPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1, %2, 0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_sse2)
EXTN(jconst_idct_float_sse2):
@@ -48,7 +48,7 @@ PD_M2_613 times 4 dd -2.613125929752753055713286
PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -83,7 +83,7 @@ EXTN(jsimd_idct_float_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
lea rsp, [workspace]
- collect_args 4
+ COLLECT_ARGS 4
push rbx
; ---- Pass 1: process columns from input, store into work array.
@@ -280,11 +280,11 @@ EXTN(jsimd_idct_float_sse2):
unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
+ UNPCKLPS2 xmm6, xmm7 ; xmm6=(00 10 20 30)
+ UNPCKHPS2 xmm3, xmm7 ; xmm3=(01 11 21 31)
movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
+ UNPCKLPS2 xmm1, xmm2 ; xmm1=(02 12 22 32)
+ UNPCKHPS2 xmm0, xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
@@ -295,11 +295,11 @@ EXTN(jsimd_idct_float_sse2):
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
+ UNPCKLPS2 xmm5, xmm7 ; xmm5=(40 50 60 70)
+ UNPCKHPS2 xmm6, xmm7 ; xmm6=(41 51 61 71)
movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
+ UNPCKLPS2 xmm4, xmm2 ; xmm4=(42 52 62 72)
+ UNPCKHPS2 xmm3, xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm6
@@ -470,7 +470,7 @@ EXTN(jsimd_idct_float_sse2):
jnz near .rowloop
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jidctfst-sse2.asm b/simd/x86_64/jidctfst-sse2.asm
index a3da8d87..55554c59 100644
--- a/simd/x86_64/jidctfst-sse2.asm
+++ b/simd/x86_64/jidctfst-sse2.asm
@@ -2,7 +2,7 @@
; jidctfst.asm - fast integer IDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -58,7 +58,7 @@ F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_ifast_sse2)
EXTN(jconst_idct_ifast_sse2):
@@ -69,7 +69,7 @@ PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -102,7 +102,7 @@ EXTN(jsimd_idct_ifast_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 4
+ COLLECT_ARGS 4
; ---- Pass 1: process columns from input.
@@ -478,7 +478,7 @@ EXTN(jsimd_idct_ifast_sse2):
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2
- uncollect_args 4
+ UNCOLLECT_ARGS 4
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jidctint-avx2.asm b/simd/x86_64/jidctint-avx2.asm
index 528da012..487c5fbc 100644
--- a/simd/x86_64/jidctint-avx2.asm
+++ b/simd/x86_64/jidctint-avx2.asm
@@ -2,7 +2,7 @@
; jidctint.asm - accurate integer IDCT (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -66,7 +66,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %5=(00 10 20 30 40 50 60 70 01 11 21 31 41 51 61 71)
; %6=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
; %7=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
@@ -119,7 +119,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%12: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 13
+%macro DODCT 13
; -- Even part
; (Original)
@@ -241,7 +241,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_avx2)
EXTN(jconst_idct_islow_avx2):
@@ -260,7 +260,7 @@ PB_CENTERJSAMP times 32 db CENTERJSAMPLE
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -284,8 +284,8 @@ PW_1_NEG1 times 8 dw 1
EXTN(jsimd_idct_islow_avx2):
push rbp
mov rbp, rsp ; rbp = aligned rbp
- push_xmm 4
- collect_args 4
+ PUSH_XMM 4
+ COLLECT_ARGS 4
; ---- Pass 1: process columns.
@@ -342,10 +342,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm2, ymm5, ymm7, 0x20 ; ymm2=in2_6
vperm2i128 ymm3, ymm7, ymm6, 0x31 ; ymm3=in7_5
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 1
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm3=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm3=data3_7
.column_end:
@@ -362,10 +362,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm4, ymm3, ymm1, 0x31 ; ymm3=in7_5
vperm2i128 ymm1, ymm3, ymm1, 0x20 ; ymm1=in3_1
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 2
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm4=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm4=data3_7
vpacksswb ymm0, ymm0, ymm1 ; ymm0=data01_45
@@ -407,8 +407,8 @@ EXTN(jsimd_idct_islow_avx2):
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm7
- uncollect_args 4
- pop_xmm 4
+ UNCOLLECT_ARGS 4
+ POP_XMM 4
pop rbp
ret
diff --git a/simd/x86_64/jidctint-sse2.asm b/simd/x86_64/jidctint-sse2.asm
index 92f633e9..87a0067f 100644
--- a/simd/x86_64/jidctint-sse2.asm
+++ b/simd/x86_64/jidctint-sse2.asm
@@ -2,7 +2,7 @@
; jidctint.asm - accurate integer IDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2020, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -65,7 +65,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_sse2)
EXTN(jconst_idct_islow_sse2):
@@ -82,7 +82,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -115,7 +115,7 @@ EXTN(jsimd_idct_islow_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, (SIZEOF_XMMWORD * WK_NUM)
- collect_args 4
+ COLLECT_ARGS 4
; ---- Pass 1: process columns from input.
@@ -835,7 +835,7 @@ EXTN(jsimd_idct_islow_sse2):
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm2
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm5
- uncollect_args 4
+ UNCOLLECT_ARGS 4
lea rsp, [rbp-8]
pop r15
pop rbp
diff --git a/simd/x86_64/jidctred-sse2.asm b/simd/x86_64/jidctred-sse2.asm
index 1ec500c9..cf92accb 100644
--- a/simd/x86_64/jidctred-sse2.asm
+++ b/simd/x86_64/jidctred-sse2.asm
@@ -2,7 +2,7 @@
; jidctred.asm - reduced-size IDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
; Copyright (C) 2023, Aliaksiej Kandracienka.
;
@@ -71,7 +71,7 @@ F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_red_sse2)
EXTN(jconst_idct_red_sse2):
@@ -89,7 +89,7 @@ PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2 - 1)
PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -123,7 +123,7 @@ EXTN(jsimd_idct_4x4_sse2):
; Allocate stack space for wk array. r15 is used to access it.
mov r15, rsp
sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
- collect_args 4
+ COLLECT_ARGS 4
; ---- Pass 1: process columns from input.
@@ -388,7 +388,7 @@ EXTN(jsimd_idct_4x4_sse2):
movd XMM_DWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1
movd XMM_DWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
- uncollect_args 4
+ UNCOLLECT_ARGS 4
lea rsp, [rbp-8]
pop r15
pop rbp
@@ -415,7 +415,7 @@ EXTN(jsimd_idct_4x4_sse2):
EXTN(jsimd_idct_2x2_sse2):
push rbp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
; ---- Pass 1: process columns from input.
@@ -563,7 +563,7 @@ EXTN(jsimd_idct_2x2_sse2):
mov word [rsi+rax*SIZEOF_JSAMPLE], cx
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/simd/x86_64/jquantf-sse2.asm b/simd/x86_64/jquantf-sse2.asm
index 232bbb2d..0d13a68c 100644
--- a/simd/x86_64/jquantf-sse2.asm
+++ b/simd/x86_64/jquantf-sse2.asm
@@ -2,7 +2,7 @@
; jquantf.asm - sample data conversion and quantization (64-bit SSE & SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -39,7 +39,7 @@
EXTN(jsimd_convsamp_float_sse2):
push rbp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
push rbx
pcmpeqw xmm7, xmm7
@@ -88,7 +88,7 @@ EXTN(jsimd_convsamp_float_sse2):
jnz short .convloop
pop rbx
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
@@ -111,7 +111,7 @@ EXTN(jsimd_convsamp_float_sse2):
EXTN(jsimd_quantize_float_sse2):
push rbp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
mov rsi, r12
mov rdx, r11
@@ -144,7 +144,7 @@ EXTN(jsimd_quantize_float_sse2):
dec rax
jnz short .quantloop
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
diff --git a/simd/x86_64/jquanti-avx2.asm b/simd/x86_64/jquanti-avx2.asm
index 66104d7d..d4c06c1b 100644
--- a/simd/x86_64/jquanti-avx2.asm
+++ b/simd/x86_64/jquanti-avx2.asm
@@ -2,7 +2,7 @@
; jquanti.asm - sample data conversion and quantization (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, 2018, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2024, D. R. Commander.
; Copyright (C) 2016, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
;
@@ -40,7 +40,7 @@
EXTN(jsimd_convsamp_avx2):
push rbp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
mov eax, r11d
@@ -83,7 +83,7 @@ EXTN(jsimd_convsamp_avx2):
vmovdqu YMMWORD [YMMBLOCK(6,0,r12,SIZEOF_DCTELEM)], ymm3
vzeroupper
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
@@ -117,7 +117,7 @@ EXTN(jsimd_convsamp_avx2):
EXTN(jsimd_quantize_avx2):
push rbp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
vmovdqu ymm4, [YMMBLOCK(0,0,r12,SIZEOF_DCTELEM)]
vmovdqu ymm5, [YMMBLOCK(2,0,r12,SIZEOF_DCTELEM)]
@@ -152,7 +152,7 @@ EXTN(jsimd_quantize_avx2):
vmovdqu [YMMBLOCK(6,0,r10,SIZEOF_DCTELEM)], ymm3
vzeroupper
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
diff --git a/simd/x86_64/jquanti-sse2.asm b/simd/x86_64/jquanti-sse2.asm
index 11e9f4c4..5898c4c4 100644
--- a/simd/x86_64/jquanti-sse2.asm
+++ b/simd/x86_64/jquanti-sse2.asm
@@ -2,7 +2,7 @@
; jquanti.asm - sample data conversion and quantization (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
@@ -39,7 +39,7 @@
EXTN(jsimd_convsamp_sse2):
push rbp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
push rbx
pxor xmm6, xmm6 ; xmm6=(all 0's)
@@ -83,7 +83,7 @@ EXTN(jsimd_convsamp_sse2):
jnz short .convloop
pop rbx
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
@@ -117,7 +117,7 @@ EXTN(jsimd_convsamp_sse2):
EXTN(jsimd_quantize_sse2):
push rbp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
mov rsi, r12
mov rdx, r11
@@ -177,7 +177,7 @@ EXTN(jsimd_quantize_sse2):
dec rax
jnz near .quantloop
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
From 3202feb08aef2d4d1fb35b5af94f1ac92fb993d0 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 29 Feb 2024 16:10:20 -0500
Subject: [PATCH 056/135] x86-64 SIMD: Support CET if C compiler enables it
- Detect at configure time, via the __CET__ C preprocessor macro,
whether the C compiler will include either indirect branch tracking
(IBT) or shadow stack support, and define a NASM macro (__CET__) if
so.
- Modify the x86-64 SIMD code so that it includes appropriate endbr64
instructions (to support IBT) and an appropriate .note.gnu.property
section (to support both IBT and shadow stack) when __CET__ is
defined.
Closes #350
---
.github/workflows/build.yml | 2 +-
BUILDING.md | 2 ++
ChangeLog.md | 4 ++++
simd/CMakeLists.txt | 12 ++++++++++++
simd/nasm/jsimdext.inc | 21 +++++++++++++++++++++
simd/x86_64/jccolext-avx2.asm | 1 +
simd/x86_64/jccolext-sse2.asm | 1 +
simd/x86_64/jcgryext-avx2.asm | 1 +
simd/x86_64/jcgryext-sse2.asm | 1 +
simd/x86_64/jchuff-sse2.asm | 1 +
simd/x86_64/jcphuff-sse2.asm | 2 ++
simd/x86_64/jcsample-avx2.asm | 2 ++
simd/x86_64/jcsample-sse2.asm | 2 ++
simd/x86_64/jdcolext-avx2.asm | 1 +
simd/x86_64/jdcolext-sse2.asm | 1 +
simd/x86_64/jdmrgext-avx2.asm | 2 ++
simd/x86_64/jdmrgext-sse2.asm | 2 ++
simd/x86_64/jdsample-avx2.asm | 4 ++++
simd/x86_64/jdsample-sse2.asm | 4 ++++
simd/x86_64/jfdctflt-sse.asm | 1 +
simd/x86_64/jfdctfst-sse2.asm | 1 +
simd/x86_64/jfdctint-avx2.asm | 1 +
simd/x86_64/jfdctint-sse2.asm | 1 +
simd/x86_64/jidctflt-sse2.asm | 1 +
simd/x86_64/jidctfst-sse2.asm | 1 +
simd/x86_64/jidctint-avx2.asm | 1 +
simd/x86_64/jidctint-sse2.asm | 1 +
simd/x86_64/jidctred-sse2.asm | 2 ++
simd/x86_64/jquantf-sse2.asm | 2 ++
simd/x86_64/jquanti-avx2.asm | 2 ++
simd/x86_64/jquanti-sse2.asm | 2 ++
31 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 542635a4..ffae8f8e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -149,7 +149,7 @@ jobs:
mkdir build
pushd build
cmake -G"Unix Makefiles" -DWITH_JPEG8=1 \
- -DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wpedantic -pedantic-errors -Wdouble-promotion -Wformat-overflow=2 -Wformat-security -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k -Wmissing-include-dirs -Wshift-overflow=2 -Wswitch-bool -Wno-unused-parameter -Wuninitialized -Wstrict-overflow=2 -Wstringop-overflow=4 -Wstringop-truncation -Wduplicated-branches -Wduplicated-cond -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wundef -Wcast-align -Wno-clobbered -Wjump-misses-init -Wno-sign-compare -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wdisabled-optimization -Wno-overlength-strings' \
+ -DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wpedantic -pedantic-errors -Wdouble-promotion -Wformat-overflow=2 -Wformat-security -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k -Wmissing-include-dirs -Wshift-overflow=2 -Wswitch-bool -Wno-unused-parameter -Wuninitialized -Wstrict-overflow=2 -Wstringop-overflow=4 -Wstringop-truncation -Wduplicated-branches -Wduplicated-cond -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wundef -Wcast-align -Wno-clobbered -Wjump-misses-init -Wno-sign-compare -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wdisabled-optimization -Wno-overlength-strings -fcf-protection' \
..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
diff --git a/BUILDING.md b/BUILDING.md
index f6ec42e1..d06bce86 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -14,6 +14,8 @@ Build Requirements
(if building x86 or x86-64 SIMD extensions)
* If using NASM, 2.13 or later is required.
* If using Yasm, 1.2.0 or later is required.
+ * NASM 2.15 or later is required if building libjpeg-turbo with Intel
+ Control-flow Enforcement Technology (CET) support.
* If building on macOS, NASM or Yasm can be obtained from
[MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
- NOTE: Currently, if it is desirable to hide the SIMD function symbols in
diff --git a/ChangeLog.md b/ChangeLog.md
index 3982dcd8..c4872e27 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -8,6 +8,10 @@ libjpeg-turbo components to depend on the Visual C++ run-time DLL when built
with Visual C++ and CMake 3.15 or later, regardless of value of the
`WITH_CRT_DLL` CMake variable.
+2. The x86-64 SIMD extensions now include support for Intel Control-flow
+Enforcement Technology (CET), which is enabled automatically if CET is enabled
+in the C compiler.
+
3.0.2
=====
diff --git a/simd/CMakeLists.txt b/simd/CMakeLists.txt
index 60249001..02379559 100644
--- a/simd/CMakeLists.txt
+++ b/simd/CMakeLists.txt
@@ -96,6 +96,18 @@ if(NOT WIN32 AND (CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED))
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DPIC")
endif()
+if(CPU_TYPE STREQUAL "x86_64" AND CMAKE_ASM_NASM_OBJECT_FORMAT MATCHES "^elf")
+ check_c_source_compiles("
+ #if (__CET__ & 3) == 0
+ #error \"CET not enabled\"
+ #endif
+ int main(void) { return 0; }" HAVE_CET)
+
+ if(HAVE_CET)
+ set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -D__CET__")
+ endif()
+endif()
+
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
set(EFFECTIVE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} ${CMAKE_ASM_NASM_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
message(STATUS "CMAKE_ASM_NASM_FLAGS = ${EFFECTIVE_ASM_NASM_FLAGS}")
diff --git a/simd/nasm/jsimdext.inc b/simd/nasm/jsimdext.inc
index 2da5017e..b5341ed2 100644
--- a/simd/nasm/jsimdext.inc
+++ b/simd/nasm/jsimdext.inc
@@ -76,6 +76,14 @@
; mark stack as non-executable
section .note.GNU-stack noalloc noexec nowrite progbits
+%ifdef __CET__
+%ifdef __x86_64__
+section .note.gnu.property note alloc noexec align=8
+ dd 0x00000004, 0x00000010, 0x00000005, 0x00554e47
+ dd 0xc0000002, 0x00000004, 0x00000003, 0x00000000
+%endif
+%endif
+
; -- segment definition --
;
%ifdef __x86_64__
@@ -513,6 +521,19 @@ const_base:
%endif
+%ifdef __CET__
+
+%imacro ENDBR64 0
+ dd 0xfa1e0ff3
+%endmacro
+
+%else
+
+%imacro ENDBR64 0
+%endmacro
+
+%endif
+
; --------------------------------------------------------------------------
; Defines picked up from the C headers
;
diff --git a/simd/x86_64/jccolext-avx2.asm b/simd/x86_64/jccolext-avx2.asm
index 2b29add4..39e6f207 100644
--- a/simd/x86_64/jccolext-avx2.asm
+++ b/simd/x86_64/jccolext-avx2.asm
@@ -41,6 +41,7 @@
GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_avx2)
EXTN(jsimd_rgb_ycc_convert_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jccolext-sse2.asm b/simd/x86_64/jccolext-sse2.asm
index 18b367eb..2073988d 100644
--- a/simd/x86_64/jccolext-sse2.asm
+++ b/simd/x86_64/jccolext-sse2.asm
@@ -40,6 +40,7 @@
GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_sse2)
EXTN(jsimd_rgb_ycc_convert_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jcgryext-avx2.asm b/simd/x86_64/jcgryext-avx2.asm
index d780336d..d2ae6d63 100644
--- a/simd/x86_64/jcgryext-avx2.asm
+++ b/simd/x86_64/jcgryext-avx2.asm
@@ -41,6 +41,7 @@
GLOBAL_FUNCTION(jsimd_rgb_gray_convert_avx2)
EXTN(jsimd_rgb_gray_convert_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jcgryext-sse2.asm b/simd/x86_64/jcgryext-sse2.asm
index 4789fccf..3c2834e9 100644
--- a/simd/x86_64/jcgryext-sse2.asm
+++ b/simd/x86_64/jcgryext-sse2.asm
@@ -40,6 +40,7 @@
GLOBAL_FUNCTION(jsimd_rgb_gray_convert_sse2)
EXTN(jsimd_rgb_gray_convert_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jchuff-sse2.asm b/simd/x86_64/jchuff-sse2.asm
index fca3e94d..39aa2465 100644
--- a/simd/x86_64/jchuff-sse2.asm
+++ b/simd/x86_64/jchuff-sse2.asm
@@ -261,6 +261,7 @@ times 1 << 15 db 16
GLOBAL_FUNCTION(jsimd_huff_encode_one_block_sse2)
EXTN(jsimd_huff_encode_one_block_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
diff --git a/simd/x86_64/jcphuff-sse2.asm b/simd/x86_64/jcphuff-sse2.asm
index 1d47b9a1..0e274046 100644
--- a/simd/x86_64/jcphuff-sse2.asm
+++ b/simd/x86_64/jcphuff-sse2.asm
@@ -283,6 +283,7 @@
GLOBAL_FUNCTION(jsimd_encode_mcu_AC_first_prepare_sse2)
EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
@@ -446,6 +447,7 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
GLOBAL_FUNCTION(jsimd_encode_mcu_AC_refine_prepare_sse2)
EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
diff --git a/simd/x86_64/jcsample-avx2.asm b/simd/x86_64/jcsample-avx2.asm
index ff13862b..fede6b38 100644
--- a/simd/x86_64/jcsample-avx2.asm
+++ b/simd/x86_64/jcsample-avx2.asm
@@ -44,6 +44,7 @@
GLOBAL_FUNCTION(jsimd_h2v1_downsample_avx2)
EXTN(jsimd_h2v1_downsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 6
@@ -205,6 +206,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v2_downsample_avx2)
EXTN(jsimd_h2v2_downsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 6
diff --git a/simd/x86_64/jcsample-sse2.asm b/simd/x86_64/jcsample-sse2.asm
index 44384466..0a0ee65e 100644
--- a/simd/x86_64/jcsample-sse2.asm
+++ b/simd/x86_64/jcsample-sse2.asm
@@ -43,6 +43,7 @@
GLOBAL_FUNCTION(jsimd_h2v1_downsample_sse2)
EXTN(jsimd_h2v1_downsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 6
@@ -187,6 +188,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v2_downsample_sse2)
EXTN(jsimd_h2v2_downsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 6
diff --git a/simd/x86_64/jdcolext-avx2.asm b/simd/x86_64/jdcolext-avx2.asm
index 5b9d60ad..a8384cb5 100644
--- a/simd/x86_64/jdcolext-avx2.asm
+++ b/simd/x86_64/jdcolext-avx2.asm
@@ -42,6 +42,7 @@
GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_avx2)
EXTN(jsimd_ycc_rgb_convert_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jdcolext-sse2.asm b/simd/x86_64/jdcolext-sse2.asm
index 33eb7abd..bfb59abf 100644
--- a/simd/x86_64/jdcolext-sse2.asm
+++ b/simd/x86_64/jdcolext-sse2.asm
@@ -41,6 +41,7 @@
GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_sse2)
EXTN(jsimd_ycc_rgb_convert_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jdmrgext-avx2.asm b/simd/x86_64/jdmrgext-avx2.asm
index d19c5f4b..3392f3a3 100644
--- a/simd/x86_64/jdmrgext-avx2.asm
+++ b/simd/x86_64/jdmrgext-avx2.asm
@@ -42,6 +42,7 @@
GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_avx2)
EXTN(jsimd_h2v1_merged_upsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
@@ -506,6 +507,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_avx2)
EXTN(jsimd_h2v2_merged_upsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
diff --git a/simd/x86_64/jdmrgext-sse2.asm b/simd/x86_64/jdmrgext-sse2.asm
index db934201..901db984 100644
--- a/simd/x86_64/jdmrgext-sse2.asm
+++ b/simd/x86_64/jdmrgext-sse2.asm
@@ -41,6 +41,7 @@
GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_sse2)
EXTN(jsimd_h2v1_merged_upsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
@@ -448,6 +449,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_sse2)
EXTN(jsimd_h2v2_merged_upsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
diff --git a/simd/x86_64/jdsample-avx2.asm b/simd/x86_64/jdsample-avx2.asm
index e88778e2..017427a1 100644
--- a/simd/x86_64/jdsample-avx2.asm
+++ b/simd/x86_64/jdsample-avx2.asm
@@ -62,6 +62,7 @@ PW_EIGHT times 16 dw 8
GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_avx2)
EXTN(jsimd_h2v1_fancy_upsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
PUSH_XMM 3
@@ -215,6 +216,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_avx2)
EXTN(jsimd_h2v2_fancy_upsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
@@ -524,6 +526,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v1_upsample_avx2)
EXTN(jsimd_h2v1_upsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
@@ -612,6 +615,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v2_upsample_avx2)
EXTN(jsimd_h2v2_upsample_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
diff --git a/simd/x86_64/jdsample-sse2.asm b/simd/x86_64/jdsample-sse2.asm
index d590b0cd..95c4d4c9 100644
--- a/simd/x86_64/jdsample-sse2.asm
+++ b/simd/x86_64/jdsample-sse2.asm
@@ -61,6 +61,7 @@ PW_EIGHT times 8 dw 8
GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_sse2)
EXTN(jsimd_h2v1_fancy_upsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
@@ -202,6 +203,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_sse2)
EXTN(jsimd_h2v2_fancy_upsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
@@ -497,6 +499,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v1_upsample_sse2)
EXTN(jsimd_h2v1_upsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
@@ -583,6 +586,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v2_upsample_sse2)
EXTN(jsimd_h2v2_upsample_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
diff --git a/simd/x86_64/jfdctflt-sse.asm b/simd/x86_64/jfdctflt-sse.asm
index d80610c0..cf46d93d 100644
--- a/simd/x86_64/jfdctflt-sse.asm
+++ b/simd/x86_64/jfdctflt-sse.asm
@@ -66,6 +66,7 @@ PD_1_306 times 4 dd 1.306562964876376527856643
GLOBAL_FUNCTION(jsimd_fdct_float_sse)
EXTN(jsimd_fdct_float_sse):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jfdctfst-sse2.asm b/simd/x86_64/jfdctfst-sse2.asm
index fa6e4e5e..cdc62365 100644
--- a/simd/x86_64/jfdctfst-sse2.asm
+++ b/simd/x86_64/jfdctfst-sse2.asm
@@ -81,6 +81,7 @@ PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
GLOBAL_FUNCTION(jsimd_fdct_ifast_sse2)
EXTN(jsimd_fdct_ifast_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jfdctint-avx2.asm b/simd/x86_64/jfdctint-avx2.asm
index 22c5fa9b..b6b4c73a 100644
--- a/simd/x86_64/jfdctint-avx2.asm
+++ b/simd/x86_64/jfdctint-avx2.asm
@@ -260,6 +260,7 @@ PW_1_NEG1 times 8 dw 1
GLOBAL_FUNCTION(jsimd_fdct_islow_avx2)
EXTN(jsimd_fdct_islow_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 1
diff --git a/simd/x86_64/jfdctint-sse2.asm b/simd/x86_64/jfdctint-sse2.asm
index 4b2e0f2f..44e7cd05 100644
--- a/simd/x86_64/jfdctint-sse2.asm
+++ b/simd/x86_64/jfdctint-sse2.asm
@@ -102,6 +102,7 @@ PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
GLOBAL_FUNCTION(jsimd_fdct_islow_sse2)
EXTN(jsimd_fdct_islow_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jidctflt-sse2.asm b/simd/x86_64/jidctflt-sse2.asm
index fd448ceb..c7cb39a0 100644
--- a/simd/x86_64/jidctflt-sse2.asm
+++ b/simd/x86_64/jidctflt-sse2.asm
@@ -76,6 +76,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_float_sse2)
EXTN(jsimd_idct_float_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jidctfst-sse2.asm b/simd/x86_64/jidctfst-sse2.asm
index 55554c59..fd3bc32c 100644
--- a/simd/x86_64/jidctfst-sse2.asm
+++ b/simd/x86_64/jidctfst-sse2.asm
@@ -95,6 +95,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_ifast_sse2)
EXTN(jsimd_idct_ifast_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jidctint-avx2.asm b/simd/x86_64/jidctint-avx2.asm
index 487c5fbc..84d125bd 100644
--- a/simd/x86_64/jidctint-avx2.asm
+++ b/simd/x86_64/jidctint-avx2.asm
@@ -282,6 +282,7 @@ PW_1_NEG1 times 8 dw 1
GLOBAL_FUNCTION(jsimd_idct_islow_avx2)
EXTN(jsimd_idct_islow_avx2):
+ ENDBR64
push rbp
mov rbp, rsp ; rbp = aligned rbp
PUSH_XMM 4
diff --git a/simd/x86_64/jidctint-sse2.asm b/simd/x86_64/jidctint-sse2.asm
index 87a0067f..3f098b2c 100644
--- a/simd/x86_64/jidctint-sse2.asm
+++ b/simd/x86_64/jidctint-sse2.asm
@@ -108,6 +108,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_islow_sse2)
EXTN(jsimd_idct_islow_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
diff --git a/simd/x86_64/jidctred-sse2.asm b/simd/x86_64/jidctred-sse2.asm
index cf92accb..2657cf3c 100644
--- a/simd/x86_64/jidctred-sse2.asm
+++ b/simd/x86_64/jidctred-sse2.asm
@@ -116,6 +116,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_4x4_sse2)
EXTN(jsimd_idct_4x4_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
push r15
@@ -413,6 +414,7 @@ EXTN(jsimd_idct_4x4_sse2):
GLOBAL_FUNCTION(jsimd_idct_2x2_sse2)
EXTN(jsimd_idct_2x2_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 4
diff --git a/simd/x86_64/jquantf-sse2.asm b/simd/x86_64/jquantf-sse2.asm
index 0d13a68c..8bd79662 100644
--- a/simd/x86_64/jquantf-sse2.asm
+++ b/simd/x86_64/jquantf-sse2.asm
@@ -37,6 +37,7 @@
GLOBAL_FUNCTION(jsimd_convsamp_float_sse2)
EXTN(jsimd_convsamp_float_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 3
@@ -109,6 +110,7 @@ EXTN(jsimd_convsamp_float_sse2):
GLOBAL_FUNCTION(jsimd_quantize_float_sse2)
EXTN(jsimd_quantize_float_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 3
diff --git a/simd/x86_64/jquanti-avx2.asm b/simd/x86_64/jquanti-avx2.asm
index d4c06c1b..c8ebd796 100644
--- a/simd/x86_64/jquanti-avx2.asm
+++ b/simd/x86_64/jquanti-avx2.asm
@@ -38,6 +38,7 @@
GLOBAL_FUNCTION(jsimd_convsamp_avx2)
EXTN(jsimd_convsamp_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 3
@@ -115,6 +116,7 @@ EXTN(jsimd_convsamp_avx2):
GLOBAL_FUNCTION(jsimd_quantize_avx2)
EXTN(jsimd_quantize_avx2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 3
diff --git a/simd/x86_64/jquanti-sse2.asm b/simd/x86_64/jquanti-sse2.asm
index 5898c4c4..352d7405 100644
--- a/simd/x86_64/jquanti-sse2.asm
+++ b/simd/x86_64/jquanti-sse2.asm
@@ -37,6 +37,7 @@
GLOBAL_FUNCTION(jsimd_convsamp_sse2)
EXTN(jsimd_convsamp_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 3
@@ -115,6 +116,7 @@ EXTN(jsimd_convsamp_sse2):
GLOBAL_FUNCTION(jsimd_quantize_sse2)
EXTN(jsimd_quantize_sse2):
+ ENDBR64
push rbp
mov rbp, rsp
COLLECT_ARGS 3
From 7bb958b732e6b4f261595e2d1527d46964fe3aed Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 4 Mar 2024 12:12:03 -0500
Subject: [PATCH 057/135] 12-bit: Don't gen opt Huff tbls if tbls supplied
(regression introduced by e8b40f3c2ba187ba95c13c3e8ce21c8534256df7)
The documented behavior of the libjpeg API is to compute optimal Huffman
tables when generating 12-bit lossy Huffman-coded JPEG images, unless
the calling application supplies its own Huffman tables. However,
e8b40f3c2ba187ba95c13c3e8ce21c8534256df7 and
96bc40c1b36775afdbad4ae05a6b3f48e2eebeb9 modified
jinit_c_master_control() so that it always set cinfo->optimize_coding to
TRUE when generarating 12-bit lossy Huffman-coded JPEG images, which
prevented calling applications from supplying custom Huffman tables for
such images.
This commit modifies jinit_c_master_control() so that it only overrides
cinfo->optimize_coding when generating 12-bit lossy Huffman-coded JPEG
images if all Huffman table slots are empty or all slots contain default
Huffman tables. Determining whether the latter is true requires using
memcmp() to compare the allocated Huffman tables with the default
Huffman tables, because:
- The documented behavior of jpeg_set_defaults() is to initialize any
empty Huffman table slot with the default Huffman table corresponding
to that slot, regardless of the data precision. There is also no
requirement that the data precision be specified prior to calling
jpeg_set_defaults(). Thus, there is no reliable way to prevent
jpeg_set_defaults() from initializing empty Huffman table slots with
default Huffman tables, which are useless for 12-bit data precision.
- There is no requirement that custom Huffman tables be defined prior to
calling jpeg_set_defaults(). A calling application could call
jpeg_set_defaults() and modify the values in the default Huffman
tables rather than allocating new tables. Thus, there is no reliable
way to detect whether the allocated Huffman tables contain default
values without comparing the tables with the default Huffman tables.
Fortunately, comparing the allocated Huffman tables with the default
Huffman tables is the last stop on the logic train, so it won't happen
unless cinfo->data_precision == 12, cinfo->arith_code == FALSE,
cinfo->optimize_coding == FALSE, and one or more Huffman tables are
allocated. (If the compressor object is reused, this ensures that the
full comparison will be performed at most once.) Custom Huffman tables
will be flagged as non-default when the first non-default value is
encountered, and the worst case (comparing 400 bytes) is very fast on
modern CPUs anyhow.
Fixes #751
---
ChangeLog.md | 4 ++
jcmaster.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++-
turbojpeg.c | 5 ++-
3 files changed, 127 insertions(+), 4 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index c4872e27..f15f87ad 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -12,6 +12,10 @@ with Visual C++ and CMake 3.15 or later, regardless of value of the
Enforcement Technology (CET), which is enabled automatically if CET is enabled
in the C compiler.
+3. Fixed a regression introduced by 3.0 beta2[6] that made it impossible for
+calling applications to supply custom Huffman tables when generating
+12-bit-per-component lossy JPEG images using the libjpeg API.
+
3.0.2
=====
diff --git a/jcmaster.c b/jcmaster.c
index 7e1408fc..16101976 100644
--- a/jcmaster.c
+++ b/jcmaster.c
@@ -7,7 +7,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, 2022-2023, D. R. Commander.
+ * Copyright (C) 2010, 2016, 2018, 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -50,6 +50,113 @@ jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo)
#endif
+LOCAL(boolean)
+using_std_huff_tables(j_compress_ptr cinfo)
+{
+ int i;
+
+ static const UINT8 bits_dc_luminance[17] = {
+ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
+ };
+ static const UINT8 val_dc_luminance[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+ };
+
+ static const UINT8 bits_dc_chrominance[17] = {
+ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
+ };
+ static const UINT8 val_dc_chrominance[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+ };
+
+ static const UINT8 bits_ac_luminance[17] = {
+ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
+ };
+ static const UINT8 val_ac_luminance[] = {
+ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
+ 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
+ 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
+ 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
+ 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
+ 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
+ 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+ 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
+ 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
+ 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
+ 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
+ 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
+ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+ };
+
+ static const UINT8 bits_ac_chrominance[17] = {
+ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
+ };
+ static const UINT8 val_ac_chrominance[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
+ 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
+ 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
+ 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
+ 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
+ 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
+ 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
+ 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
+ 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
+ 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
+ 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
+ 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
+ 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
+ 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+ };
+
+ if (cinfo->dc_huff_tbl_ptrs[0] == NULL ||
+ cinfo->ac_huff_tbl_ptrs[0] == NULL ||
+ cinfo->dc_huff_tbl_ptrs[1] == NULL ||
+ cinfo->ac_huff_tbl_ptrs[1] == NULL)
+ return FALSE;
+
+ for (i = 2; i < NUM_HUFF_TBLS; i++) {
+ if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
+ cinfo->ac_huff_tbl_ptrs[i] != NULL)
+ return FALSE;
+ }
+
+ if (memcmp(cinfo->dc_huff_tbl_ptrs[0]->bits, bits_dc_luminance,
+ sizeof(bits_dc_luminance)) ||
+ memcmp(cinfo->dc_huff_tbl_ptrs[0]->huffval, val_dc_luminance,
+ sizeof(val_dc_luminance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[0]->bits, bits_ac_luminance,
+ sizeof(bits_ac_luminance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[0]->huffval, val_ac_luminance,
+ sizeof(val_ac_luminance)) ||
+ memcmp(cinfo->dc_huff_tbl_ptrs[1]->bits, bits_dc_chrominance,
+ sizeof(bits_dc_chrominance)) ||
+ memcmp(cinfo->dc_huff_tbl_ptrs[1]->huffval, val_dc_chrominance,
+ sizeof(val_dc_chrominance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[1]->bits, bits_ac_chrominance,
+ sizeof(bits_ac_chrominance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[1]->huffval, val_ac_chrominance,
+ sizeof(val_ac_chrominance)))
+ return FALSE;
+
+ return TRUE;
+}
+
+
LOCAL(void)
initial_setup(j_compress_ptr cinfo, boolean transcode_only)
/* Do computations that are needed before master selection phase */
@@ -605,6 +712,8 @@ GLOBAL(void)
jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
{
my_master_ptr master = (my_master_ptr)cinfo->master;
+ boolean empty_huff_tables = TRUE;
+ int i;
master->pub.prepare_for_pass = prepare_for_pass;
master->pub.pass_startup = pass_startup;
@@ -646,7 +755,16 @@ jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
(cinfo->progressive_mode && !cinfo->arith_code))
cinfo->optimize_coding = TRUE; /* assume default tables no good for
progressive mode or lossless mode */
- if (cinfo->data_precision == 12 && !cinfo->arith_code)
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
+ if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
+ cinfo->ac_huff_tbl_ptrs[i] != NULL) {
+ empty_huff_tables = FALSE;
+ break;
+ }
+ }
+ if (cinfo->data_precision == 12 && !cinfo->arith_code &&
+ !cinfo->optimize_coding &&
+ (empty_huff_tables || using_std_huff_tables(cinfo)))
cinfo->optimize_coding = TRUE; /* assume default tables no good for 12-bit
data precision */
diff --git a/turbojpeg.c b/turbojpeg.c
index b9fe6e9f..87011efb 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.
* Copyright (C)2021 Alex Richardson. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -370,7 +370,8 @@ static void setCompDefaults(tjinstance *this, int pixelFormat)
jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);
}
- this->cinfo.optimize_coding = this->optimize;
+ if (this->cinfo.data_precision == 8)
+ this->cinfo.optimize_coding = this->optimize;
#ifdef C_PROGRESSIVE_SUPPORTED
if (this->progressive) jpeg_simple_progression(&this->cinfo);
#endif
From 34c055851ecb66a2d9bee1a3318c55cd9acd6586 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 6 Mar 2024 15:12:31 -0500
Subject: [PATCH 058/135] Fix warnings with -Wmissing-variable-declarations
---
CMakeLists.txt | 6 +++---
cjpeg.c | 8 ++++----
djpeg.c | 16 ++++++++--------
jerror.c | 4 ++--
jpegtran.c | 8 ++++----
tjbench.c | 31 ++++++++++++++++---------------
tjexample.c | 10 +++++-----
tjunittest.c | 22 +++++++++++-----------
8 files changed, 53 insertions(+), 52 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 03cb1d64..2f6bbdd0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -475,7 +475,7 @@ if(UNIX)
check_c_source_runs("
#include
#include
- int is_shifting_signed (long arg) {
+ static int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
@@ -495,7 +495,7 @@ if(UNIX)
endif()
if(NOT MSVC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
- check_c_source_compiles("const int __attribute__((visibility(\"hidden\"))) table[1] = { 0 }; int main(void) { return table[0]; }"
+ check_c_source_compiles("extern const int table[1]; const int __attribute__((visibility(\"hidden\"))) table[1] = { 0 }; int main(void) { return table[0]; }"
HIDDEN_WORKS)
if(HIDDEN_WORKS)
set(HIDDEN "__attribute__((visibility(\"hidden\")))")
@@ -536,7 +536,7 @@ if(MSVC)
else()
set(THREAD_LOCAL "__thread")
endif()
-check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }"
+check_c_source_compiles("static ${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }"
HAVE_THREAD_LOCAL)
if(HAVE_THREAD_LOCAL)
message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}")
diff --git a/cjpeg.c b/cjpeg.c
index ed649d21..b7385bff 100644
--- a/cjpeg.c
+++ b/cjpeg.c
@@ -7,7 +7,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, D. R. Commander.
+ * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -156,9 +156,9 @@ select_file_type(j_compress_ptr cinfo, FILE *infile)
static const char *progname; /* program name for error messages */
static char *icc_filename; /* for -icc switch */
static char *outfilename; /* for -outfile switch */
-boolean memdst; /* for -memdst switch */
-boolean report; /* for -report switch */
-boolean strict; /* for -strict switch */
+static boolean memdst; /* for -memdst switch */
+static boolean report; /* for -report switch */
+static boolean strict; /* for -strict switch */
#ifdef CJPEG_FUZZER
diff --git a/djpeg.c b/djpeg.c
index 4ea5c4bd..fd30a9ed 100644
--- a/djpeg.c
+++ b/djpeg.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2013-2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022-2023, D. R. Commander.
+ * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022-2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -84,14 +84,14 @@ static IMAGE_FORMATS requested_fmt;
static const char *progname; /* program name for error messages */
static char *icc_filename; /* for -icc switch */
-JDIMENSION max_scans; /* for -maxscans switch */
+static JDIMENSION max_scans; /* for -maxscans switch */
static char *outfilename; /* for -outfile switch */
-boolean memsrc; /* for -memsrc switch */
-boolean report; /* for -report switch */
-boolean skip, crop;
-JDIMENSION skip_start, skip_end;
-JDIMENSION crop_x, crop_y, crop_width, crop_height;
-boolean strict; /* for -strict switch */
+static boolean memsrc; /* for -memsrc switch */
+static boolean report; /* for -report switch */
+static boolean skip, crop;
+static JDIMENSION skip_start, skip_end;
+static JDIMENSION crop_x, crop_y, crop_width, crop_height;
+static boolean strict; /* for -strict switch */
#define INPUT_BUF_SIZE 4096
diff --git a/jerror.c b/jerror.c
index d0ab5b88..c12c34fc 100644
--- a/jerror.c
+++ b/jerror.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -46,7 +46,7 @@
#define JMESSAGE(code, string) string,
-const char * const jpeg_std_message_table[] = {
+static const char * const jpeg_std_message_table[] = {
#include "jerror.h"
NULL
};
diff --git a/jpegtran.c b/jpegtran.c
index d1552ec7..2857a564 100644
--- a/jpegtran.c
+++ b/jpegtran.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2014, 2017, 2019-2022, D. R. Commander.
+ * Copyright (C) 2010, 2014, 2017, 2019-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -35,11 +35,11 @@
static const char *progname; /* program name for error messages */
static char *icc_filename; /* for -icc switch */
-JDIMENSION max_scans; /* for -maxscans switch */
+static JDIMENSION max_scans; /* for -maxscans switch */
static char *outfilename; /* for -outfile switch */
static char *dropfilename; /* for -drop switch */
-boolean report; /* for -report switch */
-boolean strict; /* for -strict switch */
+static boolean report; /* for -report switch */
+static boolean strict; /* for -strict switch */
static JCOPY_OPTION copyoption; /* -copy switch */
static jpeg_transform_info transformoption; /* image transformation options */
diff --git a/tjbench.c b/tjbench.c
index bedc94b4..a3592e85 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2019, 2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2019, 2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -48,8 +48,8 @@
}
#define THROW_UNIX(m) THROW(m, strerror(errno))
-char tjErrorStr[JMSG_LENGTH_MAX] = "\0";
-int tjErrorLine = -1, tjErrorCode = -1;
+static char tjErrorStr[JMSG_LENGTH_MAX] = "\0";
+static int tjErrorLine = -1, tjErrorCode = -1;
#define THROW_TJG() { \
printf("ERROR in line %d\n%s\n", __LINE__, tj3GetErrorStr(NULL)); \
@@ -88,30 +88,31 @@ int tjErrorLine = -1, tjErrorCode = -1;
(IS_CROPPED(cr) ? (cr.h != 0 ? cr.h : TJSCALED(height, sf) - cr.y) : \
TJSCALED(height, sf))
-int stopOnWarning = 0, bottomUp = 0, noRealloc = 1, fastUpsample = 0,
+static int stopOnWarning = 0, bottomUp = 0, noRealloc = 1, fastUpsample = 0,
fastDCT = 0, optimize = 0, progressive = 0, limitScans = 0, maxMemory = 0,
maxPixels = 0, arithmetic = 0, lossless = 0, restartIntervalBlocks = 0,
restartIntervalRows = 0;
-int precision = 8, sampleSize, compOnly = 0, decompOnly = 0, doYUV = 0,
+static int precision = 8, sampleSize, compOnly = 0, decompOnly = 0, doYUV = 0,
quiet = 0, doTile = 0, pf = TJPF_BGR, yuvAlign = 1, doWrite = 1;
-char *ext = "ppm";
-const char *pixFormatStr[TJ_NUMPF] = {
+static char *ext = "ppm";
+static const char *pixFormatStr[TJ_NUMPF] = {
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY", "", "", "", "", "CMYK"
};
-const char *subNameLong[TJ_NUMSAMP] = {
+static const char *subNameLong[TJ_NUMSAMP] = {
"4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1", "4:4:1"
};
-const char *csName[TJ_NUMCS] = {
+static const char *csName[TJ_NUMCS] = {
"RGB", "YCbCr", "GRAY", "CMYK", "YCCK"
};
-const char *subName[TJ_NUMSAMP] = {
+static const char *subName[TJ_NUMSAMP] = {
"444", "422", "420", "GRAY", "440", "411", "441"
};
-tjscalingfactor *scalingFactors = NULL, sf = { 1, 1 };
-tjregion cr = { 0, 0, 0, 0 };
-int nsf = 0, xformOp = TJXOP_NONE, xformOpt = 0;
-int (*customFilter) (short *, tjregion, tjregion, int, int, tjtransform *);
-double benchTime = 5.0, warmup = 1.0;
+static tjscalingfactor *scalingFactors = NULL, sf = { 1, 1 };
+static tjregion cr = { 0, 0, 0, 0 };
+static int nsf = 0, xformOp = TJXOP_NONE, xformOpt = 0;
+static int (*customFilter) (short *, tjregion, tjregion, int, int,
+ tjtransform *);
+static double benchTime = 5.0, warmup = 1.0;
static char *formatName(int subsamp, int cs, char *buf)
diff --git a/tjexample.c b/tjexample.c
index 1edf30f7..59aa5959 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011-2012, 2014-2015, 2017, 2019, 2021-2023
+ * Copyright (C)2011-2012, 2014-2015, 2017, 2019, 2021-2024
* D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,16 +61,16 @@
#define DEFAULT_QUALITY 95
-const char *subsampName[TJ_NUMSAMP] = {
+static const char *subsampName[TJ_NUMSAMP] = {
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0", "4:1:1", "4:4:1"
};
-const char *colorspaceName[TJ_NUMCS] = {
+static const char *colorspaceName[TJ_NUMCS] = {
"RGB", "YCbCr", "GRAY", "CMYK", "YCCK"
};
-tjscalingfactor *scalingFactors = NULL;
-int numScalingFactors = 0;
+static tjscalingfactor *scalingFactors = NULL;
+static int numScalingFactors = 0;
/* DCT filter example. This produces a negative of the image. */
diff --git a/tjunittest.c b/tjunittest.c
index dcd5006e..3942833a 100644
--- a/tjunittest.c
+++ b/tjunittest.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2014, 2017-2019, 2022-2023 D. R. Commander.
+ * Copyright (C)2009-2014, 2017-2019, 2022-2024 D. R. Commander.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -83,29 +83,29 @@ static void usage(char *progName)
BAILOUT() \
}
-const char *subNameLong[TJ_NUMSAMP] = {
+static const char *subNameLong[TJ_NUMSAMP] = {
"4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1", "4:4:1"
};
-const char *subName[TJ_NUMSAMP] = {
+static const char *subName[TJ_NUMSAMP] = {
"444", "422", "420", "GRAY", "440", "411", "441"
};
-const char *pixFormatStr[TJ_NUMPF] = {
+static const char *pixFormatStr[TJ_NUMPF] = {
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale",
"RGBA", "BGRA", "ABGR", "ARGB", "CMYK"
};
-const int _3sampleFormats[] = { TJPF_RGB, TJPF_BGR };
-const int _4sampleFormats[] = {
+static const int _3sampleFormats[] = { TJPF_RGB, TJPF_BGR };
+static const int _4sampleFormats[] = {
TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB, TJPF_CMYK
};
-const int _onlyGray[] = { TJPF_GRAY };
-const int _onlyRGB[] = { TJPF_RGB };
+static const int _onlyGray[] = { TJPF_GRAY };
+static const int _onlyRGB[] = { TJPF_RGB };
-int doYUV = 0, lossless = 0, psv = 1, alloc = 0, yuvAlign = 4;
-int precision = 8, sampleSize, maxSample, tolerance, redToY, yellowToY;
+static int doYUV = 0, lossless = 0, psv = 1, alloc = 0, yuvAlign = 4;
+static int precision = 8, sampleSize, maxSample, tolerance, redToY, yellowToY;
-int exitStatus = 0;
+static int exitStatus = 0;
#define BAILOUT() { exitStatus = -1; goto bailout; }
From 905ec0fa017ffc450479d40f8d8a3d82c083f369 Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 8 Mar 2024 10:29:27 -0500
Subject: [PATCH 059/135] Avoid tautological comparisons
Several TurboJPEG functions store their return value in an unsigned
long long intermediate and compare it against the maximum value of
unsigned long or size_t in order to avoid integer overflow. However,
such comparisons are tautological (always true, i.e. redundant) unless
the size of unsigned long or size_t is less than the size of unsigned
long long. Explicitly guarding the comparisons with #if avoids compiler
warnings with -Wtautological-constant-in-range-compare in Clang and also
makes it clear to the reader that the comparisons are only intended for
32-bit code.
Refer to #752
---
tjbench.c | 7 +++++++
tjexample.c | 6 ++++++
turbojpeg-mp.c | 7 +++++--
turbojpeg.c | 11 +++++++++++
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/tjbench.c b/tjbench.c
index a3592e85..9dc64278 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -37,6 +37,9 @@
#include
#include
#include
+#if !defined(_MSC_VER) || _MSC_VER > 1600
+#include
+#endif
#include
#include "./tjutil.h"
#include "./turbojpeg.h"
@@ -223,9 +226,11 @@ static int decomp(unsigned char **jpegBufs, size_t *jpegSizes, void *dstBuf,
pitch = scaledw * ps;
if (dstBuf == NULL) {
+#if ULLONG_MAX > SIZE_MAX
if ((unsigned long long)pitch * (unsigned long long)scaledh *
(unsigned long long)sampleSize > (unsigned long long)((size_t)-1))
THROW("allocating destination buffer", "Image is too large");
+#endif
if ((dstBuf = malloc((size_t)pitch * scaledh * sampleSize)) == NULL)
THROW_UNIX("allocating destination buffer");
dstBufAlloc = 1;
@@ -382,9 +387,11 @@ static int fullTest(tjhandle handle, void *srcBuf, int w, int h, int subsamp,
int ntilesw = 1, ntilesh = 1, pitch = w * ps;
const char *pfStr = pixFormatStr[pf];
+#if ULLONG_MAX > SIZE_MAX
if ((unsigned long long)pitch * (unsigned long long)h *
(unsigned long long)sampleSize > (unsigned long long)((size_t)-1))
THROW("allocating temporary image buffer", "Image is too large");
+#endif
if ((tmpBuf = malloc((size_t)pitch * h * sampleSize)) == NULL)
THROW_UNIX("allocating temporary image buffer");
diff --git a/tjexample.c b/tjexample.c
index 59aa5959..aa3a4b92 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -40,6 +40,10 @@
#include
#include
#include
+#include
+#if !defined(_MSC_VER) || _MSC_VER > 1600
+#include
+#endif
#include
@@ -335,9 +339,11 @@ int main(int argc, char **argv)
outSubsamp = inSubsamp;
pixelFormat = TJPF_BGRX;
+#if ULLONG_MAX > SIZE_MAX
if ((unsigned long long)width * height * tjPixelSize[pixelFormat] >
(unsigned long long)((size_t)-1))
THROW("allocating uncompressed image buffer", "Image is too large");
+#endif
if ((imgBuf =
(unsigned char *)malloc(sizeof(unsigned char) * width * height *
tjPixelSize[pixelFormat])) == NULL)
diff --git a/turbojpeg-mp.c b/turbojpeg-mp.c
index 9bf346b4..5090bf48 100644
--- a/turbojpeg-mp.c
+++ b/turbojpeg-mp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -366,8 +366,11 @@ DLLEXPORT _JSAMPLE *GET_NAME(tj3LoadImage, BITS_IN_JSAMPLE)
*pixelFormat = cs2pf[cinfo->in_color_space];
pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
- if ((unsigned long long)pitch * (unsigned long long)(*height) >
+ if (
+#if ULLONG_MAX > SIZE_MAX
+ (unsigned long long)pitch * (unsigned long long)(*height) >
(unsigned long long)((size_t)-1) ||
+#endif
(dstBuf = (_JSAMPLE *)malloc(pitch * (*height) *
sizeof(_JSAMPLE))) == NULL)
THROW("Memory allocation failure");
diff --git a/turbojpeg.c b/turbojpeg.c
index 87011efb..c377d59f 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -32,6 +32,9 @@
#include
#include
+#if !defined(_MSC_VER) || _MSC_VER > 1600
+#include
+#endif
#include
#define JPEG_INTERNALS
#include
@@ -946,8 +949,10 @@ DLLEXPORT size_t tj3JPEGBufSize(int width, int height, int jpegSubsamp)
mcuh = tjMCUHeight[jpegSubsamp];
chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
retval = PAD(width, mcuw) * PAD(height, mcuh) * (2ULL + chromasf) + 2048ULL;
+#if ULLONG_MAX > ULONG_MAX
if (retval > (unsigned long long)((unsigned long)-1))
THROWG("Image is too large", 0);
+#endif
bailout:
return (size_t)retval;
@@ -981,8 +986,10 @@ DLLEXPORT unsigned long TJBUFSIZE(int width, int height)
larger than the uncompressed input (we wouldn't mention it if it hadn't
happened before.) */
retval = PAD(width, 16) * PAD(height, 16) * 6ULL + 2048ULL;
+#if ULLONG_MAX > ULONG_MAX
if (retval > (unsigned long long)((unsigned long)-1))
THROWG("Image is too large", (unsigned long)-1);
+#endif
bailout:
return (unsigned long)retval;
@@ -1008,8 +1015,10 @@ DLLEXPORT size_t tj3YUVBufSize(int width, int align, int height, int subsamp)
if (pw == 0 || ph == 0) return 0;
else retval += (unsigned long long)stride * ph;
}
+#if ULLONG_MAX > ULONG_MAX
if (retval > (unsigned long long)((unsigned long)-1))
THROWG("Image is too large", 0);
+#endif
bailout:
return (size_t)retval;
@@ -1123,8 +1132,10 @@ DLLEXPORT size_t tj3YUVPlaneSize(int componentID, int width, int stride,
else stride = abs(stride);
retval = (unsigned long long)stride * (ph - 1) + pw;
+#if ULLONG_MAX > ULONG_MAX
if (retval > (unsigned long long)((unsigned long)-1))
THROWG("Image is too large", 0);
+#endif
bailout:
return (size_t)retval;
From dfde1f857d5bdc0ff214c5f920f04ea8287005ed Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 8 Mar 2024 12:09:23 -0500
Subject: [PATCH 060/135] Fix (and test) more Clang 14 compiler warnings
-Woverlength-strings, -Wshift-negative-value, -Wsign-compare
---
.github/workflows/build.yml | 3 ++-
CMakeLists.txt | 2 +-
cjpeg.c | 3 ++-
djpeg.c | 3 ++-
jpegtran.c | 3 ++-
jversion.h.in | 7 ++++---
md5/md5hl.c | 5 +++--
turbojpeg-mp.c | 3 ++-
turbojpeg.c | 5 +++--
9 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ffae8f8e..6018f317 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -149,7 +149,8 @@ jobs:
mkdir build
pushd build
cmake -G"Unix Makefiles" -DWITH_JPEG8=1 \
- -DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wpedantic -pedantic-errors -Wdouble-promotion -Wformat-overflow=2 -Wformat-security -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k -Wmissing-include-dirs -Wshift-overflow=2 -Wswitch-bool -Wno-unused-parameter -Wuninitialized -Wstrict-overflow=2 -Wstringop-overflow=4 -Wstringop-truncation -Wduplicated-branches -Wduplicated-cond -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wundef -Wcast-align -Wno-clobbered -Wjump-misses-init -Wno-sign-compare -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wdisabled-optimization -Wno-overlength-strings -fcf-protection' \
+ -DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wmost -Wnon-gcc -Wpedantic -pedantic-errors -Walloca -Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wbitfield-enum-conversion -Wc99-extensions -Wc2x-extensions -Wcast-function-type -Wcompound-token-split -Wdate-time -Wdeclaration-after-statement -Wdeprecated -Wdocumentation -Wdocumentation-pedantic -Wdouble-promotion -Wduplicate-decl-specifier -Wduplicate-enum -Wempty-init-stmt -Wexpansion-to-defined -Wextra-semi -Wformat=2 -Wformat-non-iso -Wno-format-nonliteral -Wformat-pedantic -Wformat-type-confusion -Wfour-char-constants -Wgcc-compat -Wgnu -Wheader-hygiene -Widiomatic-parentheses -Wignored-qualifiers -Wimplicit-fallthrough -Wno-implicit-int-conversion -Wincompatible-function-pointer-types -Wno-long-long -Wloop-analysis -Wmain -Wmax-tokens -Wmisleading-indentation -Wmissing-field-initializers -Wmissing-prototypes -Wmissing-variable-declarations -Wnewline-eof -Wnonportable-system-include-path -Wnullable-to-nonnull-conversion -Wold-style-cast -Wover-aligned -Wparentheses -Wpointer-arith -Wpragmas -Wpre-c2x-compat -Wredundant-parens -Wself-assign -Wshadow-all -Wshift-sign-overflow -Wno-shorten-64-to-32 -Wno-sign-conversion -Wsometimes-uninitialized -Wstatic-in-inline -Wstrict-prototypes -Wswitch-default -Wtautological-constant-in-range-compare -Wthread-safety -Wthread-safety-verbose -Wunaligned-access -Wundef -Wundef-prefix -Wundefined-func-template -Wuninitialized -Wunneeded-internal-declaration -Wunreachable-code-fallthrough -Wno-unused-command-line-argument -Wunused-member-function -Wno-unused-parameter -Wvariadic-macros -Wzero-as-null-pointer-constant -Wzero-length-array -fcf-protection' \
+ -DCMAKE_C_COMPILER=clang-14 \
..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f6bbdd0..e6fc9323 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -481,7 +481,7 @@ if(UNIX)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
- res |= (~0L) << (32-4);
+ res |= 0xFFFFFFFFL << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
diff --git a/cjpeg.c b/cjpeg.c
index b7385bff..44c39bec 100644
--- a/cjpeg.c
+++ b/cjpeg.c
@@ -361,7 +361,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
if (!printed_version) {
fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
+ fprintf(stderr, JCOPYRIGHT1);
+ fprintf(stderr, JCOPYRIGHT2 "\n");
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
JVERSION);
printed_version = TRUE;
diff --git a/djpeg.c b/djpeg.c
index fd30a9ed..1baeddde 100644
--- a/djpeg.c
+++ b/djpeg.c
@@ -267,7 +267,8 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
if (!printed_version) {
fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
+ fprintf(stderr, JCOPYRIGHT1);
+ fprintf(stderr, JCOPYRIGHT2 "\n");
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
JVERSION);
printed_version = TRUE;
diff --git a/jpegtran.c b/jpegtran.c
index 2857a564..407cc438 100644
--- a/jpegtran.c
+++ b/jpegtran.c
@@ -241,7 +241,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
if (!printed_version) {
fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
+ fprintf(stderr, JCOPYRIGHT1);
+ fprintf(stderr, JCOPYRIGHT2 "\n");
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
JVERSION);
printed_version = TRUE;
diff --git a/jversion.h.in b/jversion.h.in
index 0f68fe63..fc0ce3e0 100644
--- a/jversion.h.in
+++ b/jversion.h.in
@@ -36,20 +36,21 @@
* their code
*/
-#define JCOPYRIGHT \
+#define JCOPYRIGHT1 \
"Copyright (C) 2009-2024 D. R. Commander\n" \
"Copyright (C) 2015, 2020 Google, Inc.\n" \
"Copyright (C) 2019-2020 Arm Limited\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
- "Copyright (C) 2015 Intel Corporation\n" \
+ "Copyright (C) 2015 Intel Corporation\n"
+#define JCOPYRIGHT2 \
"Copyright (C) 2013-2014 Linaro Limited\n" \
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
"Copyright (C) 1999 Ken Murchison\n" \
- "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
+ "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding\n"
#define JCOPYRIGHT_SHORT \
"Copyright (C) @COPYRIGHT_YEAR@ The libjpeg-turbo Project and many others"
diff --git a/md5/md5hl.c b/md5/md5hl.c
index 849a1366..81200935 100644
--- a/md5/md5hl.c
+++ b/md5/md5hl.c
@@ -6,7 +6,8 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
* libjpeg-turbo Modifications:
- * Copyright (C)2016, 2018-2019, 2022 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2016, 2018-2019, 2022, 2024 D. R. Commander.
+ * All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -111,7 +112,7 @@ char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
n = len;
i = 0;
while (n > 0) {
- if (n > sizeof(buffer))
+ if ((size_t)n > sizeof(buffer))
i = read(f, buffer, sizeof(buffer));
else
i = read(f, buffer, n);
diff --git a/turbojpeg-mp.c b/turbojpeg-mp.c
index 5090bf48..d4b3c74c 100644
--- a/turbojpeg-mp.c
+++ b/turbojpeg-mp.c
@@ -180,7 +180,8 @@ DLLEXPORT int GET_NAME(tj3Decompress, BITS_IN_JSAMPLE)
}
setDecompParameters(this);
if (this->maxPixels &&
- (unsigned long long)this->jpegWidth * this->jpegHeight > this->maxPixels)
+ (unsigned long long)this->jpegWidth * this->jpegHeight >
+ (unsigned long long)this->maxPixels)
THROW("Image is too large");
this->dinfo.out_color_space = pf2cs[pixelFormat];
#if BITS_IN_JSAMPLE != 16
diff --git a/turbojpeg.c b/turbojpeg.c
index c377d59f..3c936160 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -2361,7 +2361,8 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
}
setDecompParameters(this);
if (this->maxPixels &&
- (unsigned long long)this->jpegWidth * this->jpegHeight > this->maxPixels)
+ (unsigned long long)this->jpegWidth * this->jpegHeight >
+ (unsigned long long)this->maxPixels)
THROW("Image is too large");
if (this->subsamp == TJSAMP_UNKNOWN)
THROW("Could not determine subsampling level of JPEG image");
@@ -2730,7 +2731,7 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
jpeg_read_header(dinfo, TRUE);
if (this->maxPixels &&
(unsigned long long)dinfo->image_width * dinfo->image_height >
- this->maxPixels)
+ (unsigned long long)this->maxPixels)
THROW("Image is too large");
this->subsamp = getSubsamp(&this->dinfo);
From fe218ca19c0f508d2ae7a55c9cad9e5c980237d7 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 18 Mar 2024 11:27:30 -0400
Subject: [PATCH 061/135] Build: Handle CMAKE_C_COMPILER_ID=AppleClang
Because of 1644bdb7d2fac66cd0ce25adef7754e008b5bc1e, we are now
effectively using the NEW behavior for all CMake policies introduced in
all CMake versions up to and including CMake 3.28. The NEW behavior for
CMP0025, introduced in CMake 3.0, sets CMAKE_C_COMPILER_ID to
"AppleClang" instead of "Clang" when using Apple's variant of Clang (in
Xcode), so we need to match all values of CMAKE_C_COMPILER_ID that
contain "Clang".
This fixes three issues:
- -O2 was not replaced with -O3 in CMAKE_C_FLAGS_RELWITHDEBINFO. This
was a minor issue, since -O3 is now the default in
CMAKE_C_FLAGS_RELEASE, and we use CMAKE_BUILD_TYPE=Release in our
official builds.
- The build system erroneously set the default value of FLOATTEST8 and
FLOATTEST12 to no-fp-contract when compiling for PowerPC or Arm using
Apple Clang 14+ (effectively reverting
5b2beb4bc4f41dd9dd2a905cb931b8d5054d909b.) Because Clang 14+ now
enables -ffp-contract=on by default, this issue caused floating point
test failures unless FLOATTEST8 and FLOATTEST12 were overridden.
- The build system set MD5_PPM_3x2_FLOAT_FP_CONTRACT as appropriate for
GCC, not as appropriate for Clang (effectively reverting
47656a082091f9c9efda054674522513f4768c6c.) This also caused floating
point test failures.
Fixes #753
Closes #755
---
CMakeLists.txt | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e6fc9323..81ba1b0b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -423,7 +423,7 @@ if(MSVC)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
endif()
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# Use the maximum optimization level for release builds
foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${var} MATCHES "-O2")
@@ -494,7 +494,7 @@ if(UNIX)
endif()
endif()
-if(NOT MSVC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+if(NOT MSVC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
check_c_source_compiles("extern const int table[1]; const int __attribute__((visibility(\"hidden\"))) table[1] = { 0 }; int main(void) { return table[0]; }"
HIDDEN_WORKS)
if(HIDDEN_WORKS)
@@ -932,7 +932,7 @@ if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
set(DEFAULT_FLOATTEST8 no-fp-contract)
endif()
elseif(CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64")
- if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 14.0.0 OR
CMAKE_C_COMPILER_VERSION VERSION_GREATER 14.0.0)
set(DEFAULT_FLOATTEST8 fp-contract)
@@ -974,7 +974,7 @@ endif()
if(CPU_TYPE STREQUAL "x86_64")
set(DEFAULT_FLOATTEST12 no-fp-contract)
elseif(CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64")
- if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 14.0.0 OR
CMAKE_C_COMPILER_VERSION VERSION_GREATER 14.0.0)
set(DEFAULT_FLOATTEST12 fp-contract)
@@ -1229,7 +1229,7 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_SSE})
set(MD5_JPEG_3x2_FLOAT_PROG_FP_CONTRACT
${MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT})
- if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(MD5_PPM_3x2_FLOAT_FP_CONTRACT 2da9de6ae869e88b8372de815d366b03)
else()
set(MD5_PPM_3x2_FLOAT_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_SSE})
@@ -1301,7 +1301,7 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT f6bfab038438ed8f5522fbd33595dcdc)
set(MD5_JPEG_3x2_FLOAT_PROG_FP_CONTRACT
${MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT})
- if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(MD5_PPM_3x2_FLOAT_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT})
else()
set(MD5_PPM_3x2_FLOAT_FP_CONTRACT 0e917a34193ef976b679a6b069b1be26)
From 710865cf0e9da0dfd1ecd0cbc4ae2172328139e6 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 18 Mar 2024 12:56:42 -0400
Subject: [PATCH 062/135] Build: Don't explicitly set CMP0065 to NEW
This is no longer necessary, because of
1644bdb7d2fac66cd0ce25adef7754e008b5bc1e.
---
CMakeLists.txt | 5 -----
1 file changed, 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81ba1b0b..26c1283e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,4 @@
cmake_minimum_required(VERSION 2.8.12...3.28)
-# When using CMake 3.4 and later, don't export symbols from executables unless
-# the CMAKE_ENABLE_EXPORTS variable is set.
-if(POLICY CMP0065)
- cmake_policy(SET CMP0065 NEW)
-endif()
if(CMAKE_EXECUTABLE_SUFFIX)
set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX})
From 2dfe6c0fe9e18671105e94f7cbf044d4a1d157e6 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 18 Mar 2024 14:51:04 -0400
Subject: [PATCH 063/135] CI: Work around segfaults in ASan/MSan jobs
Referring to actions/runner-images#9491, the sanitizers in LLVM 14 that
ships with Ubuntu 22.04 are incompatible with high-entropy address space
layout randomization (ASLR), which is enabled in the GitHub runners via
their use of a newer kernel than ubuntu 22.04 uses.
---
.github/workflows/build.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6018f317..a490a584 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -94,6 +94,7 @@ jobs:
- name: Set up build
run: |
sudo apt install -y nasm
+ sudo sysctl vm.mmap_rnd_bits=28
- name: Build
env:
ASAN_OPTIONS: "detect_leaks=1 symbolize=1"
@@ -164,6 +165,9 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
+ - name: Set up build
+ run: |
+ sudo sysctl vm.mmap_rnd_bits=28
- name: Build
env:
CTEST_OUTPUT_ON_FAILURE: 1
From 6a522fcda46934b3dc2464114d1283f110105d5e Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 2 May 2024 14:07:45 -0400
Subject: [PATCH 064/135] jpegtran -drop: Ensure all quant tables defined
It is possible to craft a malformed JPEG image in which all of the
scans contain fewer components than the number of components specified
in the Start Of Frame (SOF) segment. Attempting to use such an image as
either an input image or a drop image with 'jpegtran -drop' caused a
NULL dereference and subsequent segfault in transupp.c:adjust_quant(),
so this commit adds appropriate checks to guard against that.
Since the issue involved an interface that is only exposed on the
jpegtran command line, it did not represent a security risk.
'jpegtran -drop' could not ever be used successfully with images such as
the ones described above. This commit simply makes jpegtran fail
gracefully rather than crash.
Fixes #758
---
ChangeLog.md | 5 +++++
transupp.c | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index f15f87ad..8039c553 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -16,6 +16,11 @@ in the C compiler.
calling applications to supply custom Huffman tables when generating
12-bit-per-component lossy JPEG images using the libjpeg API.
+4. Fixed a segfault that occurred when attempting to use the jpegtran `-drop`
+option with a specially-crafted malformed input image or drop image
+(specifically an image in which all of the scans contain fewer components than
+the number of components specified in the Start Of Frame segment.)
+
3.0.2
=====
diff --git a/transupp.c b/transupp.c
index 34fbb371..62587d38 100644
--- a/transupp.c
+++ b/transupp.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2017, 2021-2022, D. R. Commander.
+ * Copyright (C) 2010, 2017, 2021-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -201,7 +201,11 @@ adjust_quant(j_decompress_ptr srcinfo, jvirt_barray_ptr *src_coef_arrays,
compptr1 = srcinfo->comp_info + ci;
compptr2 = dropinfo->comp_info + ci;
qtblptr1 = compptr1->quant_table;
+ if (qtblptr1 == NULL)
+ ERREXIT1(srcinfo, JERR_NO_QUANT_TABLE, compptr1->quant_tbl_no);
qtblptr2 = compptr2->quant_table;
+ if (qtblptr2 == NULL)
+ ERREXIT1(dropinfo, JERR_NO_QUANT_TABLE, compptr2->quant_tbl_no);
for (k = 0; k < DCTSIZE2; k++) {
if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) {
if (trim)
From 24e09baaf024e71841a92d30d0e763242ed959ef Mon Sep 17 00:00:00 2001
From: Kleis Auke Wolthuizen
Date: Fri, 12 Apr 2024 11:46:21 +0200
Subject: [PATCH 065/135] Build: Add COMPONENT to all install() commands
This makes it possible for downstream packagers and other integrators of
libjpeg-turbo to include only specific directories from the
libjpeg-turbo installation (or to install specific directories under a
different prefix, etc.) The names of the components correspond to the
directories into which they will be installed.
Refer to libvips/libvips#3931, #265, #338
Closes #756
---
CMakeLists.txt | 52 +++++++++++++++++++++-------------------
fuzz/CMakeLists.txt | 8 +++----
java/CMakeLists.txt | 7 +++++-
sharedlib/CMakeLists.txt | 12 +++++-----
4 files changed, 44 insertions(+), 35 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 26c1283e..36c36fe3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1726,22 +1726,22 @@ set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
if(WITH_TURBOJPEG)
if(ENABLE_SHARED)
install(TARGETS turbojpeg EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
install(TARGETS tjbench
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
CMAKE_C_LINKER_SUPPORTS_PDB)
install(FILES "$"
- DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
+ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin OPTIONAL)
endif()
endif()
if(ENABLE_STATIC)
install(TARGETS turbojpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
if(NOT ENABLE_SHARED)
if(GENERATOR_IS_MULTI_CONFIG)
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
@@ -1749,17 +1749,17 @@ if(WITH_TURBOJPEG)
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(PROGRAMS ${DIR}/tjbench-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
+ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME tjbench${EXE})
endif()
endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include)
endif()
if(ENABLE_STATIC)
install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
if(NOT ENABLE_SHARED)
if(GENERATOR_IS_MULTI_CONFIG)
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
@@ -1767,15 +1767,16 @@ if(ENABLE_STATIC)
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(PROGRAMS ${DIR}/cjpeg-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
+ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME cjpeg${EXE})
install(PROGRAMS ${DIR}/djpeg-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
+ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME djpeg${EXE})
install(PROGRAMS ${DIR}/jpegtran-static${EXE}
- DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
+ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME jpegtran${EXE})
endif()
endif()
-install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(TARGETS rdjpgcom wrjpgcom
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.c
@@ -1783,10 +1784,11 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt
${CMAKE_CURRENT_SOURCE_DIR}/structure.txt
${CMAKE_CURRENT_SOURCE_DIR}/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/wizard.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
+ ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR}
+ COMPONENT doc)
if(WITH_JAVA)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java
- DESTINATION ${CMAKE_INSTALL_DOCDIR})
+ DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc)
endif()
if(UNIX OR MINGW)
@@ -1794,26 +1796,28 @@ if(UNIX OR MINGW)
${CMAKE_CURRENT_SOURCE_DIR}/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/jpegtran.1
${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
- DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+ DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT man)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT lib)
if(WITH_TURBOJPEG)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT lib)
endif()
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/${CMAKE_PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
+ COMPONENT lib)
install(EXPORT ${CMAKE_PROJECT_NAME}Targets
NAMESPACE ${CMAKE_PROJECT_NAME}::
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
+ COMPONENT lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include)
include(cmakescripts/BuildPackages.cmake)
diff --git a/fuzz/CMakeLists.txt b/fuzz/CMakeLists.txt
index a08cb46a..2ed3f72e 100644
--- a/fuzz/CMakeLists.txt
+++ b/fuzz/CMakeLists.txt
@@ -30,15 +30,15 @@ add_executable(cjpeg_fuzzer${FUZZER_SUFFIX} cjpeg.cc ../cdjpeg.c ../rdbmp.c
set_property(TARGET cjpeg_fuzzer${FUZZER_SUFFIX} PROPERTY COMPILE_FLAGS
${COMPILE_FLAGS})
target_link_libraries(cjpeg_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY} jpeg-static)
-install(TARGETS cjpeg_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
- ${FUZZ_BINDIR})
+install(TARGETS cjpeg_fuzzer${FUZZER_SUFFIX}
+ RUNTIME DESTINATION ${FUZZ_BINDIR} COMPONENT bin)
macro(add_fuzz_target target source_file)
add_executable(${target}_fuzzer${FUZZER_SUFFIX} ${source_file})
target_link_libraries(${target}_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY}
turbojpeg-static)
- install(TARGETS ${target}_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
- ${FUZZ_BINDIR})
+ install(TARGETS ${target}_fuzzer${FUZZER_SUFFIX}
+ RUNTIME DESTINATION ${FUZZ_BINDIR} COMPONENT bin)
endmacro()
add_fuzz_target(compress compress.cc)
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index cff93e7d..e699e94b 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -89,5 +89,10 @@ GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_JAVADIR
set(CMAKE_INSTALL_JAVADIR ${CMAKE_INSTALL_JAVADIR} PARENT_SCOPE)
set(CMAKE_INSTALL_FULL_JAVADIR ${CMAKE_INSTALL_FULL_JAVADIR} PARENT_SCOPE)
report_directory(JAVADIR)
-install_jar(turbojpeg-java ${CMAKE_INSTALL_JAVADIR})
+if(CMAKE_VERSION VERSION_EQUAL "3.4" OR CMAKE_VERSION VERSION_GREATER "3.4")
+ install_jar(turbojpeg-java DESTINATION ${CMAKE_INSTALL_JAVADIR}
+ COMPONENT java)
+else()
+ install_jar(turbojpeg-java ${CMAKE_INSTALL_JAVADIR})
+endif()
mark_as_advanced(CLEAR CMAKE_INSTALL_JAVADIR)
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index 5ca8a8b8..27077101 100644
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -119,14 +119,14 @@ add_executable(jcstest ../jcstest.c)
target_link_libraries(jcstest jpeg)
install(TARGETS jpeg EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
install(TARGETS cjpeg djpeg jpegtran
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
CMAKE_C_LINKER_SUPPORTS_PDB)
install(FILES "$"
- DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
+ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin OPTIONAL)
endif()
From 3f43bb332077fce5d4c5da6878995294edb2ee7e Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 6 May 2024 13:03:46 -0400
Subject: [PATCH 066/135] Build: Don't use COMPONENT w/install(INCLUDES ...)
(Regression introduced by 24e09baaf024e71841a92d30d0e763242ed959ef)
The install() INCLUDES option is not an artifact option. It specifies
a list of directories that will be added to the
INTERFACE_INCLUDE_DIRECTORIES target property when the target is
exported using the install() EXPORT option, which occurs when CMake
package config files are generated. Specifying 'COMPONENT include' with
the install() INCLUDES option caused the INTERFACE_INCLUDE_DIRECTORIES
properties in our CMake package config files to contain
'${_IMPORT_PREFIX}/COMPONENT', which caused errors of the form 'Imported
target "libjpeg-turbo::XXXX" includes non-existent path' when downstream
build systems attempted to include libjpeg-turbo using find_package().
Fixes #759
Closes #760
---
CMakeLists.txt | 6 +++---
sharedlib/CMakeLists.txt | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36c36fe3..ff9c9c27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1726,7 +1726,7 @@ set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
if(WITH_TURBOJPEG)
if(ENABLE_SHARED)
install(TARGETS turbojpeg EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
@@ -1740,7 +1740,7 @@ if(WITH_TURBOJPEG)
endif()
if(ENABLE_STATIC)
install(TARGETS turbojpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
if(NOT ENABLE_SHARED)
if(GENERATOR_IS_MULTI_CONFIG)
@@ -1758,7 +1758,7 @@ endif()
if(ENABLE_STATIC)
install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib)
if(NOT ENABLE_SHARED)
if(GENERATOR_IS_MULTI_CONFIG)
diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
index 27077101..eaed9e95 100644
--- a/sharedlib/CMakeLists.txt
+++ b/sharedlib/CMakeLists.txt
@@ -119,7 +119,7 @@ add_executable(jcstest ../jcstest.c)
target_link_libraries(jcstest jpeg)
install(TARGETS jpeg EXPORT ${CMAKE_PROJECT_NAME}Targets
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin)
From 7fa4b5b762c9a99b46b0b7838f5fd55071b92ea5 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 6 May 2024 17:28:07 -0400
Subject: [PATCH 067/135] jerror.c: Silence MSan uninitialized value warning
If an error manager instance is passed to jpeg_std_error(), then its
format_message() method will point to the format_message() function in
jerror.c. The format_message() function passes all eight values from
the jpeg_error_mgr::msg_parm.i[] array as arguments to
snprintf()/_snprintf_s(), even if the format string doesn't use all of
those values. Subsequently invoking one of the ERREXIT[1-6]() macros
will leave the unused values uninitialized, and if the
-fsanitize-memory-param-retval option (introduced in Clang 14) is
enabled (which it is by default in Clang 16 and later), then MSan will
complain when the format_message() function tries to pass the
uninitialized-but-unused values as function arguments.
This commit modifies jpeg_std_error() so that it zeroes out the error
manager instance passed to it, thus working around the warning as well
as simplifying the code.
Closes #761
---
.github/workflows/build.yml | 2 +-
jerror.c | 10 ++--------
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a490a584..e8e30198 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -174,7 +174,7 @@ jobs:
run: |
mkdir build
pushd build
- cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O0 -g -fsanitize=memory -fno-sanitize-recover=all -fPIE" -DWITH_SIMD=0 ..
+ cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O0 -g -fsanitize=memory -fsanitize-memory-param-retval -fno-sanitize-recover=all -fPIE" -DWITH_SIMD=0 ..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
make test
diff --git a/jerror.c b/jerror.c
index c12c34fc..3a75fec0 100644
--- a/jerror.c
+++ b/jerror.c
@@ -229,23 +229,17 @@ reset_error_mgr(j_common_ptr cinfo)
GLOBAL(struct jpeg_error_mgr *)
jpeg_std_error(struct jpeg_error_mgr *err)
{
+ memset(err, 0, sizeof(struct jpeg_error_mgr));
+
err->error_exit = error_exit;
err->emit_message = emit_message;
err->output_message = output_message;
err->format_message = format_message;
err->reset_error_mgr = reset_error_mgr;
- err->trace_level = 0; /* default = no tracing */
- err->num_warnings = 0; /* no warnings emitted yet */
- err->msg_code = 0; /* may be useful as a flag for "no error" */
-
/* Initialize message table pointers */
err->jpeg_message_table = jpeg_std_message_table;
err->last_jpeg_message = (int)JMSG_LASTMSGCODE - 1;
- err->addon_message_table = NULL;
- err->first_addon_message = 0; /* for safety */
- err->last_addon_message = 0;
-
return err;
}
From 0fc7313e545a3ff499c19ee6591bb87f0ad8b2a4 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 14 May 2024 11:41:16 -0400
Subject: [PATCH 068/135] Don't traverse linked list when saving a marker
If the calling application invokes jpeg_save_markers() to save a
particular type of marker, then the save_marker() function will be
invoked for every marker of that type that is encountered. Previously,
only the head of the marker linked list was stored (in
jpeg_decompress_struct), so save_marker() had to traverse the entire
linked list before it could add a new marker to the tail of the list.
That caused CPU usage to grow exponentially with the number of markers.
Referring to #764, it is possible to create a JPEG image that contains
an excessive number of markers. The specific reproducer that uncovered
this issue is a specially-crafted 1-megabyte malformed JPEG image with
tens of thousands of APP1 markers, which required approximately 30
seconds of CPU time (on a modern Intel processor) to process. However,
it should also be possible to create a legitimate JPEG image that
reproduces the issue (such as an image with tens of thousands of
duplicate EXIF tags.)
This commit introduces a new pointer (in jpeg_decomp_master, in order to
preserve backward ABI compatibility) that is used to store the tail of
the marker linked list whenever a marker is added to it. Thus, it is no
longer necessary to traverse the list when adding a marker, and CPU
usage will grow linearly rather than exponentially with the number of
markers.
Fixes #764
---
jcomapi.c | 5 +++--
jdmarker.c | 12 +++++-------
jpegint.h | 5 ++++-
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/jcomapi.c b/jcomapi.c
index efbb8357..84f37e17 100644
--- a/jcomapi.c
+++ b/jcomapi.c
@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -51,6 +51,7 @@ jpeg_abort(j_common_ptr cinfo)
* A bit kludgy to do it here, but this is the most central place.
*/
((j_decompress_ptr)cinfo)->marker_list = NULL;
+ ((j_decompress_ptr)cinfo)->master->marker_list_end = NULL;
} else {
cinfo->global_state = CSTATE_START;
}
diff --git a/jdmarker.c b/jdmarker.c
index acd28ce6..ee6b6d41 100644
--- a/jdmarker.c
+++ b/jdmarker.c
@@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2012, 2015, 2022, D. R. Commander.
+ * Copyright (C) 2012, 2015, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -819,13 +819,11 @@ save_marker(j_decompress_ptr cinfo)
/* Done reading what we want to read */
if (cur_marker != NULL) { /* will be NULL if bogus length word */
/* Add new marker to end of list */
- if (cinfo->marker_list == NULL) {
- cinfo->marker_list = cur_marker;
+ if (cinfo->marker_list == NULL || cinfo->master->marker_list_end == NULL) {
+ cinfo->marker_list = cinfo->master->marker_list_end = cur_marker;
} else {
- jpeg_saved_marker_ptr prev = cinfo->marker_list;
- while (prev->next != NULL)
- prev = prev->next;
- prev->next = cur_marker;
+ cinfo->master->marker_list_end->next = cur_marker;
+ cinfo->master->marker_list_end = cur_marker;
}
/* Reset pointer & calc remaining data length */
data = cur_marker->data;
diff --git a/jpegint.h b/jpegint.h
index 65414201..7c28da3d 100644
--- a/jpegint.h
+++ b/jpegint.h
@@ -7,7 +7,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015-2017, 2019, 2021-2022, D. R. Commander.
+ * Copyright (C) 2015-2017, 2019, 2021-2022, 2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -249,6 +249,9 @@ struct jpeg_decomp_master {
/* Last iMCU row that was successfully decoded */
JDIMENSION last_good_iMCU_row;
+
+ /* Tail of list of saved markers */
+ jpeg_saved_marker_ptr marker_list_end;
};
/* Input control module */
From bc491b16e2b163027bb96e35566a70eebb1c190c Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 16 May 2024 17:32:02 -0400
Subject: [PATCH 069/135] ChangeLog.md: Document previous commit
---
CMakeLists.txt | 2 +-
ChangeLog.md | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff9c9c27..50b83bf9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ if(CMAKE_EXECUTABLE_SUFFIX)
endif()
project(libjpeg-turbo C)
-set(VERSION 3.0.3)
+set(VERSION 3.0.4)
set(COPYRIGHT_YEAR "1991-2024")
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
diff --git a/ChangeLog.md b/ChangeLog.md
index 8039c553..c5b91bb2 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,16 @@
+3.0.4
+=====
+
+### Significant changes relative to 3.0.3:
+
+1. Fixed an issue whereby the CPU usage of the default marker processor in the
+decompressor grew exponentially with the number of markers. This caused an
+unreasonable slow-down in `jpeg_read_header()` if an application called
+`jpeg_save_markers()` to save markers of a particular type and then attempted
+to decompress a JPEG image containing an excessive number of markers of that
+type.
+
+
3.0.3
=====
From 9ddcae4a8f4aaa096ccdcddec36afc52fbc01481 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 20 May 2024 12:13:51 -0400
Subject: [PATCH 070/135] jpeglib.h: Document the need to include stdio.h
libjpeg.txt documents the need to "include system headers that define at
least the typedefs FILE and size_t" before including jpeglib.h.
However, some software developers unfortunately assume that any
downstream build failure is due to an upstream oversight (as if such an
oversight would have gone unnoticed for 14 years in a library as
ubiquitous as libjpeg-turbo) and "come in hot" with a proposal and
arguments that have already been carefully considered and rejected
multiple times (as opposed to grepping the documentation or searching
existing issues and PRs to find out whether the upstream behavior is
intentional.)
Multiple issues and PRs (including #17, #18, #116, #737, and #766) have
been filed regarding this, so this commit adds a comment to jpeglib.h in
the hope of heading off future issues and PRs. I suspect that some
people will still choose to waste my time by arguing about it, even
though the decision was made by Tom Lane nearly 20 years before
libjpeg-turbo even existed, the decision was supportable based on the
needs of early 1990s computing systems, and reversing that decision
would break backward API compatibility (which is one of the reasons that
many downstream projects adopted libjpeg-turbo in the first place.) At
least now, if someone posts an issue or PR about this again, I can just
link to this commit and close the issue/PR without comment.
---
jpeglib.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/jpeglib.h b/jpeglib.h
index a59e98c2..bd379cab 100644
--- a/jpeglib.h
+++ b/jpeglib.h
@@ -7,7 +7,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, 2022-2023,
+ * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, 2022-2024,
D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -18,6 +18,16 @@
* and perhaps jerror.h if they want to know the exact error codes.
*/
+/* NOTE: This header file does not include stdio.h, despite the fact that it
+ * uses FILE and size_t. That is by design, since the libjpeg API predates the
+ * widespread adoption of ANSI/ISO C. Referring to libjpeg.txt, it is a
+ * documented requirement that calling programs "include system headers that
+ * define at least the typedefs FILE and size_t" before including jpeglib.h.
+ * Technically speaking, changing that requirement by including stdio.h here
+ * would break backward API compatibility. Please do not file bug reports,
+ * feature requests, or pull requests regarding this.
+ */
+
#ifndef JPEGLIB_H
#define JPEGLIB_H
From 46173635be3dfcae84a7807f1a056d1c6b3c80b0 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 28 May 2024 23:04:37 -0400
Subject: [PATCH 071/135] Remove jpeg_std_message_table[] extern sym comment
jpeg_std_message_table[] was never a documented part of the libjpeg API,
nor was it exposed in jpegint.h or the Windows libjpeg API DLL. Thus,
it was never a good idea (nor was it even remotely necessary) for
applications to use it. However, referring to #763 and #767, one
application (RawTherapee) did use it.
34c055851ecb66a2d9bee1a3318c55cd9acd6586 hid the symbol, which broke the
Un*x builds of RawTherapee. (RawTherapee already did the right thing on
Windows, because jpeg_std_message_table[] was not exposed in the
Windows libjpeg API DLL. Referring to
https://github.com/Beep6581/RawTherapee/issues/7074, RawTherapee now
does the right thing on Un*x platforms as well.)
The comment in jerror.c indicated that Tom Lane intended the symbol to
be external "just in case any applications want to refer to it
directly." However, with respect to libjpeg-turbo, the comment was
effectively already a lie on Windows. My choices at this point are:
1. Revert 34c055851ecb66a2d9bee1a3318c55cd9acd6586 and start exposing
the symbol on Windows, thus making the comment true again.
2. Remove the comment.
Option 1 would have created whiplash, since 3.0.3 has already been
released with the symbol hidden, and that option would have further
encouraged ill-advised behavior on the part of applications. Since the
issue has already been fixed in RawTherapee, and since it is known to
affect only that application, I chose Option 2.
In my professional opinion, a code comment does not rise to the level
of a contract between a library and a calling application. In other
words, the comment did not make the symbol part of the API, even though
the symbol was exposed on some platforms. Applications that use
internal symbols (even the symbols defined in jpegint.h) do so at their
own risk. There is no guarantee that those symbols will remain
unchanged from release to release, as it is sometimes necessary to
modify the internal (opaque) structures and methods in order to
implement new features or even fix bugs. Some implementations of the
libjpeg API (such as the one in Jpegli, for instance), do not provide
those internal symbols at all. Best practices are for applications that
use the internal libjpeg-turbo symbols to provide their own copy of
libjpeg-turbo (for instance, via static linking), so they can manage any
unexpected changes in those symbols. (In fact, that is how libjpeg was
originally used. Application developers built it from source with
compile-time options to exclude unneeded functionality. Thus, no two
builds of libjpeg were guaranteed to be API/ABI-compatible. The idea of
a libjpeg shared library that exposes a pseudo-standard ABI came later,
and that has always been an awkward fit for an API that was intended to
be modified at compile time to suit specific application needs.
libjpeg-turbo's colorspace extensions are but one example, among many,
of our attempts to reconcile that awkwardness while preserving backward
compatibility with the aforementioned pseudo-standard ABI.)
---
jerror.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/jerror.c b/jerror.c
index 3a75fec0..2133244f 100644
--- a/jerror.c
+++ b/jerror.c
@@ -40,8 +40,6 @@
* Create the message string table.
* We do this from the master message list in jerror.h by re-reading
* jerror.h with a suitable definition for macro JMESSAGE.
- * The message table is made an external symbol just in case any applications
- * want to refer to it directly.
*/
#define JMESSAGE(code, string) string,
From 3c17063ef1ab43f5877f19d670dc39497c5cd036 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 27 May 2024 11:41:35 -0400
Subject: [PATCH 072/135] Guard against dupe SOF w/ incorrect source manager
Referring to https://bugzilla.mozilla.org/show_bug.cgi?id=1898606,
attempting to decompress a specially-crafted malformed JPEG image
(specifically an image with a complete 12-bit Start Of Frame segment
followed by an incomplete 8-bit Start Of Frame segment) using the
default marker processor, buffered-image mode, and input prefetching
triggered the following sequence of events:
- When the 12-bit SOF segment was encountered (in the body of
jpeg_read_header()), the marker processor's read_markers() method
called the get_sof() function, which processed the 12-bit SOF segment
and set cinfo->data_precision to 12.
- If the application subsequently called jpeg_consume_input() in a loop
to prefetch input data, and it didn't stop calling
jpeg_consume_input() when the function returned JPEG_REACHED_SOS, then
the 8-bit SOF segment was encountered in the body of
jpeg_consume_input(). As a result, the marker processor's
read_markers() method called get_sof(), which started to process the
8-bit SOF segment and set cinfo->data_precision to 8.
- Since the 8-bit SOF segment was incomplete, the end of the JPEG data
stream was encountered when get_sof() attempted to read the image
height, width, and number of components.
- If the fill_input_buffer() method in the application's custom source
manager incorrectly returned FALSE in response to a prematurely-
terminated JPEG data stream, then get_sof() returned FALSE while
attempting to read the image height, width, and number of components
(before the duplicate SOF check was reached.) That caused the default
marker processor's read_markers() method, and subsequently
jpeg_consume_input(), to return JPEG_SUSPENDED.
- If the application failed to respond to the JPEG_SUSPENDED return
value and subsequently attempted to call jpeg_read_scanlines(),
then the data precision check in jpeg_read_scanlines() succeeded
(because cinfo->data_precision was now 8.) However, because
cinfo->data_precision had been 12 during the previous call to
jpeg_start_decompress(), only the 12-bit version of the main
controller was initialized, and the cinfo->main->process_data() method
was undefined. Thus, a segfault occurred when jpeg_read_scanlines()
attempted to invoke that method.
Scenarios in which the issue was thwarted:
1. The default source managers handle a prematurely-terminated JPEG data
stream by inserting a fake EOI marker into the data stream. Thus, when
using one of those source managers, the INPUT_2BYTES() and INPUT_BYTE()
macros (which get_sof() invokes to read the image height, width, and
number of components) succeeded-- albeit with bogus data, since the fake
EOI marker was read into those fields. The duplicate SOF check in
get_sof() then failed, generating a fatal libjpeg error.
2. When using a custom source manager that correctly returns TRUE in
response to a prematurely-terminated JPEG data stream, the
aforementioned INPUT_2BYTES() and INPUT_BYTE() macros also succeeded
(albeit with bogus data read from the previous bytes of the data
stream), and the duplicate SOF check failed.
3. If the application did not prefetch input data, or if it stopped
invoking jpeg_consume_input() when the function returned
JPEG_REACHED_SOS, then the duplicate SOF segment was not read prior to
the first call to jpeg_read_scanlines(). Thus, the data precision check
in jpeg_read_scanlines() failed. If the application instead called
jpeg12_read_scanlines() (that is, if it properly supported multiple data
precisions), then the duplicate SOF segment was not read until the body
of jpeg_finish_decompress(). At that point, its only negative effect
was to cause jpeg_finish_decompress() to return FALSE before the
duplicate SOF check was reached.
In other words, this issue depended not only upon an incorrectly-written
source manager but also upon a very specific sequence of API calls. It
also depended upon the multi-precision feature introduced in
libjpeg-turbo 3.0.x. When using an 8-bit-per-sample build of
libjpeg-turbo 2.1.x, jpeg_read_header() failed with "Unsupported JPEG
data precision 12" after the 12-bit SOF segment was processed. When
using a 12-bit-per-sample build of libjpeg-turbo 2.1.x, the behavior
was the same as if the application called jpeg12_read_scanlines() in
Scenario 3 above.
This commit simply moves the duplicate SOF check to the top of
get_sof() so the check will fail before the marker processor attempts to
read the duplicate SOF. It should be noted that this issue isn't a
libjpeg-turbo bug per se, because it occurs only when the calling
application does something it shouldn't. It is, rather, an issue of API
hardening/caller-proofing.
---
ChangeLog.md | 9 +++++++++
jdmarker.c | 6 +++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index c5b91bb2..c50c073d 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -10,6 +10,15 @@ unreasonable slow-down in `jpeg_read_header()` if an application called
to decompress a JPEG image containing an excessive number of markers of that
type.
+2. Hardened the default marker processor in the decompressor to guard against
+an issue (exposed by 3.0 beta2[6]) whereby attempting to decompress a
+specially-crafted malformed JPEG image (specifically an image with a complete
+12-bit-per-component Start Of Frame segment followed by an incomplete
+8-bit-per-component Start Of Frame segment) using buffered-image mode and input
+prefetching caused a segfault if the `fill_input_buffer()` method in the
+calling application's custom source manager incorrectly returned `FALSE` in
+response to a prematurely-terminated JPEG data stream.
+
3.0.3
=====
diff --git a/jdmarker.c b/jdmarker.c
index ee6b6d41..f918ee4d 100644
--- a/jdmarker.c
+++ b/jdmarker.c
@@ -248,6 +248,9 @@ get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_lossless,
jpeg_component_info *compptr;
INPUT_VARS(cinfo);
+ if (cinfo->marker->saw_SOF)
+ ERREXIT(cinfo, JERR_SOF_DUPLICATE);
+
cinfo->progressive_mode = is_prog;
cinfo->master->lossless = is_lossless;
cinfo->arith_code = is_arith;
@@ -265,9 +268,6 @@ get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_lossless,
(int)cinfo->image_width, (int)cinfo->image_height,
cinfo->num_components);
- if (cinfo->marker->saw_SOF)
- ERREXIT(cinfo, JERR_SOF_DUPLICATE);
-
/* We don't support files in which the image height is initially specified */
/* as 0 and is later redefined by DNL. As long as we have to check that, */
/* might as well have a general sanity check. */
From 2c5312fd12f9c36675a330f8ad74f17c00bc409f Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 13 Jun 2024 21:16:20 -0400
Subject: [PATCH 073/135] cderror.h: Always include all img I/O err messages
The 8-bit-per-sample image I/O modules have always been built with BMP,
GIF, PBMPLUS, and Targa support, and the 12-bit-per-sample image I/O
modules have always been built with only GIF and PBMPLUS support. In
libjpeg-turbo 2.1.x and prior, cjpeg and djpeg were built with the same
image format support as the image I/O modules. However, because of the
multi-precision feature introduced in libjpeg-turbo 3.0.x, cjpeg and
djpeg are now always built with support for all image formats. Thus,
the error message table compiled into cjpeg and djpeg was a superset of
the error message table compiled into the 12-bit-per-sample and
16-bit-per-sample image I/O modules. If, for example, the
12-bit-per-sample PPM writer threw JERR_PPM_COLORSPACE (== 15, because
it was built with only GIF and PBMPLUS support), then djpeg interpreted
that as JERR_GIF_COLORSPACE (== 15, because it was built with support
for all image formats.) There was no chance of a buffer overrun, since
the error message table lookup was performed against the table compiled
into cjpeg and djpeg, which contained all possible entries. However,
this issue caused an incorrect error message to be displayed by cjpeg or
djpeg if a 12-bit-per-sample or 16-bit-per-sample image I/O module threw
an error. This commit simply removes the *_SUPPORTED #ifdefs from
cderror.h so that all image I/O error messages are always included in
every instance of the image I/O error message table.
Note that a similar issue could have also occurred with the
12-bit-per-sample and 16-bit-per-sample TurboJPEG image I/O functions,
since the 12-bit-per-sample and 16-bit-per-sample image I/O modules
supporting those functions are built with only PBMPLUS support whereas
the library as a whole is built with BMP and PBMPLUS support.
---
cderror.h | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/cderror.h b/cderror.h
index 2844346e..1bac441c 100644
--- a/cderror.h
+++ b/cderror.h
@@ -42,7 +42,6 @@ typedef enum {
JMESSAGE(JMSG_FIRSTADDONCODE = 1000, NULL) /* Must be first entry! */
-#ifdef BMP_SUPPORTED
JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
JMESSAGE(JERR_BMP_BADDEPTH, "Only 8-, 24-, and 32-bit BMP files are supported")
JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")
@@ -56,9 +55,7 @@ JMESSAGE(JTRC_BMP, "%ux%u %d-bit BMP image")
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
JMESSAGE(JTRC_BMP_OS2, "%ux%u %d-bit OS2 BMP image")
JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")
-#endif /* BMP_SUPPORTED */
-#ifdef GIF_SUPPORTED
JMESSAGE(JERR_GIF_BUG, "GIF output got confused")
JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d")
JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB")
@@ -74,9 +71,7 @@ JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file")
JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring")
JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image")
JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
-#endif /* GIF_SUPPORTED */
-#ifdef PPM_SUPPORTED
JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
@@ -85,18 +80,14 @@ JMESSAGE(JTRC_PGM, "%ux%u PGM image")
JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
JMESSAGE(JTRC_PPM, "%ux%u PPM image")
JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
-#endif /* PPM_SUPPORTED */
-#ifdef TARGA_SUPPORTED
JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB")
JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image")
JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image")
JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image")
-#else
JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled")
-#endif /* TARGA_SUPPORTED */
JMESSAGE(JERR_BAD_CMAP_FILE,
"Color map file is invalid or of unsupported format")
From 94c64ead85b4af254df089f16c10253598b0705e Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 17 Jun 2024 20:27:57 -0400
Subject: [PATCH 074/135] Various doc tweaks
- "bits per component" = "bits per sample"
Describing the data precision of a JPEG image using "bits per
component" is technically correct, but "bits per sample" is the
terminology that the JPEG-1 spec uses. Also, "bits per component" is
more commonly used to describe the precision of packed-pixel formats
(as opposed to "bits per pixel") rather than planar formats, in which
all components are grouped together.
- Unmention legacy display technologies. Colormapped and monochrome
displays aren't a thing anymore, and even when they were still a
thing, it was possible to display full-color images to them. In 1991,
when JPEG decompression time was measured in minutes per megapixel, it
made sense to keep a decompressed copy of JPEG images on disk, in a
format that could be displayed without further color conversion (since
color conversion was slow and memory-intensive.) In 2024, JPEG
decompression time is measured in milliseconds per megapixel, and
color conversion is even faster. Thus, JPEG images can be
decompressed, displayed, and color-converted (if necessary) "on the
fly" at speeds too fast for human vision to perceive. (In fact, your
TV performs much more complicated decompression algorithms at least 60
times per second.)
- Document that color quantization (and associated features), GIF
input/output, Targa input/output, and OS/2 BMP input/output are legacy
features. Legacy status doesn't necessarily mean that the features
are deprecated. Rather, it is meant to discourage users from using
features that may be of little or no benefit on modern machines (such
as low-quality modes that had significant performance advantages in
the early 1990s but no longer do) and that are maintained on a
break/fix basis only.
- General wordsmithing, grammar/punctuation policing, and formatting
tweaks
- Clarify which data precisions each cjpeg input format and each djpeg
output format supports.
- cjpeg.1: Remove unnecessary and impolitic statement about the -targa
switch.
- Adjust or remove performance claims to reflect the fact that:
* On modern machines, the djpeg "-fast" switch has a negligible effect
on performance.
* There is a measurable difference between the performance of Floyd-
Steinberg dithering and no dithering, but it is not likely
perceptible to most users.
* There is a measurable difference between the performance of 1-pass
and 2-pass color quantization, but it is not likely perceptible to
most users.
* There is a measurable difference between the performance of
full-color and grayscale output when decompressing a full-color JPEG
image, but it is not likely perceptible to most users.
* IDCT scaling does not necessarily improve performance. (It
generally does if the scaling factor is <= 1/2 and generally doesn't
if the scaling factor is > 1/2, at least on my machine. The
performance claim made in jpeg-6b was probably invalidated when we
merged the additional scaling factors from jpeg-7.)
- Clarify which djpeg switches/output formats cannot be used when
decompressing lossless JPEG images.
- Remove djpeg hints, since those involve quality vs. speed tradeoffs
that are no longer relevant for modern machines.
- Remove documentation regarding using color quantization with 16-bit
data precision. (Color quantization requires lossy mode.)
- Java: Fix typos in TJDecompressor.decompress12() and
TJDecompressor.decompress16() documentation.
- jpegtran.1: Fix truncated paragraph
In a man page, a single quote at the start of a line is interpreted as
a macro.
Closes #775
- libjpeg.txt:
* Mention J16SAMPLE data type (oversight.)
* Remove statement about extending jdcolor.c. (libjpeg-turbo is not
quite as DIY as libjpeg once was.)
* Remove paragraph about tweaking the various typedefs in jmorecfg.h.
It is no longer relevant for modern machines.
* Remove caveat regarding systems with ints less than 16 bits wide.
(ANSI/ISO C requires an int to be at least 16 bits wide, and
libjpeg-turbo has never supported non-ANSI compilers.)
- usage.txt:
* Add copyright header.
* Document cjpeg -icc, -memdst, -report, -strict, and -version
switches.
* Document djpeg -icc, -maxscans, -memsrc, -report, -skip, -crop,
-strict, and -version switches.
* Document jpegtran -icc, -maxscans, -report, -strict, and -version
switches.
---
CMakeLists.txt | 4 +-
ChangeLog.md | 4 +-
README.ijg | 6 +-
cjpeg.1 | 62 ++--
djpeg.1 | 129 ++++----
djpeg.c | 26 +-
java/doc/index-all.html | 2 +-
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
.../libjpegturbo/turbojpeg/TJCompressor.html | 4 +-
.../turbojpeg/TJDecompressor.html | 4 +-
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
.../libjpegturbo/turbojpeg/TJCompressor.java | 2 +-
.../turbojpeg/TJDecompressor.java | 4 +-
jpeglib.h | 9 +-
jpegtran.1 | 14 +-
libjpeg.txt | 126 ++++---
usage.txt | 308 +++++++++++-------
18 files changed, 383 insertions(+), 321 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50b83bf9..9952b24d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -309,12 +309,12 @@ endif()
# 1: + In-memory source/destination managers (libjpeg-turbo 1.3.x)
# 2: + Partial image decompression functions (libjpeg-turbo 1.5.x)
# 3: + ICC functions (libjpeg-turbo 2.0.x)
-# 4: + 12-bit-per-component and lossless functions (libjpeg-turbo 2.2.x)
+# 4: + 12-bit-per-sample and lossless functions (libjpeg-turbo 2.2.x)
#
# libjpeg v8 API/ABI emulation:
# 1: + Partial image decompression functions (libjpeg-turbo 1.5.x)
# 2: + ICC functions (libjpeg-turbo 2.0.x)
-# 3: + 12-bit-per-component and lossless functions (libjpeg-turbo 2.2.x)
+# 3: + 12-bit-per-sample and lossless functions (libjpeg-turbo 2.2.x)
set(SO_AGE 3)
if(NOT WITH_JPEG8)
set(SO_AGE 4)
diff --git a/ChangeLog.md b/ChangeLog.md
index c50c073d..7780f415 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -13,8 +13,8 @@ type.
2. Hardened the default marker processor in the decompressor to guard against
an issue (exposed by 3.0 beta2[6]) whereby attempting to decompress a
specially-crafted malformed JPEG image (specifically an image with a complete
-12-bit-per-component Start Of Frame segment followed by an incomplete
-8-bit-per-component Start Of Frame segment) using buffered-image mode and input
+12-bit-per-sample Start Of Frame segment followed by an incomplete
+8-bit-per-sample Start Of Frame segment) using buffered-image mode and input
prefetching caused a segfault if the `fill_input_buffer()` method in the
calling application's custom source manager incorrectly returned `FALSE` in
response to a prematurely-terminated JPEG data stream.
diff --git a/README.ijg b/README.ijg
index 8f376826..1be35958 100644
--- a/README.ijg
+++ b/README.ijg
@@ -89,9 +89,9 @@ The library is intended to be reused in other applications.
In order to support file conversion and viewing software, we have included
considerable functionality beyond the bare JPEG coding/decoding capability;
for example, the color quantization modules are not strictly part of JPEG
-decoding, but they are essential for output to colormapped file formats or
-colormapped displays. These extra functions can be compiled out of the
-library if not required for a particular application.
+decoding, but they are essential for output to colormapped file formats. These
+extra functions can be compiled out of the library if not required for a
+particular application.
We have also included "jpegtran", a utility for lossless transcoding between
different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
diff --git a/cjpeg.1 b/cjpeg.1
index f88714d6..6d329ed9 100644
--- a/cjpeg.1
+++ b/cjpeg.1
@@ -1,4 +1,4 @@
-.TH CJPEG 1 "14 Dec 2023"
+.TH CJPEG 1 "21 June 2024"
.SH NAME
cjpeg \- compress an image file to a JPEG file
.SH SYNOPSIS
@@ -16,7 +16,8 @@ cjpeg \- compress an image file to a JPEG file
compresses the named image file, or the standard input if no file is
named, and produces a JPEG/JFIF file on the standard output.
The currently supported input file formats are: PPM (PBMPLUS color
-format), PGM (PBMPLUS grayscale format), BMP, GIF, and Targa.
+format), PGM (PBMPLUS grayscale format), BMP, GIF [legacy feature], and Targa
+[legacy feature].
.SH OPTIONS
All switch names may be abbreviated; for example,
.B \-grayscale
@@ -29,7 +30,7 @@ Upper and lower case are equivalent (thus
.B \-BMP
is the same as
.BR \-bmp ).
-British spellings are also accepted (e.g.,
+British spellings are also accepted (e.g.
.BR \-greyscale ),
though for brevity these are not mentioned below.
.PP
@@ -40,13 +41,12 @@ Scale quantization tables to adjust image quality. Quality is 0 (worst) to
100 (best); default is 75. (See below for more info.)
.TP
.B \-grayscale
-Create monochrome JPEG file from color input. By saying
+Create monochrome JPEG file from color input. By specifying
.BR \-grayscale,
you'll get a smaller JPEG file that takes less time to process.
.TP
.B \-rgb
-Create RGB JPEG file.
-Using this switch suppresses the conversion from RGB
+Create RGB JPEG file. Using this switch suppresses the conversion from RGB
colorspace input to the default YCbCr JPEG colorspace.
.TP
.B \-optimize
@@ -63,15 +63,15 @@ decompression are unaffected by
Create progressive JPEG file (see below).
.TP
.B \-targa
-Input file is Targa format. Targa files that contain an "identification"
-field will not be automatically recognized by
-.BR cjpeg ;
-for such files you must specify
+Input file is Targa format [legacy feature]. Targa files that contain an
+"identification" field will not be automatically recognized by
+.BR cjpeg .
+For such files, you must specify
.B \-targa
to make
.B cjpeg
-treat the input as Targa format.
-For most Targa files, you won't need this switch.
+treat the input as Targa format. For most Targa files, you won't need this
+switch.
.PP
The
.B \-quality
@@ -153,10 +153,15 @@ Switches for advanced users:
Create JPEG file with N-bit data precision. N is 8, 12, or 16; default is 8.
If N is 16, then
.B -lossless
-must also be specified.
+must also be specified. Note that only the PBMPLUS input file format supports
+data precisions other than 8. (For historical reasons,
+.B cjpeg
+allows GIF input files to be converted into 12-bit-per-sample JPEG files, but
+this is not a useful conversion.)
.B Caution:
-12-bit and 16-bit JPEG is not yet widely implemented, so many decoders will be
-unable to view a 12-bit or 16-bit JPEG file at all.
+12-bit and 16-bit data precision is not yet widely implemented, so many
+decoders will be unable to handle a 12-bit-per-sample or 16-bit-per-sample JPEG
+file at all.
.TP
.BI \-lossless " psv[,Pt]"
Create a lossless JPEG file using the specified predictor selection value
@@ -174,11 +179,11 @@ non-zero point transform value right-shifts the input samples by the specified
number of bits, which is effectively a form of lossy color quantization.)
.B Caution:
lossless JPEG is not yet widely implemented, so many decoders will be unable to
-view a lossless JPEG file at all. In most cases, compressing and decompressing
-a lossless JPEG file is considerably slower than compressing and decompressing
-a lossy JPEG file, and lossless JPEG files are much larger than lossy JPEG
-files. Also note that the following features will be unavailable when
-compressing or decompressing a lossless JPEG file:
+handle a lossless JPEG file at all. In most cases, compressing and
+decompressing a lossless JPEG file is considerably slower than compressing and
+decompressing a lossy JPEG file, and lossless JPEG files are much larger than
+lossy JPEG files. Also note that the following features will be unavailable
+when compressing or decompressing a lossless JPEG file:
.IP
- Quality/quantization table selection
.IP
@@ -205,8 +210,8 @@ Any switches used to enable or configure those features will be ignored.
.B \-arithmetic
Use arithmetic coding.
.B Caution:
-arithmetic coded JPEG is not yet widely implemented, so many decoders will be
-unable to view an arithmetic coded JPEG file at all.
+arithmetic-coded JPEG is not yet widely implemented, so many decoders will be
+unable to handle an arithmetic-coded JPEG file at all.
.TP
.B \-dct int
Use accurate integer DCT method (default).
@@ -349,10 +354,10 @@ This example compresses the PPM file foo.ppm with a quality factor of
.I foo.jpg
.SH HINTS
Color GIF files are not the ideal input for JPEG; JPEG is really intended for
-compressing full-color (24-bit) images. In particular, don't try to convert
-cartoons, line drawings, and other images that have only a few distinct
-colors. GIF works great on these, JPEG does not. If you want to convert a
-GIF to JPEG, you should experiment with
+compressing full-color (24-bit through 48-bit) images. In particular, don't
+try to convert cartoons, line drawings, and other images that have only a few
+distinct colors. GIF works great on these; JPEG does not. If you want to
+convert a GIF to JPEG, you should experiment with
.BR cjpeg 's
.B \-quality
and
@@ -407,8 +412,3 @@ relevant to libjpeg-turbo, to wordsmith certain sections, and to describe
features not present in libjpeg.
.SH ISSUES
Not all variants of BMP and Targa file formats are supported.
-.PP
-The
-.B \-targa
-switch is not a bug, it's a feature. (It would be a bug if the Targa format
-designers had not been clueless.)
diff --git a/djpeg.1 b/djpeg.1
index 31431b98..617eacea 100644
--- a/djpeg.1
+++ b/djpeg.1
@@ -1,4 +1,4 @@
-.TH DJPEG 1 "4 November 2020"
+.TH DJPEG 1 "17 June 2024"
.SH NAME
djpeg \- decompress a JPEG file to an image file
.SH SYNOPSIS
@@ -28,47 +28,46 @@ Upper and lower case are equivalent (thus
.B \-BMP
is the same as
.BR \-bmp ).
-British spellings are also accepted (e.g.,
+British spellings are also accepted (e.g.
.BR \-greyscale ),
though for brevity these are not mentioned below.
.PP
The basic switches are:
.TP
.BI \-colors " N"
-Reduce image to at most N colors. This reduces the number of colors used in
-the output image, so that it can be displayed on a colormapped display or
-stored in a colormapped file format. For example, if you have an 8-bit
-display, you'd need to reduce to 256 or fewer colors.
+Reduce image to at most N colors [legacy feature]. This reduces the number of
+colors used in the output image so that it can be stored in a colormapped file
+format. This feature cannot be used when decompressing lossless JPEG images.
.TP
.BI \-quantize " N"
Same as
.BR \-colors .
.B \-colors
-is the recommended name,
+is the recommended name.
.B \-quantize
-is provided only for backwards compatibility.
+is provided only for backward compatibility.
.TP
.B \-fast
-Select recommended processing options for fast, low quality output. (The
-default options are chosen for highest quality output.) Currently, this is
-equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR.
+Select recommended processing options for low-quality output [legacy feature].
+(The default options are chosen for highest-quality output.) Currently, this
+is equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR. On
+modern CPUs, these settings have little or no performance benefit and are
+retained solely for backward compatibility.
.TP
.B \-grayscale
-Force grayscale output even if JPEG file is color. Useful for viewing on
-monochrome displays; also,
-.B djpeg
-runs noticeably faster in this mode.
+Force grayscale output even if JPEG file is full-color. This feature cannot be
+used when decompressing full-color lossless JPEG images.
.TP
.B \-rgb
-Force RGB output even if JPEG file is grayscale.
+Force RGB output even if JPEG file is grayscale. This feature cannot be used
+when decompressing grayscale lossless JPEG images.
.TP
.BI \-scale " M/N"
Scale the output image by a factor M/N. Currently the scale factor must be
M/8, where M is an integer between 1 and 16 inclusive, or any reduced fraction
thereof (such as 1/2, 3/4, etc.) Scaling is handy if the image is larger than
-your screen; also,
-.B djpeg
-runs much faster when scaling down the output.
+your screen. This feature cannot be used when decompressing lossless JPEG
+images.
.TP
.B \-bmp
Select BMP output format (Windows flavor). 8-bit colormapped format is
@@ -77,32 +76,36 @@ emitted if
or
.B \-grayscale
is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color
-format is emitted.
+format is emitted. This format can only be used when decompressing
+8-bit-per-sample JPEG images.
.TP
.B \-gif
-Select GIF output format (LZW-compressed). Since GIF does not support more
-than 256 colors,
+Select GIF output format (LZW-compressed) [legacy feature]. Since GIF does not
+support more than 256 colors,
.B \-colors 256
is assumed (unless you specify a smaller number of colors). If you specify
.BR \-fast,
-the default number of colors is 216.
+the default number of colors is 216. This format can only be used when
+decompressing 8-bit-per-sample or 12-bit-per-sample lossy JPEG images.
.TP
.B \-gif0
-Select GIF output format (uncompressed). Since GIF does not support more than
-256 colors,
+Select GIF output format (uncompressed) [legacy feature]. Since GIF does not
+support more than 256 colors,
.B \-colors 256
is assumed (unless you specify a smaller number of colors). If you specify
.BR \-fast,
-the default number of colors is 216.
+the default number of colors is 216. This format can only be used when
+decompressing 8-bit-per-sample or 12-bit-per-sample lossy JPEG images.
.TP
.B \-os2
-Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is
-emitted if
+Select BMP output format (OS/2 1.x flavor) [legacy feature]. 8-bit colormapped
+format is emitted if
.B \-colors
or
.B \-grayscale
is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color
-format is emitted.
+format is emitted. This format can only be used when decompressing
+8-bit-per-sample JPEG images.
.TP
.B \-pnm
Select PBMPLUS (PPM/PGM) output format (this is the default format).
@@ -111,12 +114,13 @@ PGM is emitted if the JPEG file is grayscale or if
is specified; otherwise PPM is emitted.
.TP
.B \-targa
-Select Targa output format. Grayscale format is emitted if the JPEG file is
-grayscale or if
+Select Targa output format [legacy feature]. Grayscale format is emitted if
+the JPEG file is grayscale or if
.B \-grayscale
is specified; otherwise, colormapped format is emitted if
.B \-colors
-is specified; otherwise, 24-bit full-color format is emitted.
+is specified; otherwise, 24-bit full-color format is emitted. This format can
+only be used when decompressing 8-bit-per-sample JPEG images.
.PP
Switches for advanced users:
.TP
@@ -157,18 +161,18 @@ behavior, whereas the integer methods should give the same results on all
machines.
.TP
.B \-dither fs
-Use Floyd-Steinberg dithering in color quantization.
+Use Floyd-Steinberg dithering when quantizing colors [legacy feature].
.TP
.B \-dither ordered
-Use ordered dithering in color quantization.
+Use ordered dithering when quantizing colors [legacy feature].
.TP
.B \-dither none
-Do not use dithering in color quantization.
-By default, Floyd-Steinberg dithering is applied when quantizing colors; this
-is slow but usually produces the best results. Ordered dither is a compromise
-between speed and quality; no dithering is fast but usually looks awful. Note
-that these switches have no effect unless color quantization is being done.
-Ordered dither is only available in
+Do not use dithering when quantizing colors [legacy feature]. By default,
+Floyd-Steinberg dithering is applied when quantizing colors. This is slower
+but usually produces the best results. Ordered dithering is a compromise
+between speed and quality. No dithering is faster but usually looks awful.
+Note that these switches have no effect unless color quantization is being
+done. Ordered dithering is only available in
.B \-onepass
mode.
.TP
@@ -176,9 +180,9 @@ mode.
Extract ICC color management profile to the specified file.
.TP
.BI \-map " file"
-Quantize to the colors used in the specified image file. This is useful for
-producing multiple files with identical color maps, or for forcing a
-predefined set of colors to be used. The
+Quantize to the colors used in the specified image file [legacy feature]. This
+is useful for producing multiple files with identical color maps, or for
+forcing a predefined set of colors to be used. The
.I file
must be a GIF or PPM file. This option overrides
.B \-colors
@@ -189,14 +193,14 @@ and
Use a faster, lower-quality upsampling routine.
.TP
.B \-onepass
-Use one-pass instead of two-pass color quantization. The one-pass method is
-faster and needs less memory, but it produces a lower-quality image.
+Use one-pass instead of two-pass color quantization [legacy feature]. The
+one-pass method needs less memory, but it produces a lower-quality image.
.B \-onepass
-is ignored unless you also say
+is ignored unless you also specify
.B \-colors
.IR N .
-Also, the one-pass method is always used for grayscale output (the two-pass
-method is no improvement then).
+Also, the one-pass method is always used for grayscale output. (The two-pass
+method has no improvement in that case.)
.TP
.BI \-maxmemory " N"
Set limit for amount of memory to use in processing large images. Value is
@@ -260,36 +264,13 @@ Same as
Print version information and exit.
.SH EXAMPLES
.LP
-This example decompresses the JPEG file foo.jpg, quantizes it to
-256 colors, and saves the output in 8-bit BMP format in foo.bmp:
+This example decompresses the JPEG file foo.jpg and saves the output in 8-bit
+BMP format in foo.bmp:
.IP
-.B djpeg \-colors 256 \-bmp
+.B djpeg \-bmp
.I foo.jpg
.B >
.I foo.bmp
-.SH HINTS
-To get a quick preview of an image, use the
-.B \-grayscale
-and/or
-.B \-scale
-switches.
-.B \-grayscale \-scale 1/8
-is the fastest case.
-.PP
-Several options are available that trade off image quality to gain speed.
-.B \-fast
-turns on the recommended settings.
-.PP
-.B \-dct fast
-and/or
-.B \-nosmooth
-gain speed at a small sacrifice in quality.
-When producing a color-quantized image,
-.B \-onepass \-dither ordered
-is fast but much lower quality than the default behavior.
-.B \-dither none
-may give acceptable results in two-pass mode, but is seldom tolerable in
-one-pass mode.
.SH ENVIRONMENT
.TP
.B JPEGMEM
diff --git a/djpeg.c b/djpeg.c
index 1baeddde..fde2b8e4 100644
--- a/djpeg.c
+++ b/djpeg.c
@@ -107,8 +107,8 @@ usage(void)
#endif
fprintf(stderr, "Switches (names may be abbreviated):\n");
- fprintf(stderr, " -colors N Reduce image to no more than N colors\n");
- fprintf(stderr, " -fast Fast, low-quality processing\n");
+ fprintf(stderr, " -colors N Reduce image to no more than N colors [legacy feature]\n");
+ fprintf(stderr, " -fast Low-quality processing [legacy feature]\n");
fprintf(stderr, " -grayscale Force grayscale output\n");
fprintf(stderr, " -rgb Force RGB output\n");
fprintf(stderr, " -rgb565 Force RGB565 output\n");
@@ -120,13 +120,13 @@ usage(void)
(DEFAULT_FMT == FMT_BMP ? " (default)" : ""));
#endif
#ifdef GIF_SUPPORTED
- fprintf(stderr, " -gif Select GIF output format (LZW-compressed)%s\n",
+ fprintf(stderr, " -gif Select GIF output format (LZW-compressed)%s [legacy feature]\n",
(DEFAULT_FMT == FMT_GIF ? " (default)" : ""));
- fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n",
+ fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s [legacy feature]\n",
(DEFAULT_FMT == FMT_GIF0 ? " (default)" : ""));
#endif
#ifdef BMP_SUPPORTED
- fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n",
+ fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s [legacy feature]\n",
(DEFAULT_FMT == FMT_OS2 ? " (default)" : ""));
#endif
#ifdef PPM_SUPPORTED
@@ -134,7 +134,7 @@ usage(void)
(DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
#endif
#ifdef TARGA_SUPPORTED
- fprintf(stderr, " -targa Select Targa output format%s\n",
+ fprintf(stderr, " -targa Select Targa output format%s [legacy feature]\n",
(DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
#endif
fprintf(stderr, "Switches for advanced users:\n");
@@ -150,16 +150,18 @@ usage(void)
fprintf(stderr, " -dct float Use floating-point DCT method [legacy feature]%s\n",
(JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
#endif
- fprintf(stderr, " -dither fs Use F-S dithering (default)\n");
- fprintf(stderr, " -dither none Don't use dithering in quantization\n");
- fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n");
+ fprintf(stderr, " -dither fs Use Floyd-Steinberg dithering when quantizing colors (default)\n");
+ fprintf(stderr, " [legacy feature]\n");
+ fprintf(stderr, " -dither none Don't use dithering when quantizing colors [legacy feature]\n");
+ fprintf(stderr, " -dither ordered Use ordered dithering when quantizing colors\n");
+ fprintf(stderr, " [legacy feature]\n");
fprintf(stderr, " -icc FILE Extract ICC profile to FILE\n");
#ifdef QUANT_2PASS_SUPPORTED
- fprintf(stderr, " -map FILE Map to colors used in named image file\n");
+ fprintf(stderr, " -map FILE Quantize to colors used in named image file [legacy feature]\n");
#endif
- fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n");
+ fprintf(stderr, " -nosmooth Use faster, lower-quality upsampling\n");
#ifdef QUANT_1PASS_SUPPORTED
- fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n");
+ fprintf(stderr, " -onepass Use 1-pass color quantization (low quality) [legacy feature]\n");
#endif
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
fprintf(stderr, " -maxscans N Maximum number of scans to allow in input file\n");
diff --git a/java/doc/index-all.html b/java/doc/index-all.html
index e83d338f..5937a9ae 100644
--- a/java/doc/index-all.html
+++ b/java/doc/index-all.html
@@ -968,7 +968,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index 893f84cba5f5fd621d7650321a32ffad3fc36506..7b81a746ee657f308df5fc9f88dc88698b202629 100644
GIT binary patch
delta 30
icmaFM_?D3`z?+#xgn@&DgTW^9M#MzEJ{B;&z!v~|E(r1f
delta 30
icmaFM_?D3`z?+#xgn@&DgMlrlFMJ|j9}AdX;0pk8!Uz@s
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index 19801181f87734d71aac767f628d23f2369f000d..27b05a1b1dd4a9231a93e6c3d590d98dc5a7f0fa 100644
GIT binary patch
delta 30
icmdnaw4I4Bz?+#xgn@&DgTW^9M#MzE+bm%Etrq}sb_pK<
delta 30
icmdnaw4I4Bz?+#xgn@&DgMlrlFMJ~3Z5A;7)(Ze>3J600
diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
index fed47de6..e47a2c9f 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
@@ -263,7 +263,7 @@ public class TJCompressor implements Closeable {
}
/**
- * Associate an 8-bit-per-pixel packed-pixel RGB or grayscale source image
+ * Associate an 8-bit-per-sample packed-pixel RGB or grayscale source image
* with this compressor instance.
*
* @param srcImage a BufferedImage instance containing a
diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
index d8c05459..d821a445 100644
--- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
@@ -582,7 +582,7 @@ public class TJDecompressor implements Closeable {
* @param pixelFormat pixel format of the decompressed image (one of
* {@link TJ#PF_RGB TJ.PF_*})
*
- * @return a buffer containing an 8-bit-per-sample packed-pixel decompressed
+ * @return a buffer containing a 12-bit-per-sample packed-pixel decompressed
* image.
*/
public short[] decompress12(int pitch, int pixelFormat) throws TJException {
@@ -655,7 +655,7 @@ public class TJDecompressor implements Closeable {
* @param pixelFormat pixel format of the decompressed image (one of
* {@link TJ#PF_RGB TJ.PF_*})
*
- * @return a buffer containing an 8-bit-per-sample packed-pixel decompressed
+ * @return a buffer containing a 16-bit-per-sample packed-pixel decompressed
* image.
*/
public short[] decompress16(int pitch, int pixelFormat) throws TJException {
diff --git a/jpeglib.h b/jpeglib.h
index bd379cab..17e78333 100644
--- a/jpeglib.h
+++ b/jpeglib.h
@@ -585,11 +585,10 @@ struct jpeg_decompress_struct {
*/
int actual_number_of_colors; /* number of entries in use */
JSAMPARRAY colormap; /* The color map as a 2-D pixel array
- If data_precision is 12 or 16, then this is
- actually a J12SAMPARRAY or a J16SAMPARRAY,
- so callers must type-cast it in order to
- read/write 12-bit or 16-bit samples from/to
- the array. */
+ If data_precision is 12, then this is
+ actually a J12SAMPARRAY, so callers must
+ type-cast it in order to read/write 12-bit
+ samples from/to the array. */
/* State variables: these variables indicate the progress of decompression.
* The application may examine these but must not modify them.
diff --git a/jpegtran.1 b/jpegtran.1
index 5b1ded24..e52259b7 100644
--- a/jpegtran.1
+++ b/jpegtran.1
@@ -1,4 +1,4 @@
-.TH JPEGTRAN 1 "13 July 2021"
+.TH JPEGTRAN 1 "17 June 2024"
.SH NAME
jpegtran \- lossless transformation of JPEG files
.SH SYNOPSIS
@@ -13,7 +13,7 @@ jpegtran \- lossless transformation of JPEG files
.SH DESCRIPTION
.LP
.B jpegtran
-performs various useful transformations of JPEG files.
+performs various useful transformations of lossy (DCT-based) JPEG files.
It can translate the coded representation from one variant of JPEG to another,
for example from baseline JPEG to progressive JPEG or vice versa. It can also
perform some rearrangements of the image data, for example turning an image
@@ -64,13 +64,13 @@ Perform optimization of entropy encoding parameters.
.B \-progressive
Create progressive JPEG file.
.TP
+.B \-arithmetic
+Use arithmetic coding.
+.TP
.BI \-restart " N"
Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
attached to the number.
.TP
-.B \-arithmetic
-Use arithmetic coding.
-.TP
.BI \-scans " file"
Use the scan script given in the specified text file.
.PP
@@ -166,8 +166,8 @@ the current JPEG format; the upper left corner of the selected region must fall
on an iMCU boundary. If it doesn't, then it is silently moved up and/or left
to the nearest iMCU boundary (the lower right corner is unchanged.) Thus, the
output image covers at least the requested region, but it may cover more. The
-adjustment of the region dimensions may be optionally disabled by attaching an
-'f' character ("force") to the width or height number.
+adjustment of the region dimensions may be optionally disabled by attaching
+an 'f' character ("force") to the width or height number.
The image can be losslessly cropped by giving the switch:
.TP
diff --git a/libjpeg.txt b/libjpeg.txt
index 0fe95bb6..f3392c7d 100644
--- a/libjpeg.txt
+++ b/libjpeg.txt
@@ -5,7 +5,7 @@ Copyright (C) 1994-2013, Thomas G. Lane, Guido Vollbeding.
Lossless JPEG Modifications:
Copyright (C) 1999, Ken Murchison.
libjpeg-turbo Modifications:
-Copyright (C) 2010, 2014-2018, 2020, 2022-2023, D. R. Commander.
+Copyright (C) 2010, 2014-2018, 2020, 2022-2024, D. R. Commander.
Copyright (C) 2015, Google, Inc.
For conditions of distribution and use, see the accompanying README.ijg file.
@@ -114,22 +114,24 @@ used by the free LIBTIFF library to support JPEG compression in TIFF.)
12-bit and 16-bit Data Precision
--------------------------------
-The JPEG standard provides for baseline 8-bit and 12-bit DCT processes as well
-as 8-bit, 12-bit, and 16-bit lossless (predictive) processes. This code
-supports 12-bit-per-component lossy or lossless JPEG if you set
-cinfo->data_precision to 12 and 16-bit-per-component lossless JPEG if you set
-cinfo->data_precision to 16. Note that this causes the sample size to be
-larger than a char, so it affects the surrounding application's image data.
-The sample applications cjpeg and djpeg can support 12-bit mode only for PPM,
-PGM, and GIF file formats and 16-bit mode only for PPM and PGM file formats.
+The JPEG standard provides for baseline (8-bit-per-sample) and
+12-bit-per-sample DCT processes as well as 8-bit-per-sample, 12-bit-per-sample,
+and 16-bit-per-sample lossless (predictive) processes. This code supports
+12-bit-per-sample lossy or lossless JPEG if you set cinfo->data_precision to 12
+and 16-bit-per-sample lossless JPEG if you set cinfo->data_precision to 16.
+Note that this causes the sample size to be larger than a char, so it affects
+the surrounding application's image data. The sample applications cjpeg and
+djpeg can support 12-bit data precision only for PPM, PGM, and GIF file formats
+and 16-bit data precision only for PPM and PGM file formats.
-Note that, when 12-bit data precision is enabled, the library always compresses
-in Huffman optimization mode, in order to generate valid Huffman tables. This
-is necessary because our default Huffman tables only cover 8-bit data. If you
-need to output 12-bit files in one pass, you'll have to supply suitable default
-Huffman tables. You may also want to supply your own DCT quantization tables;
-the existing quality-scaling code has been developed for 8-bit use, and
-probably doesn't generate especially good tables for 12-bit.
+Note that, when 12-bit data precision is enabled in lossy mode, the library
+compresses in Huffman optimization mode by default, in order to generate valid
+Huffman tables. This is necessary because our default Huffman tables only
+cover 8-bit data. If you need to output 12-bit-per-sample JPEG files in one
+pass, you'll have to supply suitable default Huffman tables. You may also want
+to supply your own DCT quantization tables; the existing quality-scaling code
+has been developed for 8-bit data precision and probably doesn't generate
+especially good tables for 12-bit data precision.
Functions that are specific to 12-bit data precision have a prefix of "jpeg12_"
instead of "jpeg_" and use the following data types and macros:
@@ -160,7 +162,8 @@ Refer to the descriptions of the data_precision compression and decompression
parameters below for further information.
This documentation uses "J*SAMPLE", "J*SAMPROW", "J*SAMPARRAY", and
-"J*SAMPIMAGE" to generically refer to the 8-bit, 12-bit, or 16-bit data types.
+"J*SAMPIMAGE" to generically refer to the 8-bit-per-sample, 12-bit-per-sample,
+or 16-bit-per-sample data types.
Outline of typical usage
@@ -267,10 +270,9 @@ and the other references mentioned in the README.ijg file.
Pixels are stored by scanlines, with each scanline running from left to
right. The component values for each pixel are adjacent in the row; for
example, R,G,B,R,G,B,R,G,B,... for 24-bit RGB color. Each scanline is an
-array of data type JSAMPLE or J12SAMPLE --- which is typically "unsigned char"
-or "short" (respectively), unless you've changed jmorecfg.h. (You can also
-change the RGB pixel layout, say to B,G,R order, by modifying jmorecfg.h. But
-see the restrictions listed in that file before doing so.)
+array of data type JSAMPLE, J12SAMPLE, or J16SAMPLE --- which is typically
+"unsigned char", "short", or "unsigned short" (respectively) unless you've
+changed jmorecfg.h.
A 2-D array of pixels is formed by making a list of pointers to the starts of
scanlines; so the scanlines need not be physically adjacent in memory. Even
@@ -285,10 +287,11 @@ have it all in memory, but usually it's simplest to process one scanline at
a time.
For best results, source data values should have the precision specified by
-cinfo->data_precision (normally 8 bits). For instance, if you choose to
-compress data that's only 6 bits/channel, you should left-justify each value in
-a byte before passing it to the compressor. If you need to compress data
-that has more than 8 bits/channel, set cinfo->data_precision = 12 or 16.
+cinfo->data_precision (normally 8 bits per sample). For instance, if you
+choose to compress data that's only 6 bits/channel, you should left-justify
+each value in a byte before passing it to the compressor. If you need to
+compress data that has more than 8 bits/channel, set cinfo->data_precision = 12
+or 16.
The data format returned by the decompressor is the same in all details,
@@ -301,8 +304,8 @@ a 2-D J*SAMPARRAY in which each row holds the values of one color component,
that is, colormap[i][j] is the value of the i'th color component for pixel
value (map index) j. Note that since the colormap indexes are stored in
J*SAMPLEs, the maximum number of colors is limited by the size of J*SAMPLE
-(ie, at most 256 colors for 8-bit data precision, 4096 colors for 12-bit data
-precision, and 65536 colors for 16-bit data precision).
+(ie, at most 256 colors for 8-bit data precision and 4096 colors for 12-bit
+data precision).
Compression details
@@ -972,7 +975,7 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
entries are constrained to the range 1..255 for full JPEG baseline
compatibility. In the current implementation, this only makes a
difference for quality settings below 25, and it effectively prevents
- very small/low quality files from being generated. The IJG decoder
+ very small/low-quality files from being generated. The IJG decoder
is capable of reading the non-baseline files generated at low quality
settings when force_baseline is FALSE, but other decoders may not be.
@@ -1079,12 +1082,12 @@ boolean arith_code
If FALSE, use Huffman coding.
int data_precision
- To create a 12-bit-per-component JPEG file, set data_precision to 12
- prior to calling jpeg_start_compress() or using the memory manager,
- then use jpeg12_write_scanlines() or jpeg12_write_raw_data() instead of
- jpeg_write_scanlines() or jpeg_write_raw_data(). To create a
- 16-bit-per-component lossless JPEG file, set data_precision to 16 prior
+ To create a 12-bit-per-sample JPEG file, set data_precision to 12 prior
to calling jpeg_start_compress() or using the memory manager, then use
+ jpeg12_write_scanlines() or jpeg12_write_raw_data() instead of
+ jpeg_write_scanlines() or jpeg_write_raw_data(). To create a
+ 16-bit-per-sample lossless JPEG file, set data_precision to 16 prior to
+ calling jpeg_start_compress() or using the memory manager, then use
jpeg16_write_scanlines() instead of jpeg_write_scanlines(). Note that
16-bit data precision requires lossless mode. (See
jpeg_enable_lossless().)
@@ -1138,7 +1141,10 @@ boolean optimize_coding
Huffman tables. In most cases optimal tables save only a few percent
of file size compared to the default tables. Note that when this is
TRUE, you need not supply Huffman tables at all, and any you do
- supply will be overwritten.
+ supply will be overwritten. This parameter has no effect in
+ progressive mode or lossless mode, in which optimal Huffman tables are
+ always computed, and it defaults to TRUE for 12-bit data precision
+ unless Huffman tables have been supplied.
unsigned int restart_interval
int restart_in_rows
@@ -1303,13 +1309,13 @@ recorded in the source file and need not be supplied by the application.
the postprocessing done on the image to deliver it in a format suitable
for the application's use. Many of the parameters control speed/quality
tradeoffs, in which faster decompression may be obtained at the price of
-a poorer-quality image. The defaults select the highest quality (slowest)
+a poorer-quality image. The defaults select the highest-quality (slowest)
processing.
The following fields in the JPEG object are set by jpeg_read_header() and
may be useful to the application in choosing decompression parameters:
-int data_precision Data precision (bits per component)
+int data_precision Data precision (bits per sample)
If data_precision is 12, then use jpeg12_read_scanlines(),
jpeg12_skip_scanlines(), jpeg12_crop_scanline(), and/or
jpeg12_read_raw_data() instead of jpeg_read_scanlines(),
@@ -1344,11 +1350,8 @@ J_COLOR_SPACE out_color_space
based on jpeg_color_space; typically it will be RGB or grayscale.
The application can change this field to request output in a different
colorspace. For example, set it to JCS_GRAYSCALE to get grayscale
- output from a color file. (This is useful for previewing: grayscale
- output is faster than full color since the color components need not
- be processed.) Note that not all possible color space transforms are
- currently implemented; you may need to extend jdcolor.c if you want an
- unusual conversion.
+ output from a color file. Note that not all possible color space
+ transforms are currently implemented.
unsigned int scale_num, scale_denom
Scale the image by the fraction scale_num/scale_denom. Default is
@@ -1356,31 +1359,33 @@ unsigned int scale_num, scale_denom
are M/8 with all M from 1 to 16, or any reduced fraction thereof (such
as 1/2, 3/4, etc.) (The library design allows for arbitrary
scaling ratios but this is not likely to be implemented any time soon.)
- Smaller scaling ratios permit significantly faster decoding since
- fewer pixels need be processed and a simpler IDCT method can be used.
boolean quantize_colors
+ [legacy feature]
If set TRUE, colormapped output will be delivered. Default is FALSE,
meaning that full-color output will be delivered.
The next three parameters are relevant only if quantize_colors is TRUE.
int desired_number_of_colors
+ [legacy feature]
Maximum number of colors to use in generating a library-supplied color
map (the actual number of colors is returned in a different field).
Default 256. Ignored when the application supplies its own color map.
boolean two_pass_quantize
+ [legacy feature]
If TRUE, an extra pass over the image is made to select a custom color
map for the image. This usually looks a lot better than the one-size-
fits-all colormap that is used otherwise. Default is TRUE. Ignored
when the application supplies its own color map.
J_DITHER_MODE dither_mode
+ [legacy feature]
Selects color dithering method. Supported values are:
- JDITHER_NONE no dithering: fast, very low quality
+ JDITHER_NONE no dithering: faster, very low quality
JDITHER_ORDERED ordered dither: moderate speed and quality
- JDITHER_FS Floyd-Steinberg dither: slow, high quality
+ JDITHER_FS Floyd-Steinberg dither: slower, high quality
Default is JDITHER_FS. (At present, ordered dither is implemented
only in the single-pass, standard-colormap case. If you ask for
ordered dither when two_pass_quantize is TRUE or when you supply
@@ -1395,16 +1400,18 @@ selects a suitable color map and sets these two fields itself.
only accepted for 3-component output color spaces.]
JSAMPARRAY colormap
+ [legacy feature]
The color map, represented as a 2-D pixel array of out_color_components
rows and actual_number_of_colors columns. Ignored if not quantizing.
CAUTION: if the JPEG library creates its own colormap, the storage
pointed to by this field is released by jpeg_finish_decompress().
Copy the colormap somewhere else first, if you want to save it.
- CAUTION: if data_precision is 12 or 16, then this is actually a
- J12SAMPARRAY or a J16SAMPARRAY, so it must be type-cast in order to
- read/write 12-bit or 16-bit samples from/to the array.
+ CAUTION: if data_precision is 12, then this is actually a J12SAMPARRAY,
+ so it must be type-cast in order to read/write 12-bit samples from/to
+ the array.
int actual_number_of_colors
+ [legacy feature]
The number of colors in the color map.
Additional decompression parameters that the application may set include:
@@ -1461,6 +1468,7 @@ boolean do_block_smoothing
boolean enable_1pass_quant
boolean enable_external_quant
boolean enable_2pass_quant
+ [legacy feature]
These are significant only in buffered-image mode, which is
described in its own section below.
@@ -2330,7 +2338,7 @@ limited changes of parameters. ONLY THE FOLLOWING parameter changes are
allowed after jpeg_start_decompress() is called:
* dct_method can be changed before each call to jpeg_start_output().
For example, one could use a fast DCT method for early scans, changing
- to a higher quality method for the final scan.
+ to a higher-quality method for the final scan.
* dither_mode can be changed before each call to jpeg_start_output();
of course this has no impact if not using color quantization. Typically
one would use ordered dither for initial passes, then switch to
@@ -3182,10 +3190,10 @@ This does not count any memory allocated by the application, such as a
buffer to hold the final output image.
The above figures are valid for 8-bit JPEG data precision and a machine with
-32-bit ints. For 12-bit and 16-bit JPEG data, double the size of the strip
-buffers and quantization pixel buffer. The "fixed-size" data will be somewhat
-smaller with 16-bit ints, larger with 64-bit ints. Also, CMYK or other unusual
-color spaces will require different amounts of space.
+32-bit ints. For 12-bit-per-sample and 16-bit-per-sample JPEG data, double the
+size of the strip buffers and quantization pixel buffer. The "fixed-size" data
+will be somewhat smaller with 16-bit ints, larger with 64-bit ints. Also, CMYK
+or other unusual color spaces will require different amounts of space.
The full-image coefficient and pixel buffers, if needed at all, do not
have to be fully RAM resident; you can have the library use temporary
@@ -3211,14 +3219,6 @@ The maximum number of components (color channels) in the image is determined
by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we
expect that few applications will need more than four or so.
-On machines with unusual data type sizes, you may be able to improve
-performance or reduce memory space by tweaking the various typedefs in
-jmorecfg.h. In particular, on some RISC CPUs, access to arrays of "short"s
-is quite slow; consider trading memory for speed by making JCOEF, INT16, and
-UINT16 be "int" or "unsigned int". UINT8 is also a candidate to become int.
-You probably don't want to make J*SAMPLE be int unless you have lots of memory
-to burn.
-
You can reduce the size of the library by compiling out various optional
functions. To do this, undefine xxx_SUPPORTED symbols as necessary.
@@ -3257,9 +3257,7 @@ than 8 bits or short is much bigger than 16 bits. The code should work
equally well with 16- or 32-bit ints.
In a system where these assumptions are not met, you may be able to make the
-code work by modifying the typedefs in jmorecfg.h. However, you will probably
-have difficulty if int is less than 16 bits wide, since references to plain
-int abound in the code.
+code work by modifying the typedefs in jmorecfg.h.
char can be either signed or unsigned, although the code runs faster if an
unsigned char type is available. If char is wider than 8 bits, you will need
diff --git a/usage.txt b/usage.txt
index 2497ce08..71f6ca1f 100644
--- a/usage.txt
+++ b/usage.txt
@@ -1,5 +1,8 @@
-NOTE: This file was modified by The libjpeg-turbo Project to include only
-information relevant to libjpeg-turbo and to wordsmith certain sections.
+This file was part of the Independent JPEG Group's software:
+Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
+libjpeg-turbo Modifications:
+Copyright (C) 2010, 2012, 2014-2017, 2020-2024, D. R. Commander.
+For conditions of distribution and use, see the accompanying README.ijg file.
USAGE instructions for the Independent JPEG Group's JPEG software
=================================================================
@@ -50,9 +53,10 @@ or
This syntax works on all systems, so it is useful for scripts.
The currently supported image file formats are: PPM (PBMPLUS color format),
-PGM (PBMPLUS grayscale format), BMP, GIF, and Targa. cjpeg recognizes the
-input image format automatically, with the exception of some Targa files. You
-have to tell djpeg which format to generate.
+PGM (PBMPLUS grayscale format), BMP, GIF [legacy feature], and Targa [legacy
+feature]. cjpeg recognizes the input image format automatically, with the
+exception of some Targa files. You have to tell djpeg which format to
+generate.
JPEG files are in the defacto standard JFIF file format. There are other,
less widely used JPEG-based file formats, but we don't support them.
@@ -73,12 +77,12 @@ The basic command line switches for cjpeg are:
(See below for more info.)
-grayscale Create monochrome JPEG file from color input. By
- saying -grayscale, you'll get a smaller JPEG file that
- takes less time to process.
+ specifying -grayscale, you'll get a smaller JPEG file
+ that takes less time to process.
- -rgb Create RGB JPEG file.
- Using this switch suppresses the conversion from RGB
- colorspace input to the default YCbCr JPEG colorspace.
+ -rgb Create RGB JPEG file. Using this switch suppresses the
+ conversion from RGB colorspace input to the default
+ YCbCr JPEG colorspace.
-optimize Perform optimization of entropy encoding parameters.
Without this, default encoding parameters are used.
@@ -89,11 +93,12 @@ The basic command line switches for cjpeg are:
-progressive Create progressive JPEG file (see below).
- -targa Input file is Targa format. Targa files that contain
- an "identification" field will not be automatically
- recognized by cjpeg; for such files you must specify
- -targa to make cjpeg treat the input as Targa format.
- For most Targa files, you won't need this switch.
+ -targa Input file is Targa format [legacy feature]. Targa
+ files that contain an "identification" field will not
+ be automatically recognized by cjpeg. For such files,
+ you must specify -targa to make cjpeg treat the input
+ as Targa format. For most Targa files, you won't need
+ this switch.
The -quality switch lets you trade off compressed file size against quality of
the reconstructed image: the higher the quality setting, the larger the JPEG
@@ -162,10 +167,14 @@ Switches for advanced users:
-precision N Create JPEG file with N-bit data precision.
N is 8, 12, or 16; default is 8. If N is 16, then
- -lossless must also be specified. CAUTION: 12-bit and
- 16-bit JPEG is not yet widely implemented, so many
- decoders will be unable to view a 12-bit or 16-bit JPEG
- file at all.
+ -lossless must also be specified. Note that only the
+ PBMPLUS input file format supports data precisions other
+ than 8. (For historical reasons, cjpeg allows GIF input
+ files to be converted into 12-bit-per-sample JPEG files,
+ but this is not a useful conversion.) CAUTION: 12-bit
+ and 16-bit data precision is not yet widely implemented,
+ so many decoders will be unable to handle a
+ 12-bit-per-sample or 16-bit-per-sample JPEG file at all.
-lossless psv[,Pt] Create a lossless JPEG file using the specified
predictor selection value (1 - 7) and optional point
@@ -177,7 +186,7 @@ Switches for advanced users:
number of bits, which is effectively a form of lossy
color quantization.) CAUTION: lossless JPEG is not yet
widely implemented, so many decoders will be unable to
- view a lossless JPEG file at all. In most cases,
+ handle a lossless JPEG file at all. In most cases,
compressing and decompressing a lossless JPEG file is
considerably slower than compressing and decompressing
a lossy JPEG file, and lossless JPEG files are much
@@ -197,9 +206,9 @@ Switches for advanced users:
Any switches used to enable or configure those features
will be ignored.
- -arithmetic Use arithmetic coding. CAUTION: arithmetic coded JPEG
+ -arithmetic Use arithmetic coding. CAUTION: arithmetic-coded JPEG
is not yet widely implemented, so many decoders will
- be unable to view an arithmetic coded JPEG file at
+ be unable to handle an arithmetic-coded JPEG file at
all.
-dct int Use accurate integer DCT method (default).
@@ -240,6 +249,9 @@ Switches for advanced users:
behavior, whereas the integer methods should give the
same results on all machines.
+ -icc FILE Embed ICC color management profile contained in the
+ specified file.
+
-restart N Emit a JPEG restart marker every N MCU rows, or every
N MCU blocks (samples in lossless mode) if "B" is
attached to the number. -restart 0 (the default) means
@@ -255,9 +267,23 @@ Switches for advanced users:
For example, -max 4m selects 4000000 bytes. If more
space is needed, an error will occur.
- -verbose Enable debug printout. More -v's give more printout.
+ -memdst Compress to memory instead of a file. This feature was
+ implemented mainly as a way of testing the in-memory
+ destination manager (jpeg_mem_dest()), but it is also
+ useful for benchmarking, since it reduces the I/O
+ overhead.
+
+ -report Report compression progress.
+
+ -strict Treat all warnings as fatal. Enabling this option will
+ cause the compressor to abort if an LZW-compressed GIF
+ input image contains incomplete or corrupt image data.
+
+ -verbose Enable debug printout. More -v's give more output.
or -debug Also, version information is printed at startup.
+ -version Print version information and exit.
+
The -restart option inserts extra markers that allow a JPEG decoder to
resynchronize after a transmission error. Without restart markers, any damage
to a compressed file will usually ruin the image from the point of the error
@@ -300,64 +326,78 @@ DJPEG DETAILS
The basic command line switches for djpeg are:
- -colors N Reduce image to at most N colors. This reduces the
- or -quantize N number of colors used in the output image, so that it
- can be displayed on a colormapped display or stored in
- a colormapped file format. For example, if you have
- an 8-bit display, you'd need to reduce to 256 or fewer
- colors. (-colors is the recommended name, -quantize
- is provided only for backwards compatibility.)
+ -colors N Reduce image to at most N colors [legacy feature].
+ or -quantize N This reduces the number of colors used in the output
+ image so that it can be stored in a colormapped file
+ format. This feature cannot be used when decompressing
+ lossless JPEG images. (-colors is the recommended
+ name. -quantize is provided only for backward
+ compatibility.)
- -fast Select recommended processing options for fast, low
- quality output. (The default options are chosen for
- highest quality output.) Currently, this is equivalent
- to "-dct fast -nosmooth -onepass -dither ordered".
+ -fast Select recommended processing options for low-quality
+ output [legacy feature]. (The default options are
+ chosen for highest-quality output.) Currently, this is
+ equivalent to "-dct fast -nosmooth -onepass -dither
+ ordered". On modern CPUs, these settings have little
+ or no performance benefit and are retained solely for
+ backward compatibility.
- -grayscale Force grayscale output even if JPEG file is color.
- Useful for viewing on monochrome displays; also,
- djpeg runs noticeably faster in this mode.
+ -grayscale Force grayscale output even if JPEG file is full-color.
+ This feature cannot be used when decompressing
+ full-color lossless JPEG images.
- -rgb Force RGB output even if JPEG file is grayscale.
+ -rgb Force RGB output even if JPEG file is grayscale. This
+ feature cannot be used when decompressing grayscale
+ lossless JPEG images.
- -scale M/N Scale the output image by a factor M/N. Currently
- the scale factor must be M/8, where M is an integer
- between 1 and 16 inclusive, or any reduced fraction
- thereof (such as 1/2, 3/4, etc. Scaling is handy if
- the image is larger than your screen; also, djpeg runs
- much faster when scaling down the output.
+ -scale M/N Scale the output image by a factor M/N. Currently the
+ scale factor must be M/8, where M is an integer between
+ 1 and 16 inclusive, or any reduced fraction thereof
+ (such as 1/2, 3/4, etc.) Scaling is handy if the image
+ is larger than your screen. This feature cannot be
+ used when decompressing lossless JPEG images.
-bmp Select BMP output format (Windows flavor). 8-bit
colormapped format is emitted if -colors or -grayscale
is specified, or if the JPEG file is grayscale;
- otherwise, 24-bit full-color format is emitted.
+ otherwise, 24-bit full-color format is emitted. This
+ format can only be used when decompressing
+ 8-bit-per-sample JPEG images.
- -gif Select GIF output format (LZW-compressed). Since GIF
- does not support more than 256 colors, -colors 256 is
- assumed (unless you specify a smaller number of
- colors). If you specify -fast, the default number of
- colors is 216.
+ -gif Select GIF output format (LZW-compressed) [legacy
+ feature]. Since GIF does not support more than 256
+ colors, -colors 256 is assumed (unless you specify a
+ smaller number of colors). If you specify -fast, the
+ default number of colors is 216. This format can only
+ be used when decompressing 8-bit-per-sample or
+ 12-bit-per-sample lossy JPEG images.
- -gif0 Select GIF output format (uncompressed). Since GIF
- does not support more than 256 colors, -colors 256 is
- assumed (unless you specify a smaller number of
- colors). If you specify -fast, the default number of
- colors is 216.
+ -gif0 Select GIF output format (uncompressed) [legacy
+ feature]. Since GIF does not support more than 256
+ colors, -colors 256 is assumed (unless you specify a
+ smaller number of colors). If you specify -fast, the
+ default number of colors is 216. This format can only
+ be used when decompressing 8-bit-per-sample or
+ 12-bit-per-sample lossy JPEG images.
- -os2 Select BMP output format (OS/2 1.x flavor). 8-bit
- colormapped format is emitted if -colors or -grayscale
- is specified, or if the JPEG file is grayscale;
- otherwise, 24-bit full-color format is emitted.
+ -os2 Select BMP output format (OS/2 1.x flavor) [legacy
+ feature]. 8-bit colormapped format is emitted if
+ -colors or -grayscale is specified, or if the JPEG file
+ is grayscale; otherwise, 24-bit full-color format is
+ emitted. This format can only be used when
+ decompressing 8-bit-per-sample JPEG images.
-pnm Select PBMPLUS (PPM/PGM) output format (this is the
default format). PGM is emitted if the JPEG file is
- grayscale or if -grayscale is specified; otherwise
- PPM is emitted.
+ grayscale or if -grayscale is specified; otherwise PPM
+ is emitted.
- -targa Select Targa output format. Grayscale format is
- emitted if the JPEG file is grayscale or if
+ -targa Select Targa output format [legacy feature]. Grayscale
+ format is emitted if the JPEG file is grayscale or if
-grayscale is specified; otherwise, colormapped format
is emitted if -colors is specified; otherwise, 24-bit
- full-color format is emitted.
+ full-color format is emitted. This format can only be
+ used when decompressing 8-bit-per-sample JPEG images.
Switches for advanced users:
@@ -401,32 +441,39 @@ Switches for advanced users:
behavior, whereas the integer methods should give the
same results on all machines.
- -dither fs Use Floyd-Steinberg dithering in color quantization.
- -dither ordered Use ordered dithering in color quantization.
- -dither none Do not use dithering in color quantization.
- By default, Floyd-Steinberg dithering is applied when
- quantizing colors; this is slow but usually produces
- the best results. Ordered dither is a compromise
- between speed and quality; no dithering is fast but
- usually looks awful. Note that these switches have
- no effect unless color quantization is being done.
- Ordered dither is only available in -onepass mode.
+ -dither fs Use Floyd-Steinberg dithering when quantizing colors
+ [legacy feature].
+ -dither ordered Use ordered dithering when quantizing colors [legacy
+ feature].
+ -dither none Do not use dithering when quantizing colors [legacy
+ feature]. By default, Floyd-Steinberg dithering is
+ applied when quantizing colors. This is slower but
+ usually produces the best results. Ordered dithering
+ is a compromise between speed and quality. No
+ dithering is faster but usually looks awful. Note that
+ these switches have no effect unless color quantization
+ is being done. Ordered dithering is only available in
+ -onepass mode.
- -map FILE Quantize to the colors used in the specified image
- file. This is useful for producing multiple files
- with identical color maps, or for forcing a predefined
- set of colors to be used. The FILE must be a GIF
- or PPM file. This option overrides -colors and
- -onepass.
+ -icc FILE Extract ICC color management profile to the specified
+ file.
+
+ -map FILE Quantize to the colors used in the specified image file
+ [legacy feature]. This is useful for producing
+ multiple files with identical color maps, or for
+ forcing a predefined set of colors to be used. The
+ FILE must be a GIF or PPM file. This option overrides
+ -colors and -onepass.
-nosmooth Use a faster, lower-quality upsampling routine.
- -onepass Use one-pass instead of two-pass color quantization.
- The one-pass method is faster and needs less memory,
- but it produces a lower-quality image. -onepass is
- ignored unless you also say -colors N. Also,
- the one-pass method is always used for grayscale
- output (the two-pass method is no improvement then).
+ -onepass Use one-pass instead of two-pass color quantization
+ [legacy feature]. The one-pass method needs less
+ memory, but it produces a lower-quality image.
+ -onepass is ignored unless you also specify -colors N.
+ Also, the one-pass method is always used for grayscale
+ output. (The two-pass method has no improvement in
+ that case.)
-maxmemory N Set limit for amount of memory to use in processing
large images. Value is in thousands of bytes, or
@@ -434,18 +481,62 @@ Switches for advanced users:
For example, -max 4m selects 4000000 bytes. If more
space is needed, an error will occur.
- -verbose Enable debug printout. More -v's give more printout.
+ -maxscans N Abort if the JPEG image contains more than N scans.
+ This feature demonstrates a method by which
+ applications can guard against denial-of-service
+ attacks instigated by specially-crafted malformed JPEG
+ images containing numerous scans with missing image
+ data or image data consisting only of "EOB runs" (a
+ feature of progressive JPEG images that allows
+ potentially hundreds of thousands of adjoining
+ zero-value pixels to be represented using only a few
+ bytes.) Attempting to decompress such malformed JPEG
+ images can cause excessive CPU activity, since the
+ decompressor must fully process each scan (even if the
+ scan is corrupt) before it can proceed to the next
+ scan.
+
+ -memsrc Load input file into memory before decompressing. This
+ feature was implemented mainly as a way of testing the
+ in-memory source manager (jpeg_mem_src().)
+
+ -report Report decompression progress.
+
+ -skip Y0,Y1 Decompress all rows of the JPEG image except those
+ between Y0 and Y1 (inclusive.) Note that if
+ decompression scaling is being used, then Y0 and Y1 are
+ relative to the scaled image dimensions.
+
+ -crop WxH+X+Y Decompress only a rectangular subregion of the image,
+ starting at point X,Y with width W and height H. If
+ necessary, X will be shifted left to the nearest iMCU
+ boundary, and the width will be increased accordingly.
+ Note that if decompression scaling is being used, then
+ X, Y, W, and H are relative to the scaled image
+ dimensions. Currently this option only works with the
+ PBMPLUS (PPM/PGM), GIF, and Targa output formats.
+
+ -strict Treat all warnings as fatal. This feature also
+ demonstrates a method by which applications can guard
+ against attacks instigated by specially-crafted
+ malformed JPEG images. Enabling this option will cause
+ the decompressor to abort if the JPEG image contains
+ incomplete or corrupt image data.
+
+ -verbose Enable debug printout. More -v's give more output.
or -debug Also, version information is printed at startup.
+ -version Print version information and exit.
+
HINTS FOR CJPEG
Color GIF files are not the ideal input for JPEG; JPEG is really intended for
-compressing full-color (24-bit) images. In particular, don't try to convert
-cartoons, line drawings, and other images that have only a few distinct
-colors. GIF works great on these, JPEG does not. If you want to convert a
-GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options
-to get a satisfactory conversion. -smooth 10 or so is often helpful.
+compressing full-color (24-bit through 48-bit) images. In particular, don't
+try to convert cartoons, line drawings, and other images that have only a few
+distinct colors. GIF works great on these; JPEG does not. If you want to
+convert a GIF to JPEG, you should experiment with cjpeg's -quality and -smooth
+options to get a satisfactory conversion. -smooth 10 or so is often helpful.
Avoid running an image through a series of JPEG compression/decompression
cycles. Image quality loss will accumulate; after ten or so cycles the image
@@ -460,20 +551,6 @@ is often a lot more than it is on larger files. (At present, -optimize
mode is always selected when generating progressive JPEG files.)
-HINTS FOR DJPEG
-
-To get a quick preview of an image, use the -grayscale and/or -scale switches.
-"-grayscale -scale 1/8" is the fastest case.
-
-Several options are available that trade off image quality to gain speed.
-"-fast" turns on the recommended settings.
-
-"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality.
-When producing a color-quantized image, "-onepass -dither ordered" is fast but
-much lower quality than the default behavior. "-dither none" may give
-acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
-
-
HINTS FOR BOTH PROGRAMS
If the memory needed by cjpeg or djpeg exceeds the limit specified by
@@ -489,12 +566,12 @@ explicit -maxmemory switch.
JPEGTRAN
-jpegtran performs various useful transformations of JPEG files.
-It can translate the coded representation from one variant of JPEG to another,
-for example from baseline JPEG to progressive JPEG or vice versa. It can also
-perform some rearrangements of the image data, for example turning an image
-from landscape to portrait format by rotation. For EXIF files and JPEG files
-containing Exif data, you may prefer to use exiftran instead.
+jpegtran performs various useful transformations of lossy (DCT-based) JPEG
+files. It can translate the coded representation from one variant of JPEG to
+another, for example from baseline JPEG to progressive JPEG or vice versa. It
+can also perform some rearrangements of the image data, for example turning an
+image from landscape to portrait format by rotation. For EXIF files and JPEG
+files containing Exif data, you may prefer to use exiftran instead.
jpegtran works by rearranging the compressed data (DCT coefficients), without
ever fully decoding the image. Therefore, its transformations are lossless:
@@ -650,10 +727,15 @@ The default behavior is -copy comments. (Note: in IJG releases v6 and v6a,
jpegtran always did the equivalent of -copy none.)
Additional switches recognized by jpegtran are:
- -outfile filename
+ -icc FILE
-maxmemory N
+ -maxscans N
+ -outfile filename
+ -report
+ -strict
-verbose
-debug
+ -version
These work the same as in cjpeg or djpeg.
From a8aaaf5d5bbe64e4e809cca4b0d0253c4d0cfb66 Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 21 Jun 2024 10:58:17 -0400
Subject: [PATCH 075/135] cjpeg -verbose: Print PBMPLUS input file precision
This gives the user a hint as to whether converting the input file into
a JPEG file with a particular data precision will result in a loss of
precision. Also modify usage.txt and the cjpeg man page to warn the
user about that possibility.
---
cderror.h | 10 +++++-----
cjpeg.1 | 8 +++++++-
rdppm.c | 10 +++++-----
usage.txt | 13 +++++++++----
4 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/cderror.h b/cderror.h
index 1bac441c..cd3e8064 100644
--- a/cderror.h
+++ b/cderror.h
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2021, D. R. Commander.
+ * Copyright (C) 2021, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -76,10 +76,10 @@ JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
-JMESSAGE(JTRC_PGM, "%ux%u PGM image")
-JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
-JMESSAGE(JTRC_PPM, "%ux%u PPM image")
-JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
+JMESSAGE(JTRC_PGM, "%ux%u PGM image (maximum color value = %u)")
+JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image (maximum color value = %u)")
+JMESSAGE(JTRC_PPM, "%ux%u PPM image (maximum color value = %u)")
+JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image (maximum color value = %u)")
JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
diff --git a/cjpeg.1 b/cjpeg.1
index 6d329ed9..491e71ef 100644
--- a/cjpeg.1
+++ b/cjpeg.1
@@ -157,7 +157,13 @@ must also be specified. Note that only the PBMPLUS input file format supports
data precisions other than 8. (For historical reasons,
.B cjpeg
allows GIF input files to be converted into 12-bit-per-sample JPEG files, but
-this is not a useful conversion.)
+this is not a useful conversion.) Note also that PBMPLUS input files are
+silently scaled to the target data precision, even if it is lower than the
+precision of the input file. Passing an argument of
+.B \-verbose
+to
+.B cjpeg
+will cause it to print information about the precision of the input file.
.B Caution:
12-bit and 16-bit data precision is not yet widely implemented, so many
decoders will be unable to handle a 12-bit-per-sample or 16-bit-per-sample JPEG
diff --git a/rdppm.c b/rdppm.c
index 84e26f7b..8a9afdf8 100644
--- a/rdppm.c
+++ b/rdppm.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2009 by Bill Allombert, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015-2017, 2020-2023, D. R. Commander.
+ * Copyright (C) 2015-2017, 2020-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -707,7 +707,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (cinfo->in_color_space == JCS_UNKNOWN ||
cinfo->in_color_space == JCS_RGB)
cinfo->in_color_space = JCS_GRAYSCALE;
- TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
if (cinfo->in_color_space == JCS_GRAYSCALE)
source->pub.get_pixel_rows = get_text_gray_row;
else if (IsExtRGB(cinfo->in_color_space))
@@ -722,7 +722,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
case '3': /* it's a text-format PPM file */
if (cinfo->in_color_space == JCS_UNKNOWN)
cinfo->in_color_space = JCS_EXT_RGB;
- TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
if (IsExtRGB(cinfo->in_color_space))
source->pub.get_pixel_rows = get_text_rgb_row;
else if (cinfo->in_color_space == JCS_CMYK)
@@ -736,7 +736,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (cinfo->in_color_space == JCS_UNKNOWN ||
cinfo->in_color_space == JCS_RGB)
cinfo->in_color_space = JCS_GRAYSCALE;
- TRACEMS2(cinfo, 1, JTRC_PGM, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
if (maxval > 255) {
if (cinfo->in_color_space == JCS_GRAYSCALE)
source->pub.get_pixel_rows = get_word_gray_row;
@@ -766,7 +766,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
case '6': /* it's a raw-format PPM file */
if (cinfo->in_color_space == JCS_UNKNOWN)
cinfo->in_color_space = JCS_EXT_RGB;
- TRACEMS2(cinfo, 1, JTRC_PPM, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
if (maxval > 255) {
if (IsExtRGB(cinfo->in_color_space))
source->pub.get_pixel_rows = get_word_rgb_row;
diff --git a/usage.txt b/usage.txt
index 71f6ca1f..ca4ca62c 100644
--- a/usage.txt
+++ b/usage.txt
@@ -171,10 +171,15 @@ Switches for advanced users:
PBMPLUS input file format supports data precisions other
than 8. (For historical reasons, cjpeg allows GIF input
files to be converted into 12-bit-per-sample JPEG files,
- but this is not a useful conversion.) CAUTION: 12-bit
- and 16-bit data precision is not yet widely implemented,
- so many decoders will be unable to handle a
- 12-bit-per-sample or 16-bit-per-sample JPEG file at all.
+ but this is not a useful conversion.) Note also that
+ PBMPLUS input files are silently scaled to the target
+ data precision, even if it is lower than the precision
+ of the input file. Passing an argument of -verbose to
+ cjpeg will cause it to print information about the
+ precision of the input file. CAUTION: 12-bit and 16-bit
+ data precision is not yet widely implemented, so many
+ decoders will be unable to handle a 12-bit-per-sample or
+ 16-bit-per-sample JPEG file at all.
-lossless psv[,Pt] Create a lossless JPEG file using the specified
predictor selection value (1 - 7) and optional point
From bb3ab5315706b7e7e8fe07c59b97674a09100c4b Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 19 Jun 2024 17:27:01 -0400
Subject: [PATCH 076/135] cjpeg: Don't enable lossless until precision known
jpeg_enable_lossless() checks the point transform value against the data
precision, so we need to defer calling jpeg_enable_lossless() until
after all command-line options have been parsed.
---
ChangeLog.md | 5 +++++
cjpeg.c | 10 ++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 7780f415..ac4f86c7 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -19,6 +19,11 @@ prefetching caused a segfault if the `fill_input_buffer()` method in the
calling application's custom source manager incorrectly returned `FALSE` in
response to a prematurely-terminated JPEG data stream.
+3. Fixed an issue in cjpeg whereby, when generating a 12-bit-per-sample or
+16-bit-per-sample lossless JPEG image, specifying a point transform value
+greater than 7 resulted in an error ("Invalid progressive/lossless parameters")
+unless the `-precision` option was specified before the `-lossless` option.
+
3.0.3
=====
diff --git a/cjpeg.c b/cjpeg.c
index 44c39bec..cf0e12d5 100644
--- a/cjpeg.c
+++ b/cjpeg.c
@@ -290,7 +290,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
int argn;
char *arg;
#ifdef C_LOSSLESS_SUPPORTED
- int psv, pt = 0;
+ int psv = 0, pt = 0;
#endif
boolean force_baseline;
boolean simple_progressive;
@@ -403,7 +403,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
string */
if (*ptr)
sscanf(ptr, "%d", &pt);
- jpeg_enable_lossless(cinfo, psv, pt);
+
+ /* We must postpone execution until data_precision is known. */
#else
fprintf(stderr, "%s: sorry, lossless output was not compiled\n",
progname);
@@ -589,6 +590,11 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
jpeg_simple_progression(cinfo);
#endif
+#ifdef C_LOSSLESS_SUPPORTED
+ if (psv != 0) /* process -lossless */
+ jpeg_enable_lossless(cinfo, psv, pt);
+#endif
+
#ifdef C_MULTISCAN_FILES_SUPPORTED
if (scansarg != NULL) /* process -scans if it was present */
if (!read_scan_script(cinfo, scansarg))
From 51d021bf0168ee2d6ad79f70248a88b7f57156d0 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 24 Jun 2024 12:17:22 -0400
Subject: [PATCH 077/135] TurboJPEG: Fix 12-bit-per-sample arith-coded compr
(Regression introduced by 7bb958b732e6b4f261595e2d1527d46964fe3aed)
Because of 7bb958b732e6b4f261595e2d1527d46964fe3aed, the TurboJPEG
compression and encoding functions no longer transfer the value of
TJPARAM_OPTIMIZE into cinfo->data_precision unless the data precision
is 8. The intent of that was to prevent using_std_huff_tables() from
being called more than once when reusing the same compressor object to
generate multiple 12-bit-per-sample JPEG images. However, because
cinfo->optimize_coding is always set to TRUE by jpeg_set_defaults() if
the data precision is 12, calling applications that use 12-bit data
precision had to unset cinfo->optimize_coding if they set
cinfo->arith_code after calling jpeg_set_defaults(). Because of
7bb958b732e6b4f261595e2d1527d46964fe3aed, the TurboJPEG API stopped
doing that except with 8-bit data precision. Thus, attempting to
generate a 12-bit-per-sample arithmetic-coded lossy JPEG image using
the TurboJPEG API failed with "Requested features are incompatible."
Since the compressor will always fail if cinfo->arith_code and
cinfo->optimize_coding are both set, and since cinfo->optimize_coding
has no relevance for arithmetic coding, the most robust and user-proof
solution is for jinit_c_master_control() to set cinfo->optimize_coding
to FALSE if cinfo->arith_code is TRUE.
This commit also:
- modifies TJBench so that it no longer reports that it is using
optimized baseline entropy coding in modes where that setting
is irrelevant,
- amends the cjpeg documentation to clarify that -optimize is implied
when specifying -progressive or '-precision 12' without -arithmetic,
and
- prevents jpeg_set_defaults() from uselessly checking the value of
cinfo->arith_code immediately after it has been set to FALSE.
---
ChangeLog.md | 4 ++++
cjpeg.1 | 15 +++++++++++++--
java/TJBench.java | 7 +++++--
jcmaster.c | 31 +++++++++++++++++--------------
jcparam.c | 2 +-
libjpeg.txt | 9 +++++----
tjbench.c | 4 +++-
usage.txt | 6 +++++-
8 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index ac4f86c7..9561ff16 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -24,6 +24,10 @@ response to a prematurely-terminated JPEG data stream.
greater than 7 resulted in an error ("Invalid progressive/lossless parameters")
unless the `-precision` option was specified before the `-lossless` option.
+4. Fixed a regression introduced by 3.0.3[3] that made it impossible for
+calling applications to generate 12-bit-per-sample arithmetic-coded lossy JPEG
+images using the TurboJPEG API.
+
3.0.3
=====
diff --git a/cjpeg.1 b/cjpeg.1
index 491e71ef..ca184571 100644
--- a/cjpeg.1
+++ b/cjpeg.1
@@ -1,4 +1,4 @@
-.TH CJPEG 1 "21 June 2024"
+.TH CJPEG 1 "24 June 2024"
.SH NAME
cjpeg \- compress an image file to a JPEG file
.SH SYNOPSIS
@@ -60,7 +60,11 @@ decompression are unaffected by
.BR \-optimize .
.TP
.B \-progressive
-Create progressive JPEG file (see below).
+Create progressive JPEG file (see below). Implies
+.B \-optimize
+unless
+.B \-arithmetic
+is also specified.
.TP
.B \-targa
Input file is Targa format [legacy feature]. Targa files that contain an
@@ -168,6 +172,13 @@ will cause it to print information about the precision of the input file.
12-bit and 16-bit data precision is not yet widely implemented, so many
decoders will be unable to handle a 12-bit-per-sample or 16-bit-per-sample JPEG
file at all.
+.IP
+.B \-precision\ 12
+implies
+.B \-optimize
+unless
+.B \-arithmetic
+is also specified.
.TP
.BI \-lossless " psv[,Pt]"
Create a lossless JPEG file using the specified predictor selection value
diff --git a/java/TJBench.java b/java/TJBench.java
index 03238acd..16d782ae 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2014, 2016-2019, 2021-2023 D. R. Commander.
+ * Copyright (C)2009-2014, 2016-2019, 2021-2024 D. R. Commander.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -926,7 +926,6 @@ final class TJBench {
System.out.println("Using fastest DCT/IDCT algorithm\n");
fastDCT = true;
} else if (argv[i].equalsIgnoreCase("-optimize")) {
- System.out.println("Using optimized baseline entropy coding\n");
optimize = true;
xformOpt |= TJTransform.OPT_OPTIMIZE;
} else if (argv[i].equalsIgnoreCase("-progressive")) {
@@ -1127,6 +1126,10 @@ final class TJBench {
}
}
+ if (optimize && !progressive && !arithmetic && !lossless &&
+ precision != 12)
+ System.out.println("Using optimized baseline entropy coding\n");
+
if (precision == 16 && !lossless)
throw new Exception("-lossless must be specified along with -precision 16");
if (precision != 8 && doYUV)
diff --git a/jcmaster.c b/jcmaster.c
index 16101976..5d891783 100644
--- a/jcmaster.c
+++ b/jcmaster.c
@@ -751,22 +751,25 @@ jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
/* Validate parameters, determine derived values */
initial_setup(cinfo, transcode_only);
- if (cinfo->master->lossless || /* TEMPORARY HACK ??? */
- (cinfo->progressive_mode && !cinfo->arith_code))
- cinfo->optimize_coding = TRUE; /* assume default tables no good for
- progressive mode or lossless mode */
- for (i = 0; i < NUM_HUFF_TBLS; i++) {
- if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
- cinfo->ac_huff_tbl_ptrs[i] != NULL) {
- empty_huff_tables = FALSE;
- break;
+ if (cinfo->arith_code)
+ cinfo->optimize_coding = FALSE;
+ else {
+ if (cinfo->master->lossless || /* TEMPORARY HACK ??? */
+ cinfo->progressive_mode)
+ cinfo->optimize_coding = TRUE; /* assume default tables no good for
+ progressive mode or lossless mode */
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
+ if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
+ cinfo->ac_huff_tbl_ptrs[i] != NULL) {
+ empty_huff_tables = FALSE;
+ break;
+ }
}
+ if (cinfo->data_precision == 12 && !cinfo->optimize_coding &&
+ (empty_huff_tables || using_std_huff_tables(cinfo)))
+ cinfo->optimize_coding = TRUE; /* assume default tables no good for
+ 12-bit data precision */
}
- if (cinfo->data_precision == 12 && !cinfo->arith_code &&
- !cinfo->optimize_coding &&
- (empty_huff_tables || using_std_huff_tables(cinfo)))
- cinfo->optimize_coding = TRUE; /* assume default tables no good for 12-bit
- data precision */
/* Initialize my private state */
if (transcode_only) {
diff --git a/jcparam.c b/jcparam.c
index d1dee4da..1d6e2254 100644
--- a/jcparam.c
+++ b/jcparam.c
@@ -233,7 +233,7 @@ jpeg_set_defaults(j_compress_ptr cinfo)
* tables will be computed. This test can be removed if default tables
* are supplied that are valid for the desired precision.
*/
- if (cinfo->data_precision == 12 && !cinfo->arith_code)
+ if (cinfo->data_precision == 12)
cinfo->optimize_coding = TRUE;
/* By default, use the simpler non-cosited sampling alignment */
diff --git a/libjpeg.txt b/libjpeg.txt
index f3392c7d..01a486b7 100644
--- a/libjpeg.txt
+++ b/libjpeg.txt
@@ -1141,10 +1141,11 @@ boolean optimize_coding
Huffman tables. In most cases optimal tables save only a few percent
of file size compared to the default tables. Note that when this is
TRUE, you need not supply Huffman tables at all, and any you do
- supply will be overwritten. This parameter has no effect in
- progressive mode or lossless mode, in which optimal Huffman tables are
- always computed, and it defaults to TRUE for 12-bit data precision
- unless Huffman tables have been supplied.
+ supply will be overwritten. Optimal Huffman tables are always
+ computed, and this parameter has no effect, in progressive mode or
+ lossless mode or with 12-bit data precision (unless Huffman tables have
+ been supplied.) This parameter also has no effect when using
+ arithmetic coding.
unsigned int restart_interval
int restart_in_rows
diff --git a/tjbench.c b/tjbench.c
index 9dc64278..e00d55db 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -1047,7 +1047,6 @@ int main(int argc, char *argv[])
printf("Using fastest DCT/IDCT algorithm\n\n");
fastDCT = 1;
} else if (!strcasecmp(argv[i], "-optimize")) {
- printf("Using optimized baseline entropy coding\n\n");
optimize = 1;
xformOpt |= TJXOPT_OPTIMIZE;
} else if (!strcasecmp(argv[i], "-progressive")) {
@@ -1197,6 +1196,9 @@ int main(int argc, char *argv[])
}
}
+ if (optimize && !progressive && !arithmetic && !lossless && precision != 12)
+ printf("Using optimized baseline entropy coding\n\n");
+
if (precision == 16 && !lossless) {
printf("ERROR: -lossless must be specified along with -precision 16\n");
retval = -1; goto bailout;
diff --git a/usage.txt b/usage.txt
index ca4ca62c..9d8af6fe 100644
--- a/usage.txt
+++ b/usage.txt
@@ -91,7 +91,8 @@ The basic command line switches for cjpeg are:
memory. Image quality and speed of decompression are
unaffected by -optimize.
- -progressive Create progressive JPEG file (see below).
+ -progressive Create progressive JPEG file (see below). Implies
+ -optimize unless -arithmetic is also specified.
-targa Input file is Targa format [legacy feature]. Targa
files that contain an "identification" field will not
@@ -181,6 +182,9 @@ Switches for advanced users:
decoders will be unable to handle a 12-bit-per-sample or
16-bit-per-sample JPEG file at all.
+ "-precision 12" implies -optimize unless -arithmetic is
+ also specified.
+
-lossless psv[,Pt] Create a lossless JPEG file using the specified
predictor selection value (1 - 7) and optional point
transform (0 - {precision}-1, where {precision} is the
From e287a35762cba20e2253efb3260007289a2f2186 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 4 Jul 2024 10:03:50 -0400
Subject: [PATCH 078/135] Build: Put gastest.o in ${CMAKE_BINARY_DIR}/simd
Closes #776
---
simd/CMakeLists.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/simd/CMakeLists.txt b/simd/CMakeLists.txt
index 02379559..9c063d56 100644
--- a/simd/CMakeLists.txt
+++ b/simd/CMakeLists.txt
@@ -366,7 +366,8 @@ if(NOT NEON_INTRINSICS)
separate_arguments(CMAKE_ASM_FLAGS_SEP UNIX_COMMAND "${CMAKE_ASM_FLAGS}")
execute_process(COMMAND ${CMAKE_ASM_COMPILER} ${CMAKE_ASM_FLAGS_SEP}
-x assembler-with-cpp -c ${CMAKE_CURRENT_BINARY_DIR}/gastest.S
- RESULT_VARIABLE RESULT OUTPUT_VARIABLE OUTPUT ERROR_VARIABLE ERROR)
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE RESULT
+ OUTPUT_VARIABLE OUTPUT ERROR_VARIABLE ERROR)
if(NOT RESULT EQUAL 0)
message(WARNING "GAS appears to be broken. Using the full Neon SIMD intrinsics implementation.")
set(NEON_INTRINSICS 1 CACHE INTERNAL "" FORCE)
From 0566d51e092f8c75e868d54ffa3670ce0949a46e Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 9 Jul 2024 17:18:53 -0400
Subject: [PATCH 079/135] GitHub Actions: Specify Monterey for macOS build
The Big Sur hosted runner is no longer available.
---
.github/workflows/build.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e8e30198..4608a46b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -51,7 +51,7 @@ jobs:
run: |
aws s3 sync --acl public-read --delete $HOME/src/ljt.nightly/latest/files/ s3://libjpeg-turbo-pr/${{env.BRANCH}}/${{github.job}}/
macos:
- runs-on: macos-11
+ runs-on: macos-12
steps:
- name: Set global environment variables
run: |
@@ -61,7 +61,7 @@ jobs:
- name: Set up build
run: |
brew install yasm md5sha1sum
- sudo xcode-select -s /Applications/Xcode_12.4.app
+ sudo xcode-select -s /Applications/Xcode_13.2.1.app
mkdir -p $HOME/src/ljt.nightly
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git -b $BRANCH $HOME/src/buildscripts
- name: Configure GPG signing
From 8db0312668f986891f65af9dbcc94e7e92ede099 Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 2 Aug 2024 08:45:36 -0400
Subject: [PATCH 080/135] example.c: Write correct dimensions to PPM header
The dimensions in the PPM header of the output file generated by
'example decompress' were always 640 x 480, regardless of the size of
the JPEG image being decompressed. Our regression tests (which this
commit also fixes) missed the bug because they decompressed the
640 x 480 image generated by 'example compress'.
Fixes #778
---
CMakeLists.txt | 8 +++-----
example.c | 4 ++--
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9952b24d..c105b22c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1259,7 +1259,7 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_JPEG_CROP cdb35ff4b4519392690ea040c56ea99c)
set(MD5_JPEG_EXAMPLE_COMPRESS 5e502da0c3c0f957a58c536f31e973dc)
- set(MD5_PPM_EXAMPLE_DECOMPRESS 2ff0e8505ee6e0ffaeb24037d5650b57)
+ set(MD5_PPM_EXAMPLE_DECOMPRESS 70194fdcb73370ee7ba0db868d0c6fc8)
else()
set(cjpeg cjpeg)
set(djpeg djpeg)
@@ -1343,7 +1343,7 @@ foreach(libtype ${TEST_LIBTYPES})
set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
set(MD5_JPEG_EXAMPLE_COMPRESS 95d4d72e2ef127332654c2599afb47bf)
- set(MD5_PPM_EXAMPLE_DECOMPRESS 6fdde7301575bfd711e295b969b6b3de)
+ set(MD5_PPM_EXAMPLE_DECOMPRESS dea1d7bbc37e39adf628342c86096641)
endif()
# CC: null SAMP: fullsize FDCT: islow ENT: huff
@@ -1673,9 +1673,7 @@ foreach(libtype ${TEST_LIBTYPES})
add_test(NAME example-${sample_bits}bit-${libtype}-decompress
COMMAND example${suffix} decompress ${EXAMPLE_12BIT_ARG}
- ${testout}-example.jpg ${testout}-example.ppm)
- set_tests_properties(example-${sample_bits}bit-${libtype}-decompress
- PROPERTIES DEPENDS example-${sample_bits}bit-${libtype}-compress)
+ ${TESTIMAGES}/${TESTORIG} ${testout}-example.ppm)
add_test(NAME example-${sample_bits}bit-${libtype}-decompress-cmp
COMMAND md5cmp ${MD5_PPM_EXAMPLE_DECOMPRESS} ${testout}-example.ppm)
set_tests_properties(example-${sample_bits}bit-${libtype}-decompress-cmp
diff --git a/example.c b/example.c
index 78b658a0..43d5f521 100644
--- a/example.c
+++ b/example.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software.
* Copyright (C) 1992-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2022-2023, D. R. Commander.
+ * Copyright (C) 2017, 2019, 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -443,7 +443,7 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
*/
/* emit header for raw PPM format */
- fprintf(outfile, "P6\n%d %d\n%d\n", WIDTH, HEIGHT,
+ fprintf(outfile, "P6\n%u %u\n%d\n", cinfo->image_width, cinfo->image_height,
cinfo->data_precision == 12 ? MAXJ12SAMPLE : MAXJSAMPLE);
/* Step 4: set parameters for decompression */
From b4336c3afb575d4390365a1be0f7dbabb0cc5161 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 13 Aug 2024 15:41:54 -0400
Subject: [PATCH 081/135] Work around valgrind/MSan SIMD false positives
Referring to
https://sourceforge.net/p/libjpeg-turbo/bugs/48,
https://sourceforge.net/p/libjpeg-turbo/bugs/82,
#15, #238, #253, and #619,
valgrind and MSan have failed to properly detect data initialization by
libjpeg-turbo's x86 SIMD extensions for the entire 14 years that
libjpeg-turbo has been a project, resulting in false positives unless
libjpeg-turbo is built with WITH_SIMD=0 or run with JSIMD_FORCENONE=1.
This commit introduces a new C preprocessor macro (ZERO_BUFFERS) that,
if set, causes libjpeg-turbo to zero certain buffers in order to work
around the specific valgrind/MSan test failures caused by the
aforementioned false positives. This allows us to more closely
approximate the production configuration of libjpeg-turbo when testing
with valgrind or MSan.
Closes #781
---
.github/workflows/build.yml | 3 ++-
fuzz/cjpeg.cc | 7 -------
fuzz/compress.cc | 7 -------
fuzz/compress12.cc | 7 -------
fuzz/compress12_lossless.cc | 7 -------
fuzz/compress16_lossless.cc | 7 -------
fuzz/compress_lossless.cc | 7 -------
fuzz/compress_yuv.cc | 7 -------
fuzz/decompress.cc | 7 -------
fuzz/decompress_yuv.cc | 7 -------
fuzz/transform.cc | 7 -------
jchuff.c | 4 ++++
jcphuff.c | 10 ++++++++++
jdatadst-tj.c | 5 +++--
jmemnobs.c | 6 +++---
jpegint.h | 6 ++++++
turbojpeg.c | 8 ++++----
17 files changed, 32 insertions(+), 80 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4608a46b..cfd5ffc3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -167,6 +167,7 @@ jobs:
uses: actions/checkout@v4
- name: Set up build
run: |
+ sudo apt install -y nasm
sudo sysctl vm.mmap_rnd_bits=28
- name: Build
env:
@@ -174,7 +175,7 @@ jobs:
run: |
mkdir build
pushd build
- cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O0 -g -fsanitize=memory -fsanitize-memory-param-retval -fno-sanitize-recover=all -fPIE" -DWITH_SIMD=0 ..
+ cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O0 -g -fsanitize=memory -fsanitize-memory-param-retval -fno-sanitize-recover=all -fPIE -DZERO_BUFFERS=1" -DREQUIRE_SIMD=1 ..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
make test
diff --git a/fuzz/cjpeg.cc b/fuzz/cjpeg.cc
index ee7b7ab8..4d598f35 100644
--- a/fuzz/cjpeg.cc
+++ b/fuzz/cjpeg.cc
@@ -57,13 +57,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
(char *)"-targa", NULL
};
int fd = -1;
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
snprintf(filename, FILENAME_MAX, "/tmp/libjpeg-turbo_cjpeg_fuzz.XXXXXX");
if ((fd = mkstemp(filename)) < 0 || write(fd, data, size) < 0)
diff --git a/fuzz/compress.cc b/fuzz/compress.cc
index f59f66d1..daad0471 100644
--- a/fuzz/compress.cc
+++ b/fuzz/compress.cc
@@ -59,13 +59,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ TJPF_GRAY, TJSAMP_GRAY, 50 },
{ TJPF_CMYK, TJSAMP_440, 40 }
};
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
snprintf(filename, FILENAME_MAX, "/tmp/libjpeg-turbo_compress_fuzz.XXXXXX");
if ((fd = mkstemp(filename)) < 0 || write(fd, data, size) < 0)
diff --git a/fuzz/compress12.cc b/fuzz/compress12.cc
index 8a082999..12cb7565 100644
--- a/fuzz/compress12.cc
+++ b/fuzz/compress12.cc
@@ -60,13 +60,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ TJPF_GRAY, TJSAMP_GRAY, 50 },
{ TJPF_CMYK, TJSAMP_440, 40 }
};
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
snprintf(filename, FILENAME_MAX, "/tmp/libjpeg-turbo_compress12_fuzz.XXXXXX");
if ((fd = mkstemp(filename)) < 0 || write(fd, data, size) < 0)
diff --git a/fuzz/compress12_lossless.cc b/fuzz/compress12_lossless.cc
index 76a0a0d9..3ac10f7c 100644
--- a/fuzz/compress12_lossless.cc
+++ b/fuzz/compress12_lossless.cc
@@ -59,13 +59,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ TJPF_GRAY, 6, 3 },
{ TJPF_CMYK, 7, 0 }
};
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
snprintf(filename, FILENAME_MAX, "/tmp/libjpeg-turbo_compress_fuzz.XXXXXX");
if ((fd = mkstemp(filename)) < 0 || write(fd, data, size) < 0)
diff --git a/fuzz/compress16_lossless.cc b/fuzz/compress16_lossless.cc
index aa6037ec..35cfff6f 100644
--- a/fuzz/compress16_lossless.cc
+++ b/fuzz/compress16_lossless.cc
@@ -59,13 +59,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ TJPF_GRAY, 6, 3 },
{ TJPF_CMYK, 7, 0 }
};
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
snprintf(filename, FILENAME_MAX, "/tmp/libjpeg-turbo_compress_fuzz.XXXXXX");
if ((fd = mkstemp(filename)) < 0 || write(fd, data, size) < 0)
diff --git a/fuzz/compress_lossless.cc b/fuzz/compress_lossless.cc
index 7c2bb790..d094cad2 100644
--- a/fuzz/compress_lossless.cc
+++ b/fuzz/compress_lossless.cc
@@ -58,13 +58,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ TJPF_GRAY, 6, 3 },
{ TJPF_CMYK, 7, 0 }
};
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
snprintf(filename, FILENAME_MAX, "/tmp/libjpeg-turbo_compress_fuzz.XXXXXX");
if ((fd = mkstemp(filename)) < 0 || write(fd, data, size) < 0)
diff --git a/fuzz/compress_yuv.cc b/fuzz/compress_yuv.cc
index 0b12e0ce..ddde0b85 100644
--- a/fuzz/compress_yuv.cc
+++ b/fuzz/compress_yuv.cc
@@ -58,13 +58,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ TJPF_BGR, TJSAMP_GRAY, 60 },
{ TJPF_GRAY, TJSAMP_GRAY, 50 }
};
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
snprintf(filename, FILENAME_MAX, "/tmp/libjpeg-turbo_compress_yuv_fuzz.XXXXXX");
if ((fd = mkstemp(filename)) < 0 || write(fd, data, size) < 0)
diff --git a/fuzz/decompress.cc b/fuzz/decompress.cc
index eadc7342..bb14c6bb 100644
--- a/fuzz/decompress.cc
+++ b/fuzz/decompress.cc
@@ -44,13 +44,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
necessary to achieve full coverage. */
enum TJPF pixelFormats[NUMPF] =
{ TJPF_RGB, TJPF_BGRX, TJPF_GRAY, TJPF_CMYK };
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
if ((handle = tj3Init(TJINIT_DECOMPRESS)) == NULL)
goto bailout;
diff --git a/fuzz/decompress_yuv.cc b/fuzz/decompress_yuv.cc
index 4e869df6..36252104 100644
--- a/fuzz/decompress_yuv.cc
+++ b/fuzz/decompress_yuv.cc
@@ -44,13 +44,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
necessary to achieve full coverage. */
enum TJPF pixelFormats[NUMPF] =
{ TJPF_BGR, TJPF_XRGB, TJPF_GRAY };
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
if ((handle = tj3Init(TJINIT_DECOMPRESS)) == NULL)
goto bailout;
diff --git a/fuzz/transform.cc b/fuzz/transform.cc
index 8d2e6aca..84a8ccec 100644
--- a/fuzz/transform.cc
+++ b/fuzz/transform.cc
@@ -39,13 +39,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
size_t dstSizes[1] = { 0 }, maxBufSize;
int width = 0, height = 0, jpegSubsamp, i;
tjtransform transforms[1];
-#if defined(__has_feature) && __has_feature(memory_sanitizer)
- char env[18] = "JSIMD_FORCENONE=1";
-
- /* The libjpeg-turbo SIMD extensions produce false positives with
- MemorySanitizer. */
- putenv(env);
-#endif
if ((handle = tj3Init(TJINIT_TRANSFORM)) == NULL)
goto bailout;
diff --git a/jchuff.c b/jchuff.c
index 488c9b5c..8cdd5bd3 100644
--- a/jchuff.c
+++ b/jchuff.c
@@ -542,6 +542,10 @@ encode_one_block_simd(working_state *state, JCOEFPTR block, int last_dc_val,
JOCTET _buffer[BUFSIZE], *buffer;
int localbuf = 0;
+#ifdef ZERO_BUFFERS
+ memset(_buffer, 0, sizeof(_buffer));
+#endif
+
LOAD_BUFFER()
buffer = jsimd_huff_encode_one_block(state, buffer, block, last_dc_val,
diff --git a/jcphuff.c b/jcphuff.c
index 484e2d85..58287328 100644
--- a/jcphuff.c
+++ b/jcphuff.c
@@ -650,6 +650,11 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
size_t bits[8 / SIZEOF_SIZE_T];
int max_coef_bits = cinfo->data_precision + 2;
+#ifdef ZERO_BUFFERS
+ memset(values_unaligned, 0, sizeof(values_unaligned));
+ memset(bits, 0, sizeof(bits));
+#endif
+
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
@@ -915,6 +920,11 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
size_t zerobits, signbits;
size_t bits[16 / SIZEOF_SIZE_T];
+#ifdef ZERO_BUFFERS
+ memset(absvalues_unaligned, 0, sizeof(absvalues_unaligned));
+ memset(bits, 0, sizeof(bits));
+#endif
+
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
diff --git a/jdatadst-tj.c b/jdatadst-tj.c
index cce263af..270b2c2c 100644
--- a/jdatadst-tj.c
+++ b/jdatadst-tj.c
@@ -19,6 +19,7 @@
*/
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
+#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"
@@ -92,7 +93,7 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
/* Try to allocate new buffer with double size */
nextsize = dest->bufsize * 2;
- nextbuffer = (JOCTET *)malloc(nextsize);
+ nextbuffer = (JOCTET *)MALLOC(nextsize);
if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
@@ -183,7 +184,7 @@ jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
if (*outbuffer == NULL || *outsize == 0) {
if (alloc) {
/* Allocate initial buffer */
- dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
+ dest->newbuffer = *outbuffer = (unsigned char *)MALLOC(OUTPUT_BUF_SIZE);
if (dest->newbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
*outsize = OUTPUT_BUF_SIZE;
diff --git a/jmemnobs.c b/jmemnobs.c
index cd6571ba..692775f5 100644
--- a/jmemnobs.c
+++ b/jmemnobs.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1992-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017-2018, D. R. Commander.
+ * Copyright (C) 2017-2018, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -31,7 +31,7 @@
GLOBAL(void *)
jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject)
{
- return (void *)malloc(sizeofobject);
+ return (void *)MALLOC(sizeofobject);
}
GLOBAL(void)
@@ -48,7 +48,7 @@ jpeg_free_small(j_common_ptr cinfo, void *object, size_t sizeofobject)
GLOBAL(void *)
jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject)
{
- return (void *)malloc(sizeofobject);
+ return (void *)MALLOC(sizeofobject);
}
GLOBAL(void)
diff --git a/jpegint.h b/jpegint.h
index 7c28da3d..a90493f9 100644
--- a/jpegint.h
+++ b/jpegint.h
@@ -446,6 +446,12 @@ struct jpeg_color_quantizer {
#undef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#ifdef ZERO_BUFFERS
+#define MALLOC(size) calloc(1, size)
+#else
+#define MALLOC(size) malloc(size)
+#endif
+
/* We assume that right shift corresponds to signed division by 2 with
* rounding towards minus infinity. This is correct for typical "arithmetic
diff --git a/turbojpeg.c b/turbojpeg.c
index 3c936160..6c484d5b 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -879,7 +879,7 @@ DLLEXPORT void tjFree(unsigned char *buf)
/* TurboJPEG 3+ */
DLLEXPORT void *tj3Alloc(size_t bytes)
{
- return malloc(bytes);
+ return MALLOC(bytes);
}
/* TurboJPEG 1.2+ */
@@ -1292,7 +1292,7 @@ DLLEXPORT int tj3EncodeYUVPlanes8(tjhandle handle, const unsigned char *srcBuf,
for (i = 0; i < cinfo->num_components; i++) {
compptr = &cinfo->comp_info[i];
- _tmpbuf[i] = (JSAMPLE *)malloc(
+ _tmpbuf[i] = (JSAMPLE *)MALLOC(
PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
compptr->h_samp_factor, 32) *
cinfo->max_v_samp_factor + 32);
@@ -1311,7 +1311,7 @@ DLLEXPORT int tj3EncodeYUVPlanes8(tjhandle handle, const unsigned char *srcBuf,
compptr->h_samp_factor, 32) * row];
}
_tmpbuf2[i] =
- (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
+ (JSAMPLE *)MALLOC(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
compptr->v_samp_factor + 32);
if (!_tmpbuf2[i])
THROW("Memory allocation failure");
@@ -2399,7 +2399,7 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
}
}
if (usetmpbuf) {
- if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
+ if ((_tmpbuf = (JSAMPLE *)MALLOC(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
THROW("Memory allocation failure");
ptr = _tmpbuf;
for (i = 0; i < dinfo->num_components; i++) {
From 0c23b0ad60a0589f384c791aa32fe07ceb419036 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 14 Aug 2024 09:21:54 -0400
Subject: [PATCH 082/135] Various doc tweaks
- "Optimized baseline entropy coding" = "Huffman table optimization"
"Optimized baseline entropy coding" was meant to emphasize that the
feature is only useful when generating baseline (single-scan lossy
8-bit-per-sample Huffman-coded) JPEG images, because it is
automatically enabled when generating Huffman-coded progressive
(multi-scan), 12-bit-per-sample, and lossless JPEG images. However,
Huffman table optimization isn't actually an integral part of those
non-baseline modes. You can forego Huffman table optimization with
12-bit data precision if you supply your own Huffman tables. The spec
doesn't require it with progressive or lossless mode, either, although
our implementation does. Furthermore, "baseline" describes more than
just the type of entropy coding used. It was incorrect to say that
optimized "baseline" entropy coding is automatically enabled for
Huffman-coded progressive, 12-bit-per-sample, and lossless JPEG
images, since those are clearly not baseline images.
- "Progressive entropy coding" = "Progressive JPEG"
"Progressive" describes more than just the type of entropy coding
used. (In fact, both Huffman-coded and arithmetic-coded images can be
progressive.)
- Mention that TJPARAM_OPTIMIZE/TJ.PARAM_OPTIMIZE can be used with
lossless transformation as well.
- General wordsmithing
- Formatting tweaks
---
ChangeLog.md | 28 +-
doc/html/group___turbo_j_p_e_g.html | 161 +++---
doc/html/structtjtransform.html | 2 +-
java/TJBench.java | 18 +-
java/doc/index-all.html | 82 ++-
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 419 ++++++++-------
.../turbojpeg/TJCustomFilter.html | 2 +-
.../turbojpeg/TJDecompressor.html | 42 +-
.../libjpegturbo/turbojpeg/TJTransform.html | 95 ++--
.../org/libjpegturbo/turbojpeg/YUVImage.html | 24 +-
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 367 +++++++------
.../turbojpeg/TJCustomFilter.java | 4 +-
.../turbojpeg/TJDecompressor.java | 44 +-
.../libjpegturbo/turbojpeg/TJTransform.java | 73 ++-
java/org/libjpegturbo/turbojpeg/YUVImage.java | 26 +-
tjbench.c | 18 +-
turbojpeg.h | 481 ++++++++++--------
20 files changed, 1016 insertions(+), 870 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 9561ff16..6962f5f7 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -69,10 +69,10 @@ easier to detect actual security issues, should they arise in the future.
`TJ.PARAM_MAXMEMORY` in the TurboJPEG Java API) and a corresponding TJBench
option (`-maxmemory`) for specifying the maximum amount of memory (in
megabytes) that will be allocated for intermediate buffers, which are used with
-progressive JPEG compression and decompression, optimized baseline entropy
-coding, lossless JPEG compression, and lossless transformation. The new
-parameter and option serve the same purpose as the `max_memory_to_use` field in
-the `jpeg_memory_mgr` struct in the libjpeg API, the `JPEGMEM` environment
+progressive JPEG compression and decompression, Huffman table optimization,
+lossless JPEG compression, and lossless transformation. The new parameter and
+option serve the same purpose as the `max_memory_to_use` field in the
+`jpeg_memory_mgr` struct in the libjpeg API, the `JPEGMEM` environment
variable, and the cjpeg/djpeg/jpegtran `-maxmemory` option.
3. Introduced a new parameter (`TJPARAM_MAXPIXELS` in the TurboJPEG C API and
@@ -210,11 +210,10 @@ through pointer arguments.
- `TJFLAG_LIMITSCANS`/`TJ.FLAG_LIMITSCANS` has been reimplemented as an
API parameter (`TJPARAM_SCANLIMIT`/`TJ.PARAM_SCANLIMIT`) that allows the number
of scans to be specified.
- - Optimized baseline entropy coding (the computation of optimal Huffman
-tables, as opposed to using the default Huffman tables) can now be specified,
-using a new API parameter (`TJPARAM_OPTIMIZE`/`TJ.PARAM_OPTIMIZE`), a new
-transform option (`TJXOPT_OPTIMIZE`/`TJTransform.OPT_OPTIMIZE`), and a new
-TJBench option (`-optimize`.)
+ - Huffman table optimization can now be specified using a new API
+parameter (`TJPARAM_OPTIMIZE`/`TJ.PARAM_OPTIMIZE`), a new transform option
+(`TJXOPT_OPTIMIZE`/`TJTransform.OPT_OPTIMIZE`), and a new TJBench option
+(`-optimize`.)
- Arithmetic entropy coding can now be specified or queried, using a new
API parameter (`TJPARAM_ARITHMETIC`/`TJ.PARAM_ARITHMETIC`), a new transform
option (`TJXOPT_ARITHMETIC`/`TJTransform.OPT_ARITHMETIC`), and a new TJBench
@@ -1041,12 +1040,11 @@ encounters a warning from the underlying libjpeg API (the default behavior is
to allow the operation to complete unless a fatal error is encountered.)
5. Introduced a new flag in the TurboJPEG C and Java APIs (`TJFLAG_PROGRESSIVE`
-and `TJ.FLAG_PROGRESSIVE`, respectively) that causes the library to use
-progressive entropy coding in JPEG images generated by compression and
-transform operations. Additionally, a new transform option
-(`TJXOPT_PROGRESSIVE` in the C API and `TJTransform.OPT_PROGRESSIVE` in the
-Java API) has been introduced, allowing progressive entropy coding to be
-enabled for selected transforms in a multi-transform operation.
+and `TJ.FLAG_PROGRESSIVE`, respectively) that causes compression and transform
+operations to generate progressive JPEG images. Additionally, a new transform
+option (`TJXOPT_PROGRESSIVE` in the C API and `TJTransform.OPT_PROGRESSIVE` in
+the Java API) has been introduced, allowing progressive JPEG images to be
+generated by selected transforms in a multi-transform operation.
6. Introduced a new transform option in the TurboJPEG API (`TJXOPT_COPYNONE` in
the C API and `TJTransform.OPT_COPYNONE` in the Java API) that allows the
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index 1cb09e14..33704245 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -117,31 +117,31 @@ Macros
This option will prevent tj3Transform() from copying any extra markers (including EXIF and ICC profile data) from the source image to the destination image.
+
Do not copy any extra markers (including EXIF and ICC profile data) from the source image to the destination image.
Compute the scaled value of dimension using the given scaling factor.
@@ -563,8 +563,8 @@ scalingFactor).
-
This option will enable arithmetic entropy coding in the JPEG image generated by this particular transform.
-
Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding (the default), but it will reduce decompression performance considerably. Can be combined with TJXOPT_PROGRESSIVE.
+
Enable arithmetic entropy coding in the destination image.
+
Arithmetic entropy coding generally improves compression relative to Huffman entropy coding (the default), but it reduces decompression performance considerably. Can be combined with TJXOPT_PROGRESSIVE.
@@ -580,7 +580,7 @@ scalingFactor).
-
This option will prevent tj3Transform() from copying any extra markers (including EXIF and ICC profile data) from the source image to the destination image.
+
Do not copy any extra markers (including EXIF and ICC profile data) from the source image to the destination image.
This option will discard the color data in the source image and produce a grayscale destination image.
+
Discard the color data in the source image, and generate a grayscale destination image.
@@ -629,7 +629,7 @@ scalingFactor).
-
This option will prevent tj3Transform() from outputting a JPEG image for this particular transform.
+
Do not generate a destination image.
(This can be used in conjunction with a custom filter to capture the transformed DCT coefficients without transcoding them.)
@@ -646,8 +646,8 @@ scalingFactor).
-
This option will enable optimized baseline entropy coding in the JPEG image generated by this particular transform.
-
Optimized baseline entropy coding will improve compression slightly (generally 5% or less.)
+
Enable Huffman table optimization for the destination image.
+
Huffman table optimization improves compression slightly (generally 5% or less.)
@@ -663,8 +663,8 @@ scalingFactor).
-
This option will cause tj3Transform() to return an error if the transform is not perfect.
-
Lossless transforms operate on MCU blocks, whose size depends on the level of chrominance subsampling used (see tjMCUWidth and tjMCUHeight.) If the image's width or height is not evenly divisible by the MCU block size, then there will be partial MCU blocks on the right and/or bottom edges. It is not possible to move these partial MCU blocks to the top or left of the image, so any transform that would require that is "imperfect." If this option is not specified, then any partial MCU blocks that cannot be transformed will be left in place, which will create odd-looking strips on the right or bottom edge of the image.
+
This option causes tj3Transform() to return an error if the transform is not perfect.
+
Lossless transforms operate on MCU blocks, the size of which depends on the level of chrominance subsampling used (see tjMCUWidth and tjMCUHeight.) If the image's width or height is not evenly divisible by the MCU block size, then there will be partial MCU blocks on the right and/or bottom edges. It is not possible to move these partial MCU blocks to the top or left of the image, so any transform that would require that is "imperfect." If this option is not specified, then any partial MCU blocks that cannot be transformed will be left in place, which will create odd-looking strips on the right or bottom edge of the image.
@@ -680,8 +680,8 @@ scalingFactor).
-
This option will enable progressive entropy coding in the JPEG image generated by this particular transform.
-
Progressive entropy coding will generally improve compression relative to baseline entropy coding (the default), but it will reduce decompression performance considerably. Can be combined with TJXOPT_ARITHMETIC. Implies TJXOPT_OPTIMIZE unless TJXOPT_ARITHMETIC is also specified.
+
Generate a progressive destination image instead of a single-scan destination image.
+
Progressive JPEG images generally have better compression ratios than single-scan JPEG images (much better if the image has large areas of solid color), but progressive JPEG decompression is considerably slower than single-scan JPEG decompression. Can be combined with TJXOPT_ARITHMETIC. Implies TJXOPT_OPTIMIZE unless TJXOPT_ARITHMETIC is also specified.
@@ -697,7 +697,7 @@ scalingFactor).
-
This option will cause tj3Transform() to discard any partial MCU blocks that cannot be transformed.
+
Discard any partial MCU blocks that cannot be transformed.
@@ -750,19 +750,19 @@ scalingFactor).
JPEG colorspaces.
Enumerator
TJCS_RGB
RGB colorspace.
-
When compressing the JPEG image, the R, G, and B components in the source image are reordered into image planes, but no colorspace conversion or subsampling is performed. RGB JPEG images can be compressed from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats, but they cannot be compressed from or decompressed to planar YUV images.
+
When generating the JPEG image, the R, G, and B components in the source image are reordered into image planes, but no colorspace conversion or subsampling is performed. RGB JPEG images can be generated from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats, but they cannot be generated from or decompressed to planar YUV images.
TJCS_YCbCr
YCbCr colorspace.
-
YCbCr is not an absolute colorspace but rather a mathematical transformation of RGB designed solely for storage and transmission. YCbCr images must be converted to RGB before they can actually be displayed. In the YCbCr colorspace, the Y (luminance) component represents the black & white portion of the original image, and the Cb and Cr (chrominance) components represent the color portion of the original image. Originally, the analog equivalent of this transformation allowed the same signal to drive both black & white and color televisions, but JPEG images use YCbCr primarily because it allows the color data to be optionally subsampled for the purposes of reducing network or disk usage. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images can be compressed from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats. YCbCr JPEG images can also be compressed from and decompressed to planar YUV images.
+
YCbCr is not an absolute colorspace but rather a mathematical transformation of RGB designed solely for storage and transmission. YCbCr images must be converted to RGB before they can be displayed. In the YCbCr colorspace, the Y (luminance) component represents the black & white portion of the original image, and the Cb and Cr (chrominance) components represent the color portion of the original image. Historically, the analog equivalent of this transformation allowed the same signal to be displayed to both black & white and color televisions, but JPEG images use YCbCr primarily because it allows the color data to be optionally subsampled in order to reduce network and disk usage. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images can be generated from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats. YCbCr JPEG images can also be generated from and decompressed to planar YUV images.
TJCS_GRAY
Grayscale colorspace.
-
The JPEG image retains only the luminance data (Y component), and any color data from the source image is discarded. Grayscale JPEG images can be compressed from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats, or they can be compressed from and decompressed to planar YUV images.
+
The JPEG image retains only the luminance data (Y component), and any color data from the source image is discarded. Grayscale JPEG images can be generated from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats, or they can be generated from and decompressed to planar YUV images.
TJCS_CMYK
CMYK colorspace.
-
When compressing the JPEG image, the C, M, Y, and K components in the source image are reordered into image planes, but no colorspace conversion or subsampling is performed. CMYK JPEG images can only be compressed from and decompressed to packed-pixel images with the CMYK pixel format.
+
When generating the JPEG image, the C, M, Y, and K components in the source image are reordered into image planes, but no colorspace conversion or subsampling is performed. CMYK JPEG images can only be generated from and decompressed to packed-pixel images with the CMYK pixel format.
TJCS_YCCK
YCCK colorspace.
-
YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a mathematical transformation of CMYK designed solely for storage and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be reversibly transformed into YCCK, and as with YCbCr, the chrominance components in the YCCK pixels can be subsampled without incurring major perceptual loss. YCCK JPEG images can only be compressed from and decompressed to packed-pixel images with the CMYK pixel format.
+
YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a mathematical transformation of CMYK designed solely for storage and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be reversibly transformed into YCCK, and as with YCbCr, the chrominance components in the YCCK pixels can be subsampled without incurring major perceptual loss. YCCK JPEG images can only be generated from and decompressed to packed-pixel images with the CMYK pixel format.
0[default] Use smooth upsampling when decompressing a JPEG image that was compressed using chrominance subsampling. This creates a smooth transition between neighboring chrominance components in order to reduce upsampling artifacts in the decompressed image.
+
0[default] Use smooth upsampling when decompressing a JPEG image that was generated using chrominance subsampling. This creates a smooth transition between neighboring chrominance components in order to reduce upsampling artifacts in the decompressed image.
1 Use the fastest chrominance upsampling algorithm available, which may combine upsampling with color conversion.
@@ -889,48 +889,49 @@ scalingFactor).
The "fast" and "accurate" DCT/IDCT algorithms perform similarly on modern x86/x86-64 CPUs that support AVX2 instructions.
The "fast" algorithm is generally only about 5-15% faster than the "accurate" algorithm on other types of CPUs.
The difference in accuracy between the "fast" and "accurate" algorithms is the most pronounced at JPEG quality levels above 90 and tends to be more pronounced with decompression than with compression.
-
The "fast" algorithm degrades and is not fully accelerated for JPEG quality levels above 97, so it will be slower than the "accurate" algorithm.
+
For JPEG quality levels above 97, the "fast" algorithm degrades and is not fully accelerated, so it is slower than the "accurate" algorithm.
0[default] The JPEG image will use the default Huffman tables.
-
1 Optimal Huffman tables will be computed for the JPEG image. For lossless transformation, this can also be specified using TJXOPT_OPTIMIZE.
+
1 Optimal Huffman tables will be computed for the JPEG image. For lossless transformation, this can also be specified using TJXOPT_OPTIMIZE.
-
Optimized baseline entropy coding will improve compression slightly (generally 5% or less), but it will reduce compression performance considerably.
+
Huffman table optimization improves compression slightly (generally 5% or less), but it reduces compression performance considerably.
-
TJPARAM_PROGRESSIVE
Progressive entropy coding.
+
TJPARAM_PROGRESSIVE
Progressive JPEG.
+
In a progressive JPEG image, the DCT coefficients are split across multiple "scans" of increasing quality. Thus, a low-quality scan containing the lowest-frequency DCT coefficients can be transmitted first and refined with subsequent higher-quality scans containing higher-frequency DCT coefficients. When using Huffman entropy coding, the progressive JPEG format also provides an "end-of-bands (EOB) run" feature that allows large groups of zeroes, potentially spanning multiple MCU blocks, to be represented using only a few bytes.
Value
-
0[default for compression, lossless transformation] The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) baseline entropy coding.
-
1 The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) progressive entropy coding. For lossless transformation, this can also be specified using TJXOPT_PROGRESSIVE.
+
0[default for compression, lossless transformation] The lossy JPEG image is (decompression) or will be (compression, lossless transformation) single-scan.
+
1 The lossy JPEG image is (decompression) or will be (compression, lossless transformation) progressive. For lossless transformation, this can also be specified using TJXOPT_PROGRESSIVE.
-
Progressive entropy coding will generally improve compression relative to baseline entropy coding, but it will reduce compression and decompression performance considerably. Can be combined with TJPARAM_ARITHMETIC. Implies TJPARAM_OPTIMIZE unless TJPARAM_ARITHMETIC is also set.
+
Progressive JPEG images generally have better compression ratios than single-scan JPEG images (much better if the image has large areas of solid color), but progressive JPEG compression and decompression is considerably slower than single-scan JPEG compression and decompression. Can be combined with TJPARAM_ARITHMETIC. Implies TJPARAM_OPTIMIZE unless TJPARAM_ARITHMETIC is also set.
Setting this parameter will cause the decompression and transform functions to return an error if the number of scans in a progressive JPEG image exceeds the specified limit. The primary purpose of this is to allow security-critical applications to guard against an exploit of the progressive JPEG format described in this report.
+
Setting this parameter causes the decompression and transform functions to return an error if the number of scans in a progressive JPEG image exceeds the specified limit. The primary purpose of this is to allow security-critical applications to guard against an exploit of the progressive JPEG format described in this report.
Value
maximum number of progressive JPEG scans that the decompression and transform functions will process [default: 0 (no limit)]
0[default for compression, lossless transformation] The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) Huffman entropy coding.
-
1 The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) arithmetic entropy coding. For lossless transformation, this can also be specified using TJXOPT_ARITHMETIC.
+
1 The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) arithmetic entropy coding. For lossless transformation, this can also be specified using TJXOPT_ARITHMETIC.
-
Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding, but it will reduce compression and decompression performance considerably. Can be combined with TJPARAM_PROGRESSIVE.
+
Arithmetic entropy coding generally improves compression relative to Huffman entropy coding, but it reduces compression and decompression performance considerably. Can be combined with TJPARAM_PROGRESSIVE.
TJPARAM_LOSSLESS
Lossless JPEG.
Value
0[default for compression] The JPEG image is (decompression) or will be (compression) lossy/DCT-based.
1 The JPEG image is (decompression) or will be (compression) lossless/predictive.
-
In most cases, compressing and decompressing lossless JPEG images is considerably slower than compressing and decompressing lossy JPEG images, and lossless JPEG images are much larger than lossy JPEG images. Thus, lossless JPEG images are typically used only for applications that require mathematically lossless compression. Also note that the following features are not available with lossless JPEG images:
+
In most cases, lossless JPEG compression and decompression is considerably slower than lossy JPEG compression and decompression, and lossless JPEG images are much larger than lossy JPEG images. Thus, lossless JPEG images are typically used only for applications that require mathematically lossless compression. Also note that the following features are not available with lossless JPEG images:
Colorspace conversion (lossless JPEG images always use TJCS_RGB, TJCS_GRAY, or TJCS_CMYK, depending on the pixel format of the source image)
-
Chrominance subsampling (lossless JPEG images always use TJSAMP_444)
+
Chrominance subsampling (lossless JPEG images always use TJSAMP_444)
JPEG quality selection
DCT/IDCT algorithm selection
-
Progressive entropy coding
+
Progressive JPEG
Arithmetic entropy coding
Compression from/decompression to planar YUV images
Decompression scaling
@@ -1010,11 +1011,11 @@ scalingFactor).
TJPARAM_MAXMEMORY
Memory limit for intermediate buffers.
Value
-
the maximum amount of memory (in megabytes) that will be allocated for intermediate buffers, which are used with progressive JPEG compression and decompression, optimized baseline entropy coding, lossless JPEG compression, and lossless transformation [default: 0 (no limit)]
+
the maximum amount of memory (in megabytes) that will be allocated for intermediate buffers, which are used with progressive JPEG compression and decompression, Huffman table optimization, lossless JPEG compression, and lossless transformation [default: 0 (no limit)]
Setting this parameter will cause the decompression, transform, and image loading functions to return an error if the number of pixels in the source image exceeds the specified limit. This allows security-critical applications to guard against excessive memory consumption.
+
Setting this parameter causes the decompression, transform, and image loading functions to return an error if the number of pixels in the source image exceeds the specified limit. This allows security-critical applications to guard against excessive memory consumption.
Value
maximum number of pixels that the decompression, transform, and image loading functions will process [default: 0 (no limit)]
@@ -1044,31 +1045,31 @@ scalingFactor).
The red, green, and blue components in the image are stored in 3-sample pixels in the order B, G, R from lowest to highest memory address within each pixel.
TJPF_RGBX
RGBX pixel format.
-
The red, green, and blue components in the image are stored in 4-sample pixels in the order R, G, B from lowest to highest memory address within each pixel. The X component is ignored when compressing and undefined when decompressing.
+
The red, green, and blue components in the image are stored in 4-sample pixels in the order R, G, B from lowest to highest memory address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
TJPF_BGRX
BGRX pixel format.
-
The red, green, and blue components in the image are stored in 4-sample pixels in the order B, G, R from lowest to highest memory address within each pixel. The X component is ignored when compressing and undefined when decompressing.
+
The red, green, and blue components in the image are stored in 4-sample pixels in the order B, G, R from lowest to highest memory address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
TJPF_XBGR
XBGR pixel format.
-
The red, green, and blue components in the image are stored in 4-sample pixels in the order R, G, B from highest to lowest memory address within each pixel. The X component is ignored when compressing and undefined when decompressing.
+
The red, green, and blue components in the image are stored in 4-sample pixels in the order R, G, B from highest to lowest memory address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
TJPF_XRGB
XRGB pixel format.
-
The red, green, and blue components in the image are stored in 4-sample pixels in the order B, G, R from highest to lowest memory address within each pixel. The X component is ignored when compressing and undefined when decompressing.
+
The red, green, and blue components in the image are stored in 4-sample pixels in the order B, G, R from highest to lowest memory address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
TJPF_GRAY
Grayscale pixel format.
Each 1-sample pixel represents a luminance (brightness) level from 0 to the maximum sample value (255 for 8-bit samples, 4095 for 12-bit samples, and 65535 for 16-bit samples.)
TJPF_RGBA
RGBA pixel format.
-
This is the same as TJPF_RGBX, except that when decompressing, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
+
This is the same as TJPF_RGBX, except that when decompressing/decoding, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
TJPF_BGRA
BGRA pixel format.
-
This is the same as TJPF_BGRX, except that when decompressing, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
+
This is the same as TJPF_BGRX, except that when decompressing/decoding, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
TJPF_ABGR
ABGR pixel format.
-
This is the same as TJPF_XBGR, except that when decompressing, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
+
This is the same as TJPF_XBGR, except that when decompressing/decoding, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
TJPF_ARGB
ARGB pixel format.
-
This is the same as TJPF_XRGB, except that when decompressing, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
+
This is the same as TJPF_XRGB, except that when decompressing/decoding, the X component is guaranteed to be equal to the maximum sample value, which can be interpreted as an opaque alpha channel.
TJPF_CMYK
CMYK pixel format.
Unlike RGB, which is an additive color model used primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used primarily for printing. In the CMYK color model, the value of each color component typically corresponds to an amount of cyan, magenta, yellow, or black ink that is applied to a white background. In order to convert between CMYK and RGB, it is necessary to use a color management system (CMS.) A CMS will attempt to map colors within the printer's gamut to perceptually similar colors in the display's gamut and vice versa, but the mapping is typically not 1:1 or reversible, nor can it be defined with a simple formula. Thus, such a conversion is out of scope for a codec library. However, the TurboJPEG API allows for compressing packed-pixel CMYK images into YCCK JPEG images (see TJCS_YCCK) and decompressing YCCK JPEG images into packed-pixel CMYK images.
@@ -1093,36 +1094,36 @@ scalingFactor).
Chrominance subsampling options.
-
When pixels are converted from RGB to YCbCr (see TJCS_YCbCr) or from CMYK to YCCK (see TJCS_YCCK) as part of the JPEG compression process, some of the Cb and Cr (chrominance) components can be discarded or averaged together to produce a smaller image with little perceptible loss of image clarity. (The human eye is more sensitive to small changes in brightness than to small changes in color.) This is called "chrominance subsampling".
+
When pixels are converted from RGB to YCbCr (see TJCS_YCbCr) or from CMYK to YCCK (see TJCS_YCCK) as part of the JPEG compression process, some of the Cb and Cr (chrominance) components can be discarded or averaged together to produce a smaller image with little perceptible loss of image quality. (The human eye is more sensitive to small changes in brightness than to small changes in color.) This is called "chrominance subsampling".
-
Enumerator
TJSAMP_444
4:4:4 chrominance subsampling (no chrominance subsampling).
+
Enumerator
TJSAMP_444
4:4:4 chrominance subsampling (no chrominance subsampling)
The JPEG or YUV image will contain one chrominance component for every pixel in the source image.
-
TJSAMP_422
4:2:2 chrominance subsampling.
+
TJSAMP_422
4:2:2 chrominance subsampling
The JPEG or YUV image will contain one chrominance component for every 2x1 block of pixels in the source image.
-
TJSAMP_420
4:2:0 chrominance subsampling.
+
TJSAMP_420
4:2:0 chrominance subsampling
The JPEG or YUV image will contain one chrominance component for every 2x2 block of pixels in the source image.
TJSAMP_GRAY
Grayscale.
The JPEG or YUV image will contain no chrominance components.
-
TJSAMP_440
4:4:0 chrominance subsampling.
+
TJSAMP_440
4:4:0 chrominance subsampling
The JPEG or YUV image will contain one chrominance component for every 1x2 block of pixels in the source image.
Note
4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
-
TJSAMP_411
4:1:1 chrominance subsampling.
-
The JPEG or YUV image will contain one chrominance component for every 4x1 block of pixels in the source image. JPEG images compressed with 4:1:1 subsampling will be almost exactly the same size as those compressed with 4:2:0 subsampling, and in the aggregate, both subsampling methods produce approximately the same perceptual quality. However, 4:1:1 is better able to reproduce sharp horizontal features.
+
TJSAMP_411
4:1:1 chrominance subsampling
+
The JPEG or YUV image will contain one chrominance component for every 4x1 block of pixels in the source image. All else being equal, a JPEG image with 4:1:1 subsampling is almost exactly the same size as a JPEG image with 4:2:0 subsampling, and in the aggregate, both subsampling methods produce approximately the same perceptual quality. However, 4:1:1 is better able to reproduce sharp horizontal features.
Note
4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
-
TJSAMP_441
4:4:1 chrominance subsampling.
-
The JPEG or YUV image will contain one chrominance component for every 1x4 block of pixels in the source image. JPEG images compressed with 4:4:1 subsampling will be almost exactly the same size as those compressed with 4:2:0 subsampling, and in the aggregate, both subsampling methods produce approximately the same perceptual quality. However, 4:4:1 is better able to reproduce sharp vertical features.
+
TJSAMP_441
4:4:1 chrominance subsampling
+
The JPEG or YUV image will contain one chrominance component for every 1x4 block of pixels in the source image. All else being equal, a JPEG image with 4:4:1 subsampling is almost exactly the same size as a JPEG image with 4:2:0 subsampling, and in the aggregate, both subsampling methods produce approximately the same perceptual quality. However, 4:4:1 is better able to reproduce sharp vertical features.
Note
4:4:1 subsampling is not fully accelerated in libjpeg-turbo.
TJSAMP_UNKNOWN
Unknown subsampling.
The JPEG image uses an unusual type of chrominance subsampling. Such images can be decompressed into packed-pixel images, but they cannot be
decompressed into planar YUV images,
-
losslessly transformed if TJXOPT_CROP is specified, or
+
losslessly transformed if TJXOPT_CROP is specified, or
partially decompressed using a cropping region.
@@ -1147,23 +1148,23 @@ scalingFactor).
Enumerator
TJXOP_NONE
Do not transform the position of the image pixels.
TJXOP_HFLIP
Flip (mirror) image horizontally.
-
This transform is imperfect if there are any partial MCU blocks on the right edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial MCU blocks on the right edge (see TJXOPT_PERFECT.)
TJXOP_VFLIP
Flip (mirror) image vertically.
-
This transform is imperfect if there are any partial MCU blocks on the bottom edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial MCU blocks on the bottom edge (see TJXOPT_PERFECT.)
TJXOP_TRANSPOSE
Transpose image (flip/mirror along upper left to lower right axis.) This transform is always perfect.
-
TJXOP_TRANSVERSE
Transverse transpose image (flip/mirror along upper right to lower left axis.) This transform is imperfect if there are any partial MCU blocks in the image (see TJXOPT_PERFECT.)
+
TJXOP_TRANSVERSE
Transverse transpose image (flip/mirror along upper right to lower left axis.) This transform is imperfect if there are any partial MCU blocks in the image (see TJXOPT_PERFECT.)
TJXOP_ROT90
Rotate image clockwise by 90 degrees.
-
This transform is imperfect if there are any partial MCU blocks on the bottom edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial MCU blocks on the bottom edge (see TJXOPT_PERFECT.)
TJXOP_ROT180
Rotate image 180 degrees.
-
This transform is imperfect if there are any partial MCU blocks in the image (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial MCU blocks in the image (see TJXOPT_PERFECT.)
TJXOP_ROT270
Rotate image counter-clockwise by 90 degrees.
-
This transform is imperfect if there are any partial MCU blocks on the right edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial MCU blocks on the right edge (see TJXOPT_PERFECT.)
@@ -2540,7 +2541,7 @@ If you choose option 1, then *jpegSize should be set to the size of
width
width (in pixels) of the image
height
height (in pixels) of the image
-
jpegSubsamp
the level of chrominance subsampling to be used when generating the JPEG image (see Chrominance subsampling options.) TJSAMP_UNKNOWN is treated like TJSAMP_444, since a buffer large enough to hold a JPEG image with no subsampling should also be large enough to hold a JPEG image with an arbitrary level of subsampling. Note that lossless JPEG images always use TJSAMP_444.
+
jpegSubsamp
the level of chrominance subsampling to be used when generating the JPEG image (see Chrominance subsampling options.) TJSAMP_UNKNOWN is treated like TJSAMP_444, since a buffer large enough to hold a JPEG image with no subsampling should also be large enough to hold a JPEG image with an arbitrary level of subsampling. Note that lossless JPEG images always use TJSAMP_444.
@@ -2606,7 +2607,7 @@ If you choose option 1, then *jpegSize should be set to the size of
width
pointer to an integer variable that will receive the width (in pixels) of the packed-pixel image
align
row alignment (in samples) of the packed-pixel buffer to be returned (must be a power of 2.) Setting this parameter to n will cause all rows in the buffer to be padded to the nearest multiple of n samples (1 = unpadded.)
height
pointer to an integer variable that will receive the height (in pixels) of the packed-pixel image
-
pixelFormat
pointer to an integer variable that specifies or will receive the pixel format of the packed-pixel buffer. The behavior of this function will vary depending on the value of *pixelFormat passed to the function:
+
pixelFormat
pointer to an integer variable that specifies or will receive the pixel format of the packed-pixel buffer. The behavior of this function varies depending on the value of *pixelFormat passed to the function:
TJPF_UNKNOWN : The packed-pixel buffer returned by this function will use the most optimal pixel format for the file type, and *pixelFormat will contain the ID of that pixel format upon successful return from this function.
TJPF_GRAY : Only PGM files and 8-bit-per-pixel BMP files with a grayscale colormap can be loaded.
TJPF_CMYK : The RGB or grayscale pixels stored in the file will be converted using a quick & dirty algorithm that is suitable only for testing purposes. (Proper conversion between CMYK and other formats requires a color management system.)
@@ -2678,7 +2679,7 @@ If you choose option 1, then *jpegSize should be set to the size of
width
pointer to an integer variable that will receive the width (in pixels) of the packed-pixel image
align
row alignment (in samples) of the packed-pixel buffer to be returned (must be a power of 2.) Setting this parameter to n will cause all rows in the buffer to be padded to the nearest multiple of n samples (1 = unpadded.)
height
pointer to an integer variable that will receive the height (in pixels) of the packed-pixel image
-
pixelFormat
pointer to an integer variable that specifies or will receive the pixel format of the packed-pixel buffer. The behavior of this function will vary depending on the value of *pixelFormat passed to the function:
+
pixelFormat
pointer to an integer variable that specifies or will receive the pixel format of the packed-pixel buffer. The behavior of this function varies depending on the value of *pixelFormat passed to the function:
TJPF_UNKNOWN : The packed-pixel buffer returned by this function will use the most optimal pixel format for the file type, and *pixelFormat will contain the ID of that pixel format upon successful return from this function.
TJPF_GRAY : Only PGM files and 8-bit-per-pixel BMP files with a grayscale colormap can be loaded.
TJPF_CMYK : The RGB or grayscale pixels stored in the file will be converted using a quick & dirty algorithm that is suitable only for testing purposes. (Proper conversion between CMYK and other formats requires a color management system.)
@@ -2750,7 +2751,7 @@ If you choose option 1, then *jpegSize should be set to the size of
width
pointer to an integer variable that will receive the width (in pixels) of the packed-pixel image
align
row alignment (in samples) of the packed-pixel buffer to be returned (must be a power of 2.) Setting this parameter to n will cause all rows in the buffer to be padded to the nearest multiple of n samples (1 = unpadded.)
height
pointer to an integer variable that will receive the height (in pixels) of the packed-pixel image
-
pixelFormat
pointer to an integer variable that specifies or will receive the pixel format of the packed-pixel buffer. The behavior of this function will vary depending on the value of *pixelFormat passed to the function:
+
pixelFormat
pointer to an integer variable that specifies or will receive the pixel format of the packed-pixel buffer. The behavior of this function varies depending on the value of *pixelFormat passed to the function:
TJPF_UNKNOWN : The packed-pixel buffer returned by this function will use the most optimal pixel format for the file type, and *pixelFormat will contain the ID of that pixel format upon successful return from this function.
TJPF_GRAY : Only PGM files and 8-bit-per-pixel BMP files with a grayscale colormap can be loaded.
TJPF_CMYK : The RGB or grayscale pixels stored in the file will be converted using a quick & dirty algorithm that is suitable only for testing purposes. (Proper conversion between CMYK and other formats requires a color management system.)
@@ -3329,9 +3330,9 @@ If you choose option 1, then dstSizes[i] should be set to the size
Parameters
componentID
ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
-
width
width (in pixels) of the YUV image. NOTE: this is the width of the whole image, not the plane width.
+
width
width (in pixels) of the YUV image. NOTE: This is the width of the whole image, not the plane width.
stride
bytes per row in the image plane. Setting this to 0 is the equivalent of setting it to the plane width.
-
height
height (in pixels) of the YUV image. NOTE: this is the height of the whole image, not the plane height.
+
height
height (in pixels) of the YUV image. NOTE: This is the height of the whole image, not the plane height.
@@ -3408,7 +3409,7 @@ If you choose option 1, then dstSizes[i] should be set to the size
Alpha offset (in samples) for a given pixel format.
-
This specifies the number of samples that the alpha component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRA is stored in unsigned char pixel[], then the alpha component will be pixel[tjAlphaOffset[TJPF_BGRA]]. This will be -1 if the pixel format does not have an alpha component.
+
This specifies the number of samples that the alpha component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRA is stored in unsigned char pixel[], then the alpha component is pixel[tjAlphaOffset[TJPF_BGRA]]. The offset is -1 if the pixel format does not have an alpha component.
@@ -3433,7 +3434,7 @@ If you choose option 1, then dstSizes[i] should be set to the size
Blue offset (in samples) for a given pixel format.
-
This specifies the number of samples that the blue component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the blue component will be pixel[tjBlueOffset[TJPF_BGRX]]. This will be -1 if the pixel format does not have a blue component.
+
This specifies the number of samples that the blue component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the blue component is pixel[tjBlueOffset[TJPF_BGRX]]. The offset is -1 if the pixel format does not have a blue component.
@@ -3458,7 +3459,7 @@ If you choose option 1, then dstSizes[i] should be set to the size
Green offset (in samples) for a given pixel format.
-
This specifies the number of samples that the green component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the green component will be pixel[tjGreenOffset[TJPF_BGRX]]. This will be -1 if the pixel format does not have a green component.
+
This specifies the number of samples that the green component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the green component is pixel[tjGreenOffset[TJPF_BGRX]]. The offset is -1 if the pixel format does not have a green component.
@@ -3571,7 +3572,7 @@ If you choose option 1, then dstSizes[i] should be set to the size
Red offset (in samples) for a given pixel format.
-
This specifies the number of samples that the red component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the red component will be pixel[tjRedOffset[TJPF_BGRX]]. This will be -1 if the pixel format does not have a red component.
+
This specifies the number of samples that the red component is offset from the start of the pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the red component is pixel[tjRedOffset[TJPF_BGRX]]. The offset is -1 if the pixel format does not have a red component.
diff --git a/doc/html/structtjtransform.html b/doc/html/structtjtransform.html
index eacef707..c562ead4 100644
--- a/doc/html/structtjtransform.html
+++ b/doc/html/structtjtransform.html
@@ -118,7 +118,7 @@ Data Fields
This allows for custom filters or other transformations to be applied in the frequency domain.
Parameters
-
coeffs
pointer to an array of transformed DCT coefficients. (NOTE: this pointer is not guaranteed to be valid once the callback returns, so applications wishing to hand off the DCT coefficients to another function or library should make a copy of them within the body of the callback.)
+
coeffs
pointer to an array of transformed DCT coefficients. (NOTE: This pointer is not guaranteed to be valid once the callback returns, so applications wishing to hand off the DCT coefficients to another function or library should make a copy of them within the body of the callback.)
arrayRegion
tjregion structure containing the width and height of the array pointed to by coeffs as well as its offset relative to the component plane. TurboJPEG implementations may choose to split each component plane into multiple DCT coefficient arrays and call the callback function once for each array.
planeRegion
tjregion structure containing the width and height of the component plane to which coeffs belongs
componentID
ID number of the component plane to which coeffs belongs. (Y, Cb, and Cr have, respectively, ID's of 0, 1, and 2 in typical JPEG images.)
diff --git a/java/TJBench.java b/java/TJBench.java
index 16d782ae..7f209188 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -566,7 +566,7 @@ final class TJBench {
precision = tjt.get(TJ.PARAM_PRECISION);
cs = tjt.get(TJ.PARAM_COLORSPACE);
if (tjt.get(TJ.PARAM_PROGRESSIVE) == 1)
- System.out.println("JPEG image uses progressive entropy coding\n");
+ System.out.println("JPEG image is progressive\n");
if (tjt.get(TJ.PARAM_ARITHMETIC) == 1)
System.out.println("JPEG image uses arithmetic entropy coding\n");
tjt.set(TJ.PARAM_PROGRESSIVE, progressive ? 1 : 0);
@@ -782,8 +782,8 @@ final class TJBench {
System.out.println("-lossless = Generate lossless JPEG images when compressing (implies");
System.out.println(" -subsamp 444). PSV is the predictor selection value (1-7).");
System.out.println("-maxmemory = Memory limit (in megabytes) for intermediate buffers used with");
- System.out.println(" progressive JPEG compression and decompression, optimized baseline entropy");
- System.out.println(" coding, lossless JPEG compression, and lossless transformation");
+ System.out.println(" progressive JPEG compression and decompression, Huffman table");
+ System.out.println(" optimization, lossless JPEG compression, and lossless transformation");
System.out.println(" [default = no limit]");
System.out.println("-maxpixels = Input image size limit (in pixels) [default = no limit]");
System.out.println("-nowrite = Do not write reference or output images (improves consistency of");
@@ -821,11 +821,11 @@ final class TJBench {
System.out.println(" the scaled MCU width.");
System.out.println("-fastdct = Use the fastest DCT/IDCT algorithm available");
System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available");
- System.out.println("-optimize = Use optimized baseline entropy coding in JPEG images generated by");
+ System.out.println("-optimize = Compute optimal Huffman tables for JPEG images generated by");
System.out.println(" compession and transform operations");
- System.out.println("-progressive = Use progressive entropy coding in JPEG images generated by");
- System.out.println(" compression and transform operations (can be combined with -arithmetic;");
- System.out.println(" implies -optimize unless -arithmetic is also specified)");
+ System.out.println("-progressive = Generate progressive JPEG images when compressing or");
+ System.out.println(" transforming (can be combined with -arithmetic; implies -optimize unless");
+ System.out.println(" -arithmetic is also specified)");
System.out.println("-limitscans = Refuse to decompress or transform progressive JPEG images that");
System.out.println(" have an unreasonably large number of scans");
System.out.println("-scale M/N = When decompressing, scale the width/height of the JPEG image by a");
@@ -929,7 +929,7 @@ final class TJBench {
optimize = true;
xformOpt |= TJTransform.OPT_OPTIMIZE;
} else if (argv[i].equalsIgnoreCase("-progressive")) {
- System.out.println("Using progressive entropy coding\n");
+ System.out.println("Generating progressive JPEG images\n");
progressive = true;
xformOpt |= TJTransform.OPT_PROGRESSIVE;
} else if (argv[i].equalsIgnoreCase("-arithmetic")) {
@@ -1128,7 +1128,7 @@ final class TJBench {
if (optimize && !progressive && !arithmetic && !lossless &&
precision != 12)
- System.out.println("Using optimized baseline entropy coding\n");
+ System.out.println("Computing optimal Huffman tables\n");
if (precision == 16 && !lossless)
throw new Exception("-lossless must be specified along with -precision 16");
diff --git a/java/doc/index-all.html b/java/doc/index-all.html
index 5937a9ae..28b0915f 100644
--- a/java/doc/index-all.html
+++ b/java/doc/index-all.html
@@ -150,23 +150,23 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
CS_CMYK - Static variable in class org.libjpegturbo.turbojpeg.TJ
-
CMYK colorspace.
+
CMYK colorspace
CS_GRAY - Static variable in class org.libjpegturbo.turbojpeg.TJ
-
Grayscale colorspace.
+
Grayscale colorspace
CS_RGB - Static variable in class org.libjpegturbo.turbojpeg.TJ
-
RGB colorspace.
+
RGB colorspace
CS_YCbCr - Static variable in class org.libjpegturbo.turbojpeg.TJ
-
YCbCr colorspace.
+
YCbCr colorspace
CS_YCCK - Static variable in class org.libjpegturbo.turbojpeg.TJ
This option will prevent TJTransformer.transform() from copying any extra markers (including EXIF
- and ICC profile data) from the source image to the destination image.
+
Do not copy any extra markers (including EXIF and ICC profile data) from
+ the source image to the destination image.
4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG
- or YUV image will contain one chrominance component for every pixel in the
- source image.
+
4:4:4 chrominance subsampling (no chrominance subsampling)
+
+
The JPEG or YUV image will contain one chrominance component for every
+ pixel in the source image.
4:4:0 chrominance subsampling. The JPEG or YUV image will contain one
- chrominance component for every 1x2 block of pixels in the source image.
- Note that 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
+
4:4:0 chrominance subsampling
+
+
The JPEG or YUV image will contain one chrominance component for every
+ 1x2 block of pixels in the source image.
+
+
NOTE: 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
4:1:1 chrominance subsampling. The JPEG or YUV image will contain one
- chrominance component for every 4x1 block of pixels in the source image.
- JPEG images compressed with 4:1:1 subsampling will be almost exactly the
- same size as those compressed with 4:2:0 subsampling, and in the
- aggregate, both subsampling methods produce approximately the same
- perceptual quality. However, 4:1:1 is better able to reproduce sharp
- horizontal features. Note that 4:1:1 subsampling is not fully accelerated
- in libjpeg-turbo.
+
4:1:1 chrominance subsampling
+
+
The JPEG or YUV image will contain one chrominance component for every
+ 4x1 block of pixels in the source image. All else being equal, a JPEG
+ image with 4:1:1 subsampling is almost exactly the same size as a JPEG
+ image with 4:2:0 subsampling, and in the aggregate, both subsampling
+ methods produce approximately the same perceptual quality. However, 4:1:1
+ is better able to reproduce sharp horizontal features.
+
+
NOTE: 4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
4:4:1 chrominance subsampling. The JPEG or YUV image will contain one
- chrominance component for every 1x4 block of pixels in the source image.
- JPEG images compressed with 4:4:1 subsampling will be almost exactly the
- same size as those compressed with 4:2:0 subsampling, and in the
- aggregate, both subsampling methods produce approximately the same
- perceptual quality. However, 4:4:1 is better able to reproduce sharp
- vertical features. Note that 4:4:1 subsampling is not fully accelerated
- in libjpeg-turbo.
+
4:4:1 chrominance subsampling
+
+
The JPEG or YUV image will contain one chrominance component for every
+ 1x4 block of pixels in the source image. All else being equal, a JPEG
+ image with 4:4:1 subsampling is almost exactly the same size as a JPEG
+ image with 4:2:0 subsampling, and in the aggregate, both subsampling
+ methods produce approximately the same perceptual quality. However, 4:4:1
+ is better able to reproduce sharp vertical features.
+
+
NOTE: 4:4:1 subsampling is not fully accelerated in libjpeg-turbo.
Unknown subsampling. The JPEG image uses an unusual type of chrominance
- subsampling. Such images can be decompressed into packed-pixel images,
- but they cannot be
+
Unknown subsampling
+
+
The JPEG image uses an unusual type of chrominance subsampling. Such
+ images can be decompressed into packed-pixel images, but they cannot be
decompressed into planar YUV images,
losslessly transformed if TJTransform.OPT_CROP is specified,
@@ -952,9 +967,11 @@ extends java.lang.Object
PF_RGB
public static final int PF_RGB
-
RGB pixel format. The red, green, and blue components in the image are
- stored in 3-sample pixels in the order R, G, B from lowest to highest
- memory address within each pixel.
+
RGB pixel format
+
+
The red, green, and blue components in the image are stored in 3-sample
+ pixels in the order R, G, B from lowest to highest memory address within
+ each pixel.
BGR pixel format. The red, green, and blue components in the image are
- stored in 3-sample pixels in the order B, G, R from lowest to highest
- memory address within each pixel.
+
BGR pixel format
+
+
The red, green, and blue components in the image are stored in 3-sample
+ pixels in the order B, G, R from lowest to highest memory address within
+ each pixel.
RGBX pixel format. The red, green, and blue components in the image are
- stored in 4-sample pixels in the order R, G, B from lowest to highest
- memory address within each pixel. The X component is ignored when
- compressing and undefined when decompressing.
+
RGBX pixel format
+
+
The red, green, and blue components in the image are stored in 4-sample
+ pixels in the order R, G, B from lowest to highest memory address within
+ each pixel. The X component is ignored when compressing/encoding and
+ undefined when decompressing/decoding.
BGRX pixel format. The red, green, and blue components in the image are
- stored in 4-sample pixels in the order B, G, R from lowest to highest
- memory address within each pixel. The X component is ignored when
- compressing and undefined when decompressing.
+
BGRX pixel format
+
+
The red, green, and blue components in the image are stored in 4-sample
+ pixels in the order B, G, R from lowest to highest memory address within
+ each pixel. The X component is ignored when compressing/encoding and
+ undefined when decompressing/decoding.
XBGR pixel format. The red, green, and blue components in the image are
- stored in 4-sample pixels in the order R, G, B from highest to lowest
- memory address within each pixel. The X component is ignored when
- compressing and undefined when decompressing.
+
XBGR pixel format
+
+
The red, green, and blue components in the image are stored in 4-sample
+ pixels in the order R, G, B from highest to lowest memory address within
+ each pixel. The X component is ignored when compressing/encoding and
+ undefined when decompressing/decoding.
XRGB pixel format. The red, green, and blue components in the image are
- stored in 4-sample pixels in the order B, G, R from highest to lowest
- memory address within each pixel. The X component is ignored when
- compressing and undefined when decompressing.
+
XRGB pixel format
+
+
The red, green, and blue components in the image are stored in 4-sample
+ pixels in the order B, G, R from highest to lowest memory address within
+ each pixel. The X component is ignored when compressing/encoding and
+ undefined when decompressing/decoding.
Grayscale pixel format. Each 1-sample pixel represents a luminance
- (brightness) level from 0 to the maximum sample value (255 for 8-bit
- samples, 4095 for 12-bit samples, and 65535 for 16-bit samples.)
+
Grayscale pixel format
+
+
Each 1-sample pixel represents a luminance (brightness) level from 0 to
+ the maximum sample value (255 for 8-bit samples, 4095 for 12-bit samples,
+ and 65535 for 16-bit samples.)
RGBA pixel format. This is the same as PF_RGBX, except that when
- decompressing, the X component is guaranteed to be equal to the maximum
- sample value, which can be interpreted as an opaque alpha channel.
+
RGBA pixel format
+
+
This is the same as PF_RGBX, except that when
+ decompressing/decoding, the X component is guaranteed to be equal to the
+ maximum sample value, which can be interpreted as an opaque alpha channel.
BGRA pixel format. This is the same as PF_BGRX, except that when
- decompressing, the X component is guaranteed to be equal to the maximum
- sample value, which can be interpreted as an opaque alpha channel.
+
BGRA pixel format
+
+
This is the same as PF_BGRX, except that when
+ decompressing/decoding, the X component is guaranteed to be equal to the
+ maximum sample value, which can be interpreted as an opaque alpha channel.
ABGR pixel format. This is the same as PF_XBGR, except that when
- decompressing, the X component is guaranteed to be equal to the maximum
- sample value, which can be interpreted as an opaque alpha channel.
+
ABGR pixel format
+
+
This is the same as PF_XBGR, except that when
+ decompressing/decoding, the X component is guaranteed to be equal to the
+ maximum sample value, which can be interpreted as an opaque alpha channel.
ARGB pixel format. This is the same as PF_XRGB, except that when
- decompressing, the X component is guaranteed to be equal to the maximum
- sample value, which can be interpreted as an opaque alpha channel.
+
ARGB pixel format
+
+
This is the same as PF_XRGB, except that when
+ decompressing/decoding, the X component is guaranteed to be equal to the
+ maximum sample value, which can be interpreted as an opaque alpha channel.
CMYK pixel format. Unlike RGB, which is an additive color model used
- primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive
- color model used primarily for printing. In the CMYK color model, the
- value of each color component typically corresponds to an amount of cyan,
- magenta, yellow, or black ink that is applied to a white background. In
- order to convert between CMYK and RGB, it is necessary to use a color
- management system (CMS.) A CMS will attempt to map colors within the
- printer's gamut to perceptually similar colors in the display's gamut and
- vice versa, but the mapping is typically not 1:1 or reversible, nor can it
- be defined with a simple formula. Thus, such a conversion is out of scope
- for a codec library. However, the TurboJPEG API allows for compressing
- packed-pixel CMYK images into YCCK JPEG images (see CS_YCCK) and
- decompressing YCCK JPEG images into packed-pixel CMYK images.
+
CMYK pixel format
+
+
Unlike RGB, which is an additive color model used primarily for
+ display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used
+ primarily for printing. In the CMYK color model, the value of each color
+ component typically corresponds to an amount of cyan, magenta, yellow, or
+ black ink that is applied to a white background. In order to convert
+ between CMYK and RGB, it is necessary to use a color management system
+ (CMS.) A CMS will attempt to map colors within the printer's gamut to
+ perceptually similar colors in the display's gamut and vice versa, but the
+ mapping is typically not 1:1 or reversible, nor can it be defined with a
+ simple formula. Thus, such a conversion is out of scope for a codec
+ library. However, the TurboJPEG API allows for compressing packed-pixel
+ CMYK images into YCCK JPEG images (see CS_YCCK) and decompressing
+ YCCK JPEG images into packed-pixel CMYK images.
RGB colorspace. When compressing the JPEG image, the R, G, and B
- components in the source image are reordered into image planes, but no
- colorspace conversion or subsampling is performed. RGB JPEG images can be
- compressed from and decompressed to packed-pixel images with any of the
- extended RGB or grayscale pixel formats, but they cannot be compressed
- from or decompressed to planar YUV images.
+
RGB colorspace
+
+
When generating the JPEG image, the R, G, and B components in the
+ source image are reordered into image planes, but no colorspace conversion
+ or subsampling is performed. RGB JPEG images can be generated from and
+ decompressed to packed-pixel images with any of the extended RGB or
+ grayscale pixel formats, but they cannot be generated from or
+ decompressed to planar YUV images.
YCbCr colorspace. YCbCr is not an absolute colorspace but rather a
- mathematical transformation of RGB designed solely for storage and
- transmission. YCbCr images must be converted to RGB before they can
- actually be displayed. In the YCbCr colorspace, the Y (luminance)
- component represents the black & white portion of the original image,
- and the Cb and Cr (chrominance) components represent the color portion of
- the original image. Originally, the analog equivalent of this
- transformation allowed the same signal to drive both black & white and
- color televisions, but JPEG images use YCbCr primarily because it allows
- the color data to be optionally subsampled for the purposes of reducing
- network or disk usage. YCbCr is the most common JPEG colorspace, and
- YCbCr JPEG images can be compressed from and decompressed to packed-pixel
- images with any of the extended RGB or grayscale pixel formats. YCbCr
- JPEG images can also be compressed from and decompressed to planar YUV
- images.
+
YCbCr colorspace
+
+
YCbCr is not an absolute colorspace but rather a mathematical
+ transformation of RGB designed solely for storage and transmission. YCbCr
+ images must be converted to RGB before they can be displayed. In the
+ YCbCr colorspace, the Y (luminance) component represents the black &
+ white portion of the original image, and the Cb and Cr (chrominance)
+ components represent the color portion of the original image.
+ Historically, the analog equivalent of this transformation allowed the
+ same signal to be displayed to both black & white and color
+ televisions, but JPEG images use YCbCr primarily because it allows the
+ color data to be optionally subsampled in order to reduce network and disk
+ usage. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images
+ can be generated from and decompressed to packed-pixel images with any of
+ the extended RGB or grayscale pixel formats. YCbCr JPEG images can also
+ be generated from and decompressed to planar YUV images.
Grayscale colorspace. The JPEG image retains only the luminance data (Y
- component), and any color data from the source image is discarded.
- Grayscale JPEG images can be compressed from and decompressed to
- packed-pixel images with any of the extended RGB or grayscale pixel
- formats, or they can be compressed from and decompressed to planar YUV
- images.
+
Grayscale colorspace
+
+
The JPEG image retains only the luminance data (Y component), and any
+ color data from the source image is discarded. Grayscale JPEG images can
+ be generated from and decompressed to packed-pixel images with any of the
+ extended RGB or grayscale pixel formats, or they can be generated from and
+ decompressed to planar YUV images.
CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
- components in the source image are reordered into image planes, but no
- colorspace conversion or subsampling is performed. CMYK JPEG images can
- only be compressed from and decompressed to packed-pixel images with the
- CMYK pixel format.
+
CMYK colorspace
+
+
When generating the JPEG image, the C, M, Y, and K components in the
+ source image are reordered into image planes, but no colorspace conversion
+ or subsampling is performed. CMYK JPEG images can only be generated from
+ and decompressed to packed-pixel images with the CMYK pixel format.
YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but
- rather a mathematical transformation of CMYK designed solely for storage
- and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
+
YCCK colorspace
+
+
YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a
+ mathematical transformation of CMYK designed solely for storage and
+ transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
reversibly transformed into YCCK, and as with YCbCr, the chrominance
components in the YCCK pixels can be subsampled without incurring major
- perceptual loss. YCCK JPEG images can only be compressed from and
+ perceptual loss. YCCK JPEG images can only be generated from and
decompressed to packed-pixel images with the CMYK pixel format.
See Also:
@@ -1350,7 +1396,7 @@ extends java.lang.Object
from CMYK to YCCK (see CS_YCCK) as part of the JPEG compression
process, some of the Cb and Cr (chrominance) components can be discarded
or averaged together to produce a smaller image with little perceptible
- loss of image clarity. (The human eye is more sensitive to small changes
+ loss of image quality. (The human eye is more sensitive to small changes
in brightness than to small changes in color.) This is called
"chrominance subsampling".
@@ -1453,7 +1499,7 @@ extends java.lang.Object
Value
0[default] Use smooth upsampling when
- decompressing a JPEG image that was compressed using chrominance
+ decompressing a JPEG image that was generated using chrominance
subsampling. This creates a smooth transition between neighboring
chrominance components in order to reduce upsampling artifacts in the
decompressed image.
@@ -1495,9 +1541,8 @@ extends java.lang.Object
The difference in accuracy between the "fast" and "accurate"
algorithms is the most pronounced at JPEG quality levels above 90 and
tends to be more pronounced with decompression than with compression.
-
The "fast" algorithm degrades and is not fully accelerated for JPEG
- quality levels above 97, so it will be slower than the "accurate"
- algorithm.
+
For JPEG quality levels above 97, the "fast" algorithm degrades and
+ is not fully accelerated, so it is slower than the "accurate" algorithm.
Optimized baseline entropy coding will improve compression slightly
- (generally 5% or less), but it will reduce compression performance
- considerably.
+
Huffman table optimization improves compression slightly (generally 5%
+ or less), but it reduces compression performance considerably.
In a progressive JPEG image, the DCT coefficients are split across
+ multiple "scans" of increasing quality. Thus, a low-quality scan
+ containing the lowest-frequency DCT coefficients can be transmitted first
+ and refined with subsequent higher-quality scans containing
+ higher-frequency DCT coefficients. When using Huffman entropy coding, the
+ progressive JPEG format also provides an "end-of-bands (EOB) run" feature
+ that allows large groups of zeroes, potentially spanning multiple MCU
+ blocks, to be represented using only a few bytes.
Value
0[default for compression, lossless
- transformation] The lossy JPEG image uses (decompression) or will use
- (compression, lossless transformation) baseline entropy coding.
-
1 The lossy JPEG image uses (decompression) or will use
- (compression, lossless transformation) progressive entropy coding. For
- lossless transformation, this can also be specified using
+ transformation] The lossy JPEG image is (decompression) or will be
+ (compression, lossless transformation) single-scan.
+
1 The lossy JPEG image is (decompression) or will be
+ (compression, lossless transformation) progressive. For lossless
+ transformation, this can also be specified using
TJTransform.OPT_PROGRESSIVE.
-
Progressive entropy coding will generally improve compression relative
- to baseline entropy coding, but it will reduce compression and
- decompression performance considerably. Can be combined with
- PARAM_ARITHMETIC. Implies PARAM_OPTIMIZE unless
- PARAM_ARITHMETIC is also set.
+
Progressive JPEG images generally have better compression ratios than
+ single-scan JPEG images (much better if the image has large areas of solid
+ color), but progressive JPEG compression and decompression is considerably
+ slower than single-scan JPEG compression and decompression. Can be
+ combined with PARAM_ARITHMETIC. Implies PARAM_OPTIMIZE
+ unless PARAM_ARITHMETIC is also set.
Setting this parameter will cause the decompression and transform
+
Setting this parameter causes the decompression and transform
operations to throw an error if the number of scans in a progressive JPEG
image exceeds the specified limit. The primary purpose of this is to
allow security-critical applications to guard against an exploit of the
@@ -1613,9 +1667,9 @@ extends java.lang.Object
TJTransform.OPT_ARITHMETIC.
-
Arithmetic entropy coding will generally improve compression relative
- to Huffman entropy coding, but it will reduce compression and
- decompression performance considerably. Can be combined with
+
Arithmetic entropy coding generally improves compression relative to
+ Huffman entropy coding, but it reduces compression and decompression
+ performance considerably. Can be combined with
PARAM_PROGRESSIVE.
In most cases, compressing and decompressing lossless JPEG images is
- considerably slower than compressing and decompressing lossy JPEG images,
- and lossless JPEG images are much larger than lossy JPEG images. Thus,
+
In most cases, lossless JPEG compression and decompression is
+ considerably slower than lossy JPEG compression and decompression, and
+ lossless JPEG images are much larger than lossy JPEG images. Thus,
lossless JPEG images are typically used only for applications that require
mathematically lossless compression. Also note that the following
features are not available with lossless JPEG images:
@@ -1654,7 +1708,7 @@ extends java.lang.Object
SAMP_444)
JPEG quality selection
DCT/IDCT algorithm selection
-
Progressive entropy coding
+
Progressive JPEG
Arithmetic entropy coding
Compression from/decompression to planar YUV images
the maximum amount of memory (in megabytes) that will be allocated
for intermediate buffers, which are used with progressive JPEG compression
- and decompression, optimized baseline entropy coding, lossless JPEG
- compression, and lossless transformation [default: 0 (no
- limit)]
+ and decompression, Huffman table optimization, lossless JPEG compression,
+ and lossless transformation [default: 0 (no limit)]
Setting this parameter will cause the decompression and transform
+
Setting this parameter causes the decompression and transform
operations to throw an error if the number of pixels in the JPEG source
image exceeds the specified limit. This allows security-critical
applications to guard against excessive memory consumption.
@@ -2072,8 +2125,8 @@ public static final int FLAG_LIMITSCANS
public static final int ERR_WARNING
The error was non-fatal and recoverable, but the destination image may
still be corrupt.
-
- NOTE: due to the design of the TurboJPEG Java API, only certain methods
+
+
NOTE: Due to the design of the TurboJPEG Java API, only certain methods
(specifically, TJDecompressor.decompress*() methods
with a void return type) will complete and leave the destination image in
a fully recoverable state after a non-fatal error occurs.
@@ -2192,7 +2245,7 @@ public static final int FLAG_LIMITSCANS
For the given pixel format, returns the number of samples that the red
component is offset from the start of the pixel. For instance, if an
8-bit-per-sample pixel of format TJ.PF_BGRX is stored in
- char pixel[], then the red component will be
+ char pixel[], then the red component is
pixel[TJ.getRedOffset(TJ.PF_BGRX)].
Parameters:
@@ -2213,7 +2266,7 @@ public static final int FLAG_LIMITSCANS
For the given pixel format, returns the number of samples that the green
component is offset from the start of the pixel. For instance, if an
8-bit-per-sample pixel of format TJ.PF_BGRX is stored in
- char pixel[], then the green component will be
+ char pixel[], then the green component is
pixel[TJ.getGreenOffset(TJ.PF_BGRX)].
Parameters:
@@ -2234,7 +2287,7 @@ public static final int FLAG_LIMITSCANS
For the given pixel format, returns the number of samples that the blue
component is offset from the start of the pixel. For instance, if an
8-bit-per-sample pixel of format TJ.PF_BGRX is stored in
- char pixel[], then the blue component will be
+ char pixel[], then the blue component is
pixel[TJ.getBlueOffset(TJ.PF_BGRX)].
Parameters:
@@ -2255,7 +2308,7 @@ public static final int FLAG_LIMITSCANS
For the given pixel format, returns the number of samples that the alpha
component is offset from the start of the pixel. For instance, if an
8-bit-per-sample pixel of format TJ.PF_BGRA is stored in
- char pixel[], then the alpha component will be
+ char pixel[], then the alpha component is
pixel[TJ.getAlphaOffset(TJ.PF_BGRA)].
Parameters:
@@ -2340,10 +2393,10 @@ public static final int FLAG_LIMITSCANS
Parameters:
componentID - ID number of the image plane (0 = Y, 1 = U/Cb,
2 = V/Cr)
-
width - width (in pixels) of the YUV image. NOTE: this is the width
+
width - width (in pixels) of the YUV image. NOTE: This is the width
of the whole image, not the plane width.
stride - bytes per row in the image plane.
-
height - height (in pixels) of the YUV image. NOTE: this is the
+
height - height (in pixels) of the YUV image. NOTE: This is the
height of the whole image, not the plane height.
subsamp - the level of chrominance subsampling used in the YUV
image (one of TJ.SAMP_*)
coeffBuffer - a buffer containing transformed DCT coefficients.
- (NOTE: this buffer is not guaranteed to be valid once the callback
+ (NOTE: This buffer is not guaranteed to be valid once the callback
returns, so applications wishing to hand off the DCT coefficients to
another method should make a copy of them within the body of the
callback.)
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
index 9dbc92e2..e17a36aa 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
@@ -980,9 +980,9 @@ public int getScaledHeight(int desiredWidth,
source image associated with this decompressor instance and output an
8-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given
destination buffer.
-
- NOTE: The destination image is fully recoverable if this method throws a
- non-fatal TJException (unless TJ.PARAM_STOPONWARNING is
+
+
NOTE: The destination image is fully recoverable if this method throws
+ a non-fatal TJException (unless TJ.PARAM_STOPONWARNING is
set.)
Parameters:
@@ -1011,7 +1011,7 @@ public int getScaledHeight(int desiredWidth,
TJ.getPixelSize(pixelFormat).) However,
you can also use this parameter to specify the row alignment/padding of
the destination image, to skip rows, or to decompress/decode into a
- specific region of a larger image. NOTE: if the source image is a lossy
+ specific region of a larger image. NOTE: If the source image is a lossy
JPEG image, then destinationWidth is either the scaled JPEG
width (see setScalingFactor(),
TJScalingFactor.getScaled(), and
@@ -1118,9 +1118,9 @@ public byte[] decompress(int desiredWidth,
Decompress the 12-bit-per-sample JPEG source image associated with this
decompressor instance and output a 12-bit-per-sample packed-pixel
grayscale, RGB, or CMYK image to the given destination buffer.
-
- NOTE: The destination image is fully recoverable if this method throws a
- non-fatal TJException (unless TJ.PARAM_STOPONWARNING is
+
+
NOTE: The destination image is fully recoverable if this method throws
+ a non-fatal TJException (unless TJ.PARAM_STOPONWARNING is
set.)
Parameters:
@@ -1150,7 +1150,7 @@ public byte[] decompress(int desiredWidth,
TJ.getPixelSize(pixelFormat).) However,
you can also use this parameter to specify the row alignment/padding of
the destination image, to skip rows, or to decompress into a specific
- region of a larger image. NOTE: if the source image is a lossy JPEG
+ region of a larger image. NOTE: If the source image is a lossy JPEG
image, then destinationWidth is either the scaled JPEG width
(see setScalingFactor(),
TJScalingFactor.getScaled(), and
@@ -1207,9 +1207,9 @@ public byte[] decompress(int desiredWidth,
with this decompressor instance and output a 16-bit-per-sample
packed-pixel grayscale, RGB, or CMYK image to the given destination
buffer.
-
- NOTE: The destination image is fully recoverable if this method throws a
- non-fatal TJException (unless TJ.PARAM_STOPONWARNING is
+
+
NOTE: The destination image is fully recoverable if this method throws
+ a non-fatal TJException (unless TJ.PARAM_STOPONWARNING is
set.)
Parameters:
@@ -1279,9 +1279,9 @@ public byte[] decompress(int desiredWidth,
decompression but leaves out the color conversion step, so a planar YUV
image is generated instead of a packed-pixel image. This method cannot be
used to decompress JPEG source images with the CMYK or YCCK colorspace.
-
- NOTE: The planar YUV destination image is fully recoverable if this method
- throws a non-fatal TJException (unless
+
+
NOTE: The planar YUV destination image is fully recoverable if this
+ method throws a non-fatal TJException (unless
TJ.PARAM_STOPONWARNING is set.)
This option will prevent TJTransformer.transform() from copying any extra markers (including EXIF
- and ICC profile data) from the source image to the destination image.
+
Do not copy any extra markers (including EXIF and ICC profile data) from
+ the source image to the destination image.
This option will discard any partial MCU blocks that cannot be
- transformed.
+
Discard any partial MCU blocks that cannot be transformed.
@@ -612,16 +608,16 @@ extends java.awt.Rectangle
OPT_PERFECT
public static final int OPT_PERFECT
-
This option will cause TJTransformer.transform() to throw an exception if the transform is not
- perfect. Lossless transforms operate on MCU blocks, whose size depends on
- the level of chrominance subsampling used. If the image's width or height
- is not evenly divisible by the MCU block size (see TJ.getMCUWidth() and TJ.getMCUHeight()), then
- there will be partial MCU blocks on the right and/or bottom edges. It is
- not possible to move these partial MCU blocks to the top or left of the
- image, so any transform that would require that is "imperfect." If this
- option is not specified, then any partial MCU blocks that cannot be
- transformed will be left in place, which will create odd-looking strips on
- the right or bottom edge of the image.
+
This option causes TJTransformer.transform() to throw an exception if the transform is not
+ perfect. Lossless transforms operate on MCU blocks, the size of which
+ depends on the level of chrominance subsampling used. If the image's
+ width or height is not evenly divisible by the MCU block size (see
+ TJ.getMCUWidth() and TJ.getMCUHeight()), then there will be partial MCU blocks on the right
+ and/or bottom edges. It is not possible to move these partial MCU blocks
+ to the top or left of the image, so any transform that would require that
+ is "imperfect." If this option is not specified, then any partial MCU
+ blocks that cannot be transformed will be left in place, which will create
+ odd-looking strips on the right or bottom edge of the image.
This option will prevent TJTransformer.transform() from outputting a JPEG image for this
- particular transform. This can be used in conjunction with a custom
- filter to capture the transformed DCT coefficients without transcoding
- them.
+
Do not generate a destination image. This can be used in conjunction with
+ a custom filter to capture the transformed DCT coefficients without
+ transcoding them.
This option will enable progressive entropy coding in the JPEG image
- generated by this particular transform. Progressive entropy coding will
- generally improve compression relative to baseline entropy coding (the
- default), but it will reduce decompression performance considerably.
- Can be combined with OPT_ARITHMETIC. Implies
- OPT_OPTIMIZE unless OPT_ARITHMETIC is also specified.
+
Generate a progressive destination image instead of a single-scan
+ destination image. Progressive JPEG images generally have better
+ compression ratios than single-scan JPEG images (much better if the image
+ has large areas of solid color), but progressive JPEG decompression is
+ considerably slower than single-scan JPEG decompression. Can be combined
+ with OPT_ARITHMETIC. Implies OPT_OPTIMIZE unless
+ OPT_ARITHMETIC is also specified.
This option will prevent TJTransformer.transform() from copying any extra markers (including EXIF
- and ICC profile data) from the source image to the destination image.
+
Do not copy any extra markers (including EXIF and ICC profile data) from
+ the source image to the destination image.
This option will enable arithmetic entropy coding in the JPEG image
- generated by this particular transform. Arithmetic entropy coding will
- generally improve compression relative to Huffman entropy coding (the
- default), but it will reduce decompression performance considerably. Can
- be combined with OPT_PROGRESSIVE.
+
Enable arithmetic entropy coding in the destination image. Arithmetic
+ entropy coding generally improves compression relative to Huffman entropy
+ coding (the default), but it reduces decompression performance
+ considerably. Can be combined with OPT_PROGRESSIVE.
This option will enable optimized baseline entropy coding in the JPEG
- image generated by this particular transform. Optimized baseline entropy
- coding will improve compression slightly (generally 5% or less.)
+
Enable Huffman table optimization for the destination image. Huffman
+ table optimization improves compression slightly (generally 5% or less.)
diff --git a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html
index 62d2a2a2..8c3a3d46 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html
@@ -139,15 +139,15 @@ extends java.lang.Object
serves as the destination image for YUV encode and decompress-to-YUV
operations and as the source image for compress-from-YUV and YUV decode
operations.
-
- Technically, the JPEG format uses the YCbCr colorspace (which is technically
- not a colorspace but a color transform), but per the convention of the
- digital video community, the TurboJPEG API uses "YUV" to refer to an image
- format consisting of Y, Cb, and Cr image planes.
-
- Each plane is simply a 2D array of bytes, each byte representing the value
- of one of the components (Y, Cb, or Cr) at a particular location in the
- image. The width and height of each plane are determined by the image
+
+
Technically, the JPEG format uses the YCbCr colorspace (which is
+ technically not a colorspace but a color transform), but per the convention
+ of the digital video community, the TurboJPEG API uses "YUV" to refer to an
+ image format consisting of Y, Cb, and Cr image planes.
+
+
Each plane is simply a 2D array of bytes, each byte representing the
+ value of one of the components (Y, Cb, or Cr) at a particular location in
+ the image. The width and height of each plane are determined by the image
width, height, and level of chrominance subsampling. The luminance plane
width is the image width padded to the nearest multiple of the horizontal
subsampling factor (1 in the case of 4:4:4, grayscale, 4:4:0, or 4:4:1; 2 in
@@ -160,9 +160,9 @@ extends java.lang.Object
the luminance plane width divided by the horizontal subsampling factor, and
the chrominance plane height is equal to the luminance plane height divided
by the vertical subsampling factor.
-
- For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is
- used, then the luminance plane would be 36 x 35 bytes, and each of the
+
+
For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling
+ is used, then the luminance plane would be 36 x 35 bytes, and each of the
chrominance planes would be 18 x 35 bytes. If you specify a row alignment
of 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes,
and each of the chrominance planes would be 20 x 35 bytes.
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index 7b81a746ee657f308df5fc9f88dc88698b202629..dd44bf6aa5e3b20de2c6f90872e274caac417b80 100644
GIT binary patch
delta 30
icmaFM_?D3`z?+#xgn@&DgF!M*AaWvK9}AdX;0pk0kOwFL
delta 30
icmaFM_?D3`z?+#xgn@&DgTW^9M#MzEJ{B;&z!v~|E(r1f
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index 27b05a1b1dd4a9231a93e6c3d590d98dc5a7f0fa..e248dfa119923e98c6698b676f78761b5837ad5b 100644
GIT binary patch
delta 30
icmdnaw4I4Bz?+#xgn@&DgF!M*AaWw#Z5A;7)(Ze&*auYr
delta 30
icmdnaw4I4Bz?+#xgn@&DgTW^9M#MzE+bm%Etrq}sb_pK<
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index 4b3fa99b..0927967d 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011-2013, 2017-2018, 2020-2023 D. R. Commander.
+ * Copyright (C)2011-2013, 2017-2018, 2020-2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
@@ -44,57 +44,72 @@ public final class TJ {
*/
public static final int NUMSAMP = 7;
/**
- * 4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG
- * or YUV image will contain one chrominance component for every pixel in the
- * source image.
+ * 4:4:4 chrominance subsampling (no chrominance subsampling)
+ *
+ *
The JPEG or YUV image will contain one chrominance component for every
+ * pixel in the source image.
*/
public static final int SAMP_444 = 0;
/**
- * 4:2:2 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x1 block of pixels in the source image.
+ * 4:2:2 chrominance subsampling
+ *
+ *
The JPEG or YUV image will contain one chrominance component for every
+ * 2x1 block of pixels in the source image.
*/
public static final int SAMP_422 = 1;
/**
- * 4:2:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x2 block of pixels in the source image.
+ * 4:2:0 chrominance subsampling
+ *
+ *
The JPEG or YUV image will contain one chrominance component for every
+ * 2x2 block of pixels in the source image.
*/
public static final int SAMP_420 = 2;
/**
- * Grayscale. The JPEG or YUV image will contain no chrominance components.
+ * Grayscale
+ *
+ *
The JPEG or YUV image will contain no chrominance components.
*/
public static final int SAMP_GRAY = 3;
/**
- * 4:4:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 1x2 block of pixels in the source image.
- * Note that 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
+ * 4:4:0 chrominance subsampling
+ *
+ *
The JPEG or YUV image will contain one chrominance component for every
+ * 1x2 block of pixels in the source image.
+ *
+ *
NOTE: 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
*/
public static final int SAMP_440 = 4;
/**
- * 4:1:1 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 4x1 block of pixels in the source image.
- * JPEG images compressed with 4:1:1 subsampling will be almost exactly the
- * same size as those compressed with 4:2:0 subsampling, and in the
- * aggregate, both subsampling methods produce approximately the same
- * perceptual quality. However, 4:1:1 is better able to reproduce sharp
- * horizontal features. Note that 4:1:1 subsampling is not fully accelerated
- * in libjpeg-turbo.
+ * 4:1:1 chrominance subsampling
+ *
+ *
The JPEG or YUV image will contain one chrominance component for every
+ * 4x1 block of pixels in the source image. All else being equal, a JPEG
+ * image with 4:1:1 subsampling is almost exactly the same size as a JPEG
+ * image with 4:2:0 subsampling, and in the aggregate, both subsampling
+ * methods produce approximately the same perceptual quality. However, 4:1:1
+ * is better able to reproduce sharp horizontal features.
+ *
+ *
NOTE: 4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
*/
public static final int SAMP_411 = 5;
/**
- * 4:4:1 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 1x4 block of pixels in the source image.
- * JPEG images compressed with 4:4:1 subsampling will be almost exactly the
- * same size as those compressed with 4:2:0 subsampling, and in the
- * aggregate, both subsampling methods produce approximately the same
- * perceptual quality. However, 4:4:1 is better able to reproduce sharp
- * vertical features. Note that 4:4:1 subsampling is not fully accelerated
- * in libjpeg-turbo.
+ * 4:4:1 chrominance subsampling
+ *
+ *
The JPEG or YUV image will contain one chrominance component for every
+ * 1x4 block of pixels in the source image. All else being equal, a JPEG
+ * image with 4:4:1 subsampling is almost exactly the same size as a JPEG
+ * image with 4:2:0 subsampling, and in the aggregate, both subsampling
+ * methods produce approximately the same perceptual quality. However, 4:4:1
+ * is better able to reproduce sharp vertical features.
+ *
+ *
NOTE: 4:4:1 subsampling is not fully accelerated in libjpeg-turbo.
*/
public static final int SAMP_441 = 6;
/**
- * Unknown subsampling. The JPEG image uses an unusual type of chrominance
- * subsampling. Such images can be decompressed into packed-pixel images,
- * but they cannot be
+ * Unknown subsampling
+ *
+ *
The JPEG image uses an unusual type of chrominance subsampling. Such
+ * images can be decompressed into packed-pixel images, but they cannot be
*
*
decompressed into planar YUV images,
*
losslessly transformed if {@link TJTransform#OPT_CROP} is specified,
@@ -149,89 +164,113 @@ public final class TJ {
*/
public static final int NUMPF = 12;
/**
- * RGB pixel format. The red, green, and blue components in the image are
- * stored in 3-sample pixels in the order R, G, B from lowest to highest
- * memory address within each pixel.
+ * RGB pixel format
+ *
+ *
The red, green, and blue components in the image are stored in 3-sample
+ * pixels in the order R, G, B from lowest to highest memory address within
+ * each pixel.
*/
public static final int PF_RGB = 0;
/**
- * BGR pixel format. The red, green, and blue components in the image are
- * stored in 3-sample pixels in the order B, G, R from lowest to highest
- * memory address within each pixel.
+ * BGR pixel format
+ *
+ *
The red, green, and blue components in the image are stored in 3-sample
+ * pixels in the order B, G, R from lowest to highest memory address within
+ * each pixel.
*/
public static final int PF_BGR = 1;
/**
- * RGBX pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order R, G, B from lowest to highest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * RGBX pixel format
+ *
+ *
The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order R, G, B from lowest to highest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
public static final int PF_RGBX = 2;
/**
- * BGRX pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order B, G, R from lowest to highest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * BGRX pixel format
+ *
+ *
The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order B, G, R from lowest to highest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
public static final int PF_BGRX = 3;
/**
- * XBGR pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order R, G, B from highest to lowest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * XBGR pixel format
+ *
+ *
The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order R, G, B from highest to lowest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
public static final int PF_XBGR = 4;
/**
- * XRGB pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order B, G, R from highest to lowest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * XRGB pixel format
+ *
+ *
The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order B, G, R from highest to lowest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
public static final int PF_XRGB = 5;
/**
- * Grayscale pixel format. Each 1-sample pixel represents a luminance
- * (brightness) level from 0 to the maximum sample value (255 for 8-bit
- * samples, 4095 for 12-bit samples, and 65535 for 16-bit samples.)
+ * Grayscale pixel format
+ *
+ *
Each 1-sample pixel represents a luminance (brightness) level from 0 to
+ * the maximum sample value (255 for 8-bit samples, 4095 for 12-bit samples,
+ * and 65535 for 16-bit samples.)
*/
public static final int PF_GRAY = 6;
/**
- * RGBA pixel format. This is the same as {@link #PF_RGBX}, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * RGBA pixel format
+ *
+ *
This is the same as {@link #PF_RGBX}, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
public static final int PF_RGBA = 7;
/**
- * BGRA pixel format. This is the same as {@link #PF_BGRX}, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * BGRA pixel format
+ *
+ *
This is the same as {@link #PF_BGRX}, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
public static final int PF_BGRA = 8;
/**
- * ABGR pixel format. This is the same as {@link #PF_XBGR}, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * ABGR pixel format
+ *
+ *
This is the same as {@link #PF_XBGR}, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
public static final int PF_ABGR = 9;
/**
- * ARGB pixel format. This is the same as {@link #PF_XRGB}, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * ARGB pixel format
+ *
+ *
This is the same as {@link #PF_XRGB}, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
public static final int PF_ARGB = 10;
/**
- * CMYK pixel format. Unlike RGB, which is an additive color model used
- * primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive
- * color model used primarily for printing. In the CMYK color model, the
- * value of each color component typically corresponds to an amount of cyan,
- * magenta, yellow, or black ink that is applied to a white background. In
- * order to convert between CMYK and RGB, it is necessary to use a color
- * management system (CMS.) A CMS will attempt to map colors within the
- * printer's gamut to perceptually similar colors in the display's gamut and
- * vice versa, but the mapping is typically not 1:1 or reversible, nor can it
- * be defined with a simple formula. Thus, such a conversion is out of scope
- * for a codec library. However, the TurboJPEG API allows for compressing
- * packed-pixel CMYK images into YCCK JPEG images (see {@link #CS_YCCK}) and
- * decompressing YCCK JPEG images into packed-pixel CMYK images.
+ * CMYK pixel format
+ *
+ *
Unlike RGB, which is an additive color model used primarily for
+ * display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used
+ * primarily for printing. In the CMYK color model, the value of each color
+ * component typically corresponds to an amount of cyan, magenta, yellow, or
+ * black ink that is applied to a white background. In order to convert
+ * between CMYK and RGB, it is necessary to use a color management system
+ * (CMS.) A CMS will attempt to map colors within the printer's gamut to
+ * perceptually similar colors in the display's gamut and vice versa, but the
+ * mapping is typically not 1:1 or reversible, nor can it be defined with a
+ * simple formula. Thus, such a conversion is out of scope for a codec
+ * library. However, the TurboJPEG API allows for compressing packed-pixel
+ * CMYK images into YCCK JPEG images (see {@link #CS_YCCK}) and decompressing
+ * YCCK JPEG images into packed-pixel CMYK images.
*/
public static final int PF_CMYK = 11;
@@ -257,7 +296,7 @@ public final class TJ {
* For the given pixel format, returns the number of samples that the red
* component is offset from the start of the pixel. For instance, if an
* 8-bit-per-sample pixel of format TJ.PF_BGRX is stored in
- * char pixel[], then the red component will be
+ * char pixel[], then the red component is
* pixel[TJ.getRedOffset(TJ.PF_BGRX)].
*
* @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
@@ -279,7 +318,7 @@ public final class TJ {
* For the given pixel format, returns the number of samples that the green
* component is offset from the start of the pixel. For instance, if an
* 8-bit-per-sample pixel of format TJ.PF_BGRX is stored in
- * char pixel[], then the green component will be
+ * char pixel[], then the green component is
* pixel[TJ.getGreenOffset(TJ.PF_BGRX)].
*
* @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
@@ -301,7 +340,7 @@ public final class TJ {
* For the given pixel format, returns the number of samples that the blue
* component is offset from the start of the pixel. For instance, if an
* 8-bit-per-sample pixel of format TJ.PF_BGRX is stored in
- * char pixel[], then the blue component will be
+ * char pixel[], then the blue component is
* pixel[TJ.getBlueOffset(TJ.PF_BGRX)].
*
* @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
@@ -323,7 +362,7 @@ public final class TJ {
* For the given pixel format, returns the number of samples that the alpha
* component is offset from the start of the pixel. For instance, if an
* 8-bit-per-sample pixel of format TJ.PF_BGRA is stored in
- * char pixel[], then the alpha component will be
+ * char pixel[], then the alpha component is
* pixel[TJ.getAlphaOffset(TJ.PF_BGRA)].
*
* @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
@@ -346,57 +385,64 @@ public final class TJ {
*/
public static final int NUMCS = 5;
/**
- * RGB colorspace. When compressing the JPEG image, the R, G, and B
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. RGB JPEG images can be
- * compressed from and decompressed to packed-pixel images with any of the
- * extended RGB or grayscale pixel formats, but they cannot be compressed
- * from or decompressed to planar YUV images.
+ * RGB colorspace
+ *
+ *
When generating the JPEG image, the R, G, and B components in the
+ * source image are reordered into image planes, but no colorspace conversion
+ * or subsampling is performed. RGB JPEG images can be generated from and
+ * decompressed to packed-pixel images with any of the extended RGB or
+ * grayscale pixel formats, but they cannot be generated from or
+ * decompressed to planar YUV images.
*/
public static final int CS_RGB = 0;
/**
- * YCbCr colorspace. YCbCr is not an absolute colorspace but rather a
- * mathematical transformation of RGB designed solely for storage and
- * transmission. YCbCr images must be converted to RGB before they can
- * actually be displayed. In the YCbCr colorspace, the Y (luminance)
- * component represents the black & white portion of the original image,
- * and the Cb and Cr (chrominance) components represent the color portion of
- * the original image. Originally, the analog equivalent of this
- * transformation allowed the same signal to drive both black & white and
- * color televisions, but JPEG images use YCbCr primarily because it allows
- * the color data to be optionally subsampled for the purposes of reducing
- * network or disk usage. YCbCr is the most common JPEG colorspace, and
- * YCbCr JPEG images can be compressed from and decompressed to packed-pixel
- * images with any of the extended RGB or grayscale pixel formats. YCbCr
- * JPEG images can also be compressed from and decompressed to planar YUV
- * images.
+ * YCbCr colorspace
+ *
+ *
YCbCr is not an absolute colorspace but rather a mathematical
+ * transformation of RGB designed solely for storage and transmission. YCbCr
+ * images must be converted to RGB before they can be displayed. In the
+ * YCbCr colorspace, the Y (luminance) component represents the black &
+ * white portion of the original image, and the Cb and Cr (chrominance)
+ * components represent the color portion of the original image.
+ * Historically, the analog equivalent of this transformation allowed the
+ * same signal to be displayed to both black & white and color
+ * televisions, but JPEG images use YCbCr primarily because it allows the
+ * color data to be optionally subsampled in order to reduce network and disk
+ * usage. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images
+ * can be generated from and decompressed to packed-pixel images with any of
+ * the extended RGB or grayscale pixel formats. YCbCr JPEG images can also
+ * be generated from and decompressed to planar YUV images.
*/
@SuppressWarnings("checkstyle:ConstantName")
public static final int CS_YCbCr = 1;
/**
- * Grayscale colorspace. The JPEG image retains only the luminance data (Y
- * component), and any color data from the source image is discarded.
- * Grayscale JPEG images can be compressed from and decompressed to
- * packed-pixel images with any of the extended RGB or grayscale pixel
- * formats, or they can be compressed from and decompressed to planar YUV
- * images.
+ * Grayscale colorspace
+ *
+ *
The JPEG image retains only the luminance data (Y component), and any
+ * color data from the source image is discarded. Grayscale JPEG images can
+ * be generated from and decompressed to packed-pixel images with any of the
+ * extended RGB or grayscale pixel formats, or they can be generated from and
+ * decompressed to planar YUV images.
*/
public static final int CS_GRAY = 2;
/**
- * CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. CMYK JPEG images can
- * only be compressed from and decompressed to packed-pixel images with the
- * CMYK pixel format.
+ * CMYK colorspace
+ *
+ *
When generating the JPEG image, the C, M, Y, and K components in the
+ * source image are reordered into image planes, but no colorspace conversion
+ * or subsampling is performed. CMYK JPEG images can only be generated from
+ * and decompressed to packed-pixel images with the CMYK pixel format.
*/
public static final int CS_CMYK = 3;
/**
- * YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but
- * rather a mathematical transformation of CMYK designed solely for storage
- * and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
+ * YCCK colorspace
+ *
+ *
YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a
+ * mathematical transformation of CMYK designed solely for storage and
+ * transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
* reversibly transformed into YCCK, and as with YCbCr, the chrominance
* components in the YCCK pixels can be subsampled without incurring major
- * perceptual loss. YCCK JPEG images can only be compressed from and
+ * perceptual loss. YCCK JPEG images can only be generated from and
* decompressed to packed-pixel images with the CMYK pixel format.
*/
public static final int CS_YCCK = 4;
@@ -447,7 +493,7 @@ public final class TJ {
* from CMYK to YCCK (see {@link #CS_YCCK}) as part of the JPEG compression
* process, some of the Cb and Cr (chrominance) components can be discarded
* or averaged together to produce a smaller image with little perceptible
- * loss of image clarity. (The human eye is more sensitive to small changes
+ * loss of image quality. (The human eye is more sensitive to small changes
* in brightness than to small changes in color.) This is called
* "chrominance subsampling".
*
@@ -500,7 +546,7 @@ public final class TJ {
*
Value
*
*
0[default] Use smooth upsampling when
- * decompressing a JPEG image that was compressed using chrominance
+ * decompressing a JPEG image that was generated using chrominance
* subsampling. This creates a smooth transition between neighboring
* chrominance components in order to reduce upsampling artifacts in the
* decompressed image.
@@ -532,14 +578,13 @@ public final class TJ {
*
The difference in accuracy between the "fast" and "accurate"
* algorithms is the most pronounced at JPEG quality levels above 90 and
* tends to be more pronounced with decompression than with compression.
- *
The "fast" algorithm degrades and is not fully accelerated for JPEG
- * quality levels above 97, so it will be slower than the "accurate"
- * algorithm.
+ *
For JPEG quality levels above 97, the "fast" algorithm degrades and
+ * is not fully accelerated, so it is slower than the "accurate" algorithm.
*
*/
public static final int PARAM_FASTDCT = 10;
/**
- * Optimized baseline entropy coding [lossy compression only]
+ * Huffman table optimization [lossy compression, lossless transformation]
*
*
Value
*
@@ -550,37 +595,46 @@ public final class TJ {
* {@link TJTransform#OPT_OPTIMIZE}.
*
*
- *
Optimized baseline entropy coding will improve compression slightly
- * (generally 5% or less), but it will reduce compression performance
- * considerably.
+ *
Huffman table optimization improves compression slightly (generally 5%
+ * or less), but it reduces compression performance considerably.
*/
public static final int PARAM_OPTIMIZE = 11;
/**
- * Progressive entropy coding
+ * Progressive JPEG
+ *
+ *
In a progressive JPEG image, the DCT coefficients are split across
+ * multiple "scans" of increasing quality. Thus, a low-quality scan
+ * containing the lowest-frequency DCT coefficients can be transmitted first
+ * and refined with subsequent higher-quality scans containing
+ * higher-frequency DCT coefficients. When using Huffman entropy coding, the
+ * progressive JPEG format also provides an "end-of-bands (EOB) run" feature
+ * that allows large groups of zeroes, potentially spanning multiple MCU
+ * blocks, to be represented using only a few bytes.
*
*
Value
*
*
0[default for compression, lossless
- * transformation] The lossy JPEG image uses (decompression) or will use
- * (compression, lossless transformation) baseline entropy coding.
- *
1 The lossy JPEG image uses (decompression) or will use
- * (compression, lossless transformation) progressive entropy coding. For
- * lossless transformation, this can also be specified using
+ * transformation] The lossy JPEG image is (decompression) or will be
+ * (compression, lossless transformation) single-scan.
+ *
1 The lossy JPEG image is (decompression) or will be
+ * (compression, lossless transformation) progressive. For lossless
+ * transformation, this can also be specified using
* {@link TJTransform#OPT_PROGRESSIVE}.
*
*
- *
Progressive entropy coding will generally improve compression relative
- * to baseline entropy coding, but it will reduce compression and
- * decompression performance considerably. Can be combined with
- * {@link #PARAM_ARITHMETIC}. Implies {@link #PARAM_OPTIMIZE} unless
- * {@link #PARAM_ARITHMETIC} is also set.
+ *
Progressive JPEG images generally have better compression ratios than
+ * single-scan JPEG images (much better if the image has large areas of solid
+ * color), but progressive JPEG compression and decompression is considerably
+ * slower than single-scan JPEG compression and decompression. Can be
+ * combined with {@link #PARAM_ARITHMETIC}. Implies {@link #PARAM_OPTIMIZE}
+ * unless {@link #PARAM_ARITHMETIC} is also set.
*/
public static final int PARAM_PROGRESSIVE = 12;
/**
* Progressive JPEG scan limit for lossy JPEG images [decompression, lossless
* transformation]
*
- *
Setting this parameter will cause the decompression and transform
+ *
Setting this parameter causes the decompression and transform
* operations to throw an error if the number of scans in a progressive JPEG
* image exceeds the specified limit. The primary purpose of this is to
* allow security-critical applications to guard against an exploit of the
@@ -611,9 +665,9 @@ public final class TJ {
* {@link TJTransform#OPT_ARITHMETIC}.
*
*
- *
Arithmetic entropy coding will generally improve compression relative
- * to Huffman entropy coding, but it will reduce compression and
- * decompression performance considerably. Can be combined with
+ *
Arithmetic entropy coding generally improves compression relative to
+ * Huffman entropy coding, but it reduces compression and decompression
+ * performance considerably. Can be combined with
* {@link #PARAM_PROGRESSIVE}.
*/
public static final int PARAM_ARITHMETIC = 14;
@@ -628,9 +682,9 @@ public final class TJ {
* (compression) lossless/predictive.
*
*
- *
In most cases, compressing and decompressing lossless JPEG images is
- * considerably slower than compressing and decompressing lossy JPEG images,
- * and lossless JPEG images are much larger than lossy JPEG images. Thus,
+ *
In most cases, lossless JPEG compression and decompression is
+ * considerably slower than lossy JPEG compression and decompression, and
+ * lossless JPEG images are much larger than lossy JPEG images. Thus,
* lossless JPEG images are typically used only for applications that require
* mathematically lossless compression. Also note that the following
* features are not available with lossless JPEG images:
@@ -642,7 +696,7 @@ public final class TJ {
* {@link #SAMP_444})
*
JPEG quality selection
*
DCT/IDCT algorithm selection
- *
Progressive entropy coding
+ *
Progressive JPEG
*
Arithmetic entropy coding
*
Compression from/decompression to planar YUV images
*
Decompression scaling
@@ -809,16 +863,15 @@ public final class TJ {
*
*
the maximum amount of memory (in megabytes) that will be allocated
* for intermediate buffers, which are used with progressive JPEG compression
- * and decompression, optimized baseline entropy coding, lossless JPEG
- * compression, and lossless transformation [default: 0 (no
- * limit)]
+ * and decompression, Huffman table optimization, lossless JPEG compression,
+ * and lossless transformation [default: 0 (no limit)]
*
*/
public static final int PARAM_MAXMEMORY = 23;
/**
* Image size limit [decompression, lossless transformation]
*
- *
Setting this parameter will cause the decompression and transform
+ *
Setting this parameter causes the decompression and transform
* operations to throw an error if the number of pixels in the JPEG source
* image exceeds the specified limit. This allows security-critical
* applications to guard against excessive memory consumption.
@@ -876,8 +929,8 @@ public final class TJ {
/**
* The error was non-fatal and recoverable, but the destination image may
* still be corrupt.
- *
- * NOTE: due to the design of the TurboJPEG Java API, only certain methods
+ *
+ *
NOTE: Due to the design of the TurboJPEG Java API, only certain methods
* (specifically, {@link TJDecompressor TJDecompressor.decompress*()} methods
* with a void return type) will complete and leave the destination image in
* a fully recoverable state after a non-fatal error occurs.
@@ -940,12 +993,12 @@ public final class TJ {
* @param componentID ID number of the image plane (0 = Y, 1 = U/Cb,
* 2 = V/Cr)
*
- * @param width width (in pixels) of the YUV image. NOTE: this is the width
+ * @param width width (in pixels) of the YUV image. NOTE: This is the width
* of the whole image, not the plane width.
*
* @param stride bytes per row in the image plane.
*
- * @param height height (in pixels) of the YUV image. NOTE: this is the
+ * @param height height (in pixels) of the YUV image. NOTE: This is the
* height of the whole image, not the plane height.
*
* @param subsamp the level of chrominance subsampling used in the YUV
diff --git a/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java b/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
index 0444eb7f..0818aa78 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011, 2013, 2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011, 2013, 2023-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,7 +43,7 @@ public interface TJCustomFilter {
* applied in the frequency domain.
*
* @param coeffBuffer a buffer containing transformed DCT coefficients.
- * (NOTE: this buffer is not guaranteed to be valid once the callback
+ * (NOTE: This buffer is not guaranteed to be valid once the callback
* returns, so applications wishing to hand off the DCT coefficients to
* another method should make a copy of them within the body of the
* callback.)
diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
index d821a445..f896d91a 100644
--- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011-2015, 2018, 2022-2023 D. R. Commander.
+ * Copyright (C)2011-2015, 2018, 2022-2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
@@ -380,9 +380,9 @@ public class TJDecompressor implements Closeable {
* source image associated with this decompressor instance and output an
* 8-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given
* destination buffer.
- *
- * NOTE: The destination image is fully recoverable if this method throws a
- * non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING} is
+ *
+ *
NOTE: The destination image is fully recoverable if this method throws
+ * a non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING} is
* set.)
*
* @param dstBuf buffer that will receive the packed-pixel
@@ -413,7 +413,7 @@ public class TJDecompressor implements Closeable {
* {@link TJ#getPixelSize TJ.getPixelSize}(pixelFormat).) However,
* you can also use this parameter to specify the row alignment/padding of
* the destination image, to skip rows, or to decompress/decode into a
- * specific region of a larger image. NOTE: if the source image is a lossy
+ * specific region of a larger image. NOTE: If the source image is a lossy
* JPEG image, then destinationWidth is either the scaled JPEG
* width (see {@link #setScalingFactor setScalingFactor()},
* {@link TJScalingFactor#getScaled TJScalingFactor.getScaled()}, and
@@ -515,9 +515,9 @@ public class TJDecompressor implements Closeable {
* Decompress the 12-bit-per-sample JPEG source image associated with this
* decompressor instance and output a 12-bit-per-sample packed-pixel
* grayscale, RGB, or CMYK image to the given destination buffer.
- *
- * NOTE: The destination image is fully recoverable if this method throws a
- * non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING} is
+ *
+ *
NOTE: The destination image is fully recoverable if this method throws
+ * a non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING} is
* set.)
*
* @param dstBuf buffer that will receive the packed-pixel
@@ -549,7 +549,7 @@ public class TJDecompressor implements Closeable {
* {@link TJ#getPixelSize TJ.getPixelSize}(pixelFormat).) However,
* you can also use this parameter to specify the row alignment/padding of
* the destination image, to skip rows, or to decompress into a specific
- * region of a larger image. NOTE: if the source image is a lossy JPEG
+ * region of a larger image. NOTE: If the source image is a lossy JPEG
* image, then destinationWidth is either the scaled JPEG width
* (see {@link #setScalingFactor setScalingFactor()},
* {@link TJScalingFactor#getScaled TJScalingFactor.getScaled()}, and
@@ -603,9 +603,9 @@ public class TJDecompressor implements Closeable {
* with this decompressor instance and output a 16-bit-per-sample
* packed-pixel grayscale, RGB, or CMYK image to the given destination
* buffer.
- *
- * NOTE: The destination image is fully recoverable if this method throws a
- * non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING} is
+ *
+ *
NOTE: The destination image is fully recoverable if this method throws
+ * a non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING} is
* set.)
*
* @param dstBuf buffer that will receive the packed-pixel
@@ -678,9 +678,9 @@ public class TJDecompressor implements Closeable {
* decompression but leaves out the color conversion step, so a planar YUV
* image is generated instead of a packed-pixel image. This method cannot be
* used to decompress JPEG source images with the CMYK or YCCK colorspace.
- *
- * NOTE: The planar YUV destination image is fully recoverable if this method
- * throws a non-fatal {@link TJException} (unless
+ *
+ *
NOTE: The planar YUV destination image is fully recoverable if this
+ * method throws a non-fatal {@link TJException} (unless
* {@link TJ#PARAM_STOPONWARNING} is set.)
*
* @param dstImage {@link YUVImage} instance that will receive the planar YUV
@@ -836,9 +836,9 @@ public class TJDecompressor implements Closeable {
* source image associated with this decompressor instance and output an
* 8-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given
* destination buffer.
- *
- * NOTE: The destination image is fully recoverable if this method throws a
- * non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING}
+ *
+ *
NOTE: The destination image is fully recoverable if this method throws
+ * a non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING}
* is set.)
*
* @param dstBuf buffer that will receive the packed-pixel
@@ -866,7 +866,7 @@ public class TJDecompressor implements Closeable {
* should be set to destinationWidth. (Setting this parameter
* to 0 is the equivalent of setting it to destinationWidth.)
* However, you can also use this parameter to skip rows or to
- * decompress/decode into a specific region of a larger image. NOTE: if the
+ * decompress/decode into a specific region of a larger image. NOTE: If the
* source image is a lossy JPEG image, then destinationWidth is
* either the scaled JPEG width (see {@link #setScalingFactor
* setScalingFactor()}, {@link TJScalingFactor#getScaled
@@ -921,9 +921,9 @@ public class TJDecompressor implements Closeable {
* source image associated with this decompressor instance and output an
* 8-bit-per-sample packed-pixel decompressed/decoded image to the given
* BufferedImage instance.
- *
- * NOTE: The destination image is fully recoverable if this method throws a
- * non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING}
+ *
+ *
NOTE: The destination image is fully recoverable if this method throws
+ * a non-fatal {@link TJException} (unless {@link TJ#PARAM_STOPONWARNING}
* is set.)
*
* @param dstImage a BufferedImage instance that will receive
diff --git a/java/org/libjpegturbo/turbojpeg/TJTransform.java b/java/org/libjpegturbo/turbojpeg/TJTransform.java
index 7c32cce7..69981900 100644
--- a/java/org/libjpegturbo/turbojpeg/TJTransform.java
+++ b/java/org/libjpegturbo/turbojpeg/TJTransform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011, 2013, 2018, 2022-2023 D. R. Commander.
+ * Copyright (C)2011, 2013, 2018, 2022-2024 D. R. Commander.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -92,69 +92,64 @@ public class TJTransform extends Rectangle {
/**
- * This option will cause {@link TJTransformer#transform
+ * This option causes {@link TJTransformer#transform
* TJTransformer.transform()} to throw an exception if the transform is not
- * perfect. Lossless transforms operate on MCU blocks, whose size depends on
- * the level of chrominance subsampling used. If the image's width or height
- * is not evenly divisible by the MCU block size (see {@link TJ#getMCUWidth
- * TJ.getMCUWidth()} and {@link TJ#getMCUHeight TJ.getMCUHeight()}), then
- * there will be partial MCU blocks on the right and/or bottom edges. It is
- * not possible to move these partial MCU blocks to the top or left of the
- * image, so any transform that would require that is "imperfect." If this
- * option is not specified, then any partial MCU blocks that cannot be
- * transformed will be left in place, which will create odd-looking strips on
- * the right or bottom edge of the image.
+ * perfect. Lossless transforms operate on MCU blocks, the size of which
+ * depends on the level of chrominance subsampling used. If the image's
+ * width or height is not evenly divisible by the MCU block size (see
+ * {@link TJ#getMCUWidth TJ.getMCUWidth()} and {@link TJ#getMCUHeight
+ * TJ.getMCUHeight()}), then there will be partial MCU blocks on the right
+ * and/or bottom edges. It is not possible to move these partial MCU blocks
+ * to the top or left of the image, so any transform that would require that
+ * is "imperfect." If this option is not specified, then any partial MCU
+ * blocks that cannot be transformed will be left in place, which will create
+ * odd-looking strips on the right or bottom edge of the image.
*/
public static final int OPT_PERFECT = (1 << 0);
/**
- * This option will discard any partial MCU blocks that cannot be
- * transformed.
+ * Discard any partial MCU blocks that cannot be transformed.
*/
public static final int OPT_TRIM = (1 << 1);
/**
- * This option will enable lossless cropping.
+ * Enable lossless cropping.
*/
public static final int OPT_CROP = (1 << 2);
/**
- * This option will discard the color data in the source image and produce a
- * grayscale destination image.
+ * Discard the color data in the source image, and generate a grayscale
+ * destination image.
*/
public static final int OPT_GRAY = (1 << 3);
/**
- * This option will prevent {@link TJTransformer#transform
- * TJTransformer.transform()} from outputting a JPEG image for this
- * particular transform. This can be used in conjunction with a custom
- * filter to capture the transformed DCT coefficients without transcoding
- * them.
+ * Do not generate a destination image. This can be used in conjunction with
+ * a custom filter to capture the transformed DCT coefficients without
+ * transcoding them.
*/
public static final int OPT_NOOUTPUT = (1 << 4);
/**
- * This option will enable progressive entropy coding in the JPEG image
- * generated by this particular transform. Progressive entropy coding will
- * generally improve compression relative to baseline entropy coding (the
- * default), but it will reduce decompression performance considerably.
- * Can be combined with {@link #OPT_ARITHMETIC}. Implies
- * {@link #OPT_OPTIMIZE} unless {@link #OPT_ARITHMETIC} is also specified.
+ * Generate a progressive destination image instead of a single-scan
+ * destination image. Progressive JPEG images generally have better
+ * compression ratios than single-scan JPEG images (much better if the image
+ * has large areas of solid color), but progressive JPEG decompression is
+ * considerably slower than single-scan JPEG decompression. Can be combined
+ * with {@link #OPT_ARITHMETIC}. Implies {@link #OPT_OPTIMIZE} unless
+ * {@link #OPT_ARITHMETIC} is also specified.
*/
public static final int OPT_PROGRESSIVE = (1 << 5);
/**
- * This option will prevent {@link TJTransformer#transform
- * TJTransformer.transform()} from copying any extra markers (including EXIF
- * and ICC profile data) from the source image to the destination image.
+ * Do not copy any extra markers (including EXIF and ICC profile data) from
+ * the source image to the destination image.
*/
public static final int OPT_COPYNONE = (1 << 6);
/**
- * This option will enable arithmetic entropy coding in the JPEG image
- * generated by this particular transform. Arithmetic entropy coding will
- * generally improve compression relative to Huffman entropy coding (the
- * default), but it will reduce decompression performance considerably. Can
- * be combined with {@link #OPT_PROGRESSIVE}.
+ * Enable arithmetic entropy coding in the destination image. Arithmetic
+ * entropy coding generally improves compression relative to Huffman entropy
+ * coding (the default), but it reduces decompression performance
+ * considerably. Can be combined with {@link #OPT_PROGRESSIVE}.
*/
public static final int OPT_ARITHMETIC = (1 << 7);
/**
- * This option will enable optimized baseline entropy coding in the JPEG
- * image generated by this particular transform. Optimized baseline entropy
- * coding will improve compression slightly (generally 5% or less.)
+ * Enable Huffman table optimization for the destination image. Huffman
+ * table optimization improves compression slightly (generally 5% or less.)
*/
public static final int OPT_OPTIMIZE = (1 << 8);
diff --git a/java/org/libjpegturbo/turbojpeg/YUVImage.java b/java/org/libjpegturbo/turbojpeg/YUVImage.java
index c2a43fd3..bdb25d07 100644
--- a/java/org/libjpegturbo/turbojpeg/YUVImage.java
+++ b/java/org/libjpegturbo/turbojpeg/YUVImage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2014, 2017, 2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2014, 2017, 2023-2024 D. R. Commander. All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,15 +37,15 @@ package org.libjpegturbo.turbojpeg;
* serves as the destination image for YUV encode and decompress-to-YUV
* operations and as the source image for compress-from-YUV and YUV decode
* operations.
- *
- * Technically, the JPEG format uses the YCbCr colorspace (which is technically
- * not a colorspace but a color transform), but per the convention of the
- * digital video community, the TurboJPEG API uses "YUV" to refer to an image
- * format consisting of Y, Cb, and Cr image planes.
- *
- * Each plane is simply a 2D array of bytes, each byte representing the value
- * of one of the components (Y, Cb, or Cr) at a particular location in the
- * image. The width and height of each plane are determined by the image
+ *
+ *
Technically, the JPEG format uses the YCbCr colorspace (which is
+ * technically not a colorspace but a color transform), but per the convention
+ * of the digital video community, the TurboJPEG API uses "YUV" to refer to an
+ * image format consisting of Y, Cb, and Cr image planes.
+ *
+ *
Each plane is simply a 2D array of bytes, each byte representing the
+ * value of one of the components (Y, Cb, or Cr) at a particular location in
+ * the image. The width and height of each plane are determined by the image
* width, height, and level of chrominance subsampling. The luminance plane
* width is the image width padded to the nearest multiple of the horizontal
* subsampling factor (1 in the case of 4:4:4, grayscale, 4:4:0, or 4:4:1; 2 in
@@ -58,9 +58,9 @@ package org.libjpegturbo.turbojpeg;
* the luminance plane width divided by the horizontal subsampling factor, and
* the chrominance plane height is equal to the luminance plane height divided
* by the vertical subsampling factor.
- *
- * For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is
- * used, then the luminance plane would be 36 x 35 bytes, and each of the
+ *
+ *
For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling
+ * is used, then the luminance plane would be 36 x 35 bytes, and each of the
* chrominance planes would be 18 x 35 bytes. If you specify a row alignment
* of 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes,
* and each of the chrominance planes would be 20 x 35 bytes.
diff --git a/tjbench.c b/tjbench.c
index e00d55db..e9e73c45 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -679,7 +679,7 @@ static int decompTest(char *fileName)
subsamp = tj3Get(handle, TJPARAM_SUBSAMP);
precision = tj3Get(handle, TJPARAM_PRECISION);
if (tj3Get(handle, TJPARAM_PROGRESSIVE) == 1)
- printf("JPEG image uses progressive entropy coding\n\n");
+ printf("JPEG image is progressive\n\n");
if (tj3Get(handle, TJPARAM_ARITHMETIC) == 1)
printf("JPEG image uses arithmetic entropy coding\n\n");
if (tj3Set(handle, TJPARAM_PROGRESSIVE, progressive) == -1)
@@ -919,8 +919,8 @@ static void usage(char *progName)
printf("-lossless = Generate lossless JPEG images when compressing (implies\n");
printf(" -subsamp 444). PSV is the predictor selection value (1-7).\n");
printf("-maxmemory = Memory limit (in megabytes) for intermediate buffers used with\n");
- printf(" progressive JPEG compression and decompression, optimized baseline entropy\n");
- printf(" coding, lossless JPEG compression, and lossless transformation\n");
+ printf(" progressive JPEG compression and decompression, Huffman table\n");
+ printf(" optimization, lossless JPEG compression, and lossless transformation\n");
printf(" [default = no limit]\n");
printf("-maxpixels = Input image size limit (in pixels) [default = no limit]\n");
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
@@ -958,11 +958,11 @@ static void usage(char *progName)
printf(" the scaled MCU width.\n");
printf("-fastdct = Use the fastest DCT/IDCT algorithm available\n");
printf("-fastupsample = Use the fastest chrominance upsampling algorithm available\n");
- printf("-optimize = Use optimized baseline entropy coding in JPEG images generated by\n");
+ printf("-optimize = Compute optimal Huffman tables for JPEG images generated by\n");
printf(" compession and transform operations\n");
- printf("-progressive = Use progressive entropy coding in JPEG images generated by\n");
- printf(" compression and transform operations (can be combined with -arithmetic;\n");
- printf(" implies -optimize unless -arithmetic is also specified)\n");
+ printf("-progressive = Generate progressive JPEG images when compressing or\n");
+ printf(" transforming (can be combined with -arithmetic; implies -optimize unless\n");
+ printf(" -arithmetic is also specified)\n");
printf("-limitscans = Refuse to decompress or transform progressive JPEG images that\n");
printf(" have an unreasonably large number of scans\n");
printf("-scale M/N = When decompressing, scale the width/height of the JPEG image by a\n");
@@ -1050,7 +1050,7 @@ int main(int argc, char *argv[])
optimize = 1;
xformOpt |= TJXOPT_OPTIMIZE;
} else if (!strcasecmp(argv[i], "-progressive")) {
- printf("Using progressive entropy coding\n\n");
+ printf("Generating progressive JPEG images\n\n");
progressive = 1;
xformOpt |= TJXOPT_PROGRESSIVE;
} else if (!strcasecmp(argv[i], "-arithmetic")) {
@@ -1197,7 +1197,7 @@ int main(int argc, char *argv[])
}
if (optimize && !progressive && !arithmetic && !lossless && precision != 12)
- printf("Using optimized baseline entropy coding\n\n");
+ printf("Computing optimal Huffman tables\n\n");
if (precision == 16 && !lossless) {
printf("ERROR: -lossless must be specified along with -precision 16\n");
diff --git a/turbojpeg.h b/turbojpeg.h
index 68b88a41..42c9b49e 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2009-2015, 2017, 2020-2023 D. R. Commander.
+ * Copyright (C)2009-2015, 2017, 2020-2024 D. R. Commander.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,7 +85,7 @@
#define TJ_NUMINIT 3
/**
- * Initialization options.
+ * Initialization options
*/
enum TJINIT {
/**
@@ -110,70 +110,83 @@ enum TJINIT {
#define TJ_NUMSAMP 7
/**
- * Chrominance subsampling options.
+ * Chrominance subsampling options
+ *
* When pixels are converted from RGB to YCbCr (see #TJCS_YCbCr) or from CMYK
* to YCCK (see #TJCS_YCCK) as part of the JPEG compression process, some of
* the Cb and Cr (chrominance) components can be discarded or averaged together
- * to produce a smaller image with little perceptible loss of image clarity.
+ * to produce a smaller image with little perceptible loss of image quality.
* (The human eye is more sensitive to small changes in brightness than to
* small changes in color.) This is called "chrominance subsampling".
*/
enum TJSAMP {
/**
- * 4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG or
- * YUV image will contain one chrominance component for every pixel in the
- * source image.
+ * 4:4:4 chrominance subsampling (no chrominance subsampling)
+ *
+ * The JPEG or YUV image will contain one chrominance component for every
+ * pixel in the source image.
*/
TJSAMP_444,
/**
- * 4:2:2 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x1 block of pixels in the source image.
+ * 4:2:2 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 2x1
+ * block of pixels in the source image.
*/
TJSAMP_422,
/**
- * 4:2:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x2 block of pixels in the source image.
+ * 4:2:0 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 2x2
+ * block of pixels in the source image.
*/
TJSAMP_420,
/**
- * Grayscale. The JPEG or YUV image will contain no chrominance components.
+ * Grayscale
+ *
+ * The JPEG or YUV image will contain no chrominance components.
*/
TJSAMP_GRAY,
/**
- * 4:4:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 1x2 block of pixels in the source image.
+ * 4:4:0 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 1x2
+ * block of pixels in the source image.
*
* @note 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
*/
TJSAMP_440,
/**
- * 4:1:1 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 4x1 block of pixels in the source image.
- * JPEG images compressed with 4:1:1 subsampling will be almost exactly the
- * same size as those compressed with 4:2:0 subsampling, and in the
- * aggregate, both subsampling methods produce approximately the same
- * perceptual quality. However, 4:1:1 is better able to reproduce sharp
- * horizontal features.
+ * 4:1:1 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 4x1
+ * block of pixels in the source image. All else being equal, a JPEG image
+ * with 4:1:1 subsampling is almost exactly the same size as a JPEG image
+ * with 4:2:0 subsampling, and in the aggregate, both subsampling methods
+ * produce approximately the same perceptual quality. However, 4:1:1 is
+ * better able to reproduce sharp horizontal features.
*
* @note 4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
*/
TJSAMP_411,
/**
- * 4:4:1 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 1x4 block of pixels in the source image.
- * JPEG images compressed with 4:4:1 subsampling will be almost exactly the
- * same size as those compressed with 4:2:0 subsampling, and in the
- * aggregate, both subsampling methods produce approximately the same
- * perceptual quality. However, 4:4:1 is better able to reproduce sharp
- * vertical features.
+ * 4:4:1 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 1x4
+ * block of pixels in the source image. All else being equal, a JPEG image
+ * with 4:4:1 subsampling is almost exactly the same size as a JPEG image
+ * with 4:2:0 subsampling, and in the aggregate, both subsampling methods
+ * produce approximately the same perceptual quality. However, 4:4:1 is
+ * better able to reproduce sharp vertical features.
*
* @note 4:4:1 subsampling is not fully accelerated in libjpeg-turbo.
*/
TJSAMP_441,
/**
- * Unknown subsampling. The JPEG image uses an unusual type of chrominance
- * subsampling. Such images can be decompressed into packed-pixel images,
- * but they cannot be
+ * Unknown subsampling
+ *
+ * The JPEG image uses an unusual type of chrominance subsampling. Such
+ * images can be decompressed into packed-pixel images, but they cannot be
* - decompressed into planar YUV images,
* - losslessly transformed if #TJXOPT_CROP is specified, or
* - partially decompressed using a cropping region.
@@ -182,7 +195,8 @@ enum TJSAMP {
};
/**
- * MCU block width (in pixels) for a given level of chrominance subsampling.
+ * MCU block width (in pixels) for a given level of chrominance subsampling
+ *
* MCU block sizes:
* - 8x8 for no subsampling or grayscale
* - 16x8 for 4:2:2
@@ -194,7 +208,8 @@ enum TJSAMP {
static const int tjMCUWidth[TJ_NUMSAMP] = { 8, 16, 16, 8, 8, 32, 8 };
/**
- * MCU block height (in pixels) for a given level of chrominance subsampling.
+ * MCU block height (in pixels) for a given level of chrominance subsampling
+ *
* MCU block sizes:
* - 8x8 for no subsampling or grayscale
* - 16x8 for 4:2:2
@@ -216,138 +231,168 @@ static const int tjMCUHeight[TJ_NUMSAMP] = { 8, 8, 16, 8, 16, 8, 32 };
*/
enum TJPF {
/**
- * RGB pixel format. The red, green, and blue components in the image are
- * stored in 3-sample pixels in the order R, G, B from lowest to highest
- * memory address within each pixel.
+ * RGB pixel format
+ *
+ * The red, green, and blue components in the image are stored in 3-sample
+ * pixels in the order R, G, B from lowest to highest memory address within
+ * each pixel.
*/
TJPF_RGB,
/**
- * BGR pixel format. The red, green, and blue components in the image are
- * stored in 3-sample pixels in the order B, G, R from lowest to highest
- * memory address within each pixel.
+ * BGR pixel format
+ *
+ * The red, green, and blue components in the image are stored in 3-sample
+ * pixels in the order B, G, R from lowest to highest memory address within
+ * each pixel.
*/
TJPF_BGR,
/**
- * RGBX pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order R, G, B from lowest to highest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * RGBX pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order R, G, B from lowest to highest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
TJPF_RGBX,
/**
- * BGRX pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order B, G, R from lowest to highest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * BGRX pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order B, G, R from lowest to highest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
TJPF_BGRX,
/**
- * XBGR pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order R, G, B from highest to lowest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * XBGR pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order R, G, B from highest to lowest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
TJPF_XBGR,
/**
- * XRGB pixel format. The red, green, and blue components in the image are
- * stored in 4-sample pixels in the order B, G, R from highest to lowest
- * memory address within each pixel. The X component is ignored when
- * compressing and undefined when decompressing.
+ * XRGB pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order B, G, R from highest to lowest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
*/
TJPF_XRGB,
/**
- * Grayscale pixel format. Each 1-sample pixel represents a luminance
- * (brightness) level from 0 to the maximum sample value (255 for 8-bit
- * samples, 4095 for 12-bit samples, and 65535 for 16-bit samples.)
+ * Grayscale pixel format
+ *
+ * Each 1-sample pixel represents a luminance (brightness) level from 0 to
+ * the maximum sample value (255 for 8-bit samples, 4095 for 12-bit samples,
+ * and 65535 for 16-bit samples.)
*/
TJPF_GRAY,
/**
- * RGBA pixel format. This is the same as @ref TJPF_RGBX, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * RGBA pixel format
+ *
+ * This is the same as @ref TJPF_RGBX, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
TJPF_RGBA,
/**
- * BGRA pixel format. This is the same as @ref TJPF_BGRX, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * BGRA pixel format
+ *
+ * This is the same as @ref TJPF_BGRX, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
TJPF_BGRA,
/**
- * ABGR pixel format. This is the same as @ref TJPF_XBGR, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * ABGR pixel format
+ *
+ * This is the same as @ref TJPF_XBGR, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
TJPF_ABGR,
/**
- * ARGB pixel format. This is the same as @ref TJPF_XRGB, except that when
- * decompressing, the X component is guaranteed to be equal to the maximum
- * sample value, which can be interpreted as an opaque alpha channel.
+ * ARGB pixel format
+ *
+ * This is the same as @ref TJPF_XRGB, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
*/
TJPF_ARGB,
/**
- * CMYK pixel format. Unlike RGB, which is an additive color model used
- * primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive
- * color model used primarily for printing. In the CMYK color model, the
- * value of each color component typically corresponds to an amount of cyan,
- * magenta, yellow, or black ink that is applied to a white background. In
- * order to convert between CMYK and RGB, it is necessary to use a color
- * management system (CMS.) A CMS will attempt to map colors within the
- * printer's gamut to perceptually similar colors in the display's gamut and
- * vice versa, but the mapping is typically not 1:1 or reversible, nor can it
- * be defined with a simple formula. Thus, such a conversion is out of scope
- * for a codec library. However, the TurboJPEG API allows for compressing
- * packed-pixel CMYK images into YCCK JPEG images (see #TJCS_YCCK) and
- * decompressing YCCK JPEG images into packed-pixel CMYK images.
+ * CMYK pixel format
+ *
+ * Unlike RGB, which is an additive color model used primarily for display,
+ * CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used primarily
+ * for printing. In the CMYK color model, the value of each color component
+ * typically corresponds to an amount of cyan, magenta, yellow, or black ink
+ * that is applied to a white background. In order to convert between CMYK
+ * and RGB, it is necessary to use a color management system (CMS.) A CMS
+ * will attempt to map colors within the printer's gamut to perceptually
+ * similar colors in the display's gamut and vice versa, but the mapping is
+ * typically not 1:1 or reversible, nor can it be defined with a simple
+ * formula. Thus, such a conversion is out of scope for a codec library.
+ * However, the TurboJPEG API allows for compressing packed-pixel CMYK images
+ * into YCCK JPEG images (see #TJCS_YCCK) and decompressing YCCK JPEG images
+ * into packed-pixel CMYK images.
*/
TJPF_CMYK,
/**
- * Unknown pixel format. Currently this is only used by #tj3LoadImage8(),
- * #tj3LoadImage12(), and #tj3LoadImage16().
+ * Unknown pixel format
+ *
+ * Currently this is only used by #tj3LoadImage8(), #tj3LoadImage12(), and
+ * #tj3LoadImage16().
*/
TJPF_UNKNOWN = -1
};
/**
- * Red offset (in samples) for a given pixel format. This specifies the number
- * of samples that the red component is offset from the start of the pixel.
- * For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is stored
- * in `unsigned char pixel[]`, then the red component will be
- * `pixel[tjRedOffset[TJPF_BGRX]]`. This will be -1 if the pixel format does
- * not have a red component.
+ * Red offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the red component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRX is stored in `unsigned char pixel[]`, then the red
+ * component is `pixel[tjRedOffset[TJPF_BGRX]]`. The offset is -1 if the pixel
+ * format does not have a red component.
*/
static const int tjRedOffset[TJ_NUMPF] = {
0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1
};
/**
- * Green offset (in samples) for a given pixel format. This specifies the
- * number of samples that the green component is offset from the start of the
- * pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is
- * stored in `unsigned char pixel[]`, then the green component will be
- * `pixel[tjGreenOffset[TJPF_BGRX]]`. This will be -1 if the pixel format does
- * not have a green component.
+ * Green offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the green component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRX is stored in `unsigned char pixel[]`, then the green
+ * component is `pixel[tjGreenOffset[TJPF_BGRX]]`. The offset is -1 if the
+ * pixel format does not have a green component.
*/
static const int tjGreenOffset[TJ_NUMPF] = {
1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1
};
/**
- * Blue offset (in samples) for a given pixel format. This specifies the
- * number of samples that the blue component is offset from the start of the
- * pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRX is
- * stored in `unsigned char pixel[]`, then the blue component will be
- * `pixel[tjBlueOffset[TJPF_BGRX]]`. This will be -1 if the pixel format does
- * not have a blue component.
+ * Blue offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the blue component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRX is stored in `unsigned char pixel[]`, then the blue
+ * component is `pixel[tjBlueOffset[TJPF_BGRX]]`. The offset is -1 if the
+ * pixel format does not have a blue component.
*/
static const int tjBlueOffset[TJ_NUMPF] = {
2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
};
/**
- * Alpha offset (in samples) for a given pixel format. This specifies the
- * number of samples that the alpha component is offset from the start of the
- * pixel. For instance, if an 8-bit-per-component pixel of format TJPF_BGRA is
- * stored in `unsigned char pixel[]`, then the alpha component will be
- * `pixel[tjAlphaOffset[TJPF_BGRA]]`. This will be -1 if the pixel format does
- * not have an alpha component.
+ * Alpha offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the alpha component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRA is stored in `unsigned char pixel[]`, then the alpha
+ * component is `pixel[tjAlphaOffset[TJPF_BGRA]]`. The offset is -1 if the
+ * pixel format does not have an alpha component.
*/
static const int tjAlphaOffset[TJ_NUMPF] = {
-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
@@ -370,55 +415,63 @@ static const int tjPixelSize[TJ_NUMPF] = {
*/
enum TJCS {
/**
- * RGB colorspace. When compressing the JPEG image, the R, G, and B
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. RGB JPEG images can be
- * compressed from and decompressed to packed-pixel images with any of the
- * extended RGB or grayscale pixel formats, but they cannot be compressed
- * from or decompressed to planar YUV images.
+ * RGB colorspace
+ *
+ * When generating the JPEG image, the R, G, and B components in the source
+ * image are reordered into image planes, but no colorspace conversion or
+ * subsampling is performed. RGB JPEG images can be generated from and
+ * decompressed to packed-pixel images with any of the extended RGB or
+ * grayscale pixel formats, but they cannot be generated from or
+ * decompressed to planar YUV images.
*/
TJCS_RGB,
/**
- * YCbCr colorspace. YCbCr is not an absolute colorspace but rather a
- * mathematical transformation of RGB designed solely for storage and
- * transmission. YCbCr images must be converted to RGB before they can
- * actually be displayed. In the YCbCr colorspace, the Y (luminance)
- * component represents the black & white portion of the original image, and
- * the Cb and Cr (chrominance) components represent the color portion of the
- * original image. Originally, the analog equivalent of this transformation
- * allowed the same signal to drive both black & white and color televisions,
- * but JPEG images use YCbCr primarily because it allows the color data to be
- * optionally subsampled for the purposes of reducing network or disk usage.
- * YCbCr is the most common JPEG colorspace, and YCbCr JPEG images can be
- * compressed from and decompressed to packed-pixel images with any of the
- * extended RGB or grayscale pixel formats. YCbCr JPEG images can also be
- * compressed from and decompressed to planar YUV images.
+ * YCbCr colorspace
+ *
+ * YCbCr is not an absolute colorspace but rather a mathematical
+ * transformation of RGB designed solely for storage and transmission. YCbCr
+ * images must be converted to RGB before they can be displayed. In the
+ * YCbCr colorspace, the Y (luminance) component represents the black & white
+ * portion of the original image, and the Cb and Cr (chrominance) components
+ * represent the color portion of the original image. Historically, the
+ * analog equivalent of this transformation allowed the same signal to be
+ * displayed to both black & white and color televisions, but JPEG images use
+ * YCbCr primarily because it allows the color data to be optionally
+ * subsampled in order to reduce network and disk usage. YCbCr is the most
+ * common JPEG colorspace, and YCbCr JPEG images can be generated from and
+ * decompressed to packed-pixel images with any of the extended RGB or
+ * grayscale pixel formats. YCbCr JPEG images can also be generated from
+ * and decompressed to planar YUV images.
*/
TJCS_YCbCr,
/**
- * Grayscale colorspace. The JPEG image retains only the luminance data (Y
- * component), and any color data from the source image is discarded.
- * Grayscale JPEG images can be compressed from and decompressed to
- * packed-pixel images with any of the extended RGB or grayscale pixel
- * formats, or they can be compressed from and decompressed to planar YUV
- * images.
+ * Grayscale colorspace
+ *
+ * The JPEG image retains only the luminance data (Y component), and any
+ * color data from the source image is discarded. Grayscale JPEG images can
+ * be generated from and decompressed to packed-pixel images with any of the
+ * extended RGB or grayscale pixel formats, or they can be generated from
+ * and decompressed to planar YUV images.
*/
TJCS_GRAY,
/**
- * CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. CMYK JPEG images can
- * only be compressed from and decompressed to packed-pixel images with the
- * CMYK pixel format.
+ * CMYK colorspace
+ *
+ * When generating the JPEG image, the C, M, Y, and K components in the
+ * source image are reordered into image planes, but no colorspace conversion
+ * or subsampling is performed. CMYK JPEG images can only be generated from
+ * and decompressed to packed-pixel images with the CMYK pixel format.
*/
TJCS_CMYK,
/**
- * YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but
- * rather a mathematical transformation of CMYK designed solely for storage
- * and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
+ * YCCK colorspace
+ *
+ * YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a
+ * mathematical transformation of CMYK designed solely for storage and
+ * transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
* reversibly transformed into YCCK, and as with YCbCr, the chrominance
* components in the YCCK pixels can be subsampled without incurring major
- * perceptual loss. YCCK JPEG images can only be compressed from and
+ * perceptual loss. YCCK JPEG images can only be generated from and
* decompressed to packed-pixel images with the CMYK pixel format.
*/
TJCS_YCCK
@@ -516,7 +569,7 @@ enum TJPARAM {
*
* **Value**
* - `0` *[default]* Use smooth upsampling when decompressing a JPEG image
- * that was compressed using chrominance subsampling. This creates a smooth
+ * that was generated using chrominance subsampling. This creates a smooth
* transition between neighboring chrominance components in order to reduce
* upsampling artifacts in the decompressed image.
* - `1` Use the fastest chrominance upsampling algorithm available, which
@@ -541,13 +594,12 @@ enum TJPARAM {
* - The difference in accuracy between the "fast" and "accurate" algorithms
* is the most pronounced at JPEG quality levels above 90 and tends to be
* more pronounced with decompression than with compression.
- * - The "fast" algorithm degrades and is not fully accelerated for JPEG
- * quality levels above 97, so it will be slower than the "accurate"
- * algorithm.
+ * - For JPEG quality levels above 97, the "fast" algorithm degrades and is
+ * not fully accelerated, so it is slower than the "accurate" algorithm.
*/
TJPARAM_FASTDCT,
/**
- * Optimized baseline entropy coding [lossy compression only]
+ * Huffman table optimization [lossy compression, lossless transformation]
*
* **Value**
* - `0` *[default]* The JPEG image will use the default Huffman tables.
@@ -555,36 +607,46 @@ enum TJPARAM {
* lossless transformation, this can also be specified using
* #TJXOPT_OPTIMIZE.
*
- * Optimized baseline entropy coding will improve compression slightly
- * (generally 5% or less), but it will reduce compression performance
- * considerably.
+ * Huffman table optimization improves compression slightly (generally 5% or
+ * less), but it reduces compression performance considerably.
*/
TJPARAM_OPTIMIZE,
/**
- * Progressive entropy coding
+ * Progressive JPEG
+ *
+ * In a progressive JPEG image, the DCT coefficients are split across
+ * multiple "scans" of increasing quality. Thus, a low-quality scan
+ * containing the lowest-frequency DCT coefficients can be transmitted first
+ * and refined with subsequent higher-quality scans containing
+ * higher-frequency DCT coefficients. When using Huffman entropy coding, the
+ * progressive JPEG format also provides an "end-of-bands (EOB) run" feature
+ * that allows large groups of zeroes, potentially spanning multiple MCU
+ * blocks, to be represented using only a few bytes.
*
* **Value**
* - `0` *[default for compression, lossless transformation]* The lossy JPEG
- * image uses (decompression) or will use (compression, lossless
- * transformation) baseline entropy coding.
- * - `1` The lossy JPEG image uses (decompression) or will use (compression,
- * lossless transformation) progressive entropy coding. For lossless
- * transformation, this can also be specified using #TJXOPT_PROGRESSIVE.
+ * image is (decompression) or will be (compression, lossless transformation)
+ * single-scan.
+ * - `1` The lossy JPEG image is (decompression) or will be (compression,
+ * lossless transformation) progressive. For lossless transformation, this
+ * can also be specified using #TJXOPT_PROGRESSIVE.
*
- * Progressive entropy coding will generally improve compression relative to
- * baseline entropy coding, but it will reduce compression and decompression
- * performance considerably. Can be combined with #TJPARAM_ARITHMETIC.
- * Implies #TJPARAM_OPTIMIZE unless #TJPARAM_ARITHMETIC is also set.
+ * Progressive JPEG images generally have better compression ratios than
+ * single-scan JPEG images (much better if the image has large areas of solid
+ * color), but progressive JPEG compression and decompression is considerably
+ * slower than single-scan JPEG compression and decompression. Can be
+ * combined with #TJPARAM_ARITHMETIC. Implies #TJPARAM_OPTIMIZE unless
+ * #TJPARAM_ARITHMETIC is also set.
*/
TJPARAM_PROGRESSIVE,
/**
* Progressive JPEG scan limit for lossy JPEG images [decompression, lossless
* transformation]
*
- * Setting this parameter will cause the decompression and transform
- * functions to return an error if the number of scans in a progressive JPEG
- * image exceeds the specified limit. The primary purpose of this is to
- * allow security-critical applications to guard against an exploit of the
+ * Setting this parameter causes the decompression and transform functions to
+ * return an error if the number of scans in a progressive JPEG image exceeds
+ * the specified limit. The primary purpose of this is to allow
+ * security-critical applications to guard against an exploit of the
* progressive JPEG format described in
* this report.
*
@@ -606,8 +668,8 @@ enum TJPARAM {
* lossless transformation) arithmetic entropy coding. For lossless
* transformation, this can also be specified using #TJXOPT_ARITHMETIC.
*
- * Arithmetic entropy coding will generally improve compression relative to
- * Huffman entropy coding, but it will reduce compression and decompression
+ * Arithmetic entropy coding generally improves compression relative to
+ * Huffman entropy coding, but it reduces compression and decompression
* performance considerably. Can be combined with #TJPARAM_PROGRESSIVE.
*/
TJPARAM_ARITHMETIC,
@@ -620,19 +682,19 @@ enum TJPARAM {
* - `1` The JPEG image is (decompression) or will be (compression)
* lossless/predictive.
*
- * In most cases, compressing and decompressing lossless JPEG images is
- * considerably slower than compressing and decompressing lossy JPEG images,
- * and lossless JPEG images are much larger than lossy JPEG images. Thus,
- * lossless JPEG images are typically used only for applications that require
- * mathematically lossless compression. Also note that the following
- * features are not available with lossless JPEG images:
+ * In most cases, lossless JPEG compression and decompression is considerably
+ * slower than lossy JPEG compression and decompression, and lossless JPEG
+ * images are much larger than lossy JPEG images. Thus, lossless JPEG images
+ * are typically used only for applications that require mathematically
+ * lossless compression. Also note that the following features are not
+ * available with lossless JPEG images:
* - Colorspace conversion (lossless JPEG images always use #TJCS_RGB,
* #TJCS_GRAY, or #TJCS_CMYK, depending on the pixel format of the source
* image)
* - Chrominance subsampling (lossless JPEG images always use #TJSAMP_444)
* - JPEG quality selection
* - DCT/IDCT algorithm selection
- * - Progressive entropy coding
+ * - Progressive JPEG
* - Arithmetic entropy coding
* - Compression from/decompression to planar YUV images
* - Decompression scaling
@@ -783,15 +845,15 @@ enum TJPARAM {
* **Value**
* - the maximum amount of memory (in megabytes) that will be allocated for
* intermediate buffers, which are used with progressive JPEG compression and
- * decompression, optimized baseline entropy coding, lossless JPEG
- * compression, and lossless transformation *[default: `0` (no limit)]*
+ * decompression, Huffman table optimization, lossless JPEG compression, and
+ * lossless transformation *[default: `0` (no limit)]*
*/
TJPARAM_MAXMEMORY,
/**
* Image size limit [decompression, lossless transformation, packed-pixel
* image loading]
*
- * Setting this parameter will cause the decompression, transform, and image
+ * Setting this parameter causes the decompression, transform, and image
* loading functions to return an error if the number of pixels in the source
* image exceeds the specified limit. This allows security-critical
* applications to guard against excessive memory consumption.
@@ -835,7 +897,7 @@ enum TJERR {
*/
enum TJXOP {
/**
- * Do not transform the position of the image pixels
+ * Do not transform the position of the image pixels.
*/
TJXOP_NONE,
/**
@@ -880,8 +942,8 @@ enum TJXOP {
/**
- * This option will cause #tj3Transform() to return an error if the transform
- * is not perfect. Lossless transforms operate on MCU blocks, whose size
+ * This option causes #tj3Transform() to return an error if the transform is
+ * not perfect. Lossless transforms operate on MCU blocks, the size of which
* depends on the level of chrominance subsampling used (see #tjMCUWidth and
* #tjMCUHeight.) If the image's width or height is not evenly divisible by
* the MCU block size, then there will be partial MCU blocks on the right
@@ -893,54 +955,49 @@ enum TJXOP {
*/
#define TJXOPT_PERFECT (1 << 0)
/**
- * This option will cause #tj3Transform() to discard any partial MCU blocks
- * that cannot be transformed.
+ * Discard any partial MCU blocks that cannot be transformed.
*/
#define TJXOPT_TRIM (1 << 1)
/**
- * This option will enable lossless cropping. See #tj3Transform() for more
- * information.
+ * Enable lossless cropping. See #tj3Transform() for more information.
*/
#define TJXOPT_CROP (1 << 2)
/**
- * This option will discard the color data in the source image and produce a
- * grayscale destination image.
+ * Discard the color data in the source image, and generate a grayscale
+ * destination image.
*/
#define TJXOPT_GRAY (1 << 3)
/**
- * This option will prevent #tj3Transform() from outputting a JPEG image for
- * this particular transform. (This can be used in conjunction with a custom
- * filter to capture the transformed DCT coefficients without transcoding
- * them.)
+ * Do not generate a destination image. (This can be used in conjunction with
+ * a custom filter to capture the transformed DCT coefficients without
+ * transcoding them.)
*/
#define TJXOPT_NOOUTPUT (1 << 4)
/**
- * This option will enable progressive entropy coding in the JPEG image
- * generated by this particular transform. Progressive entropy coding will
- * generally improve compression relative to baseline entropy coding (the
- * default), but it will reduce decompression performance considerably.
- * Can be combined with #TJXOPT_ARITHMETIC. Implies #TJXOPT_OPTIMIZE unless
- * #TJXOPT_ARITHMETIC is also specified.
+ * Generate a progressive destination image instead of a single-scan
+ * destination image. Progressive JPEG images generally have better
+ * compression ratios than single-scan JPEG images (much better if the image
+ * has large areas of solid color), but progressive JPEG decompression is
+ * considerably slower than single-scan JPEG decompression. Can be combined
+ * with #TJXOPT_ARITHMETIC. Implies #TJXOPT_OPTIMIZE unless #TJXOPT_ARITHMETIC
+ * is also specified.
*/
#define TJXOPT_PROGRESSIVE (1 << 5)
/**
- * This option will prevent #tj3Transform() from copying any extra markers
- * (including EXIF and ICC profile data) from the source image to the
- * destination image.
+ * Do not copy any extra markers (including EXIF and ICC profile data) from the
+ * source image to the destination image.
*/
#define TJXOPT_COPYNONE (1 << 6)
/**
- * This option will enable arithmetic entropy coding in the JPEG image
- * generated by this particular transform. Arithmetic entropy coding will
- * generally improve compression relative to Huffman entropy coding (the
- * default), but it will reduce decompression performance considerably. Can be
- * combined with #TJXOPT_PROGRESSIVE.
+ * Enable arithmetic entropy coding in the destination image. Arithmetic
+ * entropy coding generally improves compression relative to Huffman entropy
+ * coding (the default), but it reduces decompression performance considerably.
+ * Can be combined with #TJXOPT_PROGRESSIVE.
*/
#define TJXOPT_ARITHMETIC (1 << 7)
/**
- * This option will enable optimized baseline entropy coding in the JPEG image
- * generated by this particular transform. Optimized baseline entropy coding
- * will improve compression slightly (generally 5% or less.)
+ * Enable Huffman table optimization for the destination image. Huffman table
+ * optimization improves compression slightly (generally 5% or less.)
*/
#define TJXOPT_OPTIMIZE (1 << 8)
@@ -1019,7 +1076,7 @@ typedef struct tjtransform {
* applied in the frequency domain.
*
* @param coeffs pointer to an array of transformed DCT coefficients. (NOTE:
- * this pointer is not guaranteed to be valid once the callback returns, so
+ * This pointer is not guaranteed to be valid once the callback returns, so
* applications wishing to hand off the DCT coefficients to another function
* or library should make a copy of them within the body of the callback.)
*
@@ -1372,13 +1429,13 @@ DLLEXPORT size_t tj3YUVBufSize(int width, int align, int height, int subsamp);
*
* @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
*
- * @param width width (in pixels) of the YUV image. NOTE: this is the width of
+ * @param width width (in pixels) of the YUV image. NOTE: This is the width of
* the whole image, not the plane width.
*
* @param stride bytes per row in the image plane. Setting this to 0 is the
* equivalent of setting it to the plane width.
*
- * @param height height (in pixels) of the YUV image. NOTE: this is the height
+ * @param height height (in pixels) of the YUV image. NOTE: This is the height
* of the whole image, not the plane height.
*
* @param subsamp level of chrominance subsampling in the image (see
@@ -1985,7 +2042,7 @@ DLLEXPORT void *tj3Alloc(size_t bytes);
*
* @param pixelFormat pointer to an integer variable that specifies or will
* receive the pixel format of the packed-pixel buffer. The behavior of this
- * function will vary depending on the value of `*pixelFormat` passed to the
+ * function varies depending on the value of `*pixelFormat` passed to the
* function:
* - @ref TJPF_UNKNOWN : The packed-pixel buffer returned by this function will
* use the most optimal pixel format for the file type, and `*pixelFormat` will
From 488d42a8a5669fd227f9225258a8d6fec92d204b Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 16 Aug 2024 12:12:09 -0400
Subject: [PATCH 083/135] OSS-Fuzz: Define ZERO_BUFFERS for MSan build
... and use tj3Alloc() to allocate compression/transformation
destination buffers.
---
fuzz/build.sh | 4 ++++
fuzz/compress.cc | 4 ++--
fuzz/compress12.cc | 4 ++--
fuzz/transform.cc | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/fuzz/build.sh b/fuzz/build.sh
index d87cbdff..a856c5e3 100644
--- a/fuzz/build.sh
+++ b/fuzz/build.sh
@@ -9,6 +9,10 @@ if [ $# -ge 1 ]; then
FUZZER_SUFFIX="`echo $1 | sed 's/\./_/g'`"
fi
+if [ "$SANITIZER" = "memory" ]; then
+ export CFLAGS="$CFLAGS -DZERO_BUFFERS=1"
+fi
+
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \
diff --git a/fuzz/compress.cc b/fuzz/compress.cc
index daad0471..995840b2 100644
--- a/fuzz/compress.cc
+++ b/fuzz/compress.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021, 2023-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
- if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
+ if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
} else
dstBuf = NULL;
diff --git a/fuzz/compress12.cc b/fuzz/compress12.cc
index 12cb7565..63131c8f 100644
--- a/fuzz/compress12.cc
+++ b/fuzz/compress12.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021, 2023-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
- if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
+ if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
} else
dstBuf = NULL;
diff --git a/fuzz/transform.cc b/fuzz/transform.cc
index 84a8ccec..f3b5b265 100644
--- a/fuzz/transform.cc
+++ b/fuzz/transform.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -70,7 +70,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
transforms[0].op = TJXOP_NONE;
transforms[0].options = TJXOPT_PROGRESSIVE | TJXOPT_COPYNONE;
dstBufs[0] =
- (unsigned char *)malloc(tj3JPEGBufSize(width, height, jpegSubsamp));
+ (unsigned char *)tj3Alloc(tj3JPEGBufSize(width, height, jpegSubsamp));
if (!dstBufs[0])
goto bailout;
From 562ad7612e4d9ac7735c7d27211f012e8f4ba31e Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 19 Aug 2024 10:06:59 -0400
Subject: [PATCH 084/135] OSS-Fuzz: More MSan fixes
We need to use tj3Alloc() (which, when ZERO_BUFFERS is defined, calls
calloc() instead of malloc()) to allocate all destination buffers.
Otherwise, if the compression/decompression/transform operation fails,
then the buffer checksum (which is computed to prevent the compiler from
optimizing out the whole test, since the destination buffer is never
used otherwise) will depend upon values in the destination buffer that
were never written, and MSan will complain.
---
fuzz/compress12_lossless.cc | 4 ++--
fuzz/compress16_lossless.cc | 4 ++--
fuzz/compress_lossless.cc | 4 ++--
fuzz/compress_yuv.cc | 4 ++--
fuzz/decompress.cc | 4 ++--
fuzz/decompress_yuv.cc | 4 ++--
fuzz/transform.cc | 6 +++---
7 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/fuzz/compress12_lossless.cc b/fuzz/compress12_lossless.cc
index 3ac10f7c..fb946080 100644
--- a/fuzz/compress12_lossless.cc
+++ b/fuzz/compress12_lossless.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -85,7 +85,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
maxBufSize = tj3JPEGBufSize(width, height, TJSAMP_444);
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
- if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
+ if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
} else
dstBuf = NULL;
diff --git a/fuzz/compress16_lossless.cc b/fuzz/compress16_lossless.cc
index 35cfff6f..fe646bf0 100644
--- a/fuzz/compress16_lossless.cc
+++ b/fuzz/compress16_lossless.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -85,7 +85,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
maxBufSize = tj3JPEGBufSize(width, height, TJSAMP_444);
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
- if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
+ if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
} else
dstBuf = NULL;
diff --git a/fuzz/compress_lossless.cc b/fuzz/compress_lossless.cc
index d094cad2..34dbb897 100644
--- a/fuzz/compress_lossless.cc
+++ b/fuzz/compress_lossless.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -84,7 +84,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
maxBufSize = tj3JPEGBufSize(width, height, TJSAMP_444);
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
- if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
+ if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
} else
dstBuf = NULL;
diff --git a/fuzz/compress_yuv.cc b/fuzz/compress_yuv.cc
index ddde0b85..af30b702 100644
--- a/fuzz/compress_yuv.cc
+++ b/fuzz/compress_yuv.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -87,7 +87,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
continue;
maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
- if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
+ if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
if ((yuvBuf =
(unsigned char *)malloc(tj3YUVBufSize(width, 1, height,
diff --git a/fuzz/decompress.cc b/fuzz/decompress.cc
index bb14c6bb..1b1aefd1 100644
--- a/fuzz/decompress.cc
+++ b/fuzz/decompress.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -95,7 +95,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
tj3SetCroppingRegion(handle, TJUNCROPPED);
}
- if ((dstBuf = malloc(w * h * tjPixelSize[pf] * sampleSize)) == NULL)
+ if ((dstBuf = tj3Alloc(w * h * tjPixelSize[pf] * sampleSize)) == NULL)
goto bailout;
if (precision == 8) {
diff --git a/fuzz/decompress_yuv.cc b/fuzz/decompress_yuv.cc
index 36252104..3f371c61 100644
--- a/fuzz/decompress_yuv.cc
+++ b/fuzz/decompress_yuv.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -83,7 +83,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
tj3SetScalingFactor(handle, TJUNSCALED);
}
- if ((dstBuf = (unsigned char *)malloc(w * h * tjPixelSize[pf])) == NULL)
+ if ((dstBuf = (unsigned char *)tj3Alloc(w * h * tjPixelSize[pf])) == NULL)
goto bailout;
if ((yuvBuf =
(unsigned char *)malloc(tj3YUVBufSize(w, 1, h, jpegSubsamp))) == NULL)
diff --git a/fuzz/transform.cc b/fuzz/transform.cc
index f3b5b265..ba3acf2e 100644
--- a/fuzz/transform.cc
+++ b/fuzz/transform.cc
@@ -101,8 +101,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
transforms[0].options = TJXOPT_GRAY | TJXOPT_CROP | TJXOPT_COPYNONE |
TJXOPT_OPTIMIZE;
dstBufs[0] =
- (unsigned char *)malloc(tj3JPEGBufSize((height + 1) / 2, (width + 1) / 2,
- jpegSubsamp));
+ (unsigned char *)tj3Alloc(tj3JPEGBufSize((height + 1) / 2, (width + 1) / 2,
+ jpegSubsamp));
if (!dstBufs[0])
goto bailout;
@@ -125,7 +125,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
transforms[0].op = TJXOP_ROT90;
transforms[0].options = TJXOPT_TRIM | TJXOPT_ARITHMETIC;
dstBufs[0] =
- (unsigned char *)malloc(tj3JPEGBufSize(height, width, jpegSubsamp));
+ (unsigned char *)tj3Alloc(tj3JPEGBufSize(height, width, jpegSubsamp));
if (!dstBufs[0])
goto bailout;
From a9723f8a98593deab959dd700bc49588b4bad038 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 19 Aug 2024 16:18:37 -0400
Subject: [PATCH 085/135] cjpeg/djpeg/jpegtran: Restore jpeg-6b arg abbrevs
There are two approaches to handling abbreviated command-line options:
1. If a new option is introduced that begins with the same letters as an
existing option, require a longer abbreviation for the existing option
in order to ensure that abbreviations are always unique.
2. Require a unique abbreviation only for new options, and match all
non-unique abbreviations with existing options, thus maintaining
backward compatibility.
keymatch() supports either approach, and Tom Lane historically seemed to
prefer Approach 2, whereas both approaches have been applied
inconsistently in the years since. This commit consistently applies
Approach 2.
More specific notes:
We unnecessarily required 'cjpeg -progressive' to be abbreviated as
'cjpeg -pro' rather than 'cjpeg -p' when the -precision option was
introduced in libjpeg-turbo 3.0 beta.
The IJG unnecessarily required 'cjpeg -scans' to be abbreviated as
'cjpeg -scan' rather than 'cjpeg -sc' when the -scale option was
introduced in jpeg-7. We even more unnecessarily adopted that
requirement, even though we never adopted the -scale option.
We unnecessarily required 'djpeg -scale' to be abbreviated as
'djpeg -sc' rather than 'djpeg -s' when the -skip option was introduced
in libjpeg-turbo 1.5 beta.
The IJG unnecessarily required 'jpegtran -copy' to be abbreviated as
'jpegtran -co' rather than 'jpegtran -c' when the -crop option was
introduced in jpeg-7.
The IJG unnecessarily required 'jpegtran -progressive' to be abbreviated
as 'jpegtran -pr' rather than 'jpegtran -p' when the -perfect option was
introduced in jpeg-7.
---
cjpeg.c | 4 ++--
djpeg.c | 2 +-
jpegtran.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/cjpeg.c b/cjpeg.c
index cf0e12d5..c23036d7 100644
--- a/cjpeg.c
+++ b/cjpeg.c
@@ -456,7 +456,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
usage();
cinfo->data_precision = val;
- } else if (keymatch(arg, "progressive", 3)) {
+ } else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;
@@ -526,7 +526,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
* default sampling factors.
*/
- } else if (keymatch(arg, "scans", 4)) {
+ } else if (keymatch(arg, "scans", 2)) {
/* Set scan script. */
#ifdef C_MULTISCAN_FILES_SUPPORTED
if (++argn >= argc) /* advance to next argument */
diff --git a/djpeg.c b/djpeg.c
index fde2b8e4..80d79f02 100644
--- a/djpeg.c
+++ b/djpeg.c
@@ -392,7 +392,7 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "report", 2)) {
report = TRUE;
- } else if (keymatch(arg, "scale", 2)) {
+ } else if (keymatch(arg, "scale", 1)) {
/* Scale the output image by a fraction M/N. */
if (++argn >= argc) /* advance to next argument */
usage();
diff --git a/jpegtran.c b/jpegtran.c
index 407cc438..b7d7ebbe 100644
--- a/jpegtran.c
+++ b/jpegtran.c
@@ -183,7 +183,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
exit(EXIT_FAILURE);
#endif
- } else if (keymatch(arg, "copy", 2)) {
+ } else if (keymatch(arg, "copy", 1)) {
/* Select which extra markers to copy. */
if (++argn >= argc) /* advance to next argument */
usage();
@@ -320,7 +320,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
* handle. */
transformoption.perfect = TRUE;
- } else if (keymatch(arg, "progressive", 2)) {
+ } else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;
From 49f1b5807de3c2ad2481634af4648cff86817334 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 20 Aug 2024 12:57:37 -0400
Subject: [PATCH 086/135] TJBench.java: Explicitly set restartIntervalBlocks
This is just a readability thing. Java initializes integer fields to 0
by default.
---
java/TJBench.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/java/TJBench.java b/java/TJBench.java
index 7f209188..37706b23 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -42,7 +42,7 @@ final class TJBench {
private static boolean stopOnWarning, bottomUp, fastUpsample, fastDCT,
optimize, progressive, limitScans, arithmetic, lossless;
private static int maxMemory = 0, maxPixels = 0, precision = 8, quiet = 0,
- pf = TJ.PF_BGR, yuvAlign = 1, restartIntervalBlocks,
+ pf = TJ.PF_BGR, yuvAlign = 1, restartIntervalBlocks = 0,
restartIntervalRows = 0;
private static boolean compOnly, decompOnly, doTile, doYUV, write = true,
bmp = false;
From 8c2e7306cf8e73e3e343c681295dae577e81c2e7 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 21 Aug 2024 13:03:41 -0400
Subject: [PATCH 087/135] Java doc: Minor formatting tweak
---
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 4 ++--
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 6 +++---
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/java/doc/member-search-index.zip b/java/doc/member-search-index.zip
index dbc61799fcf0042249fe67b9a2feb6525334269d..37a2c2883822ef78124d4ab65c4784cddbaf273f 100644
GIT binary patch
delta 30
kcmbQwKcAmBz?+#xgn@&DgCQ+LbR(}5J2Q};9K`Mm09{B1K>z>%
delta 30
kcmbQwKcAmBz?+#xgn@&DgF!M*U?Z;+J2Q};9K`Mm09A+ui2wiq
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJ.html b/java/doc/org/libjpegturbo/turbojpeg/TJ.html
index e808497a..ac1381e0 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJ.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJ.html
@@ -1402,8 +1402,8 @@ extends java.lang.Object
Value
-
One of TJ.SAMP_*[no default; must be
- explicitly specified for lossy compression, encoding, and decoding]
+
One of TJ.SAMP_*[no default; must be explicitly
+ specified for lossy compression, encoding, and decoding]
See Also:
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index dd44bf6aa5e3b20de2c6f90872e274caac417b80..ab1abc884b11f2584279a1c48e3556b894ef38ad 100644
GIT binary patch
delta 28
hcmaFM_?D43z?+#xgn@&DgCQ+LbRus*Gl-h+2LNJI2P^;p
delta 28
hcmaFM_?D43z?+#xgn@&DgF!M*U?OinGl-h+2LM~A26O-b
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index e248dfa119923e98c6698b676f78761b5837ad5b..d5a3ac06212f76d5cb07ca1024d980bd40cd6c3d 100644
GIT binary patch
delta 28
hcmdnaw4I4Jz?+#xgn@&DgCQ+LbRzE^W)Stp8vt4&2U!3B
delta 28
hcmdnaw4I4Jz?+#xgn@&DgF!M*U?T4wW)Stp8vs*w2B81|
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index 0927967d..505bdb6e 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -499,8 +499,8 @@ public final class TJ {
*
*
Value
*
- *
One of {@link TJ#SAMP_444 TJ.SAMP_*} [no default; must be
- * explicitly specified for lossy compression, encoding, and decoding]
+ *
One of {@link #SAMP_444 TJ.SAMP_*} [no default; must be explicitly
+ * specified for lossy compression, encoding, and decoding]
*
*/
public static final int PARAM_SUBSAMP = 4;
@@ -534,7 +534,7 @@ public final class TJ {
*
*
Value
*
- *
One of {@link TJ#CS_RGB TJ.CS_*} [default for lossy compression:
+ *
One of {@link #CS_RGB TJ.CS_*} [default for lossy compression:
* automatically selected based on the subsampling level and pixel
* format]
*
From d44fc54f94cf5888e760a7256fb99b7e96cd926c Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 21 Aug 2024 15:00:58 -0400
Subject: [PATCH 088/135] Java: Unset srcBuf12/16 with BufferedImage/YUV src
Due to an oversight in the multi-precision feature,
TJCompressor.srcBuf12 and TJCompressor.srcBuf16 were not set to null
in TJCompressor.setSourceImage(YUVImage) or
TJCompressor.setSourceImage(BufferedImage, ...). Thus, if an
application set a 12-bit or 16-bit packed-pixel buffer as the source
image then set a BufferedImage with integer pixels as the source image,
TJCompress.compress() would compress from the 12-bit or 16-bit
packed-pixel buffer instead of the BufferedImage. The odds of an
application actually doing that are very slim, however.
---
java/org/libjpegturbo/turbojpeg/TJCompressor.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
index e47a2c9f..b18cb07d 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011-2015, 2018, 2020, 2022-2023 D. R. Commander.
+ * Copyright (C)2011-2015, 2018, 2020, 2022-2024 D. R. Commander.
* All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
@@ -335,6 +335,8 @@ public class TJCompressor implements Closeable {
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
srcBufInt = db.getData();
srcBuf8 = null;
+ srcBuf12 = null;
+ srcBuf16 = null;
} else {
ComponentSampleModel sm =
(ComponentSampleModel)srcImage.getSampleModel();
@@ -344,6 +346,8 @@ public class TJCompressor implements Closeable {
srcPitch = sm.getScanlineStride();
DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
srcBuf8 = db.getData();
+ srcBuf12 = null;
+ srcBuf16 = null;
srcBufInt = null;
}
srcYUVImage = null;
@@ -364,6 +368,8 @@ public class TJCompressor implements Closeable {
srcYUVImage = srcImage;
set(TJ.PARAM_SUBSAMP, srcImage.getSubsamp());
srcBuf8 = null;
+ srcBuf12 = null;
+ srcBuf16 = null;
srcBufInt = null;
}
From 0acb084464a3f40070df19c503203ed99bbe02e2 Mon Sep 17 00:00:00 2001
From: DRC
Date: Thu, 22 Aug 2024 16:55:55 -0400
Subject: [PATCH 089/135] JNI: Fix *Image() array size issues w/ align != 1
+ check for mismatch between C and Java APIs in *saveImage().
---
turbojpeg-jni.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c
index 32186f3f..8e6ed320 100644
--- a/turbojpeg-jni.c
+++ b/turbojpeg-jni.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011-2023 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -91,6 +91,8 @@
cArray = NULL; \
}
+#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
+
/* TurboJPEG 1.2.x: TJ::bufSize() */
JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
(JNIEnv *env, jclass cls, jint width, jint height, jint jpegSubsamp)
@@ -1274,7 +1276,8 @@ JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_loadImage
{
tjhandle handle = NULL;
void *dstBuf = NULL, *jdstPtr;
- int width, *warr, height, *harr, pixelFormat, *pfarr, n;
+ int width, *warr, height, *harr, pixelFormat, *pfarr;
+ jsize arraySize, pitch;
const char *filename = NULL;
jboolean isCopy;
jobject jdstBuf = NULL;
@@ -1331,13 +1334,14 @@ JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_loadImage
pfarr[0] = pixelFormat;
(*env)->ReleasePrimitiveArrayCritical(env, jpixelFormat, pfarr, 0);
- n = width * height * tjPixelSize[pixelFormat];
+ pitch = PAD(width * tjPixelSize[pixelFormat], align);
+ arraySize = pitch * height;
if (precision == 8)
- jdstBuf = (*env)->NewByteArray(env, n);
+ jdstBuf = (*env)->NewByteArray(env, arraySize);
else
- jdstBuf = (*env)->NewShortArray(env, n);
+ jdstBuf = (*env)->NewShortArray(env, arraySize);
BAILIF0NOEC(jdstPtr = (*env)->GetPrimitiveArrayCritical(env, jdstBuf, 0));
- memcpy(jdstPtr, dstBuf, n * (precision > 8 ? 2 : 1));
+ memcpy(jdstPtr, dstBuf, arraySize * (precision > 8 ? 2 : 1));
(*env)->ReleasePrimitiveArrayCritical(env, jdstBuf, jdstPtr, 0);
bailout:
@@ -1354,29 +1358,33 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_saveImage
tjhandle handle = NULL;
void *srcBuf = NULL, *jsrcPtr;
const char *filename = NULL;
- int n;
+ jsize arraySize, actualPitch;
jboolean isCopy;
GET_HANDLE();
if ((precision != 8 && precision != 12 && precision != 16) ||
- jfilename == NULL || jsrcBuf == NULL || width < 1 || height < 1 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
+ jfilename == NULL || jsrcBuf == NULL || width < 1 || pitch < 0 ||
+ height < 1 || pixelFormat < 0 ||
+ pixelFormat >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
THROW_ARG("Invalid argument in saveImage()");
+ if (org_libjpegturbo_turbojpeg_TJ_NUMPF != TJ_NUMPF)
+ THROW_ARG("Mismatch between Java and C API");
if ((unsigned long long)width * (unsigned long long)height *
(unsigned long long)tjPixelSize[pixelFormat] >
(unsigned long long)((unsigned int)-1))
THROW_ARG("Image is too large");
- n = width * height * tjPixelSize[pixelFormat];
- if ((*env)->GetArrayLength(env, jsrcBuf) < n)
+ actualPitch = (pitch == 0) ? width * tjPixelSize[pixelFormat] : pitch;
+ arraySize = actualPitch * height;
+ if ((*env)->GetArrayLength(env, jsrcBuf) < arraySize)
THROW_ARG("Source buffer is not large enough");
- if ((srcBuf = malloc(n * (precision > 8 ? 2 : 1))) == NULL)
+ if ((srcBuf = malloc(arraySize * (precision > 8 ? 2 : 1))) == NULL)
THROW_MEM();
BAILIF0NOEC(jsrcPtr = (*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0));
- memcpy(srcBuf, jsrcPtr, n * (precision > 8 ? 2 : 1));
+ memcpy(srcBuf, jsrcPtr, arraySize * (precision > 8 ? 2 : 1));
(*env)->ReleasePrimitiveArrayCritical(env, jsrcBuf, jsrcPtr, 0);
BAILIF0(filename = (*env)->GetStringUTFChars(env, jfilename, &isCopy));
From de4bbac55eac877fb00052de73d714274b4fd37d Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 23 Aug 2024 12:48:01 -0400
Subject: [PATCH 090/135] TJCompressor.compress(): Fix lossls buf size calc
---
ChangeLog.md | 5 +++++
java/org/libjpegturbo/turbojpeg/TJCompressor.java | 2 ++
2 files changed, 7 insertions(+)
diff --git a/ChangeLog.md b/ChangeLog.md
index 6962f5f7..17558ff7 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -28,6 +28,11 @@ unless the `-precision` option was specified before the `-lossless` option.
calling applications to generate 12-bit-per-sample arithmetic-coded lossy JPEG
images using the TurboJPEG API.
+5. Fixed an error ("Destination buffer is not large enough") that occurred when
+attempting to generate a full-color lossless JPEG image using the TurboJPEG
+Java API's `byte[] TJCompressor.compress()` method if the value of
+`TJ.PARAM_SUBSAMP` was not `TJ.SAMP_444`.
+
3.0.3
=====
diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
index b18cb07d..dff38bf7 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
@@ -485,6 +485,8 @@ public class TJCompressor implements Closeable {
} else {
checkSubsampling();
int subsamp = get(TJ.PARAM_SUBSAMP);
+ if (get(TJ.PARAM_LOSSLESS) == 1 && subsamp != TJ.SAMP_GRAY)
+ subsamp = TJ.SAMP_444;
buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
}
compress(buf);
From 548f73243228e240a311fd8a16d3061c98aee683 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 26 Aug 2024 10:14:11 -0400
Subject: [PATCH 091/135] TJBench: Usage screen tweak
Indicate that -maxmemory and -maxpixels take an integer argument.
---
java/TJBench.java | 4 ++--
tjbench.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/java/TJBench.java b/java/TJBench.java
index 37706b23..1eb1caea 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -781,11 +781,11 @@ final class TJBench {
System.out.println("-componly = Stop after running compression tests. Do not test decompression.");
System.out.println("-lossless = Generate lossless JPEG images when compressing (implies");
System.out.println(" -subsamp 444). PSV is the predictor selection value (1-7).");
- System.out.println("-maxmemory = Memory limit (in megabytes) for intermediate buffers used with");
+ System.out.println("-maxmemory N = Memory limit (in megabytes) for intermediate buffers used with");
System.out.println(" progressive JPEG compression and decompression, Huffman table");
System.out.println(" optimization, lossless JPEG compression, and lossless transformation");
System.out.println(" [default = no limit]");
- System.out.println("-maxpixels = Input image size limit (in pixels) [default = no limit]");
+ System.out.println("-maxpixels N = Input image size limit (in pixels) [default = no limit]");
System.out.println("-nowrite = Do not write reference or output images (improves consistency of");
System.out.println(" benchmark results)");
System.out.println("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =");
diff --git a/tjbench.c b/tjbench.c
index e9e73c45..316c5df5 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -918,11 +918,11 @@ static void usage(char *progName)
printf("-componly = Stop after running compression tests. Do not test decompression.\n");
printf("-lossless = Generate lossless JPEG images when compressing (implies\n");
printf(" -subsamp 444). PSV is the predictor selection value (1-7).\n");
- printf("-maxmemory = Memory limit (in megabytes) for intermediate buffers used with\n");
+ printf("-maxmemory N = Memory limit (in megabytes) for intermediate buffers used with\n");
printf(" progressive JPEG compression and decompression, Huffman table\n");
printf(" optimization, lossless JPEG compression, and lossless transformation\n");
printf(" [default = no limit]\n");
- printf("-maxpixels = Input image size limit (in pixels) [default = no limit]\n");
+ printf("-maxpixels N = Input image size limit (in pixels) [default = no limit]\n");
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
printf(" benchmark results)\n");
printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n");
From 4851cbe40687c6a02698b998717d281912498d20 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 26 Aug 2024 12:14:20 -0400
Subject: [PATCH 092/135] djpeg/jpeg_crop_scanline(): Disallow crop vals < 0
Because the crop spec was parsed using unsigned 32-bit integers,
negative numbers were interpreted as values ~= UINT_MAX (4,294,967,295).
This had the following ramifications:
- If the cropping region width was negative and the adjusted width + the
adjusted left boundary was greater than 0, then the 32-bit unsigned
integer bounds checks in djpeg and jpeg_crop_scanline() overflowed and
failed to detect the out-of-bounds width, jpeg_crop_scanline() set
cinfo->output_width to a value ~= UINT_MAX, and a buffer overrun and
subsequent segfault occurred in the upsampling or color conversion
routine. The segfault occurred in the body of
jpeg_skip_scanlines() --> read_and_discard_scanlines() if the cropping
region upper boundary was greater than 0 and the JPEG image used
chrominance subsampling and in the body of jpeg_read_scanlines()
otherwise.
- If the cropping region width was negative and the adjusted width + the
adjusted left boundary was 0, then a zero-width output image was
generated.
- If the cropping region left boundary was negative, then an output
image with bogus data was generated.
This commit modifies djpeg and jpeg_crop_scanline() so that the
aforementioned bounds checks use 64-bit unsigned integers, thus guarding
against overflow. It similarly modifies jpeg_skip_scanlines(). In the
case of jpeg_skip_scanlines(), the issue was not reproducible with
djpeg, but passing a negative number of lines to jpeg_skip_scanlines()
caused a similar overflow if the number of lines +
cinfo->output_scanline was greater than 0. That caused
jpeg_skip_scanlines() to read past the end of the JPEG image, throw a
warning ("Corrupt JPEG data: premature end of data segment"), and fail
to return unless warnings were treated as fatal. Also, djpeg now parses
the crop spec using signed integers and checks for negative values.
---
ChangeLog.md | 10 ++++++++++
djpeg.c | 23 ++++++++++++++++-------
jdapistd.c | 8 +++++---
3 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 17558ff7..108f6ccb 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -33,6 +33,16 @@ attempting to generate a full-color lossless JPEG image using the TurboJPEG
Java API's `byte[] TJCompressor.compress()` method if the value of
`TJ.PARAM_SUBSAMP` was not `TJ.SAMP_444`.
+6. Fixed a segfault in djpeg that occurred if a negative width was specified
+with the `-crop` option. Since the cropping region width was read into an
+unsigned 32-bit integer, a negative width was interpreted as a very large
+value. With certain negative width and positive left boundary values, the
+bounds checks in djpeg and `jpeg_crop_scanline()` overflowed and did not detect
+the out-of-bounds width, which caused a buffer overrun in the upsampling or
+color conversion routine. Both bounds checks now use 64-bit integers to guard
+against overflow, and djpeg now checks for negative numbers when it parses the
+crop specification from the command line.
+
3.0.3
=====
diff --git a/djpeg.c b/djpeg.c
index 80d79f02..132fc4bd 100644
--- a/djpeg.c
+++ b/djpeg.c
@@ -401,22 +401,31 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
usage();
} else if (keymatch(arg, "skip", 2)) {
+ int temp_start = -1, temp_end = -1;
if (++argn >= argc)
usage();
- if (sscanf(argv[argn], "%u,%u", &skip_start, &skip_end) != 2 ||
- skip_start > skip_end)
+ if (sscanf(argv[argn], "%d,%d", &temp_start, &temp_end) != 2 ||
+ temp_start < 0 || temp_end < 0 || temp_start > temp_end)
usage();
skip = TRUE;
+ skip_start = temp_start;
+ skip_end = temp_end;
} else if (keymatch(arg, "crop", 2)) {
+ int temp_width = -1, temp_height = -1, temp_x = -1, temp_y = -1;
char c;
if (++argn >= argc)
usage();
- if (sscanf(argv[argn], "%u%c%u+%u+%u", &crop_width, &c, &crop_height,
- &crop_x, &crop_y) != 5 ||
- (c != 'X' && c != 'x') || crop_width < 1 || crop_height < 1)
+ if (sscanf(argv[argn], "%d%c%d+%d+%d", &temp_width, &c, &temp_height,
+ &temp_x, &temp_y) != 5 ||
+ (c != 'X' && c != 'x') || temp_width < 1 || temp_height < 1 ||
+ temp_x < 0 || temp_y < 0)
usage();
crop = TRUE;
+ crop_width = temp_width;
+ crop_height = temp_height;
+ crop_x = temp_x;
+ crop_y = temp_y;
} else if (keymatch(arg, "strict", 2)) {
strict = TRUE;
@@ -776,8 +785,8 @@ main(int argc, char **argv)
/* Check for valid crop dimensions. We cannot check these values until
* after jpeg_start_decompress() is called.
*/
- if (crop_x + crop_width > cinfo.output_width ||
- crop_y + crop_height > cinfo.output_height) {
+ if ((unsigned long long)crop_x + crop_width > cinfo.output_width ||
+ (unsigned long long)crop_y + crop_height > cinfo.output_height) {
fprintf(stderr, "%s: crop dimensions exceed image dimensions %u x %u\n",
progname, cinfo.output_width, cinfo.output_height);
exit(EXIT_FAILURE);
diff --git a/jdapistd.c b/jdapistd.c
index 1f449272..38da36b7 100644
--- a/jdapistd.c
+++ b/jdapistd.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2015-2020, 2022-2023, D. R. Commander.
+ * Copyright (C) 2010, 2015-2020, 2022-2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -200,7 +200,8 @@ _jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
ERREXIT(cinfo, JERR_BAD_CROP_SPEC);
/* xoffset and width must fall within the output image dimensions. */
- if (*width == 0 || *xoffset + *width > cinfo->output_width)
+ if (*width == 0 ||
+ (unsigned long long)(*xoffset) + *width > cinfo->output_width)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
/* No need to do anything if the caller wants the entire width. */
@@ -482,7 +483,8 @@ _jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Do not skip past the bottom of the image. */
- if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
+ if ((unsigned long long)cinfo->output_scanline + num_lines >=
+ cinfo->output_height) {
num_lines = cinfo->output_height - cinfo->output_scanline;
cinfo->output_scanline = cinfo->output_height;
(*cinfo->inputctl->finish_input_pass) (cinfo);
From 00a261c4739d3da1c6e161ef993d3c6b46e29361 Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 26 Aug 2024 16:31:02 -0400
Subject: [PATCH 093/135] tjbench.c: Code formatting tweak
---
tjbench.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tjbench.c b/tjbench.c
index 316c5df5..54fec19a 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -1097,8 +1097,8 @@ int main(int argc, char *argv[])
int temp1 = -1, temp2 = -1, temp3 = -1, temp4 = -1;
if (sscanf(argv[++i], "%dx%d+%d+%d", &temp1, &temp2, &temp3,
- &temp4) == 4 && temp1 >= 0 && temp2 >= 0 && temp3 >= 0 &&
- temp4 >= 0) {
+ &temp4) == 4 &&
+ temp1 >= 0 && temp2 >= 0 && temp3 >= 0 && temp4 >= 0) {
cr.w = temp1; cr.h = temp2; cr.x = temp3; cr.y = temp4;
} else usage(argv[0]);
} else if (!strcasecmp(argv[i], "-hflip"))
From 35199878f658a2e6a6732f63284117fcecc7d0fb Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 26 Aug 2024 16:35:30 -0400
Subject: [PATCH 094/135] TurboJPEG doc: Fix incorrect/confusing parentheses
---
doc/html/group___turbo_j_p_e_g.html | 2 +-
turbojpeg.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index 33704245..f40257a3 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -3059,7 +3059,7 @@ If you choose option 1, then *jpegSize should be set to the size of
Parameters
handle
handle to a TurboJPEG instance that has been initialized for decompression
-
croppingRegion
tjregion structure that specifies a subregion of the JPEG image to decompress, or TJUNCROPPED for no cropping. The left boundary of the cropping region must be evenly divisible by the scaled MCU block width (TJSCALED(tjMCUWidth[subsamp], scalingFactor), where subsamp is the level of chrominance subsampling in the JPEG image (see TJPARAM_SUBSAMP) and scalingFactor is the decompression scaling factor (see tj3SetScalingFactor().) The cropping region should be specified relative to the scaled image dimensions. Unless croppingRegion is TJUNCROPPED, the JPEG header must be read (see tj3DecompressHeader()) prior to calling this function.
+
croppingRegion
tjregion structure that specifies a subregion of the JPEG image to decompress, or TJUNCROPPED for no cropping. The left boundary of the cropping region must be evenly divisible by the scaled MCU block width– TJSCALED(tjMCUWidth[subsamp], scalingFactor), where subsamp is the level of chrominance subsampling in the JPEG image (see TJPARAM_SUBSAMP) and scalingFactor is the decompression scaling factor (see tj3SetScalingFactor().) The cropping region should be specified relative to the scaled image dimensions. Unless croppingRegion is TJUNCROPPED, the JPEG header must be read (see tj3DecompressHeader()) prior to calling this function.
diff --git a/turbojpeg.h b/turbojpeg.h
index 42c9b49e..d35fbfc1 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -1663,7 +1663,7 @@ DLLEXPORT int tj3SetScalingFactor(tjhandle handle,
* @param croppingRegion #tjregion structure that specifies a subregion of the
* JPEG image to decompress, or #TJUNCROPPED for no cropping. The
* left boundary of the cropping region must be evenly divisible by the scaled
- * MCU block width (#TJSCALED(#tjMCUWidth[subsamp], scalingFactor),
+ * MCU block width-- #TJSCALED(#tjMCUWidth[subsamp], scalingFactor),
* where `subsamp` is the level of chrominance subsampling in the JPEG image
* (see #TJPARAM_SUBSAMP) and `scalingFactor` is the decompression scaling
* factor (see #tj3SetScalingFactor().) The cropping region should be
From c72bbd9c0673a9ecad33a55c500985cdb599b38a Mon Sep 17 00:00:00 2001
From: DRC
Date: Mon, 26 Aug 2024 18:00:23 -0400
Subject: [PATCH 095/135] tjbench.c: (Re)allow unreduced scaling factors
For reasons I can't recall, fc01f4673b71c0b833c59c21e8c4478a9c4bcf21
(the TurboJPEG 3 API overhaul) changed the C version of TJBench, but not
the Java version, so that it requires an exact scaling factor match (as
opposed to allowing unreduced scaling factors, as djpeg does and prior
versions of TJBench did.) That might have been temporary testing code
that was accidentally committed.
---
tjbench.c | 5 +++--
tjbenchtest.in | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/tjbench.c b/tjbench.c
index 54fec19a..a52170ee 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -1085,8 +1085,9 @@ int main(int argc, char *argv[])
if (sscanf(argv[++i], "%d/%d", &temp1, &temp2) == 2) {
for (j = 0; j < nsf; j++) {
- if (temp1 == scalingFactors[j].num &&
- temp2 == scalingFactors[j].denom) {
+ if ((double)temp1 / (double)temp2 ==
+ (double)scalingFactors[j].num /
+ (double)scalingFactors[j].denom) {
sf = scalingFactors[j];
match = 1; break;
}
diff --git a/tjbenchtest.in b/tjbenchtest.in
index 4f5a9729..97fa8a96 100755
--- a/tjbenchtest.in
+++ b/tjbenchtest.in
@@ -317,13 +317,13 @@ for image in $IMAGES; do
runme cmp $OUTDIR/${basename}_${samp}_Q${TJQUAL}_full.ppm $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm
rm $OUTDIR/${basename}_${samp}_Q${TJQUAL}_full.ppm $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm
- runme $EXEDIR/djpeg -rgb -scale 7/8 -crop ${CROPW7_8}x81+${CROPL7_8}+3 $NSARG -outfile $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
+ runme $EXEDIR/djpeg -rgb -scale 14/16 -crop ${CROPW7_8}x81+${CROPL7_8}+3 $NSARG -outfile $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
runme $TJBENCH $OUTDIR/${basename}_${samp}_Q${TJQUAL}.jpg -scale 7/8 -crop ${CROPW7_8}x81+${CROPL7_8}+3 -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme cmp $OUTDIR/${basename}_${samp}_Q${TJQUAL}_7_8.ppm $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm
rm $OUTDIR/${basename}_${samp}_Q${TJQUAL}_7_8.ppm $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm
runme $EXEDIR/djpeg -rgb -scale 1/2 -crop 40x40+0+0 $NSARG -outfile $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
- runme $TJBENCH $OUTDIR/${basename}_${samp}_Q${TJQUAL}.jpg -scale 1/2 -crop 40x40+0+0 -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
+ runme $TJBENCH $OUTDIR/${basename}_${samp}_Q${TJQUAL}.jpg -scale 4/8 -crop 40x40+0+0 -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme cmp $OUTDIR/${basename}_${samp}_Q${TJQUAL}_1_2.ppm $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm
rm $OUTDIR/${basename}_${samp}_Q${TJQUAL}_1_2.ppm $OUTDIR/${basename}_${samp}_scale_crop_djpeg.ppm
done
From d62079717c613c5c92f8721d1a343d7b81a08a74 Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 28 Aug 2024 18:00:14 -0400
Subject: [PATCH 096/135] TJBench: Don't override subsamp until args parsed
Otherwise, passing -subsamp after -lossless might cause the worst-case
JPEG buffer size to be too small.
---
java/TJBench.java | 8 +++++---
tjbench.c | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/java/TJBench.java b/java/TJBench.java
index 1eb1caea..e4bedce3 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -936,10 +936,9 @@ final class TJBench {
System.out.println("Using arithmetic entropy coding\n");
arithmetic = true;
xformOpt |= TJTransform.OPT_ARITHMETIC;
- } else if (argv[i].equalsIgnoreCase("-lossless")) {
+ } else if (argv[i].equalsIgnoreCase("-lossless"))
lossless = true;
- subsamp = TJ.SAMP_444;
- } else if (argv[i].equalsIgnoreCase("-rgb"))
+ else if (argv[i].equalsIgnoreCase("-rgb"))
pf = TJ.PF_RGB;
else if (argv[i].equalsIgnoreCase("-rgbx"))
pf = TJ.PF_RGBX;
@@ -1130,6 +1129,9 @@ final class TJBench {
precision != 12)
System.out.println("Computing optimal Huffman tables\n");
+ if (lossless)
+ subsamp = TJ.SAMP_444;
+
if (precision == 16 && !lossless)
throw new Exception("-lossless must be specified along with -precision 16");
if (precision != 8 && doYUV)
diff --git a/tjbench.c b/tjbench.c
index a52170ee..5925f90e 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -1057,10 +1057,9 @@ int main(int argc, char *argv[])
printf("Using arithmetic entropy coding\n\n");
arithmetic = 1;
xformOpt |= TJXOPT_ARITHMETIC;
- } else if (!strcasecmp(argv[i], "-lossless")) {
+ } else if (!strcasecmp(argv[i], "-lossless"))
lossless = 1;
- subsamp = TJSAMP_444;
- } else if (!strcasecmp(argv[i], "-rgb"))
+ else if (!strcasecmp(argv[i], "-rgb"))
pf = TJPF_RGB;
else if (!strcasecmp(argv[i], "-rgbx"))
pf = TJPF_RGBX;
@@ -1200,6 +1199,9 @@ int main(int argc, char *argv[])
if (optimize && !progressive && !arithmetic && !lossless && precision != 12)
printf("Computing optimal Huffman tables\n\n");
+ if (lossless)
+ subsamp = TJSAMP_444;
+
if (precision == 16 && !lossless) {
printf("ERROR: -lossless must be specified along with -precision 16\n");
retval = -1; goto bailout;
From 5cf79606784f0616590e6a3a7fdf17ad32a6df9b Mon Sep 17 00:00:00 2001
From: DRC
Date: Wed, 28 Aug 2024 18:36:37 -0400
Subject: [PATCH 097/135] Undocument TJ*PARAM_RESTARTBLOCKS for lossless
TJ*PARAM_RESTARTBLOCKS technically works with lossless compression, but
it is not useful, since the value must be equal to the number of samples
in a row. (In other words, it is no different than
TJ*PARAM_RESTARTINROWS, except that it requires the user to do more
math.)
---
doc/html/group___turbo_j_p_e_g.html | 8 ++++----
java/doc/index-all.html | 3 +--
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 10 ++++------
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 7 +++----
turbojpeg.h | 7 +++----
8 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index f40257a3..4deb7cba 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -972,19 +972,19 @@ scalingFactor).
A point transform value of 0 is necessary in order to generate a fully lossless JPEG image. (A non-zero point transform value right-shifts the input samples by the specified number of bits, which is effectively a form of lossy color quantization.)
JPEG restart marker interval in MCU blocks (lossy) or samples (lossless) [compression only].
+
TJPARAM_RESTARTBLOCKS
JPEG restart marker interval in MCU blocks [lossy compression only].
The nature of entropy coding is such that a corrupt JPEG image cannot be decompressed beyond the point of corruption unless it contains restart markers. A restart marker stops and restarts the entropy coding algorithm so that, if a JPEG image is corrupted, decompression can resume at the next marker. Thus, adding more restart markers improves the fault tolerance of the JPEG image, but adding too many restart markers can adversely affect the compression ratio and performance.
Value
-
the number of MCU blocks or samples between each restart marker [default: 0 (no restart markers)]
+
the number of MCU blocks between each restart marker [default: 0 (no restart markers)]
JPEG restart marker interval in MCU blocks (lossy) or samples (lossless)
- [compression only]
+
JPEG restart marker interval in MCU blocks [lossy compression only]
@@ -1804,8 +1803,7 @@ extends java.lang.Object
PARAM_RESTARTBLOCKS
public static final int PARAM_RESTARTBLOCKS
-
JPEG restart marker interval in MCU blocks (lossy) or samples (lossless)
- [compression only]
+
JPEG restart marker interval in MCU blocks [lossy compression only]
The nature of entropy coding is such that a corrupt JPEG image cannot
be decompressed beyond the point of corruption unless it contains restart
@@ -1817,8 +1815,8 @@ extends java.lang.Object
Value
-
the number of MCU blocks or samples between each restart marker
- [default: 0 (no restart markers)]
+
the number of MCU blocks between each restart marker [default:
+ 0 (no restart markers)]
Setting this parameter to a non-zero value sets
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index ab1abc884b11f2584279a1c48e3556b894ef38ad..c4a65c144d46347c46241b3a874a46e607aeccd2 100644
GIT binary patch
delta 28
hcmaFM_?D43z?+#xgn@&DgQ0nf%tYRPW)L;s4*+M+2h0Ef
delta 28
hcmaFM_?D43z?+#xgn@&DgCQ+LbRus*Gl-h+2LNJI2P^;p
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index d5a3ac06212f76d5cb07ca1024d980bd40cd6c3d..0493b849467c4329a2ecedb37a2295c766ba4399 100644
GIT binary patch
delta 28
hcmdnaw4I4Jz?+#xgn@&DgQ0nf%tYQh%pmHGHvnIr2l)U1
delta 28
hcmdnaw4I4Jz?+#xgn@&DgCQ+LbRzE^W)Stp8vt4&2U!3B
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index 505bdb6e..a42dfdb8 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -765,8 +765,7 @@ public final class TJ {
*/
public static final int PARAM_LOSSLESSPT = 17;
/**
- * JPEG restart marker interval in MCU blocks (lossy) or samples (lossless)
- * [compression only]
+ * JPEG restart marker interval in MCU blocks [lossy compression only]
*
*
The nature of entropy coding is such that a corrupt JPEG image cannot
* be decompressed beyond the point of corruption unless it contains restart
@@ -778,8 +777,8 @@ public final class TJ {
*
*
Value
*
- *
the number of MCU blocks or samples between each restart marker
- * [default: 0 (no restart markers)]
+ *
the number of MCU blocks between each restart marker [default:
+ * 0 (no restart markers)]
*
*
*
Setting this parameter to a non-zero value sets
diff --git a/turbojpeg.h b/turbojpeg.h
index d35fbfc1..4f091be2 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -752,8 +752,7 @@ enum TJPARAM {
*/
TJPARAM_LOSSLESSPT,
/**
- * JPEG restart marker interval in MCU blocks (lossy) or samples (lossless)
- * [compression only]
+ * JPEG restart marker interval in MCU blocks [lossy compression only]
*
* The nature of entropy coding is such that a corrupt JPEG image cannot
* be decompressed beyond the point of corruption unless it contains restart
@@ -764,8 +763,8 @@ enum TJPARAM {
* adversely affect the compression ratio and performance.
*
* **Value**
- * - the number of MCU blocks or samples between each restart marker
- * *[default: `0` (no restart markers)]*
+ * - the number of MCU blocks between each restart marker *[default: `0` (no
+ * restart markers)]*
*
* Setting this parameter to a non-zero value sets #TJPARAM_RESTARTROWS to 0.
*/
From 8456d2b98cf1dd4867abcad9088fabac549959ba Mon Sep 17 00:00:00 2001
From: DRC
Date: Fri, 30 Aug 2024 10:50:13 -0400
Subject: [PATCH 098/135] Doc: "MCU block" = "iMCU" or "MCU"
The JPEG-1 spec never uses the term "MCU block". That term is rarely
used in other literature to describe the equivalent of an MCU in an
interleaved JPEG image, but the libjpeg documentation uses "iMCU" to
describe the same thing. "iMCU" is a better term, since the equivalent
of an interleaved MCU can contain multiple DCT blocks (or samples in
lossless mode) that are only grouped together if the image is
interleaved.
In the case of restart markers, "MCU block" was used in the libjpeg
documentation instead of "MCU", but "MCU" is more accurate and less
confusing. (The restart interval is literally in MCUs, where one MCU
is one data unit in a non-interleaved JPEG image and multiple data units
in a multi-component interleaved JPEG image.)
In the case of 9b704f96b2dccc54363ad7a2fe8e378fc1a2893b, the issue was
actually with progressive JPEG images exactly two DCT blocks wide, not
two MCU blocks wide.
This commit also defines "MCU" and "MCU row" in the description of the
various restart marker options/parameters. Although an MCU row is
technically always a row of samples in lossless mode, "sample row" was
confusing, since it is used in other places to describe a row of samples
for a single component (whereas an MCU row in a typical lossless JPEG
image consists of a row of interleaved samples for all components.)
---
ChangeLog.md | 8 +-
cjpeg.1 | 16 ++-
doc/html/group___turbo_j_p_e_g.html | 61 ++++-----
doc/html/structtjregion.html | 4 +-
java/TJBench.java | 9 +-
java/TJExample.java | 6 +-
java/doc/index-all.html | 13 +-
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 75 +++++++----
.../turbojpeg/TJDecompressor.html | 12 +-
.../libjpegturbo/turbojpeg/TJTransform.html | 40 +++---
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 64 +++++++---
.../turbojpeg/TJDecompressor.java | 12 +-
.../libjpegturbo/turbojpeg/TJTransform.java | 41 +++---
jpegtran.1 | 6 +-
libjpeg.txt | 17 ++-
tjbench.c | 9 +-
tjexample.c | 4 +-
turbojpeg.c | 2 +-
turbojpeg.h | 120 +++++++++++-------
usage.txt | 22 +++-
23 files changed, 323 insertions(+), 218 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 108f6ccb..e771e3ef 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -114,7 +114,7 @@ within the functions.
2. Fixed two minor issues in the interblock smoothing algorithm that caused
mathematical (but not necessarily perceptible) edge block errors when
-decompressing progressive JPEG images exactly two MCU blocks in width or that
+decompressing progressive JPEG images exactly two DCT blocks in width or that
use vertical chrominance subsampling.
3. Fixed a regression introduced by 3.0 beta2[6] that, in rare cases, caused
@@ -471,9 +471,9 @@ prevented libjpeg-turbo from working properly with other linkers and also
represented a potential security risk.
2. Fixed an issue whereby the `tjTransform()` function incorrectly computed the
-MCU block size for 4:4:4 JPEG images with non-unary sampling factors and thus
-unduly rejected some cropping regions, even though those regions aligned with
-8x8 MCU block boundaries.
+iMCU size for 4:4:4 JPEG images with non-unary sampling factors and thus unduly
+rejected some cropping regions, even though those regions aligned with 8x8 iMCU
+boundaries.
3. Fixed a regression introduced by 2.1 beta1[13] that caused the build system
to enable the Arm Neon SIMD extensions when targetting Armv6 and other legacy
diff --git a/cjpeg.1 b/cjpeg.1
index ca184571..28a633b3 100644
--- a/cjpeg.1
+++ b/cjpeg.1
@@ -1,4 +1,4 @@
-.TH CJPEG 1 "24 June 2024"
+.TH CJPEG 1 "30 August 2024"
.SH NAME
cjpeg \- compress an image file to a JPEG file
.SH SYNOPSIS
@@ -270,8 +270,18 @@ machines.
Embed ICC color management profile contained in the specified file.
.TP
.BI \-restart " N"
-Emit a JPEG restart marker every N MCU rows, or every N MCU blocks (samples in
-lossless mode) if "B" is attached to the number.
+Emit a JPEG restart marker every N MCU rows, or every N MCUs if "B" is attached
+to the number.
+.IP
+In typical JPEG images, an MCU (Minimum Coded Unit) is the minimum set of
+interleaved "data units" (8x8 DCT blocks if the image is lossy or samples if
+the image is lossless) necessary to represent at least one data unit per
+component. (For example, an MCU in an interleaved lossy JPEG image that uses
+4:2:2 subsampling consists of two luminance blocks followed by one block for
+each chrominance component.) In single-component or non-interleaved JPEG
+images, an MCU is the same as a data unit. An MCU row is a row of MCUs
+spanning the entire width of the image.
+.IP
.B \-restart 0
(the default) means no restart markers.
.TP
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index 4deb7cba..b0eb355a 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -120,7 +120,7 @@ Macros
This option causes tj3Transform() to return an error if the transform is not perfect.
This option causes tj3Transform() to return an error if the transform is not perfect.
-
Lossless transforms operate on MCU blocks, the size of which depends on the level of chrominance subsampling used (see tjMCUWidth and tjMCUHeight.) If the image's width or height is not evenly divisible by the MCU block size, then there will be partial MCU blocks on the right and/or bottom edges. It is not possible to move these partial MCU blocks to the top or left of the image, so any transform that would require that is "imperfect." If this option is not specified, then any partial MCU blocks that cannot be transformed will be left in place, which will create odd-looking strips on the right or bottom edge of the image.
+
Lossless transforms operate on iMCUs, the size of which depends on the level of chrominance subsampling used (see tjMCUWidth and tjMCUHeight.) If the image's width or height is not evenly divisible by the iMCU size, then there will be partial iMCUs on the right and/or bottom edges. It is not possible to move these partial iMCUs to the top or left of the image, so any transform that would require that is "imperfect." If this option is not specified, then any partial iMCUs that cannot be transformed will be left in place, which will create odd-looking strips on the right or bottom edge of the image.
@@ -697,7 +697,7 @@ scalingFactor).
-
Discard any partial MCU blocks that cannot be transformed.
+
Discard any partial iMCUs that cannot be transformed.
@@ -900,7 +900,7 @@ scalingFactor).
Huffman table optimization improves compression slightly (generally 5% or less), but it reduces compression performance considerably.
TJPARAM_PROGRESSIVE
Progressive JPEG.
-
In a progressive JPEG image, the DCT coefficients are split across multiple "scans" of increasing quality. Thus, a low-quality scan containing the lowest-frequency DCT coefficients can be transmitted first and refined with subsequent higher-quality scans containing higher-frequency DCT coefficients. When using Huffman entropy coding, the progressive JPEG format also provides an "end-of-bands (EOB) run" feature that allows large groups of zeroes, potentially spanning multiple MCU blocks, to be represented using only a few bytes.
+
In a progressive JPEG image, the DCT coefficients are split across multiple "scans" of increasing quality. Thus, a low-quality scan containing the lowest-frequency DCT coefficients can be transmitted first and refined with subsequent higher-quality scans containing higher-frequency DCT coefficients. When using Huffman entropy coding, the progressive JPEG format also provides an "end-of-bands (EOB) run" feature that allows large groups of zeroes, potentially spanning multiple MCUs, to be represented using only a few bytes.
Value
0[default for compression, lossless transformation] The lossy JPEG image is (decompression) or will be (compression, lossless transformation) single-scan.
1 The lossy JPEG image is (decompression) or will be (compression, lossless transformation) progressive. For lossless transformation, this can also be specified using TJXOPT_PROGRESSIVE.
@@ -972,19 +972,20 @@ scalingFactor).
A point transform value of 0 is necessary in order to generate a fully lossless JPEG image. (A non-zero point transform value right-shifts the input samples by the specified number of bits, which is effectively a form of lossy color quantization.)
JPEG restart marker interval in MCU blocks [lossy compression only].
+
TJPARAM_RESTARTBLOCKS
JPEG restart marker interval in MCUs [lossy compression only].
The nature of entropy coding is such that a corrupt JPEG image cannot be decompressed beyond the point of corruption unless it contains restart markers. A restart marker stops and restarts the entropy coding algorithm so that, if a JPEG image is corrupted, decompression can resume at the next marker. Thus, adding more restart markers improves the fault tolerance of the JPEG image, but adding too many restart markers can adversely affect the compression ratio and performance.
+
In typical JPEG images, an MCU (Minimum Coded Unit) is the minimum set of interleaved "data units" (8x8 DCT blocks if the image is lossy or samples if the image is lossless) necessary to represent at least one data unit per component. (For example, an MCU in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of two luminance blocks followed by one block for each chrominance component.) In single-component or non-interleaved JPEG images, an MCU is the same as a data unit.
Value
-
the number of MCU blocks between each restart marker [default: 0 (no restart markers)]
+
the number of MCUs between each restart marker [default: 0 (no restart markers)]
Do not transform the position of the image pixels.
TJXOP_HFLIP
Flip (mirror) image horizontally.
-
This transform is imperfect if there are any partial MCU blocks on the right edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial iMCUs on the right edge (see TJXOPT_PERFECT.)
TJXOP_VFLIP
Flip (mirror) image vertically.
-
This transform is imperfect if there are any partial MCU blocks on the bottom edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial iMCUs on the bottom edge (see TJXOPT_PERFECT.)
TJXOP_TRANSPOSE
Transpose image (flip/mirror along upper left to lower right axis.) This transform is always perfect.
-
TJXOP_TRANSVERSE
Transverse transpose image (flip/mirror along upper right to lower left axis.) This transform is imperfect if there are any partial MCU blocks in the image (see TJXOPT_PERFECT.)
+
TJXOP_TRANSVERSE
Transverse transpose image (flip/mirror along upper right to lower left axis.) This transform is imperfect if there are any partial iMCUs in the image (see TJXOPT_PERFECT.)
TJXOP_ROT90
Rotate image clockwise by 90 degrees.
-
This transform is imperfect if there are any partial MCU blocks on the bottom edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial iMCUs on the bottom edge (see TJXOPT_PERFECT.)
TJXOP_ROT180
Rotate image 180 degrees.
-
This transform is imperfect if there are any partial MCU blocks in the image (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial iMCUs in the image (see TJXOPT_PERFECT.)
TJXOP_ROT270
Rotate image counter-clockwise by 90 degrees.
-
This transform is imperfect if there are any partial MCU blocks on the right edge (see TJXOPT_PERFECT.)
+
This transform is imperfect if there are any partial iMCUs on the right edge (see TJXOPT_PERFECT.)
@@ -1516,9 +1517,9 @@ If you choose option 1, then *jpegSize should be set to the size of
handle
handle to a TurboJPEG instance that has been initialized for compression
srcBuf
pointer to a buffer containing a unified planar YUV source image to be compressed. The size of this buffer should match the value returned by tj3YUVBufSize() for the given image width, height, row alignment, and level of chrominance subsampling (see TJPARAM_SUBSAMP.) The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the buffer. (Refer to YUV Image Format Notes.)
-
width
width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed.
+
width
width (in pixels) of the source image. If the width is not an even multiple of the iMCU width (see tjMCUWidth), then an intermediate buffer copy will be performed.
align
row alignment (in bytes) of the source image (must be a power of 2.) Setting this parameter to n indicates that each row in each plane of the source image is padded to the nearest multiple of n bytes (1 = unpadded.)
-
height
height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed.
+
height
height (in pixels) of the source image. If the height is not an even multiple of the iMCU height (see tjMCUHeight), then an intermediate buffer copy will be performed.
jpegBuf
address of a pointer to a byte buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
pre-allocate the JPEG buffer with an arbitrary size using tj3Alloc() and let TurboJPEG grow the buffer as needed,
set *jpegBuf to NULL to tell TurboJPEG to allocate the buffer for you, or
@@ -1594,9 +1595,9 @@ If you choose option 1, then *jpegSize should be set to the size of
handle
handle to a TurboJPEG instance that has been initialized for compression
srcPlanes
an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if compressing a grayscale image) that contain a YUV source image to be compressed. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by tj3YUVPlaneSize() for the given image width, height, strides, and level of chrominance subsampling (see TJPARAM_SUBSAMP.) Refer to YUV Image Format Notes for more details.
-
width
width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed.
+
width
width (in pixels) of the source image. If the width is not an even multiple of the iMCU width (see tjMCUWidth), then an intermediate buffer copy will be performed.
strides
an array of integers, each specifying the number of bytes per row in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to specify an arbitrary amount of row padding in each plane or to create a JPEG image from a subregion of a larger planar YUV image.
-
height
height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed.
+
height
height (in pixels) of the source image. If the height is not an even multiple of the iMCU height (see tjMCUHeight), then an intermediate buffer copy will be performed.
jpegBuf
address of a pointer to a byte buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
pre-allocate the JPEG buffer with an arbitrary size using tj3Alloc() and let TurboJPEG grow the buffer as needed,
set *jpegBuf to NULL to tell TurboJPEG to allocate the buffer for you, or
@@ -3059,7 +3060,7 @@ If you choose option 1, then *jpegSize should be set to the size of
Parameters
handle
handle to a TurboJPEG instance that has been initialized for decompression
-
croppingRegion
tjregion structure that specifies a subregion of the JPEG image to decompress, or TJUNCROPPED for no cropping. The left boundary of the cropping region must be evenly divisible by the scaled MCU block width– TJSCALED(tjMCUWidth[subsamp], scalingFactor), where subsamp is the level of chrominance subsampling in the JPEG image (see TJPARAM_SUBSAMP) and scalingFactor is the decompression scaling factor (see tj3SetScalingFactor().) The cropping region should be specified relative to the scaled image dimensions. Unless croppingRegion is TJUNCROPPED, the JPEG header must be read (see tj3DecompressHeader()) prior to calling this function.
+
croppingRegion
tjregion structure that specifies a subregion of the JPEG image to decompress, or TJUNCROPPED for no cropping. The left boundary of the cropping region must be evenly divisible by the scaled iMCU width– TJSCALED(tjMCUWidth[subsamp], scalingFactor), where subsamp is the level of chrominance subsampling in the JPEG image (see TJPARAM_SUBSAMP) and scalingFactor is the decompression scaling factor (see tj3SetScalingFactor().) The cropping region should be specified relative to the scaled image dimensions. Unless croppingRegion is TJUNCROPPED, the JPEG header must be read (see tj3DecompressHeader()) prior to calling this function.
@@ -3097,7 +3098,7 @@ If you choose option 1, then *jpegSize should be set to the size of
Parameters
handle
handle to a TurboJPEG instance that has been initialized for decompression
-
scalingFactor
tjscalingfactor structure that specifies a fractional scaling factor that the decompressor supports (see tj3GetScalingFactors()), or TJUNSCALED for no scaling. Decompression scaling is a function of the IDCT algorithm, so scaling factors are generally limited to multiples of 1/8. If the entire JPEG image will be decompressed, then the width and height of the scaled destination image can be determined by calling TJSCALED() with the JPEG width and height (see TJPARAM_JPEGWIDTH and TJPARAM_JPEGHEIGHT) and the specified scaling factor. When decompressing into a planar YUV image, an intermediate buffer copy will be performed if the width or height of the scaled destination image is not an even multiple of the MCU block size (see tjMCUWidth and tjMCUHeight.) Note that decompression scaling is not available (and the specified scaling factor is ignored) when decompressing lossless JPEG images (see TJPARAM_LOSSLESS), since the IDCT algorithm is not used with those images. Note also that TJPARAM_FASTDCT is ignored when decompression scaling is enabled.
+
scalingFactor
tjscalingfactor structure that specifies a fractional scaling factor that the decompressor supports (see tj3GetScalingFactors()), or TJUNSCALED for no scaling. Decompression scaling is a function of the IDCT algorithm, so scaling factors are generally limited to multiples of 1/8. If the entire JPEG image will be decompressed, then the width and height of the scaled destination image can be determined by calling TJSCALED() with the JPEG width and height (see TJPARAM_JPEGWIDTH and TJPARAM_JPEGHEIGHT) and the specified scaling factor. When decompressing into a planar YUV image, an intermediate buffer copy will be performed if the width or height of the scaled destination image is not an even multiple of the iMCU size (see tjMCUWidth and tjMCUHeight.) Note that decompression scaling is not available (and the specified scaling factor is ignored) when decompressing lossless JPEG images (see TJPARAM_LOSSLESS), since the IDCT algorithm is not used with those images. Note also that TJPARAM_FASTDCT is ignored when decompression scaling is enabled.
@@ -3483,8 +3484,9 @@ If you choose option 1, then dstSizes[i] should be set to the size
-
MCU block height (in pixels) for a given level of chrominance subsampling.
-
MCU block sizes:
+
iMCU height (in pixels) for a given level of chrominance subsampling
+
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The combination of the full-resolution luminance block(s) and the (possibly subsampled) chrominance blocks corresponding to the same pixels is called a "Minimum Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
+
iMCU sizes:
8x8 for no subsampling or grayscale
16x8 for 4:2:2
8x16 for 4:4:0
@@ -3515,8 +3517,9 @@ If you choose option 1, then dstSizes[i] should be set to the size
-
MCU block width (in pixels) for a given level of chrominance subsampling.
-
MCU block sizes:
+
iMCU width (in pixels) for a given level of chrominance subsampling
+
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The combination of the full-resolution luminance block(s) and the (possibly subsampled) chrominance blocks corresponding to the same pixels is called a "Minimum Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
+
iMCU sizes:
8x8 for no subsampling or grayscale
16x8 for 4:2:2
8x16 for 4:4:0
diff --git a/doc/html/structtjregion.html b/doc/html/structtjregion.html
index 8d03e5ec..8a277cda 100644
--- a/doc/html/structtjregion.html
+++ b/doc/html/structtjregion.html
@@ -146,7 +146,7 @@ Data Fields
The left boundary of the cropping region.
-
This must be evenly divisible by the MCU block width (see tjMCUWidth.)
+
This must be evenly divisible by the iMCU width (see tjMCUWidth.)
@@ -163,7 +163,7 @@ Data Fields
The upper boundary of the cropping region.
-
For lossless transformation, this must be evenly divisible by the MCU block height (see tjMCUHeight.)
+
For lossless transformation, this must be evenly divisible by the iMCU height (see tjMCUHeight.)
diff --git a/java/TJBench.java b/java/TJBench.java
index e4bedce3..7fc3377c 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -797,10 +797,9 @@ final class TJBench {
System.out.println(" default = 8; if N is 16, then -lossless must also be specified]");
System.out.println(" (-precision 12 implies -optimize unless -arithmetic is also specified)");
System.out.println("-quiet = Output results in tabular rather than verbose format");
- System.out.println("-restart N = When compressing, add a restart marker every N MCU rows (lossy) or");
- System.out.println(" N sample rows (lossless) [default = 0 (no restart markers)]. Append 'B'");
- System.out.println(" to specify the restart marker interval in MCU blocks (lossy) or samples");
- System.out.println(" (lossless).");
+ System.out.println("-restart N = When compressing, add a restart marker every N MCU rows");
+ System.out.println(" [default = 0 (no restart markers)]. Append 'B' to specify the restart");
+ System.out.println(" marker interval in MCUs (lossy only.)");
System.out.println("-stoponwarning = Immediately discontinue the current");
System.out.println(" compression/decompression/transform operation if a warning (non-fatal");
System.out.println(" error) occurs");
@@ -818,7 +817,7 @@ final class TJBench {
System.out.println(" and H are the width and height of the region (0 = maximum possible width");
System.out.println(" or height) and X and Y are the left and upper boundary of the region, all");
System.out.println(" specified relative to the scaled image dimensions. X must be divible by");
- System.out.println(" the scaled MCU width.");
+ System.out.println(" the scaled iMCU width.");
System.out.println("-fastdct = Use the fastest DCT/IDCT algorithm available");
System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available");
System.out.println("-optimize = Compute optimal Huffman tables for JPEG images generated by");
diff --git a/java/TJExample.java b/java/TJExample.java
index 6a2148ce..96a6828f 100644
--- a/java/TJExample.java
+++ b/java/TJExample.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011-2012, 2014-2015, 2017-2018, 2022-2023 D. R. Commander.
+ * Copyright (C)2011-2012, 2014-2015, 2017-2018, 2022-2024 D. R. Commander.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -125,8 +125,8 @@ class TJExample implements TJCustomFilter {
System.out.println("-crop WxH+X+Y = Perform lossless cropping on the input image prior to");
System.out.println(" decompressing it. X and Y specify the upper left corner of the cropping");
System.out.println(" region, and W and H specify the width and height of the cropping region.");
- System.out.println(" X and Y must be evenly divible by the MCU block size (8x8 if the input");
- System.out.println(" image was compressed using no subsampling or grayscale, 16x8 if it was");
+ System.out.println(" X and Y must be evenly divible by the iMCU size (8x8 if the input image");
+ System.out.println(" was compressed using no subsampling or grayscale, 16x8 if it was");
System.out.println(" compressed using 4:2:2 subsampling, or 16x16 if it was compressed using");
System.out.println(" 4:2:0 subsampling.)\n");
diff --git a/java/doc/index-all.html b/java/doc/index-all.html
index 951abdcc..c6ee8b4d 100644
--- a/java/doc/index-all.html
+++ b/java/doc/index-all.html
@@ -496,13 +496,11 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
Returns the MCU block width for the given level of chrominance
- subsampling.
+
Returns the iMCU width for the given level of chrominance subsampling.
@@ -1590,8 +1587,8 @@ extends java.lang.Object
and refined with subsequent higher-quality scans containing
higher-frequency DCT coefficients. When using Huffman entropy coding, the
progressive JPEG format also provides an "end-of-bands (EOB) run" feature
- that allows large groups of zeroes, potentially spanning multiple MCU
- blocks, to be represented using only a few bytes.
+ that allows large groups of zeroes, potentially spanning multiple MCUs, to
+ be represented using only a few bytes.
JPEG restart marker interval in MCUs [lossy compression only]
The nature of entropy coding is such that a corrupt JPEG image cannot
be decompressed beyond the point of corruption unless it contains restart
@@ -1813,9 +1810,18 @@ extends java.lang.Object
tolerance of the JPEG image, but adding too many restart markers can
adversely affect the compression ratio and performance.
+
In typical JPEG images, an MCU (Minimum Coded Unit) is the minimum set
+ of interleaved "data units" (8x8 DCT blocks if the image is lossy or
+ samples if the image is lossless) necessary to represent at least one data
+ unit per component. (For example, an MCU in an interleaved lossy JPEG
+ image that uses 4:2:2 subsampling consists of two luminance blocks
+ followed by one block for each chrominance component.) In
+ single-component or non-interleaved JPEG images, an MCU is the same as a
+ data unit.
+
Value
-
the number of MCU blocks between each restart marker [default:
+
the number of MCUs between each restart marker [default:
0 (no restart markers)]
@@ -1834,15 +1840,16 @@ extends java.lang.Object
PARAM_RESTARTROWS
public static final int PARAM_RESTARTROWS
-
JPEG restart marker interval in MCU rows (lossy) or sample rows (lossless)
- [compression only]
+
JPEG restart marker interval in MCU rows [compression only]
-
See PARAM_RESTARTBLOCKS for a description of restart markers
+ and MCUs. An MCU row is a row of MCUs spanning the entire width of the
+ image.
Value
-
the number of MCU rows or sample rows between each restart marker
- [default: 0 (no restart markers)]
+
the number of MCU rows between each restart marker [default:
+ 0 (no restart markers)]
Setting this parameter to a non-zero value sets
@@ -2186,15 +2193,25 @@ public static final int FLAG_LIMITSCANS
getMCUWidth
public static int getMCUWidth(int subsamp)
-
Returns the MCU block width for the given level of chrominance
- subsampling.
+
Returns the iMCU width for the given level of chrominance subsampling.
+
+
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ component are interleaved in a single scan. If the image uses chrominance
+ subsampling, then multiple luminance blocks are stored together, followed
+ by a single block for each chrominance component. The combination of the
+ full-resolution luminance block(s) and the (possibly subsampled)
+ chrominance blocks corresponding to the same pixels is called a "Minimum
+ Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
+ is stored in a separate scan, and an MCU is a single DCT block, so we use
+ the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
+ an interleaved JPEG image. For the common case of interleaved JPEG
+ images, an iMCU is the same as an MCU.
Parameters:
subsamp - the level of chrominance subsampling (one of
SAMP_*)
Returns:
-
the MCU block width for the given level of chrominance
- subsampling.
+
the iMCU width for the given level of chrominance subsampling.
@@ -2205,15 +2222,25 @@ public static final int FLAG_LIMITSCANS
getMCUHeight
public static int getMCUHeight(int subsamp)
-
Returns the MCU block height for the given level of chrominance
- subsampling.
+
Returns the iMCU height for the given level of chrominance subsampling.
+
+
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ component are interleaved in a single scan. If the image uses chrominance
+ subsampling, then multiple luminance blocks are stored together, followed
+ by a single block for each chrominance component. The combination of the
+ full-resolution luminance block(s) and the (possibly subsampled)
+ chrominance blocks corresponding to the same pixels is called a "Minimum
+ Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
+ is stored in a separate scan, and an MCU is a single DCT block, so we use
+ the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
+ an interleaved JPEG image. For the common case of interleaved JPEG
+ images, an iMCU is the same as an MCU.
Parameters:
subsamp - the level of chrominance subsampling (one of
SAMP_*)
Returns:
-
the MCU block height for the given level of chrominance
- subsampling.
+
the iMCU height for the given level of chrominance subsampling.
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
index e17a36aa..96edfecc 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
@@ -838,8 +838,8 @@ implements java.io.Closeable
with the JPEG image width and height (see getWidth() and
getHeight().) When decompressing into a planar YUV image, an
intermediate buffer copy will be performed if the width or height of the
- scaled destination image is not an even multiple of the MCU block size
- (see TJ.getMCUWidth() and TJ.getMCUHeight().) Note that decompression scaling is not available
+ scaled destination image is not an even multiple of the iMCU size (see
+ TJ.getMCUWidth() and TJ.getMCUHeight().) Note that decompression scaling is not available
(and the specified scaling factor is ignored) when decompressing lossless
JPEG images (see TJ.PARAM_LOSSLESS), since the IDCT algorithm is
not used with those images. Note also that TJ.PARAM_FASTDCT is
@@ -862,10 +862,10 @@ implements java.io.Closeable
croppingRegion - java.awt.Rectangle instance that
specifies a subregion of the JPEG image to decompress, or
TJ.UNCROPPED for no cropping. The left boundary of the cropping
- region must be evenly divisible by the scaled MCU block width, which can
- be determined by calling TJScalingFactor.getScaled() with the specified scaling factor (see
- setScalingFactor()) and the MCU block width
- (see TJ.getMCUWidth()) for the level of chrominance
+ region must be evenly divisible by the scaled iMCU width, which can be
+ determined by calling TJScalingFactor.getScaled() with the specified scaling factor (see
+ setScalingFactor()) and the iMCU width (see
+ TJ.getMCUWidth()) for the level of chrominance
subsampling in the JPEG image (see TJ.PARAM_SUBSAMP.) The
cropping region should be specified relative to the scaled image
dimensions. Unless croppingRegion is TJ.UNCROPPED,
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
index a8d5b329..d871218d 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
@@ -329,7 +329,7 @@ extends java.awt.Rectangle
Transverse transpose image (flip/mirror along upper right to lower left
- axis). This transform is imperfect if there are any partial MCU blocks in
- the image.
+ axis). This transform is imperfect if there are any partial iMCUs in the
+ image.
This option causes TJTransformer.transform() to throw an exception if the transform is not
- perfect. Lossless transforms operate on MCU blocks, the size of which
- depends on the level of chrominance subsampling used. If the image's
- width or height is not evenly divisible by the MCU block size (see
- TJ.getMCUWidth() and TJ.getMCUHeight()), then there will be partial MCU blocks on the right
- and/or bottom edges. It is not possible to move these partial MCU blocks
- to the top or left of the image, so any transform that would require that
- is "imperfect." If this option is not specified, then any partial MCU
- blocks that cannot be transformed will be left in place, which will create
- odd-looking strips on the right or bottom edge of the image.
+ perfect. Lossless transforms operate on iMCUs, the size of which depends
+ on the level of chrominance subsampling used. If the image's width or
+ height is not evenly divisible by the iMCU size (see TJ.getMCUWidth() and TJ.getMCUHeight()), then
+ there will be partial iMCUs on the right and/or bottom edges. It is not
+ possible to move these partial iMCUs to the top or left of the image, so
+ any transform that would require that is "imperfect." If this option is
+ not specified, then any partial iMCUs that cannot be transformed will be
+ left in place, which will create odd-looking strips on the right or bottom
+ edge of the image.
w - the width of the cropping region. Setting this to 0 is the
equivalent of setting it to (width of the source JPEG image -
x).
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index c4a65c144d46347c46241b3a874a46e607aeccd2..9a7c121c1a01620d9ef03fc848877295e5d2a889 100644
GIT binary patch
delta 28
hcmaFM_?D43z?+#xgn@&DgW+d^+(h1fW)L;s4*+gU2y_4d
delta 28
hcmaFM_?D43z?+#xgn@&DgQ0nf%tYRPW)L;s4*+M+2h0Ef
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index 0493b849467c4329a2ecedb37a2295c766ba4399..e20168bcc8d9acb32029cd6db02844d5a2446fd3 100644
GIT binary patch
delta 28
hcmdnaw4I4Jz?+#xgn@&DgW+d^+(h0x%pmHGHvncD2%!J~
delta 28
hcmdnaw4I4Jz?+#xgn@&DgQ0nf%tYQh%pmHGHvnIr2l)U1
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index a42dfdb8..a58e379e 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -120,14 +120,24 @@ public final class TJ {
public static final int SAMP_UNKNOWN = -1;
/**
- * Returns the MCU block width for the given level of chrominance
- * subsampling.
+ * Returns the iMCU width for the given level of chrominance subsampling.
+ *
+ *
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ * component are interleaved in a single scan. If the image uses chrominance
+ * subsampling, then multiple luminance blocks are stored together, followed
+ * by a single block for each chrominance component. The combination of the
+ * full-resolution luminance block(s) and the (possibly subsampled)
+ * chrominance blocks corresponding to the same pixels is called a "Minimum
+ * Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
+ * is stored in a separate scan, and an MCU is a single DCT block, so we use
+ * the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
+ * an interleaved JPEG image. For the common case of interleaved JPEG
+ * images, an iMCU is the same as an MCU.
*
* @param subsamp the level of chrominance subsampling (one of
* {@link #SAMP_444 SAMP_*})
*
- * @return the MCU block width for the given level of chrominance
- * subsampling.
+ * @return the iMCU width for the given level of chrominance subsampling.
*/
public static int getMCUWidth(int subsamp) {
checkSubsampling(subsamp);
@@ -140,14 +150,24 @@ public final class TJ {
/**
- * Returns the MCU block height for the given level of chrominance
- * subsampling.
+ * Returns the iMCU height for the given level of chrominance subsampling.
+ *
+ *
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ * component are interleaved in a single scan. If the image uses chrominance
+ * subsampling, then multiple luminance blocks are stored together, followed
+ * by a single block for each chrominance component. The combination of the
+ * full-resolution luminance block(s) and the (possibly subsampled)
+ * chrominance blocks corresponding to the same pixels is called a "Minimum
+ * Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
+ * is stored in a separate scan, and an MCU is a single DCT block, so we use
+ * the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
+ * an interleaved JPEG image. For the common case of interleaved JPEG
+ * images, an iMCU is the same as an MCU.
*
* @param subsamp the level of chrominance subsampling (one of
* {@link #SAMP_444 SAMP_*})
*
- * @return the MCU block height for the given level of chrominance
- * subsampling.
+ * @return the iMCU height for the given level of chrominance subsampling.
*/
public static int getMCUHeight(int subsamp) {
checkSubsampling(subsamp);
@@ -608,8 +628,8 @@ public final class TJ {
* and refined with subsequent higher-quality scans containing
* higher-frequency DCT coefficients. When using Huffman entropy coding, the
* progressive JPEG format also provides an "end-of-bands (EOB) run" feature
- * that allows large groups of zeroes, potentially spanning multiple MCU
- * blocks, to be represented using only a few bytes.
+ * that allows large groups of zeroes, potentially spanning multiple MCUs, to
+ * be represented using only a few bytes.
*
*
Value
*
@@ -765,7 +785,7 @@ public final class TJ {
*/
public static final int PARAM_LOSSLESSPT = 17;
/**
- * JPEG restart marker interval in MCU blocks [lossy compression only]
+ * JPEG restart marker interval in MCUs [lossy compression only]
*
*
The nature of entropy coding is such that a corrupt JPEG image cannot
* be decompressed beyond the point of corruption unless it contains restart
@@ -775,9 +795,18 @@ public final class TJ {
* tolerance of the JPEG image, but adding too many restart markers can
* adversely affect the compression ratio and performance.
*
+ *
In typical JPEG images, an MCU (Minimum Coded Unit) is the minimum set
+ * of interleaved "data units" (8x8 DCT blocks if the image is lossy or
+ * samples if the image is lossless) necessary to represent at least one data
+ * unit per component. (For example, an MCU in an interleaved lossy JPEG
+ * image that uses 4:2:2 subsampling consists of two luminance blocks
+ * followed by one block for each chrominance component.) In
+ * single-component or non-interleaved JPEG images, an MCU is the same as a
+ * data unit.
+ *
*
Value
*
- *
the number of MCU blocks between each restart marker [default:
+ *
the number of MCUs between each restart marker [default:
* 0 (no restart markers)]
*
*
@@ -786,15 +815,16 @@ public final class TJ {
*/
public static final int PARAM_RESTARTBLOCKS = 18;
/**
- * JPEG restart marker interval in MCU rows (lossy) or sample rows (lossless)
- * [compression only]
+ * JPEG restart marker interval in MCU rows [compression only]
*
- *
See {@link #PARAM_RESTARTBLOCKS} for a description of restart markers.
+ *
See {@link #PARAM_RESTARTBLOCKS} for a description of restart markers
+ * and MCUs. An MCU row is a row of MCUs spanning the entire width of the
+ * image.
*
*
Value
*
- *
the number of MCU rows or sample rows between each restart marker
- * [default: 0 (no restart markers)]
+ *
the number of MCU rows between each restart marker [default:
+ * 0 (no restart markers)]
*
*
*
Setting this parameter to a non-zero value sets
diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
index f896d91a..23da0321 100644
--- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
@@ -222,8 +222,8 @@ public class TJDecompressor implements Closeable {
* with the JPEG image width and height (see {@link #getWidth} and
* {@link #getHeight}.) When decompressing into a planar YUV image, an
* intermediate buffer copy will be performed if the width or height of the
- * scaled destination image is not an even multiple of the MCU block size
- * (see {@link TJ#getMCUWidth TJ.getMCUWidth()} and {@link TJ#getMCUHeight
+ * scaled destination image is not an even multiple of the iMCU size (see
+ * {@link TJ#getMCUWidth TJ.getMCUWidth()} and {@link TJ#getMCUHeight
* TJ.getMCUHeight()}.) Note that decompression scaling is not available
* (and the specified scaling factor is ignored) when decompressing lossless
* JPEG images (see {@link TJ#PARAM_LOSSLESS}), since the IDCT algorithm is
@@ -255,11 +255,11 @@ public class TJDecompressor implements Closeable {
* @param croppingRegion java.awt.Rectangle instance that
* specifies a subregion of the JPEG image to decompress, or
* {@link TJ#UNCROPPED} for no cropping. The left boundary of the cropping
- * region must be evenly divisible by the scaled MCU block width, which can
- * be determined by calling {@link TJScalingFactor#getScaled
+ * region must be evenly divisible by the scaled iMCU width, which can be
+ * determined by calling {@link TJScalingFactor#getScaled
* TJScalingFactor.getScaled()} with the specified scaling factor (see
- * {@link #setScalingFactor setScalingFactor()}) and the MCU block width
- * (see {@link TJ#getMCUWidth TJ.getMCUWidth()}) for the level of chrominance
+ * {@link #setScalingFactor setScalingFactor()}) and the iMCU width (see
+ * {@link TJ#getMCUWidth TJ.getMCUWidth()}) for the level of chrominance
* subsampling in the JPEG image (see {@link TJ#PARAM_SUBSAMP}.) The
* cropping region should be specified relative to the scaled image
* dimensions. Unless croppingRegion is {@link TJ#UNCROPPED},
diff --git a/java/org/libjpegturbo/turbojpeg/TJTransform.java b/java/org/libjpegturbo/turbojpeg/TJTransform.java
index 69981900..021263f2 100644
--- a/java/org/libjpegturbo/turbojpeg/TJTransform.java
+++ b/java/org/libjpegturbo/turbojpeg/TJTransform.java
@@ -48,13 +48,13 @@ public class TJTransform extends Rectangle {
public static final int OP_NONE = 0;
/**
* Flip (mirror) image horizontally. This transform is imperfect if there
- * are any partial MCU blocks on the right edge.
+ * are any partial iMCUs on the right edge.
* @see #OPT_PERFECT
*/
public static final int OP_HFLIP = 1;
/**
* Flip (mirror) image vertically. This transform is imperfect if there are
- * any partial MCU blocks on the bottom edge.
+ * any partial iMCUs on the bottom edge.
* @see #OPT_PERFECT
*/
public static final int OP_VFLIP = 2;
@@ -66,26 +66,26 @@ public class TJTransform extends Rectangle {
public static final int OP_TRANSPOSE = 3;
/**
* Transverse transpose image (flip/mirror along upper right to lower left
- * axis). This transform is imperfect if there are any partial MCU blocks in
- * the image.
+ * axis). This transform is imperfect if there are any partial iMCUs in the
+ * image.
* @see #OPT_PERFECT
*/
public static final int OP_TRANSVERSE = 4;
/**
* Rotate image clockwise by 90 degrees. This transform is imperfect if
- * there are any partial MCU blocks on the bottom edge.
+ * there are any partial iMCUs on the bottom edge.
* @see #OPT_PERFECT
*/
public static final int OP_ROT90 = 5;
/**
* Rotate image 180 degrees. This transform is imperfect if there are any
- * partial MCU blocks in the image.
+ * partial iMCUs in the image.
* @see #OPT_PERFECT
*/
public static final int OP_ROT180 = 6;
/**
* Rotate image counter-clockwise by 90 degrees. This transform is imperfect
- * if there are any partial MCU blocks on the right edge.
+ * if there are any partial iMCUs on the right edge.
* @see #OPT_PERFECT
*/
public static final int OP_ROT270 = 7;
@@ -94,20 +94,20 @@ public class TJTransform extends Rectangle {
/**
* This option causes {@link TJTransformer#transform
* TJTransformer.transform()} to throw an exception if the transform is not
- * perfect. Lossless transforms operate on MCU blocks, the size of which
- * depends on the level of chrominance subsampling used. If the image's
- * width or height is not evenly divisible by the MCU block size (see
- * {@link TJ#getMCUWidth TJ.getMCUWidth()} and {@link TJ#getMCUHeight
- * TJ.getMCUHeight()}), then there will be partial MCU blocks on the right
- * and/or bottom edges. It is not possible to move these partial MCU blocks
- * to the top or left of the image, so any transform that would require that
- * is "imperfect." If this option is not specified, then any partial MCU
- * blocks that cannot be transformed will be left in place, which will create
- * odd-looking strips on the right or bottom edge of the image.
+ * perfect. Lossless transforms operate on iMCUs, the size of which depends
+ * on the level of chrominance subsampling used. If the image's width or
+ * height is not evenly divisible by the iMCU size (see {@link TJ#getMCUWidth
+ * TJ.getMCUWidth()} and {@link TJ#getMCUHeight TJ.getMCUHeight()}), then
+ * there will be partial iMCUs on the right and/or bottom edges. It is not
+ * possible to move these partial iMCUs to the top or left of the image, so
+ * any transform that would require that is "imperfect." If this option is
+ * not specified, then any partial iMCUs that cannot be transformed will be
+ * left in place, which will create odd-looking strips on the right or bottom
+ * edge of the image.
*/
public static final int OPT_PERFECT = (1 << 0);
/**
- * Discard any partial MCU blocks that cannot be transformed.
+ * Discard any partial iMCUs that cannot be transformed.
*/
public static final int OPT_TRIM = (1 << 1);
/**
@@ -164,11 +164,10 @@ public class TJTransform extends Rectangle {
* Create a new lossless transform instance with the given parameters.
*
* @param x the left boundary of the cropping region. This must be evenly
- * divisible by the MCU block width (see {@link TJ#getMCUWidth
- * TJ.getMCUWidth()})
+ * divisible by the iMCU width (see {@link TJ#getMCUWidth TJ.getMCUWidth()})
*
* @param y the upper boundary of the cropping region. This must be evenly
- * divisible by the MCU block height (see {@link TJ#getMCUHeight
+ * divisible by the iMCU height (see {@link TJ#getMCUHeight
* TJ.getMCUHeight()})
*
* @param w the width of the cropping region. Setting this to 0 is the
diff --git a/jpegtran.1 b/jpegtran.1
index e52259b7..a4ba3839 100644
--- a/jpegtran.1
+++ b/jpegtran.1
@@ -1,4 +1,4 @@
-.TH JPEGTRAN 1 "17 June 2024"
+.TH JPEGTRAN 1 "30 August 2024"
.SH NAME
jpegtran \- lossless transformation of JPEG files
.SH SYNOPSIS
@@ -68,8 +68,8 @@ Create progressive JPEG file.
Use arithmetic coding.
.TP
.BI \-restart " N"
-Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
-attached to the number.
+Emit a JPEG restart marker every N MCU rows, or every N MCUs if "B" is attached
+to the number.
.TP
.BI \-scans " file"
Use the scan script given in the specified text file.
diff --git a/libjpeg.txt b/libjpeg.txt
index 01a486b7..cca5739d 100644
--- a/libjpeg.txt
+++ b/libjpeg.txt
@@ -1150,15 +1150,14 @@ boolean optimize_coding
unsigned int restart_interval
int restart_in_rows
To emit restart markers in the JPEG file, set one of these nonzero.
- Set restart_interval to specify the exact interval in MCU blocks
- (samples in lossless mode). Set restart_in_rows to specify the
- interval in MCU rows. (If restart_in_rows is not 0, then
- restart_interval is set after the image width in MCUs is computed.)
- Defaults are zero (no restarts). One restart marker per MCU row is
- often a good choice. NOTE: the overhead of restart markers is higher
- in grayscale JPEG files than in color files, and MUCH higher in
- progressive JPEGs. If you use restarts, you may want to use larger
- intervals in those cases.
+ Set restart_interval to specify the exact interval in MCUs. Set
+ restart_in_rows to specify the interval in MCU rows. (If
+ restart_in_rows is not 0, then restart_interval is set after the image
+ width in MCUs is computed.) Defaults are zero (no restarts). One
+ restart marker per MCU row is often a good choice. NOTE: the overhead
+ of restart markers is higher in grayscale JPEG files than in color
+ files, and MUCH higher in progressive JPEGs. If you use restarts, you
+ may want to use larger intervals in those cases.
const jpeg_scan_info *scan_info
int num_scans
diff --git a/tjbench.c b/tjbench.c
index 5925f90e..7cc15047 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -934,10 +934,9 @@ static void usage(char *progName)
printf(" default = 8; if N is 16, then -lossless must also be specified]\n");
printf(" (-precision 12 implies -optimize unless -arithmetic is also specified)\n");
printf("-quiet = Output results in tabular rather than verbose format\n");
- printf("-restart N = When compressing, add a restart marker every N MCU rows (lossy) or\n");
- printf(" N sample rows (lossless) [default = 0 (no restart markers)]. Append 'B'\n");
- printf(" to specify the restart marker interval in MCU blocks (lossy) or samples\n");
- printf(" (lossless).\n");
+ printf("-restart N = When compressing, add a restart marker every N MCU rows\n");
+ printf(" [default = 0 (no restart markers)]. Append 'B' to specify the restart\n");
+ printf(" marker interval in MCUs (lossy only.)\n");
printf("-stoponwarning = Immediately discontinue the current\n");
printf(" compression/decompression/transform operation if a warning (non-fatal\n");
printf(" error) occurs\n");
@@ -955,7 +954,7 @@ static void usage(char *progName)
printf(" and H are the width and height of the region (0 = maximum possible width\n");
printf(" or height) and X and Y are the left and upper boundary of the region, all\n");
printf(" specified relative to the scaled image dimensions. X must be divible by\n");
- printf(" the scaled MCU width.\n");
+ printf(" the scaled iMCU width.\n");
printf("-fastdct = Use the fastest DCT/IDCT algorithm available\n");
printf("-fastupsample = Use the fastest chrominance upsampling algorithm available\n");
printf("-optimize = Compute optimal Huffman tables for JPEG images generated by\n");
diff --git a/tjexample.c b/tjexample.c
index aa3a4b92..ca61f553 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -145,8 +145,8 @@ static void usage(char *programName)
printf("-crop WxH+X+Y = Perform lossless cropping on the input image prior to\n");
printf(" decompressing it. X and Y specify the upper left corner of the cropping\n");
printf(" region, and W and H specify the width and height of the cropping region.\n");
- printf(" X and Y must be evenly divible by the MCU block size (8x8 if the input\n");
- printf(" image was compressed using no subsampling or grayscale, 16x8 if it was\n");
+ printf(" X and Y must be evenly divible by the iMCU size (8x8 if the input image\n");
+ printf(" was compressed using no subsampling or grayscale, 16x8 if it was\n");
printf(" compressed using 4:2:2 subsampling, or 16x16 if it was compressed using\n");
printf(" 4:2:0 subsampling.)\n\n");
diff --git a/turbojpeg.c b/turbojpeg.c
index 6c484d5b..62c99f27 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1940,7 +1940,7 @@ DLLEXPORT int tj3SetCroppingRegion(tjhandle handle, tjregion croppingRegion)
if (croppingRegion.x %
TJSCALED(tjMCUWidth[this->subsamp], this->scalingFactor) != 0)
THROWI("The left boundary of the cropping region (%d) is not\n"
- "divisible by the scaled MCU width (%d)",
+ "divisible by the scaled iMCU width (%d)",
croppingRegion.x,
TJSCALED(tjMCUWidth[this->subsamp], this->scalingFactor));
if (croppingRegion.w == 0)
diff --git a/turbojpeg.h b/turbojpeg.h
index 4f091be2..6a2271c0 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -195,9 +195,21 @@ enum TJSAMP {
};
/**
- * MCU block width (in pixels) for a given level of chrominance subsampling
+ * iMCU width (in pixels) for a given level of chrominance subsampling
*
- * MCU block sizes:
+ * In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ * component are interleaved in a single scan. If the image uses chrominance
+ * subsampling, then multiple luminance blocks are stored together, followed by
+ * a single block for each chrominance component. The combination of the
+ * full-resolution luminance block(s) and the (possibly subsampled) chrominance
+ * blocks corresponding to the same pixels is called a "Minimum Coded Unit"
+ * (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a
+ * separate scan, and an MCU is a single DCT block, so we use the term "iMCU"
+ * (interleaved MCU) to refer to the equivalent of an MCU in an interleaved
+ * JPEG image. For the common case of interleaved JPEG images, an iMCU is the
+ * same as an MCU.
+ *
+ * iMCU sizes:
* - 8x8 for no subsampling or grayscale
* - 16x8 for 4:2:2
* - 8x16 for 4:4:0
@@ -208,9 +220,21 @@ enum TJSAMP {
static const int tjMCUWidth[TJ_NUMSAMP] = { 8, 16, 16, 8, 8, 32, 8 };
/**
- * MCU block height (in pixels) for a given level of chrominance subsampling
+ * iMCU height (in pixels) for a given level of chrominance subsampling
*
- * MCU block sizes:
+ * In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ * component are interleaved in a single scan. If the image uses chrominance
+ * subsampling, then multiple luminance blocks are stored together, followed by
+ * a single block for each chrominance component. The combination of the
+ * full-resolution luminance block(s) and the (possibly subsampled) chrominance
+ * blocks corresponding to the same pixels is called a "Minimum Coded Unit"
+ * (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a
+ * separate scan, and an MCU is a single DCT block, so we use the term "iMCU"
+ * (interleaved MCU) to refer to the equivalent of an MCU in an interleaved
+ * JPEG image. For the common case of interleaved JPEG images, an iMCU is the
+ * same as an MCU.
+ *
+ * iMCU sizes:
* - 8x8 for no subsampling or grayscale
* - 16x8 for 4:2:2
* - 8x16 for 4:4:0
@@ -620,8 +644,8 @@ enum TJPARAM {
* and refined with subsequent higher-quality scans containing
* higher-frequency DCT coefficients. When using Huffman entropy coding, the
* progressive JPEG format also provides an "end-of-bands (EOB) run" feature
- * that allows large groups of zeroes, potentially spanning multiple MCU
- * blocks, to be represented using only a few bytes.
+ * that allows large groups of zeroes, potentially spanning multiple MCUs,
+ * to be represented using only a few bytes.
*
* **Value**
* - `0` *[default for compression, lossless transformation]* The lossy JPEG
@@ -752,7 +776,7 @@ enum TJPARAM {
*/
TJPARAM_LOSSLESSPT,
/**
- * JPEG restart marker interval in MCU blocks [lossy compression only]
+ * JPEG restart marker interval in MCUs [lossy compression only]
*
* The nature of entropy coding is such that a corrupt JPEG image cannot
* be decompressed beyond the point of corruption unless it contains restart
@@ -762,22 +786,30 @@ enum TJPARAM {
* tolerance of the JPEG image, but adding too many restart markers can
* adversely affect the compression ratio and performance.
*
+ * In typical JPEG images, an MCU (Minimum Coded Unit) is the minimum set of
+ * interleaved "data units" (8x8 DCT blocks if the image is lossy or samples
+ * if the image is lossless) necessary to represent at least one data unit
+ * per component. (For example, an MCU in an interleaved lossy JPEG image
+ * that uses 4:2:2 subsampling consists of two luminance blocks followed by
+ * one block for each chrominance component.) In single-component or
+ * non-interleaved JPEG images, an MCU is the same as a data unit.
+ *
* **Value**
- * - the number of MCU blocks between each restart marker *[default: `0` (no
+ * - the number of MCUs between each restart marker *[default: `0` (no
* restart markers)]*
*
* Setting this parameter to a non-zero value sets #TJPARAM_RESTARTROWS to 0.
*/
TJPARAM_RESTARTBLOCKS,
/**
- * JPEG restart marker interval in MCU rows (lossy) or sample rows (lossless)
- * [compression only]
+ * JPEG restart marker interval in MCU rows [compression only]
*
- * See #TJPARAM_RESTARTBLOCKS for a description of restart markers.
+ * See #TJPARAM_RESTARTBLOCKS for a description of restart markers and MCUs.
+ * An MCU row is a row of MCUs spanning the entire width of the image.
*
* **Value**
- * - the number of MCU rows or sample rows between each restart marker
- * *[default: `0` (no restart markers)]*
+ * - the number of MCU rows between each restart marker *[default: `0` (no
+ * restart markers)]*
*
* Setting this parameter to a non-zero value sets #TJPARAM_RESTARTBLOCKS to
* 0.
@@ -901,12 +933,12 @@ enum TJXOP {
TJXOP_NONE,
/**
* Flip (mirror) image horizontally. This transform is imperfect if there
- * are any partial MCU blocks on the right edge (see #TJXOPT_PERFECT.)
+ * are any partial iMCUs on the right edge (see #TJXOPT_PERFECT.)
*/
TJXOP_HFLIP,
/**
* Flip (mirror) image vertically. This transform is imperfect if there are
- * any partial MCU blocks on the bottom edge (see #TJXOPT_PERFECT.)
+ * any partial iMCUs on the bottom edge (see #TJXOPT_PERFECT.)
*/
TJXOP_VFLIP,
/**
@@ -916,25 +948,23 @@ enum TJXOP {
TJXOP_TRANSPOSE,
/**
* Transverse transpose image (flip/mirror along upper right to lower left
- * axis.) This transform is imperfect if there are any partial MCU blocks in
- * the image (see #TJXOPT_PERFECT.)
+ * axis.) This transform is imperfect if there are any partial iMCUs in the
+ * image (see #TJXOPT_PERFECT.)
*/
TJXOP_TRANSVERSE,
/**
* Rotate image clockwise by 90 degrees. This transform is imperfect if
- * there are any partial MCU blocks on the bottom edge (see
- * #TJXOPT_PERFECT.)
+ * there are any partial iMCUs on the bottom edge (see #TJXOPT_PERFECT.)
*/
TJXOP_ROT90,
/**
* Rotate image 180 degrees. This transform is imperfect if there are any
- * partial MCU blocks in the image (see #TJXOPT_PERFECT.)
+ * partial iMCUs in the image (see #TJXOPT_PERFECT.)
*/
TJXOP_ROT180,
/**
* Rotate image counter-clockwise by 90 degrees. This transform is imperfect
- * if there are any partial MCU blocks on the right edge (see
- * #TJXOPT_PERFECT.)
+ * if there are any partial iMCUs on the right edge (see #TJXOPT_PERFECT.)
*/
TJXOP_ROT270
};
@@ -942,19 +972,19 @@ enum TJXOP {
/**
* This option causes #tj3Transform() to return an error if the transform is
- * not perfect. Lossless transforms operate on MCU blocks, the size of which
+ * not perfect. Lossless transforms operate on iMCUs, the size of which
* depends on the level of chrominance subsampling used (see #tjMCUWidth and
* #tjMCUHeight.) If the image's width or height is not evenly divisible by
- * the MCU block size, then there will be partial MCU blocks on the right
- * and/or bottom edges. It is not possible to move these partial MCU blocks to
- * the top or left of the image, so any transform that would require that is
- * "imperfect." If this option is not specified, then any partial MCU blocks
- * that cannot be transformed will be left in place, which will create
- * odd-looking strips on the right or bottom edge of the image.
+ * the iMCU size, then there will be partial iMCUs on the right and/or bottom
+ * edges. It is not possible to move these partial iMCUs to the top or left of
+ * the image, so any transform that would require that is "imperfect." If this
+ * option is not specified, then any partial iMCUs that cannot be transformed
+ * will be left in place, which will create odd-looking strips on the right or
+ * bottom edge of the image.
*/
#define TJXOPT_PERFECT (1 << 0)
/**
- * Discard any partial MCU blocks that cannot be transformed.
+ * Discard any partial iMCUs that cannot be transformed.
*/
#define TJXOPT_TRIM (1 << 1)
/**
@@ -1021,12 +1051,12 @@ typedef struct {
typedef struct {
/**
* The left boundary of the cropping region. This must be evenly divisible
- * by the MCU block width (see #tjMCUWidth.)
+ * by the iMCU width (see #tjMCUWidth.)
*/
int x;
/**
* The upper boundary of the cropping region. For lossless transformation,
- * this must be evenly divisible by the MCU block height (see #tjMCUHeight.)
+ * this must be evenly divisible by the iMCU height (see #tjMCUHeight.)
*/
int y;
/**
@@ -1263,7 +1293,7 @@ DLLEXPORT int tj3Compress16(tjhandle handle, const unsigned short *srcBuf,
* buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
*
* @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
+ * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
* buffer copy will be performed.
*
* @param align row alignment (in bytes) of the source image (must be a power
@@ -1272,8 +1302,8 @@ DLLEXPORT int tj3Compress16(tjhandle handle, const unsigned short *srcBuf,
* (1 = unpadded.)
*
* @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the MCU block height (see #tjMCUHeight), then an
- * intermediate buffer copy will be performed.
+ * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
+ * buffer copy will be performed.
*
* @param jpegBuf address of a pointer to a byte buffer that will receive the
* JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
@@ -1323,7 +1353,7 @@ DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
* @ref YUVnotes "YUV Image Format Notes" for more details.
*
* @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
+ * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
* buffer copy will be performed.
*
* @param strides an array of integers, each specifying the number of bytes per
@@ -1336,8 +1366,8 @@ DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
* planar YUV image.
*
* @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the MCU block height (see #tjMCUHeight), then an
- * intermediate buffer copy will be performed.
+ * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
+ * buffer copy will be performed.
*
* @param jpegBuf address of a pointer to a byte buffer that will receive the
* JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
@@ -1640,7 +1670,7 @@ DLLEXPORT tjscalingfactor *tj3GetScalingFactors(int *numScalingFactors);
* #TJPARAM_JPEGHEIGHT) and the specified scaling factor. When decompressing
* into a planar YUV image, an intermediate buffer copy will be performed if
* the width or height of the scaled destination image is not an even multiple
- * of the MCU block size (see #tjMCUWidth and #tjMCUHeight.) Note that
+ * of the iMCU size (see #tjMCUWidth and #tjMCUHeight.) Note that
* decompression scaling is not available (and the specified scaling factor is
* ignored) when decompressing lossless JPEG images (see #TJPARAM_LOSSLESS),
* since the IDCT algorithm is not used with those images. Note also that
@@ -1662,12 +1692,12 @@ DLLEXPORT int tj3SetScalingFactor(tjhandle handle,
* @param croppingRegion #tjregion structure that specifies a subregion of the
* JPEG image to decompress, or #TJUNCROPPED for no cropping. The
* left boundary of the cropping region must be evenly divisible by the scaled
- * MCU block width-- #TJSCALED(#tjMCUWidth[subsamp], scalingFactor),
- * where `subsamp` is the level of chrominance subsampling in the JPEG image
- * (see #TJPARAM_SUBSAMP) and `scalingFactor` is the decompression scaling
- * factor (see #tj3SetScalingFactor().) The cropping region should be
- * specified relative to the scaled image dimensions. Unless `croppingRegion`
- * is #TJUNCROPPED, the JPEG header must be read (see
+ * iMCU width-- #TJSCALED(#tjMCUWidth[subsamp], scalingFactor), where
+ * `subsamp` is the level of chrominance subsampling in the JPEG image (see
+ * #TJPARAM_SUBSAMP) and `scalingFactor` is the decompression scaling factor
+ * (see #tj3SetScalingFactor().) The cropping region should be specified
+ * relative to the scaled image dimensions. Unless `croppingRegion` is
+ * #TJUNCROPPED, the JPEG header must be read (see
* #tj3DecompressHeader()) prior to calling this function.
*
* @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
diff --git a/usage.txt b/usage.txt
index 9d8af6fe..1bcea5f2 100644
--- a/usage.txt
+++ b/usage.txt
@@ -261,10 +261,22 @@ Switches for advanced users:
-icc FILE Embed ICC color management profile contained in the
specified file.
- -restart N Emit a JPEG restart marker every N MCU rows, or every
- N MCU blocks (samples in lossless mode) if "B" is
- attached to the number. -restart 0 (the default) means
- no restart markers.
+ -restart N Emit a JPEG restart marker every N MCU rows, or every N
+ MCUs if "B" is attached to the number.
+
+ In typical JPEG images, an MCU (Minimum Coded Unit) is
+ the minimum set of interleaved "data units" (8x8 DCT
+ blocks if the image is lossy or samples if the image is
+ lossless) necessary to represent at least one data unit
+ per component. (For example, an MCU in an interleaved
+ lossy JPEG image that uses 4:2:2 subsampling consists
+ of two luminance blocks followed by one block for each
+ chrominance component.) In single-component or
+ non-interleaved JPEG images, an MCU is the same as a
+ data unit. An MCU row is a row of MCUs spanning the
+ entire width of the image.
+
+ -restart 0 (the default) means no restart markers.
-smooth N Smooth the input image to eliminate dithering noise.
N, ranging from 1 to 100, indicates the strength of
@@ -604,7 +616,7 @@ jpegtran accepts a subset of the switches recognized by cjpeg:
-progressive Create progressive JPEG file.
-arithmetic Use arithmetic coding.
-restart N Emit a JPEG restart marker every N MCU rows, or every
- N MCU blocks if "B" is attached to the number.
+ N MCUs if "B" is attached to the number.
-scans file Use the scan script given in the specified text file.
See the previous discussion of cjpeg for more details about these switches.
If you specify none of these switches, you get a plain baseline-JPEG output
From 9983840eb6ceba5b4a3cf820965101403b04611d Mon Sep 17 00:00:00 2001
From: DRC
Date: Sat, 31 Aug 2024 12:41:13 -0400
Subject: [PATCH 099/135] TJ/xform: Check crop region against dest. image
Lossless cropping is performed after other lossless transform
operations, so the cropping region must be specified relative to the
destination image dimensions and level of chrominance subsampling, not
the source image dimensions and level of chrominance subsampling.
More specifically, if the lossless transform operation swaps the X and Y
axes, or if the image is converted to grayscale, then that changes the
cropping region requirements.
---
ChangeLog.md | 8 ++++
doc/html/group___turbo_j_p_e_g.html | 2 +-
doc/html/structtjregion.html | 4 +-
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 3 +-
.../libjpegturbo/turbojpeg/TJTransform.html | 5 ++-
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 3 +-
.../libjpegturbo/turbojpeg/TJTransform.java | 3 +-
turbojpeg-jni.c | 8 ++--
turbojpeg.c | 41 ++++++++++--------
turbojpeg.h | 12 +++--
13 files changed, 54 insertions(+), 35 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index e771e3ef..f90a0531 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -43,6 +43,14 @@ color conversion routine. Both bounds checks now use 64-bit integers to guard
against overflow, and djpeg now checks for negative numbers when it parses the
crop specification from the command line.
+7. Fixed an issue whereby the TurboJPEG lossless transformation function and
+methods checked the specified cropping region against the source image
+dimensions and level of chrominance subsampling rather than the destination
+image dimensions and level of chrominance subsampling, which caused some
+cropping regions to be unduly rejected when performing 90-degree rotation,
+270-degree rotation, transposition, transverse transposition, or grayscale
+conversion.
+
3.0.3
=====
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index b0eb355a..b71dbcc6 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -1124,7 +1124,7 @@ scalingFactor).
TJSAMP_UNKNOWN
Unknown subsampling.
The JPEG image uses an unusual type of chrominance subsampling. Such images can be decompressed into packed-pixel images, but they cannot be
decompressed into planar YUV images,
-
losslessly transformed if TJXOPT_CROP is specified, or
diff --git a/doc/html/structtjregion.html b/doc/html/structtjregion.html
index 8a277cda..fce4016e 100644
--- a/doc/html/structtjregion.html
+++ b/doc/html/structtjregion.html
@@ -146,7 +146,7 @@ Data Fields
The left boundary of the cropping region.
-
This must be evenly divisible by the iMCU width (see tjMCUWidth.)
+
For lossless transformation, this must be evenly divisible by the iMCU width (see tjMCUWidth) of the destination image. For decompression, this must be evenly divisible by the scaled iMCU width of the source image.
@@ -163,7 +163,7 @@ Data Fields
The upper boundary of the cropping region.
-
For lossless transformation, this must be evenly divisible by the iMCU height (see tjMCUHeight.)
+
For lossless transformation, this must be evenly divisible by the iMCU height (see tjMCUHeight) of the destination image.
diff --git a/java/doc/member-search-index.zip b/java/doc/member-search-index.zip
index 508d356fdb748bce5421956e1a97db744456e2ef..3d25c5cc18ab07d61033d46e9d2732ed469cb323 100644
GIT binary patch
delta 30
kcmbQwKcAmBz?+#xgn@&DgF!G;ej~3FJ2Q};9K`Mm09L{UtpET3
delta 30
kcmbQwKcAmBz?+#xgn@&DgW+d^+(up}c4i
images can be decompressed into packed-pixel images, but they cannot be
x - the left boundary of the cropping region. This must be evenly
- divisible by the iMCU width (see TJ.getMCUWidth())
+ divisible by the iMCU width (see TJ.getMCUWidth())
+ of the destination image.
y - the upper boundary of the cropping region. This must be evenly
- divisible by the iMCU height (see TJ.getMCUHeight())
+ divisible by the iMCU height (see TJ.getMCUHeight()) of the destination image.
w - the width of the cropping region. Setting this to 0 is the
equivalent of setting it to (width of the source JPEG image -
x).
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index 9a7c121c1a01620d9ef03fc848877295e5d2a889..801c3a7becfc8d1ecf44b6f9e70fd33d33e6ff69 100644
GIT binary patch
delta 28
hcmaFM_?D43z?+#xgn@&DgF!G;ej;x_Gl-h+2LN2F2ABW<
delta 28
hcmaFM_?D43z?+#xgn@&DgW+d^+(h1fW)L;s4*+gU2y_4d
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index e20168bcc8d9acb32029cd6db02844d5a2446fd3..62d70e25d236ddbf601e642d4195fc94c5fb401e 100644
GIT binary patch
delta 28
hcmdnaw4I4Jz?+#xgn@&DgF!G;ej@K3W)Stp8vs;#2E_mX
delta 28
hcmdnaw4I4Jz?+#xgn@&DgW+d^+(h0x%pmHGHvncD2%!J~
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index a58e379e..04c68cf9 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -112,7 +112,8 @@ public final class TJ {
* images can be decompressed into packed-pixel images, but they cannot be
*
*
decompressed into planar YUV images,
- *
losslessly transformed if {@link TJTransform#OPT_CROP} is specified,
+ *
losslessly transformed if {@link TJTransform#OPT_CROP} is specified
+ * and {@link TJTransform#OPT_GRAY} is not specified,
* or
*
partially decompressed using a cropping region.
*
diff --git a/java/org/libjpegturbo/turbojpeg/TJTransform.java b/java/org/libjpegturbo/turbojpeg/TJTransform.java
index 021263f2..d976de54 100644
--- a/java/org/libjpegturbo/turbojpeg/TJTransform.java
+++ b/java/org/libjpegturbo/turbojpeg/TJTransform.java
@@ -165,10 +165,11 @@ public class TJTransform extends Rectangle {
*
* @param x the left boundary of the cropping region. This must be evenly
* divisible by the iMCU width (see {@link TJ#getMCUWidth TJ.getMCUWidth()})
+ * of the destination image.
*
* @param y the upper boundary of the cropping region. This must be evenly
* divisible by the iMCU height (see {@link TJ#getMCUHeight
- * TJ.getMCUHeight()})
+ * TJ.getMCUHeight()}) of the destination image.
*
* @param w the width of the cropping region. Setting this to 0 is the
* equivalent of setting it to (width of the source JPEG image -
diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c
index 8e6ed320..0a1d7451 100644
--- a/turbojpeg-jni.c
+++ b/turbojpeg-jni.c
@@ -1141,7 +1141,7 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf
size_t *dstSizes = NULL;
tjtransform *t = NULL;
jbyteArray *jdstBufs = NULL;
- int i, jpegWidth = 0, jpegHeight = 0, jpegSubsamp;
+ int i, jpegWidth = 0, jpegHeight = 0, srcSubsamp;
jintArray jdstSizes = 0;
jint *dstSizesi = NULL;
JNICustomFilterParams *params = NULL;
@@ -1154,8 +1154,7 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf
THROW_ARG("JPEG header has not yet been read");
if ((jpegHeight = tj3Get(handle, TJPARAM_JPEGHEIGHT)) == -1)
THROW_ARG("JPEG header has not yet been read");
- if ((jpegSubsamp = tj3Get(handle, TJPARAM_SUBSAMP)) == TJSAMP_UNKNOWN)
- THROW_ARG("TJPARAM_SUBSAMP must be specified");
+ srcSubsamp = tj3Get(handle, TJPARAM_SUBSAMP);
n = (*env)->GetArrayLength(env, dstobjs);
if (n != (*env)->GetArrayLength(env, tobjs))
@@ -1214,6 +1213,7 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf
for (i = 0; i < n; i++) {
int w = jpegWidth, h = jpegHeight;
+ int dstSubsamp = (t[i].options & TJXOPT_GRAY) ? TJSAMP_GRAY : srcSubsamp;
if (t[i].op == TJXOP_TRANSPOSE || t[i].op == TJXOP_TRANSVERSE ||
t[i].op == TJXOP_ROT90 || t[i].op == TJXOP_ROT270) {
@@ -1223,7 +1223,7 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf
if (t[i].r.h != 0) h = t[i].r.h;
BAILIF0(jdstBufs[i] = (*env)->GetObjectArrayElement(env, dstobjs, i));
if ((size_t)(*env)->GetArrayLength(env, jdstBufs[i]) <
- tj3JPEGBufSize(w, h, jpegSubsamp))
+ tj3JPEGBufSize(w, h, dstSubsamp))
THROW_ARG("Destination buffer is not large enough");
}
BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0));
diff --git a/turbojpeg.c b/turbojpeg.c
index 62c99f27..d02678b1 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -2665,7 +2665,7 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
static const char FUNCTION_NAME[] = "tj3Transform";
jpeg_transform_info *xinfo = NULL;
jvirt_barray_ptr *srccoefs, *dstcoefs;
- int retval = 0, i, saveMarkers = 0;
+ int retval = 0, i, saveMarkers = 0, srcSubsamp;
boolean alloc = TRUE;
struct my_progress_mgr progress;
@@ -2733,20 +2733,31 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
(unsigned long long)dinfo->image_width * dinfo->image_height >
(unsigned long long)this->maxPixels)
THROW("Image is too large");
- this->subsamp = getSubsamp(&this->dinfo);
+ srcSubsamp = getSubsamp(&this->dinfo);
for (i = 0; i < n; i++) {
+ int dstSubsamp = (t[i].options & TJXOPT_GRAY) ? TJSAMP_GRAY : srcSubsamp;
+
if (!jtransform_request_workspace(dinfo, &xinfo[i]))
THROW("Transform is not perfect");
if (xinfo[i].crop) {
- if (this->subsamp == TJSAMP_UNKNOWN)
+ if (dstSubsamp == TJSAMP_UNKNOWN)
THROW("Could not determine subsampling level of JPEG image");
- if ((t[i].r.x % tjMCUWidth[this->subsamp]) != 0 ||
- (t[i].r.y % tjMCUHeight[this->subsamp]) != 0)
- THROWI("To crop this JPEG image, x must be a multiple of %d\n"
- "and y must be a multiple of %d.", tjMCUWidth[this->subsamp],
- tjMCUHeight[this->subsamp]);
+ if (t[i].op == TJXOP_TRANSPOSE || t[i].op == TJXOP_TRANSVERSE ||
+ t[i].op == TJXOP_ROT90 || t[i].op == TJXOP_ROT270) {
+ if ((t[i].r.x % tjMCUHeight[dstSubsamp]) != 0 ||
+ (t[i].r.y % tjMCUWidth[dstSubsamp]) != 0)
+ THROWI("To crop this JPEG image, x must be a multiple of %d\n"
+ "and y must be a multiple of %d.", tjMCUHeight[dstSubsamp],
+ tjMCUWidth[dstSubsamp]);
+ } else {
+ if ((t[i].r.x % tjMCUWidth[dstSubsamp]) != 0 ||
+ (t[i].r.y % tjMCUHeight[dstSubsamp]) != 0)
+ THROWI("To crop this JPEG image, x must be a multiple of %d\n"
+ "and y must be a multiple of %d.", tjMCUWidth[dstSubsamp],
+ tjMCUHeight[dstSubsamp]);
+ }
}
}
@@ -2754,6 +2765,7 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
for (i = 0; i < n; i++) {
int w, h;
+ int dstSubsamp = (t[i].options & TJXOPT_GRAY) ? TJSAMP_GRAY : srcSubsamp;
if (!xinfo[i].crop) {
w = dinfo->image_width; h = dinfo->image_height;
@@ -2765,7 +2777,7 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
w = xinfo[i].crop_width; h = xinfo[i].crop_height;
}
if (this->noRealloc) {
- alloc = FALSE; dstSizes[i] = tj3JPEGBufSize(w, h, this->subsamp);
+ alloc = FALSE; dstSizes[i] = tj3JPEGBufSize(w, h, dstSubsamp);
}
if (!(t[i].options & TJXOPT_NOOUTPUT))
jpeg_mem_dest_tj(cinfo, &dstBufs[i], &dstSizes[i], alloc);
@@ -2843,22 +2855,13 @@ DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
int i, retval = 0;
size_t *sizes = NULL;
- GET_DINSTANCE(handle);
+ GET_TJINSTANCE(handle, -1);
if ((this->init & DECOMPRESS) == 0)
THROW("Instance has not been initialized for decompression");
if (n < 1 || dstSizes == NULL)
THROW("Invalid argument");
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
- if (getSubsamp(dinfo) == TJSAMP_UNKNOWN)
- THROW("Could not determine subsampling level of JPEG image");
processFlags(handle, flags, COMPRESS);
if ((sizes = (size_t *)malloc(n * sizeof(size_t))) == NULL)
diff --git a/turbojpeg.h b/turbojpeg.h
index 6a2271c0..33d1baf5 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -188,7 +188,8 @@ enum TJSAMP {
* The JPEG image uses an unusual type of chrominance subsampling. Such
* images can be decompressed into packed-pixel images, but they cannot be
* - decompressed into planar YUV images,
- * - losslessly transformed if #TJXOPT_CROP is specified, or
+ * - losslessly transformed if #TJXOPT_CROP is specified and #TJXOPT_GRAY is
+ * not specified, or
* - partially decompressed using a cropping region.
*/
TJSAMP_UNKNOWN = -1
@@ -1050,13 +1051,16 @@ typedef struct {
*/
typedef struct {
/**
- * The left boundary of the cropping region. This must be evenly divisible
- * by the iMCU width (see #tjMCUWidth.)
+ * The left boundary of the cropping region. For lossless transformation,
+ * this must be evenly divisible by the iMCU width (see #tjMCUWidth) of the
+ * destination image. For decompression, this must be evenly divisible by
+ * the scaled iMCU width of the source image.
*/
int x;
/**
* The upper boundary of the cropping region. For lossless transformation,
- * this must be evenly divisible by the iMCU height (see #tjMCUHeight.)
+ * this must be evenly divisible by the iMCU height (see #tjMCUHeight) of the
+ * destination image.
*/
int y;
/**
From 8d76e4e5504fbc2cb73c40a7406607c30cec22e4 Mon Sep 17 00:00:00 2001
From: DRC
Date: Sat, 31 Aug 2024 15:33:55 -0400
Subject: [PATCH 100/135] Doc: "EXIF" = "Exif"
---
ChangeLog.md | 6 +++---
doc/html/group___turbo_j_p_e_g.html | 6 +++---
java/TJBench.java | 2 +-
java/doc/index-all.html | 2 +-
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
.../libjpegturbo/turbojpeg/TJTransform.html | 4 ++--
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
.../libjpegturbo/turbojpeg/TJTransform.java | 2 +-
tjbench.c | 2 +-
turbojpeg.h | 4 ++--
11 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index f90a0531..48a9ecbd 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1071,7 +1071,7 @@ generated by selected transforms in a multi-transform operation.
6. Introduced a new transform option in the TurboJPEG API (`TJXOPT_COPYNONE` in
the C API and `TJTransform.OPT_COPYNONE` in the Java API) that allows the
-copying of markers (including EXIF and ICC profile data) to be disabled for a
+copying of markers (including Exif and ICC profile data) to be disabled for a
particular transform.
7. Added two functions to the TurboJPEG C API (`tjLoadImage()` and
@@ -1202,13 +1202,13 @@ bug that has existed since the introduction of libjpeg v7/v8 API/ABI emulation
in libjpeg-turbo v1.1.
7. The lossless transform features in jpegtran and the TurboJPEG API will now
-always attempt to adjust the EXIF image width and height tags if the image size
+always attempt to adjust the Exif image width and height tags if the image size
changed as a result of the transform. This behavior has always existed when
using libjpeg v8 API/ABI emulation. It was supposed to be available with
libjpeg v7 API/ABI emulation as well but did not work properly due to a bug.
Furthermore, there was never any good reason not to enable it with libjpeg v6b
API/ABI emulation, since the behavior is entirely internal. Note that
-`-copy all` must be passed to jpegtran in order to transfer the EXIF tags from
+`-copy all` must be passed to jpegtran in order to transfer the Exif tags from
the source image to the destination image.
8. Fixed several memory leaks in the TurboJPEG API library that could occur
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index b71dbcc6..f55c748b 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -135,7 +135,7 @@ Macros
Generate a progressive destination image instead of a single-scan destination image.
Enable arithmetic entropy coding in the destination image.
@@ -580,7 +580,7 @@ scalingFactor).
-
Do not copy any extra markers (including EXIF and ICC profile data) from the source image to the destination image.
+
Do not copy any extra markers (including Exif and ICC profile data) from the source image to the destination image.
@@ -3173,7 +3173,7 @@ If you choose option 1, then *jpegSize should be set to the size of
dstBufs
pointer to an array of n byte buffers. dstBufs[i] will receive a JPEG image that has been transformed using the parameters in transforms[i]. TurboJPEG has the ability to reallocate the JPEG destination buffer to accommodate the size of the transformed JPEG image. Thus, you can choose to:
pre-allocate the JPEG destination buffer with an arbitrary size using tj3Alloc() and let TurboJPEG grow the buffer as needed,
set dstBufs[i] to NULL to tell TurboJPEG to allocate the buffer for you, or
-
pre-allocate the buffer to a "worst case" size determined by calling tj3JPEGBufSize() with the transformed or cropped width and height and the level of subsampling used in the source image. Under normal circumstances, this should ensure that the buffer never has to be re-allocated. (Setting TJPARAM_NOREALLOC guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded EXIF or ICC profile data) in which the transformed JPEG image will be larger than the worst-case size, and TJPARAM_NOREALLOC cannot be used in those cases.
+
pre-allocate the buffer to a "worst case" size determined by calling tj3JPEGBufSize() with the transformed or cropped width and height and the level of subsampling used in the source image. Under normal circumstances, this should ensure that the buffer never has to be re-allocated. (Setting TJPARAM_NOREALLOC guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded Exif or ICC profile data) in which the transformed JPEG image will be larger than the worst-case size, and TJPARAM_NOREALLOC cannot be used in those cases.
If you choose option 1, then dstSizes[i] should be set to the size of your pre-allocated buffer. In any case, unless you have set TJPARAM_NOREALLOC, you should always check dstBufs[i] upon return from this function, as it may have changed.
dstSizes
pointer to an array of n size_t variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If dstBufs[i] points to a pre-allocated buffer, then dstSizes[i] should be set to the size of the buffer. Upon return, dstSizes[i] will contain the size of the transformed JPEG image (in bytes.)
diff --git a/java/TJBench.java b/java/TJBench.java
index 7fc3377c..e42142c5 100644
--- a/java/TJBench.java
+++ b/java/TJBench.java
@@ -852,7 +852,7 @@ final class TJBench {
System.out.println(" prior to decompression (these operations are mutually exclusive)");
System.out.println("-grayscale = Transform the input image into a grayscale JPEG image prior to");
System.out.println(" decompression (can be combined with the other transform operations above)");
- System.out.println("-copynone = Do not copy any extra markers (including EXIF and ICC profile data)");
+ System.out.println("-copynone = Do not copy any extra markers (including Exif and ICC profile data)");
System.out.println(" when transforming the input image");
System.out.println("-yuv = Compress from/decompress to intermediate planar YUV images");
System.out.println(" ** 8-bit data precision only **");
diff --git a/java/doc/index-all.html b/java/doc/index-all.html
index c6ee8b4d..b08dcddb 100644
--- a/java/doc/index-all.html
+++ b/java/doc/index-all.html
@@ -672,7 +672,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
Do not copy any extra markers (including EXIF and ICC profile data) from
+
Do not copy any extra markers (including Exif and ICC profile data) from
the source image to the destination image.
@@ -710,7 +710,7 @@ extends java.awt.Rectangle
OPT_COPYNONE
public static final int OPT_COPYNONE
-
Do not copy any extra markers (including EXIF and ICC profile data) from
+
Do not copy any extra markers (including Exif and ICC profile data) from
the source image to the destination image.
See Also:
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index 801c3a7becfc8d1ecf44b6f9e70fd33d33e6ff69..929c54dd2fcdaedd10377ea676ddb38adfc6f5c5 100644
GIT binary patch
delta 26
gcmaFM_?D3;z?+#xgn@&DgF(DzBF_XSAUV$;08|(TiU0rr
delta 26
gcmaFM_?D3;z?+#xgn@&DgF!HJBF_XSAUV$;08*|7SO5S3
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index 62d70e25d236ddbf601e642d4195fc94c5fb401e..bc0a78c5ebcde41ce8164adf6f07c2741bbcda50 100644
GIT binary patch
delta 26
gcmdnaw4I43z?+#xgn@&DgF(DzBF|kWAo
Date: Sat, 31 Aug 2024 15:39:34 -0400
Subject: [PATCH 101/135] CMakeLists.txt: libjpeg-turbo "2.2.x" = "3.0.x"
---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c105b22c..2caa612e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -309,12 +309,12 @@ endif()
# 1: + In-memory source/destination managers (libjpeg-turbo 1.3.x)
# 2: + Partial image decompression functions (libjpeg-turbo 1.5.x)
# 3: + ICC functions (libjpeg-turbo 2.0.x)
-# 4: + 12-bit-per-sample and lossless functions (libjpeg-turbo 2.2.x)
+# 4: + 12-bit-per-sample and lossless functions (libjpeg-turbo 3.0.x)
#
# libjpeg v8 API/ABI emulation:
# 1: + Partial image decompression functions (libjpeg-turbo 1.5.x)
# 2: + ICC functions (libjpeg-turbo 2.0.x)
-# 3: + 12-bit-per-sample and lossless functions (libjpeg-turbo 2.2.x)
+# 3: + 12-bit-per-sample and lossless functions (libjpeg-turbo 3.0.x)
set(SO_AGE 3)
if(NOT WITH_JPEG8)
set(SO_AGE 4)
From eb75363004a1c4a3f25712c96569be920d9d3c08 Mon Sep 17 00:00:00 2001
From: DRC
Date: Sat, 31 Aug 2024 16:50:08 -0400
Subject: [PATCH 102/135] Update URLs
- Eliminate unnecessary "www."
- Use HTTPS.
- Update Java, MSYS, tdm-gcc, and NSIS URLs.
- Update URL and title of Agner Fog's assembly language optimization
manual.
- Remove extraneous information about MASM and Borland Turbo Assembler
and outdated NASM URLs from the x86 assembly headers, and mention
Yasm.
---
.github/workflows/build.yml | 2 +-
BUILDING.md | 16 ++++++++--------
ChangeLog.md | 2 +-
README.md | 5 +++--
appveyor.yml | 2 +-
cmakescripts/PackageInfo.cmake | 4 ++--
jcdctmgr.c | 6 +++---
simd/i386/jccolext-avx2.asm | 6 +-----
simd/i386/jccolext-mmx.asm | 6 +-----
simd/i386/jccolext-sse2.asm | 6 +-----
simd/i386/jccolor-avx2.asm | 6 +-----
simd/i386/jccolor-mmx.asm | 6 +-----
simd/i386/jccolor-sse2.asm | 6 +-----
simd/i386/jcgray-avx2.asm | 6 +-----
simd/i386/jcgray-mmx.asm | 6 +-----
simd/i386/jcgray-sse2.asm | 6 +-----
simd/i386/jcgryext-avx2.asm | 6 +-----
simd/i386/jcgryext-mmx.asm | 6 +-----
simd/i386/jcgryext-sse2.asm | 6 +-----
simd/i386/jchuff-sse2.asm | 6 +-----
simd/i386/jcphuff-sse2.asm | 6 +-----
simd/i386/jcsample-avx2.asm | 6 +-----
simd/i386/jcsample-mmx.asm | 6 +-----
simd/i386/jcsample-sse2.asm | 6 +-----
simd/i386/jdcolext-avx2.asm | 6 +-----
simd/i386/jdcolext-mmx.asm | 6 +-----
simd/i386/jdcolext-sse2.asm | 6 +-----
simd/i386/jdcolor-avx2.asm | 6 +-----
simd/i386/jdcolor-mmx.asm | 6 +-----
simd/i386/jdcolor-sse2.asm | 6 +-----
simd/i386/jdmerge-avx2.asm | 6 +-----
simd/i386/jdmerge-mmx.asm | 6 +-----
simd/i386/jdmerge-sse2.asm | 6 +-----
simd/i386/jdmrgext-avx2.asm | 6 +-----
simd/i386/jdmrgext-mmx.asm | 6 +-----
simd/i386/jdmrgext-sse2.asm | 6 +-----
simd/i386/jdsample-avx2.asm | 6 +-----
simd/i386/jdsample-mmx.asm | 6 +-----
simd/i386/jdsample-sse2.asm | 6 +-----
simd/i386/jfdctflt-3dn.asm | 6 +-----
simd/i386/jfdctflt-sse.asm | 6 +-----
simd/i386/jfdctfst-mmx.asm | 6 +-----
simd/i386/jfdctfst-sse2.asm | 6 +-----
simd/i386/jfdctint-avx2.asm | 6 +-----
simd/i386/jfdctint-mmx.asm | 6 +-----
simd/i386/jfdctint-sse2.asm | 6 +-----
simd/i386/jidctflt-3dn.asm | 6 +-----
simd/i386/jidctflt-sse.asm | 6 +-----
simd/i386/jidctflt-sse2.asm | 6 +-----
simd/i386/jidctfst-mmx.asm | 6 +-----
simd/i386/jidctfst-sse2.asm | 6 +-----
simd/i386/jidctint-avx2.asm | 6 +-----
simd/i386/jidctint-mmx.asm | 6 +-----
simd/i386/jidctint-sse2.asm | 6 +-----
simd/i386/jidctred-mmx.asm | 6 +-----
simd/i386/jidctred-sse2.asm | 6 +-----
simd/i386/jquant-3dn.asm | 6 +-----
simd/i386/jquant-mmx.asm | 10 +++-------
simd/i386/jquant-sse.asm | 6 +-----
simd/i386/jquantf-sse2.asm | 6 +-----
simd/i386/jquanti-avx2.asm | 12 ++++--------
simd/i386/jquanti-sse2.asm | 10 +++-------
simd/i386/jsimdcpu.asm | 6 +-----
simd/x86_64/jccolext-avx2.asm | 6 +-----
simd/x86_64/jccolext-sse2.asm | 6 +-----
simd/x86_64/jccolor-avx2.asm | 6 +-----
simd/x86_64/jccolor-sse2.asm | 6 +-----
simd/x86_64/jcgray-avx2.asm | 6 +-----
simd/x86_64/jcgray-sse2.asm | 6 +-----
simd/x86_64/jcgryext-avx2.asm | 6 +-----
simd/x86_64/jcgryext-sse2.asm | 6 +-----
simd/x86_64/jchuff-sse2.asm | 6 +-----
simd/x86_64/jcphuff-sse2.asm | 6 +-----
simd/x86_64/jcsample-avx2.asm | 6 +-----
simd/x86_64/jcsample-sse2.asm | 6 +-----
simd/x86_64/jdcolext-avx2.asm | 6 +-----
simd/x86_64/jdcolext-sse2.asm | 6 +-----
simd/x86_64/jdcolor-avx2.asm | 6 +-----
simd/x86_64/jdcolor-sse2.asm | 6 +-----
simd/x86_64/jdmerge-avx2.asm | 6 +-----
simd/x86_64/jdmerge-sse2.asm | 6 +-----
simd/x86_64/jdmrgext-avx2.asm | 6 +-----
simd/x86_64/jdmrgext-sse2.asm | 6 +-----
simd/x86_64/jdsample-avx2.asm | 6 +-----
simd/x86_64/jdsample-sse2.asm | 6 +-----
simd/x86_64/jfdctflt-sse.asm | 6 +-----
simd/x86_64/jfdctfst-sse2.asm | 6 +-----
simd/x86_64/jfdctint-avx2.asm | 6 +-----
simd/x86_64/jfdctint-sse2.asm | 6 +-----
simd/x86_64/jidctflt-sse2.asm | 6 +-----
simd/x86_64/jidctfst-sse2.asm | 6 +-----
simd/x86_64/jidctint-avx2.asm | 6 +-----
simd/x86_64/jidctint-sse2.asm | 6 +-----
simd/x86_64/jidctred-sse2.asm | 6 +-----
simd/x86_64/jquantf-sse2.asm | 6 +-----
simd/x86_64/jquanti-avx2.asm | 10 +++-------
simd/x86_64/jquanti-sse2.asm | 10 +++-------
simd/x86_64/jsimdcpu.asm | 6 +-----
98 files changed, 121 insertions(+), 484 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index cfd5ffc3..9bd75297 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -24,7 +24,7 @@ jobs:
docker pull dcommander/buildljt:$BRANCH
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git -b $BRANCH $HOME/src/buildscripts
mkdir $HOME/rpmkeys
- wget --no-check-certificate "http://www.libjpeg-turbo.org/key/LJTPR-GPG-KEY" -O $HOME/rpmkeys/LJTPR-GPG-KEY
+ wget --no-check-certificate "https://libjpeg-turbo.org/key/LJTPR-GPG-KEY" -O $HOME/rpmkeys/LJTPR-GPG-KEY
- name: Configure GPG signing
if: ${{github.event_name != 'pull_request'}}
run: |
diff --git a/BUILDING.md b/BUILDING.md
index d06bce86..e1804838 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -8,16 +8,16 @@ Build Requirements
### All Systems
-- [CMake](http://www.cmake.org) v2.8.12 or later
+- [CMake](https://cmake.org) v2.8.12 or later
-- [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net)
+- [NASM](https://nasm.us) or [Yasm](https://yasm.tortall.net)
(if building x86 or x86-64 SIMD extensions)
* If using NASM, 2.13 or later is required.
* If using Yasm, 1.2.0 or later is required.
* NASM 2.15 or later is required if building libjpeg-turbo with Intel
Control-flow Enforcement Technology (CET) support.
* If building on macOS, NASM or Yasm can be obtained from
- [MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
+ [MacPorts](https://macports.org) or [Homebrew](https://brew.sh).
- NOTE: Currently, if it is desirable to hide the SIMD function symbols in
Mac executables or shared libraries that statically link with
libjpeg-turbo, then NASM 2.14 or later or Yasm must be used when
@@ -39,7 +39,7 @@ Build Requirements
required. Most modern Linux distributions, as well as Solaris 10 and later,
include JDK or OpenJDK. For other systems, you can obtain the Oracle Java
Development Kit from
- .
+ .
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
@@ -69,14 +69,14 @@ Build Requirements
- MinGW
- [MSYS2](http://msys2.github.io/) or [tdm-gcc](http://tdm-gcc.tdragon.net/)
+ [MSYS2](https://msys2.org) or [tdm-gcc](https://jmeubank.github.io/tdm-gcc)
recommended if building on a Windows machine. Both distributions install a
Start Menu link that can be used to launch a command prompt with the
appropriate compiler paths automatically set.
- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
can be downloaded from
- .
+ .
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
@@ -439,7 +439,7 @@ Building libjpeg-turbo for Android
----------------------------------
Building libjpeg-turbo for Android platforms requires v13b or later of the
-[Android NDK](https://developer.android.com/tools/sdk/ndk).
+[Android NDK](https://developer.android.com/ndk).
### Armv7 (32-bit)
@@ -679,7 +679,7 @@ as the configuration you built (such as *{build_directory}*\Debug\ or
*{build_directory}*\Release\).
Building a Windows installer requires the
-[Nullsoft Install System](http://nsis.sourceforge.net/). makensis.exe should
+[Nullsoft Install System](https://nsis.sourceforge.io). makensis.exe should
be in your `PATH`.
diff --git a/ChangeLog.md b/ChangeLog.md
index 48a9ecbd..46ca8cb1 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1230,7 +1230,7 @@ for two reasons: it allows testers to more easily work around the 2 GB limit
in libFuzzer, and it allows developers of security-sensitive applications to
more easily defend against one of the progressive JPEG exploits (LJT-01-004)
identified in
-[this report](http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
+[this report](https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
10. TJBench will now run each benchmark for 1 second prior to starting the
timer, in order to improve the consistency of the results. Furthermore, the
diff --git a/README.md b/README.md
index 923e61d2..17c84127 100644
--- a/README.md
+++ b/README.md
@@ -71,7 +71,8 @@ JPEG images:
top of the TurboJPEG API. The TurboJPEG API is recommended for first-time
users of libjpeg-turbo. Refer to [tjexample.c](tjexample.c) and
[TJExample.java](java/TJExample.java) for examples of its usage and to
- for API documentation.
+ for API
+ documentation.
- **libjpeg API**
This is the de facto industry-standard API for compressing and decompressing
@@ -199,7 +200,7 @@ supported and which aren't.
NOTE: As of this writing, extensive research has been conducted into the
usefulness of DCT scaling as a means of data reduction and SmartScale as a
means of quality improvement. Readers are invited to peruse the research at
- and draw their own conclusions,
+ and draw their own conclusions,
but it is the general belief of our project that these features have not
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
diff --git a/appveyor.yml b/appveyor.yml
index a04b4a47..4372cd6a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -4,7 +4,7 @@ install:
mkdir c:\temp
- if not exist c:\installers\nasm-2.10.01-win32.zip curl -fSL -o c:\installers\nasm-2.10.01-win32.zip http://www.nasm.us/pub/nasm/releasebuilds/2.10.01/win32/nasm-2.10.01-win32.zip
+ if not exist c:\installers\nasm-2.10.01-win32.zip curl -fSL -o c:\installers\nasm-2.10.01-win32.zip https://nasm.us/pub/nasm/releasebuilds/2.10.01/win32/nasm-2.10.01-win32.zip
7z x c:\installers\nasm-2.10.01-win32.zip -oc:\ > c:\installers\nasm.install.log
diff --git a/cmakescripts/PackageInfo.cmake b/cmakescripts/PackageInfo.cmake
index 36f6133a..86e5ca0d 100644
--- a/cmakescripts/PackageInfo.cmake
+++ b/cmakescripts/PackageInfo.cmake
@@ -5,8 +5,8 @@ set(PKGNAME ${CMAKE_PROJECT_NAME} CACHE STRING
"Distribution package name (default: ${CMAKE_PROJECT_NAME})")
set(PKGVENDOR "The ${CMAKE_PROJECT_NAME} Project" CACHE STRING
"Vendor name to be included in distribution package descriptions (default: The ${CMAKE_PROJECT_NAME} Project)")
-set(PKGURL "http://www.${CMAKE_PROJECT_NAME}.org" CACHE STRING
- "URL of project web site to be included in distribution package descriptions (default: http://www.${CMAKE_PROJECT_NAME}.org)")
+set(PKGURL "https://${CMAKE_PROJECT_NAME}.org" CACHE STRING
+ "URL of project web site to be included in distribution package descriptions (default: https://${CMAKE_PROJECT_NAME}.org)")
set(PKGEMAIL "information@${CMAKE_PROJECT_NAME}.org" CACHE STRING
"E-mail of project maintainer to be included in distribution package descriptions (default: information@${CMAKE_PROJECT_NAME}.org")
set(PKGID "com.${CMAKE_PROJECT_NAME}.${PKGNAME}" CACHE STRING
diff --git a/jcdctmgr.c b/jcdctmgr.c
index 7191ee73..dbdbad6a 100644
--- a/jcdctmgr.c
+++ b/jcdctmgr.c
@@ -6,7 +6,7 @@
* libjpeg-turbo Modifications:
* Copyright (C) 1999-2006, MIYASAKA Masaru.
* Copyright 2009 Pierre Ossman for Cendio AB
- * Copyright (C) 2011, 2014-2015, 2022, D. R. Commander.
+ * Copyright (C) 2011, 2014-2015, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -114,8 +114,8 @@ flss(UINT16 val)
* Compute values to do a division using reciprocal.
*
* This implementation is based on an algorithm described in
- * "How to optimize for the Pentium family of microprocessors"
- * (http://www.agner.org/assem/).
+ * "Optimizing subroutines in assembly language:
+ * An optimization guide for x86 platforms" (https://agner.org/optimize).
* More information about the basic algorithm can be found in
* the paper "Integer Division Using Reciprocals" by Robert Alverson.
*
diff --git a/simd/i386/jccolext-avx2.asm b/simd/i386/jccolext-avx2.asm
index af6418f0..28ac9528 100644
--- a/simd/i386/jccolext-avx2.asm
+++ b/simd/i386/jccolext-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jccolext-mmx.asm b/simd/i386/jccolext-mmx.asm
index dbec80e7..44b62512 100644
--- a/simd/i386/jccolext-mmx.asm
+++ b/simd/i386/jccolext-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jccolext-sse2.asm b/simd/i386/jccolext-sse2.asm
index 8d411451..1d8d5f5a 100644
--- a/simd/i386/jccolext-sse2.asm
+++ b/simd/i386/jccolext-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jccolor-avx2.asm b/simd/i386/jccolor-avx2.asm
index 3d6dfa6f..9ad5ea95 100644
--- a/simd/i386/jccolor-avx2.asm
+++ b/simd/i386/jccolor-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jccolor-mmx.asm b/simd/i386/jccolor-mmx.asm
index 05274885..0dbec548 100644
--- a/simd/i386/jccolor-mmx.asm
+++ b/simd/i386/jccolor-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jccolor-sse2.asm b/simd/i386/jccolor-sse2.asm
index ff6a2ecd..678306a1 100644
--- a/simd/i386/jccolor-sse2.asm
+++ b/simd/i386/jccolor-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jcgray-avx2.asm b/simd/i386/jcgray-avx2.asm
index 564974f8..ded39567 100644
--- a/simd/i386/jcgray-avx2.asm
+++ b/simd/i386/jcgray-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jcgray-mmx.asm b/simd/i386/jcgray-mmx.asm
index e791ea4a..d6f03186 100644
--- a/simd/i386/jcgray-mmx.asm
+++ b/simd/i386/jcgray-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jcgray-sse2.asm b/simd/i386/jcgray-sse2.asm
index 70c0177d..ecc7fa08 100644
--- a/simd/i386/jcgray-sse2.asm
+++ b/simd/i386/jcgray-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jcgryext-avx2.asm b/simd/i386/jcgryext-avx2.asm
index 0fb284aa..70df8f80 100644
--- a/simd/i386/jcgryext-avx2.asm
+++ b/simd/i386/jcgryext-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jcgryext-mmx.asm b/simd/i386/jcgryext-mmx.asm
index 1c69d382..dd90c3df 100644
--- a/simd/i386/jcgryext-mmx.asm
+++ b/simd/i386/jcgryext-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jcgryext-sse2.asm b/simd/i386/jcgryext-sse2.asm
index f710816a..227295f3 100644
--- a/simd/i386/jcgryext-sse2.asm
+++ b/simd/i386/jcgryext-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jchuff-sse2.asm b/simd/i386/jchuff-sse2.asm
index 4adf5eb5..ed194dd3 100644
--- a/simd/i386/jchuff-sse2.asm
+++ b/simd/i386/jchuff-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation for Huffman coding of one block.
; The following code is based on jchuff.c; see jchuff.c for more details.
diff --git a/simd/i386/jcphuff-sse2.asm b/simd/i386/jcphuff-sse2.asm
index c26b48a4..19a183fc 100644
--- a/simd/i386/jcphuff-sse2.asm
+++ b/simd/i386/jcphuff-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation of data preparation for progressive
; Huffman encoding. See jcphuff.c for more details.
diff --git a/simd/i386/jcsample-avx2.asm b/simd/i386/jcsample-avx2.asm
index 3d40f1d9..5019829c 100644
--- a/simd/i386/jcsample-avx2.asm
+++ b/simd/i386/jcsample-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jcsample-mmx.asm b/simd/i386/jcsample-mmx.asm
index 38d5b322..94dd8887 100644
--- a/simd/i386/jcsample-mmx.asm
+++ b/simd/i386/jcsample-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jcsample-sse2.asm b/simd/i386/jcsample-sse2.asm
index 26c5d740..eb8808be 100644
--- a/simd/i386/jcsample-sse2.asm
+++ b/simd/i386/jcsample-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdcolext-avx2.asm b/simd/i386/jdcolext-avx2.asm
index 53ea3128..fd79b795 100644
--- a/simd/i386/jdcolext-avx2.asm
+++ b/simd/i386/jdcolext-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jdcolext-mmx.asm b/simd/i386/jdcolext-mmx.asm
index d97faee0..636bd6d3 100644
--- a/simd/i386/jdcolext-mmx.asm
+++ b/simd/i386/jdcolext-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jdcolext-sse2.asm b/simd/i386/jdcolext-sse2.asm
index 682efc73..0150f2cb 100644
--- a/simd/i386/jdcolext-sse2.asm
+++ b/simd/i386/jdcolext-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jdcolor-avx2.asm b/simd/i386/jdcolor-avx2.asm
index 0f9baf84..d3a30d63 100644
--- a/simd/i386/jdcolor-avx2.asm
+++ b/simd/i386/jdcolor-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdcolor-mmx.asm b/simd/i386/jdcolor-mmx.asm
index 21e83329..6e67e4b7 100644
--- a/simd/i386/jdcolor-mmx.asm
+++ b/simd/i386/jdcolor-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdcolor-sse2.asm b/simd/i386/jdcolor-sse2.asm
index 481d0e4c..79c9c682 100644
--- a/simd/i386/jdcolor-sse2.asm
+++ b/simd/i386/jdcolor-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdmerge-avx2.asm b/simd/i386/jdmerge-avx2.asm
index 00201dc4..90493fd0 100644
--- a/simd/i386/jdmerge-avx2.asm
+++ b/simd/i386/jdmerge-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdmerge-mmx.asm b/simd/i386/jdmerge-mmx.asm
index be28c63f..0dc204aa 100644
--- a/simd/i386/jdmerge-mmx.asm
+++ b/simd/i386/jdmerge-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdmerge-sse2.asm b/simd/i386/jdmerge-sse2.asm
index 9b40a67d..06f07627 100644
--- a/simd/i386/jdmerge-sse2.asm
+++ b/simd/i386/jdmerge-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdmrgext-avx2.asm b/simd/i386/jdmrgext-avx2.asm
index 97988eb6..a7aa930e 100644
--- a/simd/i386/jdmrgext-avx2.asm
+++ b/simd/i386/jdmrgext-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jdmrgext-mmx.asm b/simd/i386/jdmrgext-mmx.asm
index 79cee73d..56275814 100644
--- a/simd/i386/jdmrgext-mmx.asm
+++ b/simd/i386/jdmrgext-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jdmrgext-sse2.asm b/simd/i386/jdmrgext-sse2.asm
index 33134435..13e7d980 100644
--- a/simd/i386/jdmrgext-sse2.asm
+++ b/simd/i386/jdmrgext-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/i386/jdsample-avx2.asm b/simd/i386/jdsample-avx2.asm
index b0507aa5..eba53ef7 100644
--- a/simd/i386/jdsample-avx2.asm
+++ b/simd/i386/jdsample-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdsample-mmx.asm b/simd/i386/jdsample-mmx.asm
index 6f70499c..01d09e62 100644
--- a/simd/i386/jdsample-mmx.asm
+++ b/simd/i386/jdsample-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jdsample-sse2.asm b/simd/i386/jdsample-sse2.asm
index f68c5ea5..b10d9227 100644
--- a/simd/i386/jdsample-sse2.asm
+++ b/simd/i386/jdsample-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/i386/jfdctflt-3dn.asm b/simd/i386/jfdctflt-3dn.asm
index 34af2bf0..0cedc6ca 100644
--- a/simd/i386/jfdctflt-3dn.asm
+++ b/simd/i386/jfdctflt-3dn.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the forward DCT
; (Discrete Cosine Transform). The following code is based directly on
diff --git a/simd/i386/jfdctflt-sse.asm b/simd/i386/jfdctflt-sse.asm
index d247094b..2cb95335 100644
--- a/simd/i386/jfdctflt-sse.asm
+++ b/simd/i386/jfdctflt-sse.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the forward DCT
; (Discrete Cosine Transform). The following code is based directly on
diff --git a/simd/i386/jfdctfst-mmx.asm b/simd/i386/jfdctfst-mmx.asm
index 8c55a987..fe16e83e 100644
--- a/simd/i386/jfdctfst-mmx.asm
+++ b/simd/i386/jfdctfst-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the forward DCT (Discrete Cosine Transform). The following code is
diff --git a/simd/i386/jfdctfst-sse2.asm b/simd/i386/jfdctfst-sse2.asm
index c1ba533d..890482e0 100644
--- a/simd/i386/jfdctfst-sse2.asm
+++ b/simd/i386/jfdctfst-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the forward DCT (Discrete Cosine Transform). The following code is
diff --git a/simd/i386/jfdctint-avx2.asm b/simd/i386/jfdctint-avx2.asm
index 21c3d5b2..05ea8654 100644
--- a/simd/i386/jfdctint-avx2.asm
+++ b/simd/i386/jfdctint-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/i386/jfdctint-mmx.asm b/simd/i386/jfdctint-mmx.asm
index c2f308ed..7d4c61cd 100644
--- a/simd/i386/jfdctint-mmx.asm
+++ b/simd/i386/jfdctint-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/i386/jfdctint-sse2.asm b/simd/i386/jfdctint-sse2.asm
index b6e67991..7ed5c950 100644
--- a/simd/i386/jfdctint-sse2.asm
+++ b/simd/i386/jfdctint-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/i386/jidctflt-3dn.asm b/simd/i386/jidctflt-3dn.asm
index 1f696cb5..8612eee3 100644
--- a/simd/i386/jidctflt-3dn.asm
+++ b/simd/i386/jidctflt-3dn.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
diff --git a/simd/i386/jidctflt-sse.asm b/simd/i386/jidctflt-sse.asm
index daeef22a..caf636b5 100644
--- a/simd/i386/jidctflt-sse.asm
+++ b/simd/i386/jidctflt-sse.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
diff --git a/simd/i386/jidctflt-sse2.asm b/simd/i386/jidctflt-sse2.asm
index c39ffbe7..42703a8e 100644
--- a/simd/i386/jidctflt-sse2.asm
+++ b/simd/i386/jidctflt-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
diff --git a/simd/i386/jidctfst-mmx.asm b/simd/i386/jidctfst-mmx.asm
index 19de457f..77d4613d 100644
--- a/simd/i386/jidctfst-mmx.asm
+++ b/simd/i386/jidctfst-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the inverse DCT (Discrete Cosine Transform). The following code is
diff --git a/simd/i386/jidctfst-sse2.asm b/simd/i386/jidctfst-sse2.asm
index 966311ed..c2fe34ba 100644
--- a/simd/i386/jidctfst-sse2.asm
+++ b/simd/i386/jidctfst-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the inverse DCT (Discrete Cosine Transform). The following code is
diff --git a/simd/i386/jidctint-avx2.asm b/simd/i386/jidctint-avx2.asm
index dd4a3d5e..cb119d3f 100644
--- a/simd/i386/jidctint-avx2.asm
+++ b/simd/i386/jidctint-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/i386/jidctint-mmx.asm b/simd/i386/jidctint-mmx.asm
index e2e1b3ff..c2c17f44 100644
--- a/simd/i386/jidctint-mmx.asm
+++ b/simd/i386/jidctint-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/i386/jidctint-sse2.asm b/simd/i386/jidctint-sse2.asm
index 42be940d..70516cad 100644
--- a/simd/i386/jidctint-sse2.asm
+++ b/simd/i386/jidctint-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/i386/jidctred-mmx.asm b/simd/i386/jidctred-mmx.asm
index 920dad90..96cda657 100644
--- a/simd/i386/jidctred-mmx.asm
+++ b/simd/i386/jidctred-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains inverse-DCT routines that produce reduced-size
; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
diff --git a/simd/i386/jidctred-sse2.asm b/simd/i386/jidctred-sse2.asm
index 9a6f9946..1fe967db 100644
--- a/simd/i386/jidctred-sse2.asm
+++ b/simd/i386/jidctred-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains inverse-DCT routines that produce reduced-size
; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
diff --git a/simd/i386/jquant-3dn.asm b/simd/i386/jquant-3dn.asm
index 6436bad1..58e0011f 100644
--- a/simd/i386/jquant-3dn.asm
+++ b/simd/i386/jquant-3dn.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
diff --git a/simd/i386/jquant-mmx.asm b/simd/i386/jquant-mmx.asm
index e525ba9e..4eda95ce 100644
--- a/simd/i386/jquant-mmx.asm
+++ b/simd/i386/jquant-mmx.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -120,8 +116,8 @@ EXTN(jsimd_convsamp_mmx):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_mmx(JCOEFPTR coef_block, DCTELEM *divisors,
diff --git a/simd/i386/jquant-sse.asm b/simd/i386/jquant-sse.asm
index 1cf2cc0c..6cb5f79c 100644
--- a/simd/i386/jquant-sse.asm
+++ b/simd/i386/jquant-sse.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
diff --git a/simd/i386/jquantf-sse2.asm b/simd/i386/jquantf-sse2.asm
index 66efd3ee..5668f8cb 100644
--- a/simd/i386/jquantf-sse2.asm
+++ b/simd/i386/jquantf-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
diff --git a/simd/i386/jquanti-avx2.asm b/simd/i386/jquanti-avx2.asm
index 5ed6bec2..60ae098e 100644
--- a/simd/i386/jquanti-avx2.asm
+++ b/simd/i386/jquanti-avx2.asm
@@ -2,18 +2,14 @@
; jquanti.asm - sample data conversion and quantization (AVX2)
;
; Copyright 2009 Pierre Ossman for Cendio AB
-; Copyright (C) 2016, 2018, D. R. Commander.
+; Copyright (C) 2016, 2018, 2024, D. R. Commander.
; Copyright (C) 2016, Matthieu Darbois.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -107,8 +103,8 @@ EXTN(jsimd_convsamp_avx2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_avx2(JCOEFPTR coef_block, DCTELEM *divisors,
diff --git a/simd/i386/jquanti-sse2.asm b/simd/i386/jquanti-sse2.asm
index 2a69af9c..c1edde99 100644
--- a/simd/i386/jquanti-sse2.asm
+++ b/simd/i386/jquanti-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -98,8 +94,8 @@ EXTN(jsimd_convsamp_sse2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_sse2(JCOEFPTR coef_block, DCTELEM *divisors,
diff --git a/simd/i386/jsimdcpu.asm b/simd/i386/jsimdcpu.asm
index ddcafa9e..df80f17f 100644
--- a/simd/i386/jsimdcpu.asm
+++ b/simd/i386/jsimdcpu.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jccolext-avx2.asm b/simd/x86_64/jccolext-avx2.asm
index 39e6f207..aeeda0a6 100644
--- a/simd/x86_64/jccolext-avx2.asm
+++ b/simd/x86_64/jccolext-avx2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jccolext-sse2.asm b/simd/x86_64/jccolext-sse2.asm
index 2073988d..f3a12449 100644
--- a/simd/x86_64/jccolext-sse2.asm
+++ b/simd/x86_64/jccolext-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jccolor-avx2.asm b/simd/x86_64/jccolor-avx2.asm
index 1f069caa..e2628917 100644
--- a/simd/x86_64/jccolor-avx2.asm
+++ b/simd/x86_64/jccolor-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jccolor-sse2.asm b/simd/x86_64/jccolor-sse2.asm
index c0c1526d..cc9edb4c 100644
--- a/simd/x86_64/jccolor-sse2.asm
+++ b/simd/x86_64/jccolor-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jcgray-avx2.asm b/simd/x86_64/jcgray-avx2.asm
index 354683ca..267ec514 100644
--- a/simd/x86_64/jcgray-avx2.asm
+++ b/simd/x86_64/jcgray-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jcgray-sse2.asm b/simd/x86_64/jcgray-sse2.asm
index d27c4b9a..4b94d7b8 100644
--- a/simd/x86_64/jcgray-sse2.asm
+++ b/simd/x86_64/jcgray-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jcgryext-avx2.asm b/simd/x86_64/jcgryext-avx2.asm
index d2ae6d63..77e85f76 100644
--- a/simd/x86_64/jcgryext-avx2.asm
+++ b/simd/x86_64/jcgryext-avx2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jcgryext-sse2.asm b/simd/x86_64/jcgryext-sse2.asm
index 3c2834e9..3e8087c3 100644
--- a/simd/x86_64/jcgryext-sse2.asm
+++ b/simd/x86_64/jcgryext-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jchuff-sse2.asm b/simd/x86_64/jchuff-sse2.asm
index 39aa2465..b18b7f5d 100644
--- a/simd/x86_64/jchuff-sse2.asm
+++ b/simd/x86_64/jchuff-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation for Huffman coding of one block.
; The following code is based on jchuff.c; see jchuff.c for more details.
diff --git a/simd/x86_64/jcphuff-sse2.asm b/simd/x86_64/jcphuff-sse2.asm
index 0e274046..c9ac59f2 100644
--- a/simd/x86_64/jcphuff-sse2.asm
+++ b/simd/x86_64/jcphuff-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation of data preparation for progressive
; Huffman encoding. See jcphuff.c for more details.
diff --git a/simd/x86_64/jcsample-avx2.asm b/simd/x86_64/jcsample-avx2.asm
index fede6b38..53afc7d7 100644
--- a/simd/x86_64/jcsample-avx2.asm
+++ b/simd/x86_64/jcsample-avx2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jcsample-sse2.asm b/simd/x86_64/jcsample-sse2.asm
index 0a0ee65e..d7ffa930 100644
--- a/simd/x86_64/jcsample-sse2.asm
+++ b/simd/x86_64/jcsample-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jdcolext-avx2.asm b/simd/x86_64/jdcolext-avx2.asm
index a8384cb5..7b8a0843 100644
--- a/simd/x86_64/jdcolext-avx2.asm
+++ b/simd/x86_64/jdcolext-avx2.asm
@@ -11,11 +11,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jdcolext-sse2.asm b/simd/x86_64/jdcolext-sse2.asm
index bfb59abf..261f74da 100644
--- a/simd/x86_64/jdcolext-sse2.asm
+++ b/simd/x86_64/jdcolext-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jdcolor-avx2.asm b/simd/x86_64/jdcolor-avx2.asm
index 4d52a0f1..bd5aa00b 100644
--- a/simd/x86_64/jdcolor-avx2.asm
+++ b/simd/x86_64/jdcolor-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jdcolor-sse2.asm b/simd/x86_64/jdcolor-sse2.asm
index 93d3c8dd..40343fe7 100644
--- a/simd/x86_64/jdcolor-sse2.asm
+++ b/simd/x86_64/jdcolor-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jdmerge-avx2.asm b/simd/x86_64/jdmerge-avx2.asm
index 4be43562..6a5f1dab 100644
--- a/simd/x86_64/jdmerge-avx2.asm
+++ b/simd/x86_64/jdmerge-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jdmerge-sse2.asm b/simd/x86_64/jdmerge-sse2.asm
index a22f6ac7..8c269b83 100644
--- a/simd/x86_64/jdmerge-sse2.asm
+++ b/simd/x86_64/jdmerge-sse2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jdmrgext-avx2.asm b/simd/x86_64/jdmrgext-avx2.asm
index 3392f3a3..01826fb6 100644
--- a/simd/x86_64/jdmrgext-avx2.asm
+++ b/simd/x86_64/jdmrgext-avx2.asm
@@ -11,11 +11,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jdmrgext-sse2.asm b/simd/x86_64/jdmrgext-sse2.asm
index 901db984..abd22e21 100644
--- a/simd/x86_64/jdmrgext-sse2.asm
+++ b/simd/x86_64/jdmrgext-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
diff --git a/simd/x86_64/jdsample-avx2.asm b/simd/x86_64/jdsample-avx2.asm
index 017427a1..6ae4cf81 100644
--- a/simd/x86_64/jdsample-avx2.asm
+++ b/simd/x86_64/jdsample-avx2.asm
@@ -11,11 +11,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jdsample-sse2.asm b/simd/x86_64/jdsample-sse2.asm
index 95c4d4c9..54c560fc 100644
--- a/simd/x86_64/jdsample-sse2.asm
+++ b/simd/x86_64/jdsample-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/simd/x86_64/jfdctflt-sse.asm b/simd/x86_64/jfdctflt-sse.asm
index cf46d93d..58a1f557 100644
--- a/simd/x86_64/jfdctflt-sse.asm
+++ b/simd/x86_64/jfdctflt-sse.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the forward DCT
; (Discrete Cosine Transform). The following code is based directly on
diff --git a/simd/x86_64/jfdctfst-sse2.asm b/simd/x86_64/jfdctfst-sse2.asm
index cdc62365..3b92d4ed 100644
--- a/simd/x86_64/jfdctfst-sse2.asm
+++ b/simd/x86_64/jfdctfst-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the forward DCT (Discrete Cosine Transform). The following code is
diff --git a/simd/x86_64/jfdctint-avx2.asm b/simd/x86_64/jfdctint-avx2.asm
index b6b4c73a..0c452861 100644
--- a/simd/x86_64/jfdctint-avx2.asm
+++ b/simd/x86_64/jfdctint-avx2.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/x86_64/jfdctint-sse2.asm b/simd/x86_64/jfdctint-sse2.asm
index 44e7cd05..3a6be020 100644
--- a/simd/x86_64/jfdctint-sse2.asm
+++ b/simd/x86_64/jfdctint-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/x86_64/jidctflt-sse2.asm b/simd/x86_64/jidctflt-sse2.asm
index c7cb39a0..14437340 100644
--- a/simd/x86_64/jidctflt-sse2.asm
+++ b/simd/x86_64/jidctflt-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
diff --git a/simd/x86_64/jidctfst-sse2.asm b/simd/x86_64/jidctfst-sse2.asm
index fd3bc32c..cffabb83 100644
--- a/simd/x86_64/jidctfst-sse2.asm
+++ b/simd/x86_64/jidctfst-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the inverse DCT (Discrete Cosine Transform). The following code is
diff --git a/simd/x86_64/jidctint-avx2.asm b/simd/x86_64/jidctint-avx2.asm
index 84d125bd..be3b4688 100644
--- a/simd/x86_64/jidctint-avx2.asm
+++ b/simd/x86_64/jidctint-avx2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/x86_64/jidctint-sse2.asm b/simd/x86_64/jidctint-sse2.asm
index 3f098b2c..b186871f 100644
--- a/simd/x86_64/jidctint-sse2.asm
+++ b/simd/x86_64/jidctint-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
diff --git a/simd/x86_64/jidctred-sse2.asm b/simd/x86_64/jidctred-sse2.asm
index 2657cf3c..6fb70956 100644
--- a/simd/x86_64/jidctred-sse2.asm
+++ b/simd/x86_64/jidctred-sse2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains inverse-DCT routines that produce reduced-size
; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
diff --git a/simd/x86_64/jquantf-sse2.asm b/simd/x86_64/jquantf-sse2.asm
index 8bd79662..64763338 100644
--- a/simd/x86_64/jquantf-sse2.asm
+++ b/simd/x86_64/jquantf-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
diff --git a/simd/x86_64/jquanti-avx2.asm b/simd/x86_64/jquanti-avx2.asm
index c8ebd796..7e126e88 100644
--- a/simd/x86_64/jquanti-avx2.asm
+++ b/simd/x86_64/jquanti-avx2.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -93,8 +89,8 @@ EXTN(jsimd_convsamp_avx2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_avx2(JCOEFPTR coef_block, DCTELEM *divisors,
diff --git a/simd/x86_64/jquanti-sse2.asm b/simd/x86_64/jquanti-sse2.asm
index 352d7405..284b9fea 100644
--- a/simd/x86_64/jquanti-sse2.asm
+++ b/simd/x86_64/jquanti-sse2.asm
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -93,8 +89,8 @@ EXTN(jsimd_convsamp_sse2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_sse2(JCOEFPTR coef_block, DCTELEM *divisors,
diff --git a/simd/x86_64/jsimdcpu.asm b/simd/x86_64/jsimdcpu.asm
index 251bc4cd..b72f3b0b 100644
--- a/simd/x86_64/jsimdcpu.asm
+++ b/simd/x86_64/jsimdcpu.asm
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
From 174672af4e0515f4dfc6a6d9b2a0aa7ffc8a45ae Mon Sep 17 00:00:00 2001
From: DRC
Date: Sun, 1 Sep 2024 09:55:52 -0400
Subject: [PATCH 103/135] jquant1.c: Formatting tweak
Extending the Bayer matrix past Column 80 seems like a lesser
readability sin than not putting a space after each comma, especially
since we had to explicitly whitelist the file in checkstyle.
---
jquant1.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/jquant1.c b/jquant1.c
index 2e914b91..bd68dcb8 100644
--- a/jquant1.c
+++ b/jquant1.c
@@ -86,22 +86,22 @@ static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = {
* Stephen Hawley's article "Ordered Dithering" in Graphics Gems I.
* The values in this array must range from 0 to ODITHER_CELLS-1.
*/
- { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 },
- { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
- { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
- { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
- { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 },
- { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
- { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
- { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
- { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 },
- { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
- { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
- { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
- { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 },
- { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
- { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
- { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
+ { 0, 192, 48, 240, 12, 204, 60, 252, 3, 195, 51, 243, 15, 207, 63, 255 },
+ { 128, 64, 176, 112, 140, 76, 188, 124, 131, 67, 179, 115, 143, 79, 191, 127 },
+ { 32, 224, 16, 208, 44, 236, 28, 220, 35, 227, 19, 211, 47, 239, 31, 223 },
+ { 160, 96, 144, 80, 172, 108, 156, 92, 163, 99, 147, 83, 175, 111, 159, 95 },
+ { 8, 200, 56, 248, 4, 196, 52, 244, 11, 203, 59, 251, 7, 199, 55, 247 },
+ { 136, 72, 184, 120, 132, 68, 180, 116, 139, 75, 187, 123, 135, 71, 183, 119 },
+ { 40, 232, 24, 216, 36, 228, 20, 212, 43, 235, 27, 219, 39, 231, 23, 215 },
+ { 168, 104, 152, 88, 164, 100, 148, 84, 171, 107, 155, 91, 167, 103, 151, 87 },
+ { 2, 194, 50, 242, 14, 206, 62, 254, 1, 193, 49, 241, 13, 205, 61, 253 },
+ { 130, 66, 178, 114, 142, 78, 190, 126, 129, 65, 177, 113, 141, 77, 189, 125 },
+ { 34, 226, 18, 210, 46, 238, 30, 222, 33, 225, 17, 209, 45, 237, 29, 221 },
+ { 162, 98, 146, 82, 174, 110, 158, 94, 161, 97, 145, 81, 173, 109, 157, 93 },
+ { 10, 202, 58, 250, 6, 198, 54, 246, 9, 201, 57, 249, 5, 197, 53, 245 },
+ { 138, 74, 186, 122, 134, 70, 182, 118, 137, 73, 185, 121, 133, 69, 181, 117 },
+ { 42, 234, 26, 218, 38, 230, 22, 214, 41, 233, 25, 217, 37, 229, 21, 213 },
+ { 170, 106, 154, 90, 166, 102, 150, 86, 169, 105, 153, 89, 165, 101, 149, 85 }
};
From 7ec70ee891a3e71003f1c186abf337b1595a2ebf Mon Sep 17 00:00:00 2001
From: DRC
Date: Sun, 1 Sep 2024 09:59:10 -0400
Subject: [PATCH 104/135] testclean.cmake: Remove croptest.log
---
cmakescripts/testclean.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/cmakescripts/testclean.cmake b/cmakescripts/testclean.cmake
index 6b5a1460..5f951094 100644
--- a/cmakescripts/testclean.cmake
+++ b/cmakescripts/testclean.cmake
@@ -38,6 +38,7 @@ file(GLOB FILES
*_LOSSL*S_*.bmp
*_LOSSL*S_*.ppm
*_LOSSL*S_*.jpg
+ croptest.log
tjbenchtest*.log
tjexampletest*.log)
From 797c6ccd982800706d7a2cdc31c26b84f271f922 Mon Sep 17 00:00:00 2001
From: DRC
Date: Sun, 1 Sep 2024 11:23:31 -0400
Subject: [PATCH 105/135] Doc: Further clarify MCU definition
---
doc/html/group___turbo_j_p_e_g.html | 4 +--
java/doc/member-search-index.zip | Bin 1951 -> 1951 bytes
java/doc/org/libjpegturbo/turbojpeg/TJ.html | 38 +++++++++++---------
java/doc/package-search-index.zip | Bin 237 -> 237 bytes
java/doc/type-search-index.zip | Bin 311 -> 311 bytes
java/org/libjpegturbo/turbojpeg/TJ.java | 38 +++++++++++---------
turbojpeg.h | 22 +++++++-----
7 files changed, 60 insertions(+), 42 deletions(-)
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index f55c748b..63628c7b 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -3485,7 +3485,7 @@ If you choose option 1, then dstSizes[i] should be set to the size
iMCU height (in pixels) for a given level of chrominance subsampling
-
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The combination of the full-resolution luminance block(s) and the (possibly subsampled) chrominance blocks corresponding to the same pixels is called a "Minimum Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
+
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The minimum set of full-resolution luminance block(s) and corresponding (possibly subsampled) chrominance blocks necessary to represent at least one DCT block per component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of two luminance blocks followed by one block for each chrominance component.) In a non-interleaved lossy JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
iMCU sizes:
8x8 for no subsampling or grayscale
16x8 for 4:2:2
@@ -3518,7 +3518,7 @@ If you choose option 1, then dstSizes[i] should be set to the size
iMCU width (in pixels) for a given level of chrominance subsampling
-
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The combination of the full-resolution luminance block(s) and the (possibly subsampled) chrominance blocks corresponding to the same pixels is called a "Minimum Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
+
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The minimum set of full-resolution luminance block(s) and corresponding (possibly subsampled) chrominance blocks necessary to represent at least one DCT block per component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of two luminance blocks followed by one block for each chrominance component.) In a non-interleaved lossy JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
iMCU sizes:
8x8 for no subsampling or grayscale
16x8 for 4:2:2
diff --git a/java/doc/member-search-index.zip b/java/doc/member-search-index.zip
index 8a463469d650bd97f55a6c3b1e5eff782cefb6d3..3d1f1cbc3ba2a32331dd193bb989990db043488b 100644
GIT binary patch
delta 30
kcmbQwKcAmBz?+#xgn@&DgFz!&aU-u2J2Q};9K`Mm09VKb!vFvP
delta 30
kcmbQwKcAmBz?+#xgn@&DgF(DTej~3FJ2Q};9K`Mm09e8W-v9sr
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJ.html b/java/doc/org/libjpegturbo/turbojpeg/TJ.html
index ef8a7b0c..ea04ee2d 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJ.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJ.html
@@ -2199,14 +2199,17 @@ public static final int FLAG_LIMITSCANS
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
component are interleaved in a single scan. If the image uses chrominance
subsampling, then multiple luminance blocks are stored together, followed
- by a single block for each chrominance component. The combination of the
- full-resolution luminance block(s) and the (possibly subsampled)
- chrominance blocks corresponding to the same pixels is called a "Minimum
- Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
- is stored in a separate scan, and an MCU is a single DCT block, so we use
- the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
- an interleaved JPEG image. For the common case of interleaved JPEG
- images, an iMCU is the same as an MCU.
+ by a single block for each chrominance component. The minimum set of
+ full-resolution luminance block(s) and corresponding (possibly subsampled)
+ chrominance blocks necessary to represent at least one DCT block per
+ component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ two luminance blocks followed by one block for each chrominance
+ component.) In a non-interleaved lossy JPEG image, each component is
+ stored in a separate scan, and an MCU is a single DCT block, so we use the
+ term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an
+ interleaved JPEG image. For the common case of interleaved JPEG images,
+ an iMCU is the same as an MCU.
Parameters:
subsamp - the level of chrominance subsampling (one of
@@ -2228,14 +2231,17 @@ public static final int FLAG_LIMITSCANS
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
component are interleaved in a single scan. If the image uses chrominance
subsampling, then multiple luminance blocks are stored together, followed
- by a single block for each chrominance component. The combination of the
- full-resolution luminance block(s) and the (possibly subsampled)
- chrominance blocks corresponding to the same pixels is called a "Minimum
- Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
- is stored in a separate scan, and an MCU is a single DCT block, so we use
- the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
- an interleaved JPEG image. For the common case of interleaved JPEG
- images, an iMCU is the same as an MCU.
+ by a single block for each chrominance component. The minimum set of
+ full-resolution luminance block(s) and corresponding (possibly subsampled)
+ chrominance blocks necessary to represent at least one DCT block per
+ component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ two luminance blocks followed by one block for each chrominance
+ component.) In a non-interleaved lossy JPEG image, each component is
+ stored in a separate scan, and an MCU is a single DCT block, so we use the
+ term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an
+ interleaved JPEG image. For the common case of interleaved JPEG images,
+ an iMCU is the same as an MCU.
Parameters:
subsamp - the level of chrominance subsampling (one of
diff --git a/java/doc/package-search-index.zip b/java/doc/package-search-index.zip
index 929c54dd2fcdaedd10377ea676ddb38adfc6f5c5..529fefc6d39a1242905cb7daf4731019df3e66fe 100644
GIT binary patch
delta 28
hcmaFM_?D43z?+#xgn@&DgFz!&aUyR&Gl-h+2LN4=2Ce`A
delta 28
hcmaFM_?D43z?+#xgn@&DgF(DTej;x_Gl-h+2LN7R2Fd^c
diff --git a/java/doc/type-search-index.zip b/java/doc/type-search-index.zip
index bc0a78c5ebcde41ce8164adf6f07c2741bbcda50..8e9a21c7ae964eabbfd98708c2604f08dff4fd21 100644
GIT binary patch
delta 28
hcmdnaw4I4Jz?+#xgn@&DgFz!&aU$;>W)Stp8vs>b2HOAt
delta 28
hcmdnaw4I4Jz?+#xgn@&DgF(DTej@K3W)Stp8vs@>2KN8}
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index 04c68cf9..cb60c29f 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -126,14 +126,17 @@ public final class TJ {
*
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
* component are interleaved in a single scan. If the image uses chrominance
* subsampling, then multiple luminance blocks are stored together, followed
- * by a single block for each chrominance component. The combination of the
- * full-resolution luminance block(s) and the (possibly subsampled)
- * chrominance blocks corresponding to the same pixels is called a "Minimum
- * Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
- * is stored in a separate scan, and an MCU is a single DCT block, so we use
- * the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
- * an interleaved JPEG image. For the common case of interleaved JPEG
- * images, an iMCU is the same as an MCU.
+ * by a single block for each chrominance component. The minimum set of
+ * full-resolution luminance block(s) and corresponding (possibly subsampled)
+ * chrominance blocks necessary to represent at least one DCT block per
+ * component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ * in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ * two luminance blocks followed by one block for each chrominance
+ * component.) In a non-interleaved lossy JPEG image, each component is
+ * stored in a separate scan, and an MCU is a single DCT block, so we use the
+ * term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an
+ * interleaved JPEG image. For the common case of interleaved JPEG images,
+ * an iMCU is the same as an MCU.
*
* @param subsamp the level of chrominance subsampling (one of
* {@link #SAMP_444 SAMP_*})
@@ -156,14 +159,17 @@ public final class TJ {
*
In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
* component are interleaved in a single scan. If the image uses chrominance
* subsampling, then multiple luminance blocks are stored together, followed
- * by a single block for each chrominance component. The combination of the
- * full-resolution luminance block(s) and the (possibly subsampled)
- * chrominance blocks corresponding to the same pixels is called a "Minimum
- * Coded Unit" (MCU.) In a non-interleaved lossy JPEG image, each component
- * is stored in a separate scan, and an MCU is a single DCT block, so we use
- * the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in
- * an interleaved JPEG image. For the common case of interleaved JPEG
- * images, an iMCU is the same as an MCU.
+ * by a single block for each chrominance component. The minimum set of
+ * full-resolution luminance block(s) and corresponding (possibly subsampled)
+ * chrominance blocks necessary to represent at least one DCT block per
+ * component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ * in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ * two luminance blocks followed by one block for each chrominance
+ * component.) In a non-interleaved lossy JPEG image, each component is
+ * stored in a separate scan, and an MCU is a single DCT block, so we use the
+ * term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an
+ * interleaved JPEG image. For the common case of interleaved JPEG images,
+ * an iMCU is the same as an MCU.
*
* @param subsamp the level of chrominance subsampling (one of
* {@link #SAMP_444 SAMP_*})
diff --git a/turbojpeg.h b/turbojpeg.h
index 4dfe45c9..c431c9d4 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -201,10 +201,13 @@ enum TJSAMP {
* In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
* component are interleaved in a single scan. If the image uses chrominance
* subsampling, then multiple luminance blocks are stored together, followed by
- * a single block for each chrominance component. The combination of the
- * full-resolution luminance block(s) and the (possibly subsampled) chrominance
- * blocks corresponding to the same pixels is called a "Minimum Coded Unit"
- * (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a
+ * a single block for each chrominance component. The minimum set of
+ * full-resolution luminance block(s) and corresponding (possibly subsampled)
+ * chrominance blocks necessary to represent at least one DCT block per
+ * component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ * in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ * two luminance blocks followed by one block for each chrominance component.)
+ * In a non-interleaved lossy JPEG image, each component is stored in a
* separate scan, and an MCU is a single DCT block, so we use the term "iMCU"
* (interleaved MCU) to refer to the equivalent of an MCU in an interleaved
* JPEG image. For the common case of interleaved JPEG images, an iMCU is the
@@ -226,10 +229,13 @@ static const int tjMCUWidth[TJ_NUMSAMP] = { 8, 16, 16, 8, 8, 32, 8 };
* In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
* component are interleaved in a single scan. If the image uses chrominance
* subsampling, then multiple luminance blocks are stored together, followed by
- * a single block for each chrominance component. The combination of the
- * full-resolution luminance block(s) and the (possibly subsampled) chrominance
- * blocks corresponding to the same pixels is called a "Minimum Coded Unit"
- * (MCU.) In a non-interleaved lossy JPEG image, each component is stored in a
+ * a single block for each chrominance component. The minimum set of
+ * full-resolution luminance block(s) and corresponding (possibly subsampled)
+ * chrominance blocks necessary to represent at least one DCT block per
+ * component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ * in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ * two luminance blocks followed by one block for each chrominance component.)
+ * In a non-interleaved lossy JPEG image, each component is stored in a
* separate scan, and an MCU is a single DCT block, so we use the term "iMCU"
* (interleaved MCU) to refer to the equivalent of an MCU in an interleaved
* JPEG image. For the common case of interleaved JPEG images, an iMCU is the
From 843d04d9d4ab0ac46ce65279ea56262853ff85d6 Mon Sep 17 00:00:00 2001
From: DRC
Date: Sun, 1 Sep 2024 11:52:01 -0400
Subject: [PATCH 106/135] CI: Run regression tests in parallel
---
.github/workflows/build.yml | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9bd75297..80b090a7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -105,10 +105,10 @@ jobs:
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" -DENABLE_SHARED=0 ..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
- make test
- JSIMD_FORCESSE2=1 make test
+ ctest -j$NUMCPUS
+ JSIMD_FORCESSE2=1 ctest -j$NUMCPUS
cmake -DFLOATTEST8=no-fp-contract ..
- JSIMD_FORCENONE=1 make test
+ JSIMD_FORCENONE=1 ctest -j$NUMCPUS
popd
linux-jpeg7-x32:
runs-on: ubuntu-20.04
@@ -130,10 +130,10 @@ jobs:
..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
- make test
- JSIMD_FORCESSE2=1 make test
+ ctest -j$NUMCPUS
+ JSIMD_FORCESSE2=1 ctest -j$NUMCPUS
cmake -DFLOATTEST8=no-fp-contract ..
- JSIMD_FORCENONE=1 make test
+ JSIMD_FORCENONE=1 ctest -j$NUMCPUS
popd
linux-jpeg8:
runs-on: ubuntu-latest
@@ -155,10 +155,10 @@ jobs:
..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
- make test
- JSIMD_FORCESSE2=1 make test
+ ctest -j$NUMCPUS
+ JSIMD_FORCESSE2=1 ctest -j$NUMCPUS
cmake -DFLOATTEST8=no-fp-contract ..
- JSIMD_FORCENONE=1 make test
+ JSIMD_FORCENONE=1 ctest -j$NUMCPUS
popd
linux-msan:
runs-on: ubuntu-latest
@@ -178,5 +178,5 @@ jobs:
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O0 -g -fsanitize=memory -fsanitize-memory-param-retval -fno-sanitize-recover=all -fPIE -DZERO_BUFFERS=1" -DREQUIRE_SIMD=1 ..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
- make test
+ ctest -j$NUMCPUS
popd
From f5f8f5aadc82e6d4c13187311626342f722ba6e4 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 3 Sep 2024 08:59:37 -0400
Subject: [PATCH 107/135] TJ: Reorder functions to improve readability
Put all general functions at the top of the list, and ensure that all
functions are defined before they are mentioned. Also consistify the
function ordering between turbojpeg.h and turbojpeg.c
---
doc/html/group___turbo_j_p_e_g.html | 78 +-
turbojpeg.c | 1362 +++++++++++++--------------
turbojpeg.h | 694 +++++++-------
3 files changed, 1067 insertions(+), 1067 deletions(-)
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index 63628c7b..eea39969 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -271,27 +271,27 @@ Functions
tj3Compress8 (tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, size_t *jpegSize)
-
Compress an 8-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into an 8-bit-per-sample JPEG image.
-
-
DLLEXPORT int
tj3Compress12 (tjhandle handle, const short *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, size_t *jpegSize)
-
Compress a 12-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into a 12-bit-per-sample JPEG image.
-
-
DLLEXPORT int
tj3Compress16 (tjhandle handle, const unsigned short *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, size_t *jpegSize)
-
Compress a 16-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into a 16-bit-per-sample lossless JPEG image.
-
-
DLLEXPORT int
tj3CompressFromYUV8 (tjhandle handle, const unsigned char *srcBuf, int width, int align, int height, unsigned char **jpegBuf, size_t *jpegSize)
-
Compress an 8-bit-per-sample unified planar YUV image into an 8-bit-per-sample JPEG image.
-
-
DLLEXPORT int
tj3CompressFromYUVPlanes8 (tjhandle handle, const unsigned char *const *srcPlanes, int width, const int *strides, int height, unsigned char **jpegBuf, size_t *jpegSize)
-
Compress a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into an 8-bit-per-sample JPEG image.
The plane height of a YUV image plane with the given parameters.
-
DLLEXPORT int
tj3EncodeYUV8 (tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char *dstBuf, int align)
-
Encode an 8-bit-per-sample packed-pixel RGB or grayscale image into an 8-bit-per-sample unified planar YUV image.
-
+
DLLEXPORT int
tj3Compress8 (tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, size_t *jpegSize)
+
Compress an 8-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into an 8-bit-per-sample JPEG image.
+
+
DLLEXPORT int
tj3Compress12 (tjhandle handle, const short *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, size_t *jpegSize)
+
Compress a 12-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into a 12-bit-per-sample JPEG image.
+
+
DLLEXPORT int
tj3Compress16 (tjhandle handle, const unsigned short *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, size_t *jpegSize)
+
Compress a 16-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into a 16-bit-per-sample lossless JPEG image.
+
+
DLLEXPORT int
tj3CompressFromYUVPlanes8 (tjhandle handle, const unsigned char *const *srcPlanes, int width, const int *strides, int height, unsigned char **jpegBuf, size_t *jpegSize)
+
Compress a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into an 8-bit-per-sample JPEG image.
+
+
DLLEXPORT int
tj3CompressFromYUV8 (tjhandle handle, const unsigned char *srcBuf, int width, int align, int height, unsigned char **jpegBuf, size_t *jpegSize)
+
Compress an 8-bit-per-sample unified planar YUV image into an 8-bit-per-sample JPEG image.
+
DLLEXPORT int
tj3EncodeYUVPlanes8 (tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **dstPlanes, int *strides)
Encode an 8-bit-per-sample packed-pixel RGB or grayscale image into separate 8-bit-per-sample Y, U (Cb), and V (Cr) image planes.
+
DLLEXPORT int
tj3EncodeYUV8 (tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char *dstBuf, int align)
+
Encode an 8-bit-per-sample packed-pixel RGB or grayscale image into an 8-bit-per-sample unified planar YUV image.
Decompress an 8-bit-per-sample JPEG image into an 8-bit-per-sample unified planar YUV image.
+
DLLEXPORT int
tj3DecodeYUVPlanes8 (tjhandle handle, const unsigned char *const *srcPlanes, const int *strides, unsigned char *dstBuf, int width, int pitch, int height, int pixelFormat)
Decode a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into an 8-bit-per-sample packed-pixel RGB or grayscale image.
+
DLLEXPORT int
tj3DecodeYUV8 (tjhandle handle, const unsigned char *srcBuf, int align, unsigned char *dstBuf, int width, int pitch, int height, int pixelFormat)
+
Decode an 8-bit-per-sample unified planar YUV image into an 8-bit-per-sample packed-pixel RGB or grayscale image.
+
DLLEXPORT int
tj3Transform (tjhandle handle, const unsigned char *jpegBuf, size_t jpegSize, int n, unsigned char **dstBufs, size_t *dstSizes, const tjtransform *transforms)
Losslessly transform a JPEG image into another JPEG image.
Returns a code indicating the severity of the last error.
-
Variables
diff --git a/turbojpeg.c b/turbojpeg.c
index d02678b1..ceaa70b3 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -573,6 +573,83 @@ bailout:
}
+/* TurboJPEG 3+ */
+DLLEXPORT void tj3Destroy(tjhandle handle)
+{
+ tjinstance *this = (tjinstance *)handle;
+ j_compress_ptr cinfo = NULL;
+ j_decompress_ptr dinfo = NULL;
+
+ if (!this) return;
+
+ cinfo = &this->cinfo; dinfo = &this->dinfo;
+ this->jerr.warning = FALSE;
+ this->isInstanceError = FALSE;
+
+ if (setjmp(this->jerr.setjmp_buffer)) return;
+ if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
+ if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
+ free(this);
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT int tjDestroy(tjhandle handle)
+{
+ static const char FUNCTION_NAME[] = "tjDestroy";
+ int retval = 0;
+
+ if (!handle) THROWG("Invalid handle", -1);
+
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "No error");
+ tj3Destroy(handle);
+ if (strcmp(errStr, "No error")) retval = -1;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3+ */
+DLLEXPORT char *tj3GetErrorStr(tjhandle handle)
+{
+ tjinstance *this = (tjinstance *)handle;
+
+ if (this && this->isInstanceError) {
+ this->isInstanceError = FALSE;
+ return this->errStr;
+ } else
+ return errStr;
+}
+
+/* TurboJPEG 2.0+ */
+DLLEXPORT char *tjGetErrorStr2(tjhandle handle)
+{
+ return tj3GetErrorStr(handle);
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT char *tjGetErrorStr(void)
+{
+ return errStr;
+}
+
+
+/* TurboJPEG 3+ */
+DLLEXPORT int tj3GetErrorCode(tjhandle handle)
+{
+ tjinstance *this = (tjinstance *)handle;
+
+ if (this && this->jerr.warning) return TJERR_WARNING;
+ else return TJERR_FATAL;
+}
+
+/* TurboJPEG 2.0+ */
+DLLEXPORT int tjGetErrorCode(tjhandle handle)
+{
+ return tj3GetErrorCode(handle);
+}
+
+
#define SET_PARAM(field, minValue, maxValue) { \
if (value < minValue || (maxValue > 0 && value > maxValue)) \
THROW("Parameter value out of range"); \
@@ -781,101 +858,11 @@ DLLEXPORT int tj3Get(tjhandle handle, int param)
}
-/* TurboJPEG 3+ */
-DLLEXPORT char *tj3GetErrorStr(tjhandle handle)
-{
- tjinstance *this = (tjinstance *)handle;
-
- if (this && this->isInstanceError) {
- this->isInstanceError = FALSE;
- return this->errStr;
- } else
- return errStr;
-}
-
-/* TurboJPEG 2.0+ */
-DLLEXPORT char *tjGetErrorStr2(tjhandle handle)
-{
- return tj3GetErrorStr(handle);
-}
-
-/* TurboJPEG 1.0+ */
-DLLEXPORT char *tjGetErrorStr(void)
-{
- return errStr;
-}
-
-
-/* TurboJPEG 3+ */
-DLLEXPORT int tj3GetErrorCode(tjhandle handle)
-{
- tjinstance *this = (tjinstance *)handle;
-
- if (this && this->jerr.warning) return TJERR_WARNING;
- else return TJERR_FATAL;
-}
-
-/* TurboJPEG 2.0+ */
-DLLEXPORT int tjGetErrorCode(tjhandle handle)
-{
- return tj3GetErrorCode(handle);
-}
-
-
-/* TurboJPEG 3+ */
-DLLEXPORT void tj3Destroy(tjhandle handle)
-{
- tjinstance *this = (tjinstance *)handle;
- j_compress_ptr cinfo = NULL;
- j_decompress_ptr dinfo = NULL;
-
- if (!this) return;
-
- cinfo = &this->cinfo; dinfo = &this->dinfo;
- this->jerr.warning = FALSE;
- this->isInstanceError = FALSE;
-
- if (setjmp(this->jerr.setjmp_buffer)) return;
- if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
- if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
- free(this);
-}
-
-/* TurboJPEG 1.0+ */
-DLLEXPORT int tjDestroy(tjhandle handle)
-{
- static const char FUNCTION_NAME[] = "tjDestroy";
- int retval = 0;
-
- if (!handle) THROWG("Invalid handle", -1);
-
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "No error");
- tj3Destroy(handle);
- if (strcmp(errStr, "No error")) retval = -1;
-
-bailout:
- return retval;
-}
-
-
/* These are exposed mainly because Windows can't malloc() and free() across
DLL boundaries except when the CRT DLL is used, and we don't use the CRT DLL
with turbojpeg.dll for compatibility reasons. However, these functions
can potentially be used for other purposes by different implementations. */
-/* TurboJPEG 3+ */
-DLLEXPORT void tj3Free(void *buf)
-{
- free(buf);
-}
-
-/* TurboJPEG 1.2+ */
-DLLEXPORT void tjFree(unsigned char *buf)
-{
- tj3Free(buf);
-}
-
-
/* TurboJPEG 3+ */
DLLEXPORT void *tj3Alloc(size_t bytes)
{
@@ -889,42 +876,16 @@ DLLEXPORT unsigned char *tjAlloc(int bytes)
}
-/******************************** Compressor *********************************/
-
-static tjhandle _tjInitCompress(tjinstance *this)
+/* TurboJPEG 3+ */
+DLLEXPORT void tj3Free(void *buf)
{
- static unsigned char buffer[1];
- unsigned char *buf = buffer;
- size_t size = 1;
-
- /* This is also straight out of example.c */
- this->cinfo.err = jpeg_std_error(&this->jerr.pub);
- this->jerr.pub.error_exit = my_error_exit;
- this->jerr.pub.output_message = my_output_message;
- this->jerr.emit_message = this->jerr.pub.emit_message;
- this->jerr.pub.emit_message = my_emit_message;
- this->jerr.pub.addon_message_table = turbojpeg_message_table;
- this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
- this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- free(this);
- return NULL;
- }
-
- jpeg_create_compress(&this->cinfo);
- /* Make an initial call so it will create the destination manager */
- jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
-
- this->init |= COMPRESS;
- return (tjhandle)this;
+ free(buf);
}
-/* TurboJPEG 1.0+ */
-DLLEXPORT tjhandle tjInitCompress(void)
+/* TurboJPEG 1.2+ */
+DLLEXPORT void tjFree(unsigned char *buf)
{
- return tj3Init(TJINIT_COMPRESS);
+ tj3Free(buf);
}
@@ -1045,6 +1006,43 @@ DLLEXPORT unsigned long TJBUFSIZEYUV(int width, int height, int subsamp)
}
+/* TurboJPEG 3+ */
+DLLEXPORT size_t tj3YUVPlaneSize(int componentID, int width, int stride,
+ int height, int subsamp)
+{
+ static const char FUNCTION_NAME[] = "tj3YUVPlaneSize";
+ unsigned long long retval = 0;
+ int pw, ph;
+
+ if (width < 1 || height < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROWG("Invalid argument", 0);
+
+ pw = tj3YUVPlaneWidth(componentID, width, subsamp);
+ ph = tj3YUVPlaneHeight(componentID, height, subsamp);
+ if (pw == 0 || ph == 0) return 0;
+
+ if (stride == 0) stride = pw;
+ else stride = abs(stride);
+
+ retval = (unsigned long long)stride * (ph - 1) + pw;
+#if ULLONG_MAX > ULONG_MAX
+ if (retval > (unsigned long long)((unsigned long)-1))
+ THROWG("Image is too large", 0);
+#endif
+
+bailout:
+ return (size_t)retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
+ int height, int subsamp)
+{
+ size_t retval = tj3YUVPlaneSize(componentID, width, stride, height, subsamp);
+ return (retval == 0) ? -1 : (unsigned long)retval;
+}
+
+
/* TurboJPEG 3+ */
DLLEXPORT int tj3YUVPlaneWidth(int componentID, int width, int subsamp)
{
@@ -1113,40 +1111,42 @@ DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp)
}
-/* TurboJPEG 3+ */
-DLLEXPORT size_t tj3YUVPlaneSize(int componentID, int width, int stride,
- int height, int subsamp)
+/******************************** Compressor *********************************/
+
+static tjhandle _tjInitCompress(tjinstance *this)
{
- static const char FUNCTION_NAME[] = "tj3YUVPlaneSize";
- unsigned long long retval = 0;
- int pw, ph;
+ static unsigned char buffer[1];
+ unsigned char *buf = buffer;
+ size_t size = 1;
- if (width < 1 || height < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROWG("Invalid argument", 0);
+ /* This is also straight out of example.c */
+ this->cinfo.err = jpeg_std_error(&this->jerr.pub);
+ this->jerr.pub.error_exit = my_error_exit;
+ this->jerr.pub.output_message = my_output_message;
+ this->jerr.emit_message = this->jerr.pub.emit_message;
+ this->jerr.pub.emit_message = my_emit_message;
+ this->jerr.pub.addon_message_table = turbojpeg_message_table;
+ this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
+ this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
- pw = tj3YUVPlaneWidth(componentID, width, subsamp);
- ph = tj3YUVPlaneHeight(componentID, height, subsamp);
- if (pw == 0 || ph == 0) return 0;
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ free(this);
+ return NULL;
+ }
- if (stride == 0) stride = pw;
- else stride = abs(stride);
+ jpeg_create_compress(&this->cinfo);
+ /* Make an initial call so it will create the destination manager */
+ jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
- retval = (unsigned long long)stride * (ph - 1) + pw;
-#if ULLONG_MAX > ULONG_MAX
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("Image is too large", 0);
-#endif
-
-bailout:
- return (size_t)retval;
+ this->init |= COMPRESS;
+ return (tjhandle)this;
}
-/* TurboJPEG 1.4+ */
-DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
- int height, int subsamp)
+/* TurboJPEG 1.0+ */
+DLLEXPORT tjhandle tjInitCompress(void)
{
- size_t retval = tj3YUVPlaneSize(componentID, width, stride, height, subsamp);
- return (retval == 0) ? -1 : (unsigned long)retval;
+ return tj3Init(TJINIT_COMPRESS);
}
@@ -1214,6 +1214,251 @@ DLLEXPORT int tjCompress(tjhandle handle, unsigned char *srcBuf, int width,
}
+/* TurboJPEG 3+ */
+DLLEXPORT int tj3CompressFromYUVPlanes8(tjhandle handle,
+ const unsigned char * const *srcPlanes,
+ int width, const int *strides,
+ int height, unsigned char **jpegBuf,
+ size_t *jpegSize)
+{
+ static const char FUNCTION_NAME[] = "tj3CompressFromYUVPlanes8";
+ int i, row, retval = 0;
+ boolean alloc = TRUE;
+ int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
+ tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
+ JSAMPLE *_tmpbuf = NULL, *ptr;
+ JSAMPROW *inbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
+
+ GET_CINSTANCE(handle)
+
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ tmpbuf[i] = NULL; inbuf[i] = NULL;
+ }
+
+ if ((this->init & COMPRESS) == 0)
+ THROW("Instance has not been initialized for compression");
+
+ if (!srcPlanes || !srcPlanes[0] || width <= 0 || height <= 0 ||
+ jpegBuf == NULL || jpegSize == NULL)
+ THROW("Invalid argument");
+ if (this->subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
+ THROW("Invalid argument");
+
+ if (this->quality == -1)
+ THROW("TJPARAM_QUALITY must be specified");
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ cinfo->image_width = width;
+ cinfo->image_height = height;
+ cinfo->data_precision = 8;
+
+ if (this->noRealloc) {
+ alloc = FALSE; *jpegSize = tj3JPEGBufSize(width, height, this->subsamp);
+ }
+ jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
+ setCompDefaults(this, TJPF_RGB);
+ cinfo->raw_data_in = TRUE;
+
+ jpeg_start_compress(cinfo, TRUE);
+ for (i = 0; i < cinfo->num_components; i++) {
+ jpeg_component_info *compptr = &cinfo->comp_info[i];
+ int ih;
+
+ iw[i] = compptr->width_in_blocks * DCTSIZE;
+ ih = compptr->height_in_blocks * DCTSIZE;
+ pw[i] = PAD(cinfo->image_width, cinfo->max_h_samp_factor) *
+ compptr->h_samp_factor / cinfo->max_h_samp_factor;
+ ph[i] = PAD(cinfo->image_height, cinfo->max_v_samp_factor) *
+ compptr->v_samp_factor / cinfo->max_v_samp_factor;
+ if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
+ th[i] = compptr->v_samp_factor * DCTSIZE;
+ tmpbufsize += iw[i] * th[i];
+ if ((inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
+ THROW("Memory allocation failure");
+ ptr = (JSAMPLE *)srcPlanes[i];
+ for (row = 0; row < ph[i]; row++) {
+ inbuf[i][row] = ptr;
+ ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
+ }
+ }
+ if (usetmpbuf) {
+ if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
+ THROW("Memory allocation failure");
+ ptr = _tmpbuf;
+ for (i = 0; i < cinfo->num_components; i++) {
+ if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
+ THROW("Memory allocation failure");
+ for (row = 0; row < th[i]; row++) {
+ tmpbuf[i][row] = ptr;
+ ptr += iw[i];
+ }
+ }
+ }
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ for (row = 0; row < (int)cinfo->image_height;
+ row += cinfo->max_v_samp_factor * DCTSIZE) {
+ JSAMPARRAY yuvptr[MAX_COMPONENTS];
+ int crow[MAX_COMPONENTS];
+
+ for (i = 0; i < cinfo->num_components; i++) {
+ jpeg_component_info *compptr = &cinfo->comp_info[i];
+
+ crow[i] = row * compptr->v_samp_factor / cinfo->max_v_samp_factor;
+ if (usetmpbuf) {
+ int j, k;
+
+ for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
+ memcpy(tmpbuf[i][j], inbuf[i][crow[i] + j], pw[i]);
+ /* Duplicate last sample in row to fill out MCU */
+ for (k = pw[i]; k < iw[i]; k++)
+ tmpbuf[i][j][k] = tmpbuf[i][j][pw[i] - 1];
+ }
+ /* Duplicate last row to fill out MCU */
+ for (j = ph[i] - crow[i]; j < th[i]; j++)
+ memcpy(tmpbuf[i][j], tmpbuf[i][ph[i] - crow[i] - 1], iw[i]);
+ yuvptr[i] = tmpbuf[i];
+ } else
+ yuvptr[i] = &inbuf[i][crow[i]];
+ }
+ jpeg_write_raw_data(cinfo, yuvptr, cinfo->max_v_samp_factor * DCTSIZE);
+ }
+ jpeg_finish_compress(cinfo);
+
+bailout:
+ if (cinfo->global_state > CSTATE_START && alloc)
+ (*cinfo->dest->term_destination) (cinfo);
+ if (cinfo->global_state > CSTATE_START || retval == -1)
+ jpeg_abort_compress(cinfo);
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ free(tmpbuf[i]);
+ free(inbuf[i]);
+ }
+ free(_tmpbuf);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
+ const unsigned char **srcPlanes,
+ int width, const int *strides,
+ int height, int subsamp,
+ unsigned char **jpegBuf,
+ unsigned long *jpegSize, int jpegQual,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjCompressFromYUVPlanes";
+ int retval = 0;
+ size_t size;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP || jpegSize == NULL ||
+ jpegQual < 0 || jpegQual > 100)
+ THROW("Invalid argument");
+
+ this->quality = jpegQual;
+ this->subsamp = subsamp;
+ processFlags(handle, flags, COMPRESS);
+
+ size = (size_t)(*jpegSize);
+ retval = tj3CompressFromYUVPlanes8(handle, srcPlanes, width, strides, height,
+ jpegBuf, &size);
+ *jpegSize = (unsigned long)size;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3+ */
+DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
+ const unsigned char *srcBuf, int width,
+ int align, int height,
+ unsigned char **jpegBuf, size_t *jpegSize)
+{
+ static const char FUNCTION_NAME[] = "tj3CompressFromYUV8";
+ const unsigned char *srcPlanes[3];
+ int pw0, ph0, strides[3], retval = -1;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (srcBuf == NULL || width <= 0 || align < 1 || !IS_POW2(align) ||
+ height <= 0)
+ THROW("Invalid argument");
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
+ ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
+ srcPlanes[0] = srcBuf;
+ strides[0] = PAD(pw0, align);
+ if (this->subsamp == TJSAMP_GRAY) {
+ strides[1] = strides[2] = 0;
+ srcPlanes[1] = srcPlanes[2] = NULL;
+ } else {
+ int pw1 = tjPlaneWidth(1, width, this->subsamp);
+ int ph1 = tjPlaneHeight(1, height, this->subsamp);
+
+ strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
+ srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
+ srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
+ }
+
+ return tj3CompressFromYUVPlanes8(handle, srcPlanes, width, strides, height,
+ jpegBuf, jpegSize);
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
+ int width, int align, int height, int subsamp,
+ unsigned char **jpegBuf,
+ unsigned long *jpegSize, int jpegQual,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjCompressFromYUV";
+ int retval = -1;
+ size_t size;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->quality = jpegQual;
+ this->subsamp = subsamp;
+ processFlags(handle, flags, COMPRESS);
+
+ size = (size_t)(*jpegSize);
+ retval = tj3CompressFromYUV8(handle, srcBuf, width, align, height, jpegBuf,
+ &size);
+ *jpegSize = (unsigned long)size;
+
+bailout:
+ return retval;
+}
+
+
/* TurboJPEG 3+ */
DLLEXPORT int tj3EncodeYUVPlanes8(tjhandle handle, const unsigned char *srcBuf,
int width, int pitch, int height,
@@ -1484,251 +1729,6 @@ DLLEXPORT int tjEncodeYUV(tjhandle handle, unsigned char *srcBuf, int width,
}
-/* TurboJPEG 3+ */
-DLLEXPORT int tj3CompressFromYUVPlanes8(tjhandle handle,
- const unsigned char * const *srcPlanes,
- int width, const int *strides,
- int height, unsigned char **jpegBuf,
- size_t *jpegSize)
-{
- static const char FUNCTION_NAME[] = "tj3CompressFromYUVPlanes8";
- int i, row, retval = 0;
- boolean alloc = TRUE;
- int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
- tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
- JSAMPLE *_tmpbuf = NULL, *ptr;
- JSAMPROW *inbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
-
- GET_CINSTANCE(handle)
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; inbuf[i] = NULL;
- }
-
- if ((this->init & COMPRESS) == 0)
- THROW("Instance has not been initialized for compression");
-
- if (!srcPlanes || !srcPlanes[0] || width <= 0 || height <= 0 ||
- jpegBuf == NULL || jpegSize == NULL)
- THROW("Invalid argument");
- if (this->subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
- THROW("Invalid argument");
-
- if (this->quality == -1)
- THROW("TJPARAM_QUALITY must be specified");
- if (this->subsamp == TJSAMP_UNKNOWN)
- THROW("TJPARAM_SUBSAMP must be specified");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- cinfo->image_width = width;
- cinfo->image_height = height;
- cinfo->data_precision = 8;
-
- if (this->noRealloc) {
- alloc = FALSE; *jpegSize = tj3JPEGBufSize(width, height, this->subsamp);
- }
- jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
- setCompDefaults(this, TJPF_RGB);
- cinfo->raw_data_in = TRUE;
-
- jpeg_start_compress(cinfo, TRUE);
- for (i = 0; i < cinfo->num_components; i++) {
- jpeg_component_info *compptr = &cinfo->comp_info[i];
- int ih;
-
- iw[i] = compptr->width_in_blocks * DCTSIZE;
- ih = compptr->height_in_blocks * DCTSIZE;
- pw[i] = PAD(cinfo->image_width, cinfo->max_h_samp_factor) *
- compptr->h_samp_factor / cinfo->max_h_samp_factor;
- ph[i] = PAD(cinfo->image_height, cinfo->max_v_samp_factor) *
- compptr->v_samp_factor / cinfo->max_v_samp_factor;
- if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
- th[i] = compptr->v_samp_factor * DCTSIZE;
- tmpbufsize += iw[i] * th[i];
- if ((inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
- THROW("Memory allocation failure");
- ptr = (JSAMPLE *)srcPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- inbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
- if (usetmpbuf) {
- if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
- THROW("Memory allocation failure");
- ptr = _tmpbuf;
- for (i = 0; i < cinfo->num_components; i++) {
- if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
- THROW("Memory allocation failure");
- for (row = 0; row < th[i]; row++) {
- tmpbuf[i][row] = ptr;
- ptr += iw[i];
- }
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < (int)cinfo->image_height;
- row += cinfo->max_v_samp_factor * DCTSIZE) {
- JSAMPARRAY yuvptr[MAX_COMPONENTS];
- int crow[MAX_COMPONENTS];
-
- for (i = 0; i < cinfo->num_components; i++) {
- jpeg_component_info *compptr = &cinfo->comp_info[i];
-
- crow[i] = row * compptr->v_samp_factor / cinfo->max_v_samp_factor;
- if (usetmpbuf) {
- int j, k;
-
- for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
- memcpy(tmpbuf[i][j], inbuf[i][crow[i] + j], pw[i]);
- /* Duplicate last sample in row to fill out MCU */
- for (k = pw[i]; k < iw[i]; k++)
- tmpbuf[i][j][k] = tmpbuf[i][j][pw[i] - 1];
- }
- /* Duplicate last row to fill out MCU */
- for (j = ph[i] - crow[i]; j < th[i]; j++)
- memcpy(tmpbuf[i][j], tmpbuf[i][ph[i] - crow[i] - 1], iw[i]);
- yuvptr[i] = tmpbuf[i];
- } else
- yuvptr[i] = &inbuf[i][crow[i]];
- }
- jpeg_write_raw_data(cinfo, yuvptr, cinfo->max_v_samp_factor * DCTSIZE);
- }
- jpeg_finish_compress(cinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START && alloc)
- (*cinfo->dest->term_destination) (cinfo);
- if (cinfo->global_state > CSTATE_START || retval == -1)
- jpeg_abort_compress(cinfo);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(inbuf[i]);
- }
- free(_tmpbuf);
- if (this->jerr.warning) retval = -1;
- return retval;
-}
-
-/* TurboJPEG 1.4+ */
-DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- int width, const int *strides,
- int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags)
-{
- static const char FUNCTION_NAME[] = "tjCompressFromYUVPlanes";
- int retval = 0;
- size_t size;
-
- GET_TJINSTANCE(handle, -1);
-
- if (subsamp < 0 || subsamp >= TJ_NUMSAMP || jpegSize == NULL ||
- jpegQual < 0 || jpegQual > 100)
- THROW("Invalid argument");
-
- this->quality = jpegQual;
- this->subsamp = subsamp;
- processFlags(handle, flags, COMPRESS);
-
- size = (size_t)(*jpegSize);
- retval = tj3CompressFromYUVPlanes8(handle, srcPlanes, width, strides, height,
- jpegBuf, &size);
- *jpegSize = (unsigned long)size;
-
-bailout:
- return retval;
-}
-
-
-/* TurboJPEG 3+ */
-DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
- const unsigned char *srcBuf, int width,
- int align, int height,
- unsigned char **jpegBuf, size_t *jpegSize)
-{
- static const char FUNCTION_NAME[] = "tj3CompressFromYUV8";
- const unsigned char *srcPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
-
- GET_TJINSTANCE(handle, -1);
-
- if (srcBuf == NULL || width <= 0 || align < 1 || !IS_POW2(align) ||
- height <= 0)
- THROW("Invalid argument");
-
- if (this->subsamp == TJSAMP_UNKNOWN)
- THROW("TJPARAM_SUBSAMP must be specified");
-
- pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
- ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
- srcPlanes[0] = srcBuf;
- strides[0] = PAD(pw0, align);
- if (this->subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- srcPlanes[1] = srcPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, this->subsamp);
- int ph1 = tjPlaneHeight(1, height, this->subsamp);
-
- strides[1] = strides[2] = PAD(pw1, align);
- if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
- (unsigned long long)INT_MAX ||
- (unsigned long long)strides[1] * (unsigned long long)ph1 >
- (unsigned long long)INT_MAX)
- THROW("Image or row alignment is too large");
- srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
- srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
- }
-
- return tj3CompressFromYUVPlanes8(handle, srcPlanes, width, strides, height,
- jpegBuf, jpegSize);
-
-bailout:
- return retval;
-}
-
-/* TurboJPEG 1.4+ */
-DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
- int width, int align, int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags)
-{
- static const char FUNCTION_NAME[] = "tjCompressFromYUV";
- int retval = -1;
- size_t size;
-
- GET_TJINSTANCE(handle, -1);
-
- if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROW("Invalid argument");
-
- this->quality = jpegQual;
- this->subsamp = subsamp;
- processFlags(handle, flags, COMPRESS);
-
- size = (size_t)(*jpegSize);
- retval = tj3CompressFromYUV8(handle, srcBuf, width, align, height, jpegBuf,
- &size);
- *jpegSize = (unsigned long)size;
-
-bailout:
- return retval;
-}
-
-
/******************************* Decompressor ********************************/
static tjhandle _tjInitDecompress(tjinstance *this)
@@ -2024,294 +2024,6 @@ DLLEXPORT int tjDecompress(tjhandle handle, unsigned char *jpegBuf,
}
-static void setDecodeDefaults(tjinstance *this, int pixelFormat)
-{
- int i;
-
- this->dinfo.scale_num = this->dinfo.scale_denom = 1;
-
- if (this->subsamp == TJSAMP_GRAY) {
- this->dinfo.num_components = this->dinfo.comps_in_scan = 1;
- this->dinfo.jpeg_color_space = JCS_GRAYSCALE;
- } else {
- this->dinfo.num_components = this->dinfo.comps_in_scan = 3;
- this->dinfo.jpeg_color_space = JCS_YCbCr;
- }
-
- this->dinfo.comp_info = (jpeg_component_info *)
- (*this->dinfo.mem->alloc_small) ((j_common_ptr)&this->dinfo, JPOOL_IMAGE,
- this->dinfo.num_components *
- sizeof(jpeg_component_info));
-
- for (i = 0; i < this->dinfo.num_components; i++) {
- jpeg_component_info *compptr = &this->dinfo.comp_info[i];
-
- compptr->h_samp_factor = (i == 0) ? tjMCUWidth[this->subsamp] / 8 : 1;
- compptr->v_samp_factor = (i == 0) ? tjMCUHeight[this->subsamp] / 8 : 1;
- compptr->component_index = i;
- compptr->component_id = i + 1;
- compptr->quant_tbl_no = compptr->dc_tbl_no =
- compptr->ac_tbl_no = (i == 0) ? 0 : 1;
- this->dinfo.cur_comp_info[i] = compptr;
- }
- this->dinfo.data_precision = 8;
- for (i = 0; i < 2; i++) {
- if (this->dinfo.quant_tbl_ptrs[i] == NULL)
- this->dinfo.quant_tbl_ptrs[i] =
- jpeg_alloc_quant_table((j_common_ptr)&this->dinfo);
- }
-
- this->dinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
-}
-
-
-static int my_read_markers(j_decompress_ptr dinfo)
-{
- return JPEG_REACHED_SOS;
-}
-
-static void my_reset_marker_reader(j_decompress_ptr dinfo)
-{
-}
-
-/* TurboJPEG 3+ */
-DLLEXPORT int tj3DecodeYUVPlanes8(tjhandle handle,
- const unsigned char * const *srcPlanes,
- const int *strides, unsigned char *dstBuf,
- int width, int pitch, int height,
- int pixelFormat)
-{
- static const char FUNCTION_NAME[] = "tj3DecodeYUVPlanes8";
- JSAMPROW *row_pointer = NULL;
- JSAMPLE *_tmpbuf[MAX_COMPONENTS];
- JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS];
- int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
- JSAMPLE *ptr;
- jpeg_component_info *compptr;
- int (*old_read_markers) (j_decompress_ptr);
- void (*old_reset_marker_reader) (j_decompress_ptr);
-
- GET_DINSTANCE(handle);
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; _tmpbuf[i] = NULL; inbuf[i] = NULL;
- }
-
- if ((this->init & DECOMPRESS) == 0)
- THROW("Instance has not been initialized for decompression");
-
- if (!srcPlanes || !srcPlanes[0] || dstBuf == NULL || width <= 0 ||
- pitch < 0 || height <= 0 || pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
- THROW("Invalid argument");
- if (this->subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
- THROW("Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (this->subsamp == TJSAMP_UNKNOWN)
- THROW("TJPARAM_SUBSAMP must be specified");
- if (pixelFormat == TJPF_CMYK)
- THROW("Cannot decode YUV images into packed-pixel CMYK images.");
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
- dinfo->image_width = width;
- dinfo->image_height = height;
-
- dinfo->progressive_mode = dinfo->inputctl->has_multiple_scans = FALSE;
- dinfo->Ss = dinfo->Ah = dinfo->Al = 0;
- dinfo->Se = DCTSIZE2 - 1;
- setDecodeDefaults(this, pixelFormat);
- old_read_markers = dinfo->marker->read_markers;
- dinfo->marker->read_markers = my_read_markers;
- old_reset_marker_reader = dinfo->marker->reset_marker_reader;
- dinfo->marker->reset_marker_reader = my_reset_marker_reader;
- jpeg_read_header(dinfo, TRUE);
- dinfo->marker->read_markers = old_read_markers;
- dinfo->marker->reset_marker_reader = old_reset_marker_reader;
-
- this->dinfo.out_color_space = pf2cs[pixelFormat];
- this->dinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
- dinfo->do_fancy_upsampling = FALSE;
- dinfo->Se = DCTSIZE2 - 1;
- jinit_master_decompress(dinfo);
- (*dinfo->upsample->start_pass) (dinfo);
-
- pw0 = PAD(width, dinfo->max_h_samp_factor);
- ph0 = PAD(height, dinfo->max_v_samp_factor);
-
- if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
-
- if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
- THROW("Memory allocation failure");
- for (i = 0; i < height; i++) {
- if (this->bottomUp)
- row_pointer[i] = &dstBuf[(height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = &dstBuf[i * (size_t)pitch];
- }
- if (height < ph0)
- for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
-
- for (i = 0; i < dinfo->num_components; i++) {
- compptr = &dinfo->comp_info[i];
- _tmpbuf[i] =
- (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
- compptr->v_samp_factor + 32);
- if (!_tmpbuf[i])
- THROW("Memory allocation failure");
- tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
- if (!tmpbuf[i])
- THROW("Memory allocation failure");
- for (row = 0; row < compptr->v_samp_factor; row++) {
- unsigned char *_tmpbuf_aligned =
- (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
-
- tmpbuf[i][row] =
- &_tmpbuf_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
- }
- pw[i] = pw0 * compptr->h_samp_factor / dinfo->max_h_samp_factor;
- ph[i] = ph0 * compptr->v_samp_factor / dinfo->max_v_samp_factor;
- inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
- if (!inbuf[i])
- THROW("Memory allocation failure");
- ptr = (JSAMPLE *)srcPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- inbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < ph0; row += dinfo->max_v_samp_factor) {
- JDIMENSION inrow = 0, outrow = 0;
-
- for (i = 0, compptr = dinfo->comp_info; i < dinfo->num_components;
- i++, compptr++)
- jcopy_sample_rows(inbuf[i],
- row * compptr->v_samp_factor / dinfo->max_v_samp_factor, tmpbuf[i], 0,
- compptr->v_samp_factor, pw[i]);
- (dinfo->upsample->upsample) (dinfo, tmpbuf, &inrow,
- dinfo->max_v_samp_factor, &row_pointer[row],
- &outrow, dinfo->max_v_samp_factor);
- }
- jpeg_abort_decompress(dinfo);
-
-bailout:
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- free(row_pointer);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(_tmpbuf[i]);
- free(inbuf[i]);
- }
- if (this->jerr.warning) retval = -1;
- return retval;
-}
-
-/* TurboJPEG 1.4+ */
-DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- const int *strides, int subsamp,
- unsigned char *dstBuf, int width, int pitch,
- int height, int pixelFormat, int flags)
-{
- static const char FUNCTION_NAME[] = "tjDecodeYUVPlanes";
- int retval = 0;
-
- GET_TJINSTANCE(handle, -1);
-
- if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROW("Invalid argument");
-
- this->subsamp = subsamp;
- processFlags(handle, flags, DECOMPRESS);
-
- return tj3DecodeYUVPlanes8(handle, srcPlanes, strides, dstBuf, width, pitch,
- height, pixelFormat);
-
-bailout:
- return retval;
-}
-
-
-/* TurboJPEG 3+ */
-DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
- int align, unsigned char *dstBuf, int width,
- int pitch, int height, int pixelFormat)
-{
- static const char FUNCTION_NAME[] = "tj3DecodeYUV8";
- const unsigned char *srcPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
-
- GET_TJINSTANCE(handle, -1);
-
- if (srcBuf == NULL || align < 1 || !IS_POW2(align) || width <= 0 ||
- height <= 0)
- THROW("Invalid argument");
-
- if (this->subsamp == TJSAMP_UNKNOWN)
- THROW("TJPARAM_SUBSAMP must be specified");
-
- pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
- ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
- srcPlanes[0] = srcBuf;
- strides[0] = PAD(pw0, align);
- if (this->subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- srcPlanes[1] = srcPlanes[2] = NULL;
- } else {
- int pw1 = tj3YUVPlaneWidth(1, width, this->subsamp);
- int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
-
- strides[1] = strides[2] = PAD(pw1, align);
- if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
- (unsigned long long)INT_MAX ||
- (unsigned long long)strides[1] * (unsigned long long)ph1 >
- (unsigned long long)INT_MAX)
- THROW("Image or row alignment is too large");
- srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
- srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
- }
-
- return tj3DecodeYUVPlanes8(handle, srcPlanes, strides, dstBuf, width, pitch,
- height, pixelFormat);
-
-bailout:
- return retval;
-}
-
-/* TurboJPEG 1.4+ */
-DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
- int align, int subsamp, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags)
-{
- static const char FUNCTION_NAME[] = "tjDecodeYUV";
- int retval = -1;
-
- GET_TJINSTANCE(handle, -1);
-
- if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROW("Invalid argument");
-
- this->subsamp = subsamp;
- processFlags(handle, flags, DECOMPRESS);
-
- return tj3DecodeYUV8(handle, srcBuf, align, dstBuf, width, pitch, height,
- pixelFormat);
-
-bailout:
- return retval;
-}
-
-
/* TurboJPEG 3+ */
DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
const unsigned char *jpegBuf,
@@ -2648,6 +2360,294 @@ DLLEXPORT int tjDecompressToYUV(tjhandle handle, unsigned char *jpegBuf,
}
+static void setDecodeDefaults(tjinstance *this, int pixelFormat)
+{
+ int i;
+
+ this->dinfo.scale_num = this->dinfo.scale_denom = 1;
+
+ if (this->subsamp == TJSAMP_GRAY) {
+ this->dinfo.num_components = this->dinfo.comps_in_scan = 1;
+ this->dinfo.jpeg_color_space = JCS_GRAYSCALE;
+ } else {
+ this->dinfo.num_components = this->dinfo.comps_in_scan = 3;
+ this->dinfo.jpeg_color_space = JCS_YCbCr;
+ }
+
+ this->dinfo.comp_info = (jpeg_component_info *)
+ (*this->dinfo.mem->alloc_small) ((j_common_ptr)&this->dinfo, JPOOL_IMAGE,
+ this->dinfo.num_components *
+ sizeof(jpeg_component_info));
+
+ for (i = 0; i < this->dinfo.num_components; i++) {
+ jpeg_component_info *compptr = &this->dinfo.comp_info[i];
+
+ compptr->h_samp_factor = (i == 0) ? tjMCUWidth[this->subsamp] / 8 : 1;
+ compptr->v_samp_factor = (i == 0) ? tjMCUHeight[this->subsamp] / 8 : 1;
+ compptr->component_index = i;
+ compptr->component_id = i + 1;
+ compptr->quant_tbl_no = compptr->dc_tbl_no =
+ compptr->ac_tbl_no = (i == 0) ? 0 : 1;
+ this->dinfo.cur_comp_info[i] = compptr;
+ }
+ this->dinfo.data_precision = 8;
+ for (i = 0; i < 2; i++) {
+ if (this->dinfo.quant_tbl_ptrs[i] == NULL)
+ this->dinfo.quant_tbl_ptrs[i] =
+ jpeg_alloc_quant_table((j_common_ptr)&this->dinfo);
+ }
+
+ this->dinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+}
+
+
+static int my_read_markers(j_decompress_ptr dinfo)
+{
+ return JPEG_REACHED_SOS;
+}
+
+static void my_reset_marker_reader(j_decompress_ptr dinfo)
+{
+}
+
+/* TurboJPEG 3+ */
+DLLEXPORT int tj3DecodeYUVPlanes8(tjhandle handle,
+ const unsigned char * const *srcPlanes,
+ const int *strides, unsigned char *dstBuf,
+ int width, int pitch, int height,
+ int pixelFormat)
+{
+ static const char FUNCTION_NAME[] = "tj3DecodeYUVPlanes8";
+ JSAMPROW *row_pointer = NULL;
+ JSAMPLE *_tmpbuf[MAX_COMPONENTS];
+ JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS];
+ int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
+ JSAMPLE *ptr;
+ jpeg_component_info *compptr;
+ int (*old_read_markers) (j_decompress_ptr);
+ void (*old_reset_marker_reader) (j_decompress_ptr);
+
+ GET_DINSTANCE(handle);
+
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ tmpbuf[i] = NULL; _tmpbuf[i] = NULL; inbuf[i] = NULL;
+ }
+
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (!srcPlanes || !srcPlanes[0] || dstBuf == NULL || width <= 0 ||
+ pitch < 0 || height <= 0 || pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
+ THROW("Invalid argument");
+ if (this->subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+ if (pixelFormat == TJPF_CMYK)
+ THROW("Cannot decode YUV images into packed-pixel CMYK images.");
+
+ if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
+ dinfo->image_width = width;
+ dinfo->image_height = height;
+
+ dinfo->progressive_mode = dinfo->inputctl->has_multiple_scans = FALSE;
+ dinfo->Ss = dinfo->Ah = dinfo->Al = 0;
+ dinfo->Se = DCTSIZE2 - 1;
+ setDecodeDefaults(this, pixelFormat);
+ old_read_markers = dinfo->marker->read_markers;
+ dinfo->marker->read_markers = my_read_markers;
+ old_reset_marker_reader = dinfo->marker->reset_marker_reader;
+ dinfo->marker->reset_marker_reader = my_reset_marker_reader;
+ jpeg_read_header(dinfo, TRUE);
+ dinfo->marker->read_markers = old_read_markers;
+ dinfo->marker->reset_marker_reader = old_reset_marker_reader;
+
+ this->dinfo.out_color_space = pf2cs[pixelFormat];
+ this->dinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
+ dinfo->do_fancy_upsampling = FALSE;
+ dinfo->Se = DCTSIZE2 - 1;
+ jinit_master_decompress(dinfo);
+ (*dinfo->upsample->start_pass) (dinfo);
+
+ pw0 = PAD(width, dinfo->max_h_samp_factor);
+ ph0 = PAD(height, dinfo->max_v_samp_factor);
+
+ if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
+
+ if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
+ THROW("Memory allocation failure");
+ for (i = 0; i < height; i++) {
+ if (this->bottomUp)
+ row_pointer[i] = &dstBuf[(height - i - 1) * (size_t)pitch];
+ else
+ row_pointer[i] = &dstBuf[i * (size_t)pitch];
+ }
+ if (height < ph0)
+ for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
+
+ for (i = 0; i < dinfo->num_components; i++) {
+ compptr = &dinfo->comp_info[i];
+ _tmpbuf[i] =
+ (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
+ compptr->v_samp_factor + 32);
+ if (!_tmpbuf[i])
+ THROW("Memory allocation failure");
+ tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
+ if (!tmpbuf[i])
+ THROW("Memory allocation failure");
+ for (row = 0; row < compptr->v_samp_factor; row++) {
+ unsigned char *_tmpbuf_aligned =
+ (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
+
+ tmpbuf[i][row] =
+ &_tmpbuf_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
+ }
+ pw[i] = pw0 * compptr->h_samp_factor / dinfo->max_h_samp_factor;
+ ph[i] = ph0 * compptr->v_samp_factor / dinfo->max_v_samp_factor;
+ inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
+ if (!inbuf[i])
+ THROW("Memory allocation failure");
+ ptr = (JSAMPLE *)srcPlanes[i];
+ for (row = 0; row < ph[i]; row++) {
+ inbuf[i][row] = ptr;
+ ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
+ }
+ }
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ for (row = 0; row < ph0; row += dinfo->max_v_samp_factor) {
+ JDIMENSION inrow = 0, outrow = 0;
+
+ for (i = 0, compptr = dinfo->comp_info; i < dinfo->num_components;
+ i++, compptr++)
+ jcopy_sample_rows(inbuf[i],
+ row * compptr->v_samp_factor / dinfo->max_v_samp_factor, tmpbuf[i], 0,
+ compptr->v_samp_factor, pw[i]);
+ (dinfo->upsample->upsample) (dinfo, tmpbuf, &inrow,
+ dinfo->max_v_samp_factor, &row_pointer[row],
+ &outrow, dinfo->max_v_samp_factor);
+ }
+ jpeg_abort_decompress(dinfo);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ free(row_pointer);
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ free(tmpbuf[i]);
+ free(_tmpbuf[i]);
+ free(inbuf[i]);
+ }
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
+ const unsigned char **srcPlanes,
+ const int *strides, int subsamp,
+ unsigned char *dstBuf, int width, int pitch,
+ int height, int pixelFormat, int flags)
+{
+ static const char FUNCTION_NAME[] = "tjDecodeYUVPlanes";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->subsamp = subsamp;
+ processFlags(handle, flags, DECOMPRESS);
+
+ return tj3DecodeYUVPlanes8(handle, srcPlanes, strides, dstBuf, width, pitch,
+ height, pixelFormat);
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3+ */
+DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+ int align, unsigned char *dstBuf, int width,
+ int pitch, int height, int pixelFormat)
+{
+ static const char FUNCTION_NAME[] = "tj3DecodeYUV8";
+ const unsigned char *srcPlanes[3];
+ int pw0, ph0, strides[3], retval = -1;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (srcBuf == NULL || align < 1 || !IS_POW2(align) || width <= 0 ||
+ height <= 0)
+ THROW("Invalid argument");
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
+ ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
+ srcPlanes[0] = srcBuf;
+ strides[0] = PAD(pw0, align);
+ if (this->subsamp == TJSAMP_GRAY) {
+ strides[1] = strides[2] = 0;
+ srcPlanes[1] = srcPlanes[2] = NULL;
+ } else {
+ int pw1 = tj3YUVPlaneWidth(1, width, this->subsamp);
+ int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
+
+ strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
+ srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
+ srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
+ }
+
+ return tj3DecodeYUVPlanes8(handle, srcPlanes, strides, dstBuf, width, pitch,
+ height, pixelFormat);
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
+ int align, int subsamp, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelFormat,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjDecodeYUV";
+ int retval = -1;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->subsamp = subsamp;
+ processFlags(handle, flags, DECOMPRESS);
+
+ return tj3DecodeYUV8(handle, srcBuf, align, dstBuf, width, pitch, height,
+ pixelFormat);
+
+bailout:
+ return retval;
+}
+
+
/******************************** Transformer ********************************/
/* TurboJPEG 1.2+ */
diff --git a/turbojpeg.h b/turbojpeg.h
index c431c9d4..e9de751f 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -1184,6 +1184,40 @@ extern "C" {
DLLEXPORT tjhandle tj3Init(int initType);
+/**
+ * Destroy a TurboJPEG instance.
+ *
+ * @param handle handle to a TurboJPEG instance. If the handle is NULL, then
+ * this function has no effect.
+ */
+DLLEXPORT void tj3Destroy(tjhandle handle);
+
+
+/**
+ * Returns a descriptive error message explaining why the last command failed.
+ *
+ * @param handle handle to a TurboJPEG instance, or NULL if the error was
+ * generated by a global function (but note that retrieving the error message
+ * for a global function is thread-safe only on platforms that support
+ * thread-local storage.)
+ *
+ * @return a descriptive error message explaining why the last command failed.
+ */
+DLLEXPORT char *tj3GetErrorStr(tjhandle handle);
+
+
+/**
+ * Returns a code indicating the severity of the last error. See
+ * @ref TJERR "Error codes".
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @return a code indicating the severity of the last error. See
+ * @ref TJERR "Error codes".
+ */
+DLLEXPORT int tj3GetErrorCode(tjhandle handle);
+
+
/**
* Set the value of a parameter.
*
@@ -1212,204 +1246,33 @@ DLLEXPORT int tj3Get(tjhandle handle, int param);
/**
- * Compress an 8-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into
- * an 8-bit-per-sample JPEG image.
+ * Allocate a byte buffer for use with TurboJPEG. You should always use this
+ * function to allocate the JPEG destination buffer(s) for the compression and
+ * transform functions unless you are disabling automatic buffer (re)allocation
+ * (by setting #TJPARAM_NOREALLOC.)
*
- * @param handle handle to a TurboJPEG instance that has been initialized for
- * compression
+ * @param bytes the number of bytes to allocate
*
- * @param srcBuf pointer to a buffer containing a packed-pixel RGB, grayscale,
- * or CMYK source image to be compressed. This buffer should normally be
- * `pitch * height` samples in size. However, you can also use this parameter
- * to compress from a specific region of a larger buffer.
+ * @return a pointer to a newly-allocated buffer with the specified number of
+ * bytes.
*
- * @param width width (in pixels) of the source image
- *
- * @param pitch samples per row in the source image. Normally this should be
- * width * #tjPixelSize[pixelFormat], if the image is unpadded.
- * (Setting this parameter to 0 is the equivalent of setting it to
- * width * #tjPixelSize[pixelFormat].) However, you can also use this
- * parameter to specify the row alignment/padding of the source image, to skip
- * rows, or to compress from a specific region of a larger buffer.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param jpegBuf address of a pointer to a byte buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
- * accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
- * or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tj3JPEGBufSize(). This should ensure that the buffer never has to be
- * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, then `*jpegSize` should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
- * you should always check `*jpegBuf` upon return from this function, as it may
- * have changed.
- *
- * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
- * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
- * should be set to the size of the buffer. Upon return, `*jpegSize` will
- * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
- * JPEG buffer that is being reused from a previous call to one of the JPEG
- * compression functions, then `*jpegSize` is ignored.
- *
- * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
- * and #tj3GetErrorCode().)
+ * @see tj3Free()
*/
-DLLEXPORT int tj3Compress8(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char **jpegBuf, size_t *jpegSize);
-
-/**
- * Compress a 12-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into
- * a 12-bit-per-sample JPEG image.
- *
- * \details \copydetails tj3Compress8()
- */
-DLLEXPORT int tj3Compress12(tjhandle handle, const short *srcBuf, int width,
- int pitch, int height, int pixelFormat,
- unsigned char **jpegBuf, size_t *jpegSize);
-
-/**
- * Compress a 16-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into
- * a 16-bit-per-sample lossless JPEG image.
- *
- * \details \copydetails tj3Compress8()
- */
-DLLEXPORT int tj3Compress16(tjhandle handle, const unsigned short *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char **jpegBuf, size_t *jpegSize);
+DLLEXPORT void *tj3Alloc(size_t bytes);
/**
- * Compress an 8-bit-per-sample unified planar YUV image into an
- * 8-bit-per-sample JPEG image.
+ * Free a byte buffer previously allocated by TurboJPEG. You should always use
+ * this function to free JPEG destination buffer(s) that were automatically
+ * (re)allocated by the compression and transform functions or that were
+ * manually allocated using #tj3Alloc().
*
- * @param handle handle to a TurboJPEG instance that has been initialized for
- * compression
+ * @param buffer address of the buffer to free. If the address is NULL, then
+ * this function has no effect.
*
- * @param srcBuf pointer to a buffer containing a unified planar YUV source
- * image to be compressed. The size of this buffer should match the value
- * returned by #tj3YUVBufSize() for the given image width, height, row
- * alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
- * Y, U (Cb), and V (Cr) image planes should be stored sequentially in the
- * buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
- *
- * @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
- * buffer copy will be performed.
- *
- * @param align row alignment (in bytes) of the source image (must be a power
- * of 2.) Setting this parameter to n indicates that each row in each plane of
- * the source image is padded to the nearest multiple of n bytes
- * (1 = unpadded.)
- *
- * @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
- * buffer copy will be performed.
- *
- * @param jpegBuf address of a pointer to a byte buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
- * accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
- * or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tj3JPEGBufSize(). This should ensure that the buffer never has to be
- * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, then `*jpegSize` should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
- * you should always check `*jpegBuf` upon return from this function, as it may
- * have changed.
- *
- * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
- * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
- * should be set to the size of the buffer. Upon return, `*jpegSize` will
- * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
- * JPEG buffer that is being reused from a previous call to one of the JPEG
- * compression functions, then `*jpegSize` is ignored.
- *
- * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
- * and #tj3GetErrorCode().)
+ * @see tj3Alloc()
*/
-DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
- const unsigned char *srcBuf, int width,
- int align, int height,
- unsigned char **jpegBuf, size_t *jpegSize);
-
-
-/**
- * Compress a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into
- * an 8-bit-per-sample JPEG image.
- *
- * @param handle handle to a TurboJPEG instance that has been initialized for
- * compression
- *
- * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if compressing a grayscale image) that contain a YUV
- * source image to be compressed. These planes can be contiguous or
- * non-contiguous in memory. The size of each plane should match the value
- * returned by #tj3YUVPlaneSize() for the given image width, height, strides,
- * and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) Refer to
- * @ref YUVnotes "YUV Image Format Notes" for more details.
- *
- * @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
- * buffer copy will be performed.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * row in the corresponding plane of the YUV source image. Setting the stride
- * for any plane to 0 is the same as setting it to the plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If `strides` is NULL, then the
- * strides for all planes will be set to their respective plane widths. You
- * can adjust the strides in order to specify an arbitrary amount of row
- * padding in each plane or to create a JPEG image from a subregion of a larger
- * planar YUV image.
- *
- * @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
- * buffer copy will be performed.
- *
- * @param jpegBuf address of a pointer to a byte buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
- * accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
- * or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tj3JPEGBufSize(). This should ensure that the buffer never has to be
- * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, then `*jpegSize` should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
- * you should always check `*jpegBuf` upon return from this function, as it may
- * have changed.
- *
- * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
- * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
- * should be set to the size of the buffer. Upon return, `*jpegSize` will
- * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
- * JPEG buffer that is being reused from a previous call to one of the JPEG
- * compression functions, then `*jpegSize` is ignored.
- *
- * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
- * and #tj3GetErrorCode().)
- */
-DLLEXPORT int tj3CompressFromYUVPlanes8(tjhandle handle,
- const unsigned char * const *srcPlanes,
- int width, const int *strides,
- int height, unsigned char **jpegBuf,
- size_t *jpegSize);
+DLLEXPORT void tj3Free(void *buffer);
/**
@@ -1522,51 +1385,204 @@ DLLEXPORT int tj3YUVPlaneHeight(int componentID, int height, int subsamp);
/**
- * Encode an 8-bit-per-sample packed-pixel RGB or grayscale image into an
- * 8-bit-per-sample unified planar YUV image. This function performs color
- * conversion (which is accelerated in the libjpeg-turbo implementation) but
- * does not execute any of the other steps in the JPEG compression process.
+ * Compress an 8-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into
+ * an 8-bit-per-sample JPEG image.
*
* @param handle handle to a TurboJPEG instance that has been initialized for
* compression
*
- * @param srcBuf pointer to a buffer containing a packed-pixel RGB or grayscale
- * source image to be encoded. This buffer should normally be `pitch * height`
- * bytes in size. However, you can also use this parameter to encode from a
- * specific region of a larger buffer.
+ * @param srcBuf pointer to a buffer containing a packed-pixel RGB, grayscale,
+ * or CMYK source image to be compressed. This buffer should normally be
+ * `pitch * height` samples in size. However, you can also use this parameter
+ * to compress from a specific region of a larger buffer.
*
* @param width width (in pixels) of the source image
*
- * @param pitch bytes per row in the source image. Normally this should be
+ * @param pitch samples per row in the source image. Normally this should be
* width * #tjPixelSize[pixelFormat], if the image is unpadded.
* (Setting this parameter to 0 is the equivalent of setting it to
* width * #tjPixelSize[pixelFormat].) However, you can also use this
* parameter to specify the row alignment/padding of the source image, to skip
- * rows, or to encode from a specific region of a larger packed-pixel image.
+ * rows, or to compress from a specific region of a larger buffer.
*
* @param height height (in pixels) of the source image
*
* @param pixelFormat pixel format of the source image (see @ref TJPF
* "Pixel formats".)
*
- * @param dstBuf pointer to a buffer that will receive the unified planar YUV
- * image. Use #tj3YUVBufSize() to determine the appropriate size for this
- * buffer based on the image width, height, row alignment, and level of
- * chrominance subsampling (see #TJPARAM_SUBSAMP.) The Y, U (Cb), and V (Cr)
- * image planes will be stored sequentially in the buffer. (Refer to
- * @ref YUVnotes "YUV Image Format Notes".)
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize(). This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1, then `*jpegSize` should be set to the size of your
+ * pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
+ * you should always check `*jpegBuf` upon return from this function, as it may
+ * have changed.
*
- * @param align row alignment (in bytes) of the YUV image (must be a power of
- * 2.) Setting this parameter to n will cause each row in each plane of the
- * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
- * To generate images suitable for X Video, `align` should be set to 4.
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
*
* @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
* and #tj3GetErrorCode().)
*/
-DLLEXPORT int tj3EncodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+DLLEXPORT int tj3Compress8(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char **jpegBuf, size_t *jpegSize);
+
+/**
+ * Compress a 12-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into
+ * a 12-bit-per-sample JPEG image.
+ *
+ * \details \copydetails tj3Compress8()
+ */
+DLLEXPORT int tj3Compress12(tjhandle handle, const short *srcBuf, int width,
+ int pitch, int height, int pixelFormat,
+ unsigned char **jpegBuf, size_t *jpegSize);
+
+/**
+ * Compress a 16-bit-per-sample packed-pixel RGB, grayscale, or CMYK image into
+ * a 16-bit-per-sample lossless JPEG image.
+ *
+ * \details \copydetails tj3Compress8()
+ */
+DLLEXPORT int tj3Compress16(tjhandle handle, const unsigned short *srcBuf,
int width, int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int align);
+ unsigned char **jpegBuf, size_t *jpegSize);
+
+
+/**
+ * Compress a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into
+ * an 8-bit-per-sample JPEG image.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if compressing a grayscale image) that contain a YUV
+ * source image to be compressed. These planes can be contiguous or
+ * non-contiguous in memory. The size of each plane should match the value
+ * returned by #tj3YUVPlaneSize() for the given image width, height, strides,
+ * and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) Refer to
+ * @ref YUVnotes "YUV Image Format Notes" for more details.
+ *
+ * @param width width (in pixels) of the source image. If the width is not an
+ * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param strides an array of integers, each specifying the number of bytes per
+ * row in the corresponding plane of the YUV source image. Setting the stride
+ * for any plane to 0 is the same as setting it to the plane width (see
+ * @ref YUVnotes "YUV Image Format Notes".) If `strides` is NULL, then the
+ * strides for all planes will be set to their respective plane widths. You
+ * can adjust the strides in order to specify an arbitrary amount of row
+ * padding in each plane or to create a JPEG image from a subregion of a larger
+ * planar YUV image.
+ *
+ * @param height height (in pixels) of the source image. If the height is not
+ * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize(). This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1, then `*jpegSize` should be set to the size of your
+ * pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
+ * you should always check `*jpegBuf` upon return from this function, as it may
+ * have changed.
+ *
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3CompressFromYUVPlanes8(tjhandle handle,
+ const unsigned char * const *srcPlanes,
+ int width, const int *strides,
+ int height, unsigned char **jpegBuf,
+ size_t *jpegSize);
+
+
+/**
+ * Compress an 8-bit-per-sample unified planar YUV image into an
+ * 8-bit-per-sample JPEG image.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a unified planar YUV source
+ * image to be compressed. The size of this buffer should match the value
+ * returned by #tj3YUVBufSize() for the given image width, height, row
+ * alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
+ * Y, U (Cb), and V (Cr) image planes should be stored sequentially in the
+ * buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
+ *
+ * @param width width (in pixels) of the source image. If the width is not an
+ * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param align row alignment (in bytes) of the source image (must be a power
+ * of 2.) Setting this parameter to n indicates that each row in each plane of
+ * the source image is padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
+ *
+ * @param height height (in pixels) of the source image. If the height is not
+ * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize(). This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1, then `*jpegSize` should be set to the size of your
+ * pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
+ * you should always check `*jpegBuf` upon return from this function, as it may
+ * have changed.
+ *
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
+ const unsigned char *srcBuf, int width,
+ int align, int height,
+ unsigned char **jpegBuf, size_t *jpegSize);
/**
@@ -1624,6 +1640,54 @@ DLLEXPORT int tj3EncodeYUVPlanes8(tjhandle handle, const unsigned char *srcBuf,
int *strides);
+/**
+ * Encode an 8-bit-per-sample packed-pixel RGB or grayscale image into an
+ * 8-bit-per-sample unified planar YUV image. This function performs color
+ * conversion (which is accelerated in the libjpeg-turbo implementation) but
+ * does not execute any of the other steps in the JPEG compression process.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a packed-pixel RGB or grayscale
+ * source image to be encoded. This buffer should normally be `pitch * height`
+ * bytes in size. However, you can also use this parameter to encode from a
+ * specific region of a larger buffer.
+ *
+ * @param width width (in pixels) of the source image
+ *
+ * @param pitch bytes per row in the source image. Normally this should be
+ * width * #tjPixelSize[pixelFormat], if the image is unpadded.
+ * (Setting this parameter to 0 is the equivalent of setting it to
+ * width * #tjPixelSize[pixelFormat].) However, you can also use this
+ * parameter to specify the row alignment/padding of the source image, to skip
+ * rows, or to encode from a specific region of a larger packed-pixel image.
+ *
+ * @param height height (in pixels) of the source image
+ *
+ * @param pixelFormat pixel format of the source image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @param dstBuf pointer to a buffer that will receive the unified planar YUV
+ * image. Use #tj3YUVBufSize() to determine the appropriate size for this
+ * buffer based on the image width, height, row alignment, and level of
+ * chrominance subsampling (see #TJPARAM_SUBSAMP.) The Y, U (Cb), and V (Cr)
+ * image planes will be stored sequentially in the buffer. (Refer to
+ * @ref YUVnotes "YUV Image Format Notes".)
+ *
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n will cause each row in each plane of the
+ * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
+ * To generate images suitable for X Video, `align` should be set to 4.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3EncodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char *dstBuf, int align);
+
+
/**
* Retrieve information about a JPEG image without decompressing it, or prime
* the decompressor with quantization and Huffman tables. If a JPEG image is
@@ -1782,43 +1846,6 @@ DLLEXPORT int tj3Decompress16(tjhandle handle, const unsigned char *jpegBuf,
int pitch, int pixelFormat);
-/**
- * Decompress an 8-bit-per-sample JPEG image into an 8-bit-per-sample unified
- * planar YUV image. This function performs JPEG decompression but leaves out
- * the color conversion step, so a planar YUV image is generated instead of a
- * packed-pixel image. The @ref TJPARAM "parameters" that describe the JPEG
- * image will be set when this function returns.
- *
- * @param handle handle to a TurboJPEG instance that has been initialized for
- * decompression
- *
- * @param jpegBuf pointer to a byte buffer containing the JPEG image to
- * decompress
- *
- * @param jpegSize size of the JPEG image (in bytes)
- *
- * @param dstBuf pointer to a buffer that will receive the unified planar YUV
- * decompressed image. Use #tj3YUVBufSize() to determine the appropriate size
- * for this buffer based on the scaled JPEG width and height (see #TJSCALED(),
- * #TJPARAM_JPEGWIDTH, #TJPARAM_JPEGHEIGHT, and #tj3SetScalingFactor()), row
- * alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
- * Y, U (Cb), and V (Cr) image planes will be stored sequentially in the
- * buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
- *
- * @param align row alignment (in bytes) of the YUV image (must be a power of
- * 2.) Setting this parameter to n will cause each row in each plane of the
- * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
- * To generate images suitable for X Video, `align` should be set to 4.
- *
- * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
- * and #tj3GetErrorCode().)
- */
-DLLEXPORT int tj3DecompressToYUV8(tjhandle handle,
- const unsigned char *jpegBuf,
- size_t jpegSize,
- unsigned char *dstBuf, int align);
-
-
/**
* Decompress an 8-bit-per-sample JPEG image into separate 8-bit-per-sample Y,
* U (Cb), and V (Cr) image planes. This function performs JPEG decompression
@@ -1863,52 +1890,40 @@ DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
/**
- * Decode an 8-bit-per-sample unified planar YUV image into an 8-bit-per-sample
- * packed-pixel RGB or grayscale image. This function performs color
- * conversion (which is accelerated in the libjpeg-turbo implementation) but
- * does not execute any of the other steps in the JPEG decompression process.
+ * Decompress an 8-bit-per-sample JPEG image into an 8-bit-per-sample unified
+ * planar YUV image. This function performs JPEG decompression but leaves out
+ * the color conversion step, so a planar YUV image is generated instead of a
+ * packed-pixel image. The @ref TJPARAM "parameters" that describe the JPEG
+ * image will be set when this function returns.
*
* @param handle handle to a TurboJPEG instance that has been initialized for
* decompression
*
- * @param srcBuf pointer to a buffer containing a unified planar YUV source
- * image to be decoded. The size of this buffer should match the value
- * returned by #tj3YUVBufSize() for the given image width, height, row
+ * @param jpegBuf pointer to a byte buffer containing the JPEG image to
+ * decompress
+ *
+ * @param jpegSize size of the JPEG image (in bytes)
+ *
+ * @param dstBuf pointer to a buffer that will receive the unified planar YUV
+ * decompressed image. Use #tj3YUVBufSize() to determine the appropriate size
+ * for this buffer based on the scaled JPEG width and height (see #TJSCALED(),
+ * #TJPARAM_JPEGWIDTH, #TJPARAM_JPEGHEIGHT, and #tj3SetScalingFactor()), row
* alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
- * Y, U (Cb), and V (Cr) image planes should be stored sequentially in the
- * source buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
+ * Y, U (Cb), and V (Cr) image planes will be stored sequentially in the
+ * buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
*
- * @param align row alignment (in bytes) of the YUV source image (must be a
- * power of 2.) Setting this parameter to n indicates that each row in each
- * plane of the YUV source image is padded to the nearest multiple of n bytes
- * (1 = unpadded.)
- *
- * @param dstBuf pointer to a buffer that will receive the packed-pixel decoded
- * image. This buffer should normally be `pitch * height` bytes in size.
- * However, you can also use this parameter to decode into a specific region of
- * a larger buffer.
- *
- * @param width width (in pixels) of the source and destination images
- *
- * @param pitch bytes per row in the destination image. Normally this should
- * be set to width * #tjPixelSize[pixelFormat], if the destination
- * image should be unpadded. (Setting this parameter to 0 is the equivalent of
- * setting it to width * #tjPixelSize[pixelFormat].) However, you can
- * also use this parameter to specify the row alignment/padding of the
- * destination image, to skip rows, or to decode into a specific region of a
- * larger buffer.
- *
- * @param height height (in pixels) of the source and destination images
- *
- * @param pixelFormat pixel format of the destination image (see @ref TJPF
- * "Pixel formats".)
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n will cause each row in each plane of the
+ * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
+ * To generate images suitable for X Video, `align` should be set to 4.
*
* @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
* and #tj3GetErrorCode().)
*/
-DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
- int align, unsigned char *dstBuf, int width,
- int pitch, int height, int pixelFormat);
+DLLEXPORT int tj3DecompressToYUV8(tjhandle handle,
+ const unsigned char *jpegBuf,
+ size_t jpegSize,
+ unsigned char *dstBuf, int align);
/**
@@ -1967,6 +1982,55 @@ DLLEXPORT int tj3DecodeYUVPlanes8(tjhandle handle,
int pixelFormat);
+/**
+ * Decode an 8-bit-per-sample unified planar YUV image into an 8-bit-per-sample
+ * packed-pixel RGB or grayscale image. This function performs color
+ * conversion (which is accelerated in the libjpeg-turbo implementation) but
+ * does not execute any of the other steps in the JPEG decompression process.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param srcBuf pointer to a buffer containing a unified planar YUV source
+ * image to be decoded. The size of this buffer should match the value
+ * returned by #tj3YUVBufSize() for the given image width, height, row
+ * alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
+ * Y, U (Cb), and V (Cr) image planes should be stored sequentially in the
+ * source buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
+ *
+ * @param align row alignment (in bytes) of the YUV source image (must be a
+ * power of 2.) Setting this parameter to n indicates that each row in each
+ * plane of the YUV source image is padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
+ *
+ * @param dstBuf pointer to a buffer that will receive the packed-pixel decoded
+ * image. This buffer should normally be `pitch * height` bytes in size.
+ * However, you can also use this parameter to decode into a specific region of
+ * a larger buffer.
+ *
+ * @param width width (in pixels) of the source and destination images
+ *
+ * @param pitch bytes per row in the destination image. Normally this should
+ * be set to width * #tjPixelSize[pixelFormat], if the destination
+ * image should be unpadded. (Setting this parameter to 0 is the equivalent of
+ * setting it to width * #tjPixelSize[pixelFormat].) However, you can
+ * also use this parameter to specify the row alignment/padding of the
+ * destination image, to skip rows, or to decode into a specific region of a
+ * larger buffer.
+ *
+ * @param height height (in pixels) of the source and destination images
+ *
+ * @param pixelFormat pixel format of the destination image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+ int align, unsigned char *dstBuf, int width,
+ int pitch, int height, int pixelFormat);
+
+
/**
* Losslessly transform a JPEG image into another JPEG image. Lossless
* transforms work by moving the raw DCT coefficients from one JPEG image
@@ -2032,31 +2096,6 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
size_t *dstSizes, const tjtransform *transforms);
-/**
- * Destroy a TurboJPEG instance.
- *
- * @param handle handle to a TurboJPEG instance. If the handle is NULL, then
- * this function has no effect.
- */
-DLLEXPORT void tj3Destroy(tjhandle handle);
-
-
-/**
- * Allocate a byte buffer for use with TurboJPEG. You should always use this
- * function to allocate the JPEG destination buffer(s) for the compression and
- * transform functions unless you are disabling automatic buffer (re)allocation
- * (by setting #TJPARAM_NOREALLOC.)
- *
- * @param bytes the number of bytes to allocate
- *
- * @return a pointer to a newly-allocated buffer with the specified number of
- * bytes.
- *
- * @see tj3Free()
- */
-DLLEXPORT void *tj3Alloc(size_t bytes);
-
-
/**
* Load an 8-bit-per-sample packed-pixel image from disk into memory.
*
@@ -2180,45 +2219,6 @@ DLLEXPORT int tj3SaveImage16(tjhandle handle, const char *filename,
int pitch, int height, int pixelFormat);
-/**
- * Free a byte buffer previously allocated by TurboJPEG. You should always use
- * this function to free JPEG destination buffer(s) that were automatically
- * (re)allocated by the compression and transform functions or that were
- * manually allocated using #tj3Alloc().
- *
- * @param buffer address of the buffer to free. If the address is NULL, then
- * this function has no effect.
- *
- * @see tj3Alloc()
- */
-DLLEXPORT void tj3Free(void *buffer);
-
-
-/**
- * Returns a descriptive error message explaining why the last command failed.
- *
- * @param handle handle to a TurboJPEG instance, or NULL if the error was
- * generated by a global function (but note that retrieving the error message
- * for a global function is thread-safe only on platforms that support
- * thread-local storage.)
- *
- * @return a descriptive error message explaining why the last command failed.
- */
-DLLEXPORT char *tj3GetErrorStr(tjhandle handle);
-
-
-/**
- * Returns a code indicating the severity of the last error. See
- * @ref TJERR "Error codes".
- *
- * @param handle handle to a TurboJPEG instance
- *
- * @return a code indicating the severity of the last error. See
- * @ref TJERR "Error codes".
- */
-DLLEXPORT int tj3GetErrorCode(tjhandle handle);
-
-
/* Backward compatibility functions and macros (nothing to see here) */
/* TurboJPEG 1.0+ */
From a5689cd45ba290bcf698a172d24c74aada8c5595 Mon Sep 17 00:00:00 2001
From: DRC
Date: Tue, 3 Sep 2024 15:26:52 -0400
Subject: [PATCH 108/135] Test: Replace big_tree8.bmp and big_building16.ppm
These images were only used with tjbenchtest and tjexampletest, but I
was concerned about introducing additional licensing provisions into the
libjpeg-turbo source tree. Thus, this commit replaces them with images
that I own and can thus make available under the libjpeg-turbo licenses
with no additional provisions.
---
testimages/big_building16.ppm | Bin 202955 -> 0 bytes
testimages/big_tree8.bmp | Bin 82998 -> 0 bytes
testimages/big_tree8.txt | 25 -------------------------
testimages/monkey16.ppm | Bin 0 -> 202955 bytes
testimages/shira_bird8.bmp | Bin 0 -> 82998 bytes
tjbenchtest.in | 8 ++++----
tjexampletest.in | 4 ++--
7 files changed, 6 insertions(+), 31 deletions(-)
delete mode 100644 testimages/big_building16.ppm
delete mode 100644 testimages/big_tree8.bmp
delete mode 100644 testimages/big_tree8.txt
create mode 100644 testimages/monkey16.ppm
create mode 100644 testimages/shira_bird8.bmp
diff --git a/testimages/big_building16.ppm b/testimages/big_building16.ppm
deleted file mode 100644
index b0b843932d3ee44a293adf5b0b1b4ebe7d28ce5b..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 202955
zcmXWiWmlD37l2{AJC7a5JSHY~VJo(%fPi#&v&jv+ySux)lkO4_6T7>3e7W5pVzA&WtJz{mHvScCpO2#gkUarVL-1xTgC-X{s
zSB+fW-xyIhLvhSbw@wz%!cHMn=It!~oQ=G2ZlH8Mc4vHWyUy*au)cEM8{Nj}@o5fq
z(yBeqer}%ejULCRlP03-OG5R_SVho&>k{z;B0w{Tdj%Yzi%@KVipx>tG+371xVtb8dv)VQ{KB0Rja!J7u_e=ce<
zF>;>l?jGcZ-Pzswvu^tJ)&{6XTuX7@5?pUxSYy}FO+R$m{6M;fUJ1XziemPc+TEWl
zsSuielj07g5hTx>AMm~)KCR@04IEPR`wCm&rGF{lxaSz}5xkz6)@RfamRUMKs*miE
z_#zd_DPpFSq%kj1@8O0rGB{4SwfrEwC2==vE6)n-H>Rm=G+*%${;JY-!UdFd0FiJ5
ze2C~V`-*mx>dOQ+M}{JxebIy8WkuhzJ%F?84HXkS)3rs
z3@ILW?n(+IJL=N-lDPcZ_%EO@MMtCC)94wkSNhW^8LffiA?LxE@RHnVMGG&!rk|jl
z4{xhJVfv2y)UmWCNdB=Qpze>Zo_&|rTjaw(L%UxDmcT_3xW&9REH*&Ryf0pqS>mMH
zmtc}yMCS@>y=k`L41%k%i8O_C6uyG9`Ik+0VM*Z$Y7^plln+V(UL7}$tHD^}QQmFl
zwZwNUk-Ay4iSnOxqxPq8zbFijsta@-l!4q&z28*fuyOb+dH8%Hz#6-p_zxJ7tz%rp
z`lKwVn&?$C=JpJ~G1e&d9I4wcN1IQ2eVI?~^|tqPhQ`3z4G-r}ruh{eC7#E9N*|4r
zV6+7f8{FE*?1;yp`p@P;s^9E2C0|U-1YM;b>3r@`!hgD_957s?evE-85rja_+I+0u
zSNWWHQ+Zs&;HKH^@|ESos?TUmsqFgCmGAK<^)J-t!AxETBcU8_*ufvlG-zgV6qqsM
zb}}!&nzRTvtRMuROj-?^$YQgtr9G7_{Y_|Q9nC}KANM}CZW03JBUA?bea8^>Y+Spe
zM%@5iuO7*L94nHKBJv`)3Gg&xib&xRtpfYo&}I%}V&xrsplC+Zea9nZpZ*^SlKv0M
z4^IbA!>+;&$zkd8`HA38-7e7>c$CVc#Nj#G0>c_sgN`8Rz>_6P{O*#?9<$zV>G8Lsvh3CHN-Ud8K_$-72R6c^G#B4=S8odZPiPB-;~Dv
zPoDLDsA9IHRnoH|6G7`1hR#^ZWZkeu4#09Io%v(t(
z9pS2}c@D=pog1E9SKuWJR@Vqzb;3E0AC~9*NtQ8&EZ!RJ4V|0tLAFaX2D4QM(e)6r
zomk6mHo&&eyq9pAc|^1YnV5C5>{FH^s3$HeYFi>db8G19tTVZ|h*vpR^PmY6a(3s)
zudx8RInyqsmg)+xUM)(?$a!=Hl5Z`G46G9Nu@C0Hs46oYW^Zl3U%y3O*LbE@sXrrd
zF#w<|942OB@<}iDCt1gN|$`~ozEn8kblK+O8n7&@n
z!90|{(n=7|EjXavLz$TJ4{ea9&;>7KcNj|7Q|&`av~3upHsOcNfJ=^lom2Se6u;|}suj$n
zriYC<^>}@xfr(#_*+45Te!_^S4n_>Ku9mR`>ovXX6y!
zo2xV^p@gNCXH6^li(MxaW>|KkP`Ny(yK|jBtU}rS$rguMXnQUpKz+No*AuKSpIm?b
zwbnAw#>v;eOY)kYHnqy`JuAC)usUnNVAVn!o#}Cj>LxKnPtX&&y7E6GG-
zDXMFnW=V&{C_D!FE?LTlWE`S=ruM>n&^YQ;xSn)`T?)R=S}M8^IiP4!8&H7;fMGE4
zqT-PBGr_?MAwPz8sYghR!~zS-FqGk|zb_+TC3Src0+&}iv?@$@Lf2~(nR;KbY
zW0+$c&HQLyWNj0~)}5=rrAYU#u;ED*^%O-f>VT!uMB(xW3cH3VEI2ZtFO-}Z6#F4<
zaQ5k(@fACOvvSuHzoEzGMrf<)ivWYPZ`sQsXQ0>0`V-2rH(h~swOzn$fibRaK#aKjI&2E-J0Tf;^@`v
zw|FFQ&0*yS!VudZWhcy2vst~iV3+r|dJindG>1vfJ45>iax5`~?`5qb1=#flAO5HY
zZRI;LplwwHRKDZ&ke83HcYR2E8*zJYTV}&qU4{O;KAat8?9j~>?y7IHbt}d?)=Q!&
z8+7%YQRGMJv#JmS-qdQwYNK2jmrl6M-m9uBg{!~w`oqp^%);O-Q9aGvMS$qKMZqbJ
z^$*?o;@2(JjTcp44PUGb=FtIttW>TZeZyX^50M=75)27SKYN+{9{ISM&x+1JZ>ttQ
zE{&}@XFWm?xYnC}kcEPIazV*-Ym_&g6682;%fbga!{k4TvlTw1VIgGo6{
zfKy=~f{zt8NuF|_kY;(PCNO_v-BCRrM`~iouN3-pAq_OBY(Sqhi6G57>1nan(H}hj
ze$THu?VaZ9~A`)TT}lq!@gUG@j_S&7pv!B6+R@wD@o
z)#Z46MaSIH);8ieSFs_s0_<2|n1KK~#%dR!Cb_o>&*f<(R{H#yORB$0O9N{cx*>w$
zwlPKrb+YxWZWoI7e|<0H1mSw&5Q#5#IBhwt3pu2Mf(ZQ+Y5
zW85=j23L$DPjN`U$p{eE{$JlJ?{ndQl2!%1;(%z1!hrh19jshP`oRX$vp`)GCpfQ^
z5kEfVznG%9oIDau0<9m-AQgxoIsWg!|hU4D@~r{EPIj@p$qM0148
zhQ?U|ngi%A3s)UPL}^2$e~^`eU-W1gMlgoZUfMdKkF}WmvS2B@k$$;!hWro@h1@7X
z36zK?k%7CrBE!5(RgN&Yw-_Sv3tjW|w{V9fB<`4kZ+tNR-(0Ue7>6hzDY9tkr9TYC
zl3=D)G*nh18UnaTtSv+pHiEyU|G;BWC(|P&XXv{V`&~NO-GXLsrP?1BuRP5Wpg7!R
z_)mzBY9YH8$Mfhl)tH)^B_=w4&D(@0b?pZR^mVQ1_Hk!4ooy3X9d&c-#~B+Mf*pO*
zpTzH5RlCs7(7Tl>wU5u1l^q$_~dw>vYuuFT(O$
z_Ep))-vR>azsbTd4K-Fbl&m&d%oXqlqM@2KP@+q+X>Ad~o@Cr&o0Y-T7Z@B*nvOCtIaT
zRTLId)m(K%!mHU_l`C;5cPh(}&nWAN`k0~YH{>yiiJE+d9dJoS#vh0lkSs9vwdL9t
z>9LB^0ew!hL&IqjxkQ_bUy5B~Xu)0fM~NB@kYs4$peF4|^Bo*bu~hUOBj;(zuZwQc
zP`H#>xV}<_0giH{yY~oQd5|76-zk)dK%l$4h~{f;OBATp03sL+n+3+|TXv;{$Wd`)Uh~
z@UfT3=npJdKGkF~rtoJ~3Y;CXEM>gnJ}JY(u+|IidH{}sDP4CP)f-Z%}=h5=p3R4TO3>c(}Q0uRy{yml6fmYdb<-_19
z)aS5_*xOndTV0;uI;Gpo2k5s-f|x>DFy$(=m~;+vwD>raj@w*#ocaVwP4A`WVGrcb
zq=yq4XP@>yk?5*3FQNPzsM^YZR)M4}Bq8!oLO+(y
zPWXtqS42$wJ6RM%GPtp?)AdP52AbTIM@$d{E*3B&hCz#p-USwtBS5^Xm3$md9Th44
z%w(2r$=c^fc@U90~}Jfhl@~Q_!cY4m&a2Ct8r9LU@wOq;CS+I1u{gY_9m0czE$>U4r2U
z^u&NZ(Jt=Tk_^#O78aPm2!g)|*>AWek4oNTUuoM+tTOpJ{CQ_&KrM`P4&8vgoU#=A
z8T(JlLgRGJTF!b`n&+5iiOP{~%~DEX{wxdybT2g`)D;`(H~Rp^AGcI`
zHul1dWyrw8VfHl%*XW5}pO?v=ytp0HiqfHHPO0fHsf!avDb<`=QS;eTsVCACIT@U9
z6@Qe8QXza!4Z{6ee%2ALyGquSC`$VSzR(z)t%Y9&Rs5l#c&0Cf8W+yF&3IcR9cU2=
z`LiT}z{PLMuCv$6)f}E9NRvvA!#)AuirJ&Ia&Y+20eymPOb~EB(g$@c)dW6WUX;kn
zJ(Gcs(4I{y>UC&n-TW7*S~YxM8fwAc&*h54~?9r_2}R@8u)iDc!L
zLw|smr?r;X0C2&xa1)Ey2GYqxAf+KMiOGnExqCn?=$MLM8P)lh;(wKIEUSqgsZ10^
z0a_&%)h5JLI#}}xcai3!xFZa7$P_uVsRTcRR9uuhqZ%dsC4bUkNZG#4Mpd
zB^+vJB#^d3iU+E$ke{Nj7nvpN5sT=FR6^lA-Bry<#1!>1kr*<4K%b3j8A+ezylCqZ
zrYm;}ZomMrIuJf(3v4LjQ*r>ipV|-DT*=b@$AZ+{aZG13iata4W^axDnI?>eai%h+
zRP3;xFh}!0%QhQ!Fn<{>mO}DHK8>w{F3iCvKM47qb3FN3=-|SIsbNuyvLRWg!(Krp
zg`b1p)9NtibN0#RbIZ$~X{Jj1NEpT*ZWk|;#-@zRMi}p!h$O3Ftz!bMPM=^IOrr|N
ziI>4im|f^6vHh53AXd^`W;WY<1G4sQ1(z1i#WD8nb#5adGy|ia%Mf
z)ZSb}oSqp>Se*G*YnT5Ea#;T{n{hLY08=u%P~5BVP}YkHtPA)VxSF!|4u+d5>pb^?d2bMbu?#b$&s*Aj~BfU_!0VWX6b{
zz`MJq6|Mu_-X9Fz0x_K%ff@}HMNNc_M5To;gIq?Oi0mEESJh{HDAZ?nWpgivQUB0i
zro1PlFm?kE5PUF631=yjU=>L(%A+B`^fJII*xZaRDS{(IZ2kL<6U8njOd&lk_0Nkf
zEKOP{9L@-2`00NO{cykO^YKlwG>jA;9>t~RAW_MOucb#E3A`5CAKnsj06;7F7-hg;
zMa_y@gWOheGi43!3w|fGLK;HpEG;ukR(KF!p!*^EkVV`r6nRvynWtTjKV<^TbPNYd
zj_v?dm3d12lMYy-Rkye{kH6)$vazbyouvJy_$G^|#z>y*X|W{l3OO&UQD$89Lj(J&Q(WRxV4zrLi2%M}bSox=x9f79-}
zD;%}7Z*``IZDe!Lo$KxPkGJ=>&uOZ)X`MP<8F@Wlg$|S6k`2QAX%xFPjC(D#1_r
z`mX0?N~3wcX#@PLooV`}2$O8r-eLV7&?kCKk>^h^Etg+JKGiHV>G5ww^Tam+Z)*s(
zgQP3!$9WL4VO{GQx2mr{esPmged_VAoAAcGzM4jw#@76IUbA^?Es?y<1MZkd$ibzpnE~l%!Z&7L%zYKt51tQs
zpA$qSkOd%r>w6860aHER(X?+tMV=^~l83XM{Dy
zN7J4FFK3U8W5%vYHbv(ln=7_wwUC_z{{mX3F|GA{WX8v|>47V#V*Ku`DH@=>4=OjD
zFb<{m=x3VDY>IfUVh@iAdWK$sJp-&P3QEvuo8>bxPx*1Y#JrCTj&NbJNi#vrDFUb$
z@TUP^awObDL_g&+*&jKCP)5PQ3TV5;`{}KoOLgO&^f%xqi|!5izV&r&Uv9#O=({_h
zen*dHEG;>H`rN3+@?d5}&N5Q``}B|N0Qn8&vb}4NukqNEH}J#AfOFFFJjBs+b=kfE
zWZ<=whP;g-CzHGL9*5a+fs7l>Ya(Bfqu^QI*X%R9d$6x@C*#5kv!L#jeX(QWE6zp(
zeX_upt8-!e$YgSv#=V~2^x{L
zmkZWW8W3akdo82Pes+tMk#oYHrpn
zvOZL-7Kw2y3!hXV<2+C;{$xJKyhUAs*;qT=QcIfOGRL(87TQ3u{X+2!xjF$kUa&?H
z0|{p=peAH|6>~}4)OrnuuLkg4e!2^gssVkDMspLc)1owNV8!3M-Fd;f|3k;KiJj*@
zUwV~s8}Kda#mBqT-bLSh+jyyUqP<=<-CiJH#HcioH9x6KSWSv3OhRK$wOV?%E8G*r
z<@NS71?wZ6Ld#CNHlLL%zeXO=2m4)qICcVO2mT`{iWN>;1Y9ND$=?SHFyoX;+)?9U
z;r2{7_Xer>{6?mSa3pXNZyb4FcD9JjAr*I!6X~mqwH!Fl1s_KoSP6-{wF6JAuo9u
z(mtTC=o7#hHkA8^wlyDQ7^=Pr!|D#|+pw?1{W2DbQ{o5v41AKkr?57?0Z&2uWGz)@
zO47jh2op(#8C#Vlf|_h|O^qr7*{BddWpC1w9KiPZWdaoD
z)H`{z_F4K)&3AQ2DxN7~505dFl!EI5n=)Xz$`DYV8}Kb_MJ5n%I&|V?M22ja`8+jw
z*MX-Y&vR{;cuAGHyi4Yw@!>y@osW%=x_{zeX=b+aG9zY3a`ef7Fjvf>UHe1khdXwq
z1viF~cf7uIJUC@{{iSJ9jI(KxzA+C^KFXb!d;WYELW#H-y91Mf_@1~Nw7eX7?QFTe
zXx!zerQeI;aZz|MhMjdlj^G4T{H{E1n$o{wLl9t<&ZR4uQIuvxwo{Vl!#G?4LeHn&psYf`=K!pO37vmuD+oOwT5WJ>Cw2|i2E7FvcQV*ad^Nz*usR#
z%yZN)x#`?g%=^efvrF4vvcmb?T7sHxKWThbdfN6#=R%#fkC4Y=Hpp$H`>8_>b6HDM
zhSqB}wWZG+P|Cc#iFTrj2AW~*(_CRvo=AIb)jL1#c%kST^?CK{u$y(?``^5J6g|*8
z%FcxP``(%Q6C$Q;oBTdK+A`U^hxewZtah;0b}OU#t}dwabwjrFsGv)-gR~u&gUK(M
zFUjSMD#_u*@?r~48KI5b(*=4NNpz8~YwJ5_K)1S9pfG
zuHdtMsiF^>QG41x4Tmsl^*0Dc;!8{w08=Qy;L|DvsaWQU}8-K3zLp@I~F+2hIh3?8YqS}?NKeUiW&Fy
zozD&L;~pl|9ULFNKKjvy+|W%ioBm6Wsz^D%`b^@m+(#Sjh1H0@BUc2swGHL_OoJS)
zgsF;Us7cZUhp#~TfiteC$ahgK(NoX>a9`L%_~7FCm#nCrWvI|h
zC>cb|TI<-S=q1s57uAQE00yTb9X(CFm6>12;lCggQk0by)-w9Cnq!q8#I21%^~YrE
zxK$)mzNEkdXo=RbY;+><8r#X6R7OFmX<->X>{qPYDLtyo+{;B3`UsH~6XxBi+e4b6
zTF1i{h>6FsClVOE%hcDUJa@2R8?DqJR!m~O0P28i^WSR1InPmN-2Y0ibJr&T>=7vDMAI#m|w9BunbzfiFN`@3v5X&sA%D>0MI-#JIL6ZClc
z_C|BdOg!dA((OKOdDk6RC25&*9xXb%o%e;5meC|E!T%G#hOIzcyU>9Ssz5{raj$cI
zpoxMXB7ayOT4{U{FiaLz?NRuDOaX
z6Z|ez59qUK73TaNl|agY{6ZfhMi(ZOX+W2wWjG$zl32*|rM)e*BmadXBi#e~3UUj&
zA_QqA>8r!QAV=xCW+mg)otKR!
z<)P-xx^w0c?ddH5r>bRZ<51)BW_ry5L1E|OI+{sY^b5H8Fg(qaMP9Quc4?Z=%KNds
znQPV@PbB0At&1$43|Y6cj(=ZyJh#$fuJe_i9w@be{Ud#Qj3Cu~G%NH+?BatzBGGZx
zdjMgdqD33ehBBk}Y~zRQiNNeh2u=@g-^UG3h)6rSFY02^Q`r^W+N$3zEbRioGMG>t}lD2s})^9ix!cGR-~eTfRo=1q!6v|+p=
zmIm;PvK@6TJqUWSA}z)NrB?hGbx(7NJ-duzy(>=!XEpUW67bl{<8~(EyTxmn4|>^n
z%kHMP3O90+K~IQUq<