Update bundled libjpeg-turbo to version 3.0.2

[ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 3.0.2

Fixes: QTBUG-121737
Change-Id: I0085f0f859dd9c95ed203fd22bd9702fd1e9d721
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 972bd4ed46be6ad905f2cd8bd84776cf3f1f3220)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 27625a33c548e1330ad93f81567d357fe5f4d224)
(cherry picked from commit 027724d66e649f51fee8f96fe1a2e48892848307)
This commit is contained in:
Eirik Aavitsland 2024-02-01 11:03:46 +01:00 committed by Qt Cherry-pick Bot
parent 736d6300bb
commit f9537eda1d
16 changed files with 148 additions and 121 deletions

View File

@ -61,7 +61,8 @@ set(JPEG_SOURCES
src/jerror.c
src/jfdctflt.c
src/jmemmgr.c
src/jmemnobs.c)
src/jmemnobs.c
src/jpeg_nbits.c)
qt_internal_add_3rdparty_library(BundledLibjpeg16bits
STATIC

View File

@ -1,4 +1,4 @@
Copyright (C) 2009-2023 D. R. Commander
Copyright (C) 2009-2024 D. R. Commander
Copyright (C) 2015, 2020 Google, Inc.
Copyright (C) 2019-2020 Arm Limited
Copyright (C) 2015-2016, 2018 Matthieu Darbois

View File

@ -125,7 +125,7 @@ FILES="
jmemnobs.c
jmemsys.h
jmorecfg.h
jpeg_nbits_table.h
jpeg_nbits.h
jquant1.c
jquant2.c
jsamplecomp.h

View File

@ -7,8 +7,8 @@
"Description": "The Independent JPEG Group's JPEG software",
"Homepage": "http://libjpeg-turbo.virtualgl.org/",
"Version": "3.0.1",
"DownloadLocation": "https://sourceforge.net/projects/libjpeg-turbo/files/3.0.1/libjpeg-turbo-3.0.1.tar.gz",
"Version": "3.0.2",
"DownloadLocation": "https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.0.2/libjpeg-turbo-3.0.2.tar.gz",
"License": "Independent JPEG Group License and BSD 3-Clause \"New\" or \"Revised\" License and zlib License",
"LicenseId": "IJG AND BSD-3-Clause AND Zlib",

View File

@ -1,3 +1,38 @@
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.
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. 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.
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
=====
@ -2146,7 +2181,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

View File

@ -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 <limits.h>
/*
* 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.

View File

@ -2,9 +2,9 @@
#define JPEG_LIB_VERSION 80
#define LIBJPEG_TURBO_VERSION 3.0.0
#define LIBJPEG_TURBO_VERSION 3.0.2
#define LIBJPEG_TURBO_VERSION_NUMBER 3000000
#define LIBJPEG_TURBO_VERSION_NUMBER 3000002
#define C_ARITH_CODING_SUPPORTED 1
@ -17,3 +17,4 @@
#endif
#define NO_PUTENV

View File

@ -4,11 +4,13 @@
#define BUILD ""
#define HIDDEN
#define INLINE inline
#define PACKAGE_NAME "libjpeg-turbo"
#define VERSION "3.0.0"
#define VERSION "3.0.2"
#if SIZE_MAX == 0xffffffff
#define SIZEOF_SIZE_T 4
@ -46,3 +48,4 @@
/* #undef WITH_SIMD */
#endif

View File

@ -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

View File

@ -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. */

View File

@ -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);

View File

@ -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")

View File

@ -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 <Files.h>
#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;

View File

@ -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

43
src/3rdparty/libjpeg/src/jpeg_nbits.h vendored Normal file
View File

@ -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

View File

@ -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" \
@ -52,4 +52,4 @@
"Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
#define JCOPYRIGHT_SHORT \
"Copyright (C) 1991-2023 The libjpeg-turbo Project and many others"
"Copyright (C) 1991-2024 The libjpeg-turbo Project and many others"