Merge pull request #115879 from akien-mga/libjpeg-turbo-cleanup-config

libjpeg-turbo: Improve config files and fix patches
This commit is contained in:
Thaddeus Crews
2026-02-05 09:32:32 -06:00
6 changed files with 84 additions and 103 deletions

View File

@@ -552,6 +552,7 @@ Files extracted from upstream source:
Patches:
- `0001-cmake-generated-headers.patch` ([GH-104347](https://github.com/godotengine/godot/pull/104347))
* Compare with CMake-generated headers to bump version and added potential new config values.
- `0002-disable-16bitlossless.patch` ([GH-104347](https://github.com/godotengine/godot/pull/104347))
- `0003-remove-bmp-ppm-support.patch` ([GH-104347](https://github.com/godotengine/godot/pull/104347))

View File

@@ -1,9 +1,9 @@
diff --git a/thirdparty/libjpeg-turbo/src/jconfig.h b/thirdparty/libjpeg-turbo/src/jconfig.h
new file mode 100644
index 0000000000..42d9654c0f
index 0000000000..50e5986c69
--- /dev/null
+++ b/thirdparty/libjpeg-turbo/src/jconfig.h
@@ -0,0 +1,62 @@
@@ -0,0 +1,69 @@
+// Originally generated by libjpeg-turbo's cmake build, then modified to support multiple platforms.
+
+/* Version ID for the JPEG library.
@@ -12,10 +12,10 @@ index 0000000000..42d9654c0f
+#define JPEG_LIB_VERSION 62
+
+/* libjpeg-turbo version */
+#define LIBJPEG_TURBO_VERSION 3.1.0
+#define LIBJPEG_TURBO_VERSION 3.1.3
+
+/* libjpeg-turbo version in integer form */
+#define LIBJPEG_TURBO_VERSION_NUMBER 3001000
+#define LIBJPEG_TURBO_VERSION_NUMBER 3001003
+
+/* Support arithmetic encoding when using 8-bit samples */
+#define C_ARITH_CODING_SUPPORTED 1
@@ -27,8 +27,15 @@ index 0000000000..42d9654c0f
+#define MEM_SRCDST_SUPPORTED 1
+
+/* Use accelerated SIMD routines when using 8-bit samples */
+// Godot: Disabled for simplicity of compiling the library cross-platform.
+// Could be enabled if it's confirmed to be worth the effort.
+//#define WITH_SIMD 1
+
+// Godot: Disable those as they're for forcing different SIMD CPU support
+// via environment variables, that's super niche and we don't build with SIMD.
+#define NO_GETENV
+#define NO_PUTENV
+
+/* This version of libjpeg-turbo supports run-time selection of data precision,
+ * so BITS_IN_JSAMPLE is no longer used to specify the data precision at build
+ * time. However, some downstream software expects the macro to be defined.
@@ -68,32 +75,29 @@ index 0000000000..42d9654c0f
+#endif
diff --git a/thirdparty/libjpeg-turbo/src/jconfigint.h b/thirdparty/libjpeg-turbo/src/jconfigint.h
new file mode 100644
index 0000000000..45bd3ec321
index 0000000000..38acc75108
--- /dev/null
+++ b/thirdparty/libjpeg-turbo/src/jconfigint.h
@@ -0,0 +1,102 @@
@@ -0,0 +1,103 @@
+// Originally generated by libjpeg-turbo's cmake build, then modified to support multiple platforms.
+
+/* libjpeg-turbo build number */
+#define BUILD "20250317"
+#define BUILD "Godot"
+
+/* How to hide global symbols. */
+#ifndef HIDDEN
+ #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
+ #define HIDDEN __attribute__((visibility("hidden")))
+ #else
+ #define HIDDEN
+ #endif
+#if defined(__GNUC__)
+#define HIDDEN __attribute__((visibility("hidden")))
+#else
+#define HIDDEN
+#endif
+
+/* Compiler's inline keyword */
+#undef inline
+
+/* How to obtain function inlining. */
+#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
+ #define INLINE __inline__ __attribute__((always_inline))
+#if defined(_MSC_VER)
+#define INLINE __forceinline
+#elif defined(__GNUC__)
+#define INLINE __inline__ __attribute__((always_inline))
+#else
+ #define INLINE inline
+#define INLINE inline
+#endif
+
+/* How to obtain thread-local storage */
@@ -107,7 +111,7 @@ index 0000000000..45bd3ec321
+#define PACKAGE_NAME "libjpeg-turbo"
+
+/* Version number of package */
+#define VERSION "3.1.0"
+#define VERSION "3.1.3"
+
+/* The size of `size_t', as computed by sizeof. */
+#if defined(__SIZEOF_SIZE_T__)
@@ -126,7 +130,9 @@ index 0000000000..45bd3ec321
+#endif
+
+/* Define to 1 if you have the <intrin.h> header file. */
+/* #undef HAVE_INTRIN_H */
+#if defined(_MSC_VER)
+ #define HAVE_INTRIN_H
+#endif
+
+#if defined(_MSC_VER) && defined(HAVE_INTRIN_H)
+#if (SIZEOF_SIZE_T == 8)
@@ -171,37 +177,11 @@ index 0000000000..45bd3ec321
+#define D_ARITH_CODING_SUPPORTED 1
+
+/* Use accelerated SIMD routines. */
+// Godot: Disabled for simplicity of compiling the library cross-platform.
+// Could be enabled if it's confirmed to be worth the effort.
+//#define WITH_SIMD 1
+
+#endif
diff --git a/thirdparty/libjpeg-turbo/src/jmorecfg.h b/thirdparty/libjpeg-turbo/src/jmorecfg.h
index 89c7842c87..c96edd2300 100644
--- a/thirdparty/libjpeg-turbo/src/jmorecfg.h
+++ b/thirdparty/libjpeg-turbo/src/jmorecfg.h
@@ -1,3 +1,5 @@
+// Modified to remove lossless jpeg support.
+
/*
* jmorecfg.h
*
@@ -242,7 +244,7 @@ typedef int boolean;
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define C_LOSSLESS_SUPPORTED /* Lossless JPEG? */
+//#define C_LOSSLESS_SUPPORTED /* Lossless JPEG? */
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
@@ -259,7 +261,7 @@ typedef int boolean;
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define D_LOSSLESS_SUPPORTED /* Lossless JPEG? */
+//#define D_LOSSLESS_SUPPORTED /* Lossless JPEG? */
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
diff --git a/thirdparty/libjpeg-turbo/src/jversion.h b/thirdparty/libjpeg-turbo/src/jversion.h
new file mode 100644
index 0000000000..40f7a6cc82

View File

@@ -1,18 +1,33 @@
diff --git a/thirdparty/README.md b/thirdparty/README.md
index c22ef77af7..52b635df05 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -539,7 +539,7 @@ Patches:
## libjpeg-turbo
diff --git a/thirdparty/libjpeg-turbo/src/jmorecfg.h b/thirdparty/libjpeg-turbo/src/jmorecfg.h
index 89c7842c87..c96edd2300 100644
--- a/thirdparty/libjpeg-turbo/src/jmorecfg.h
+++ b/thirdparty/libjpeg-turbo/src/jmorecfg.h
@@ -1,3 +1,5 @@
+// Modified to remove lossless jpeg support.
+
/*
* jmorecfg.h
*
@@ -242,7 +244,7 @@ typedef int boolean;
- Upstream: https://github.com/libjpeg-turbo/libjpeg-turbo
-- Version: 3.1.0 (20ade4dea9589515a69793e447a6c6220b464535, 2024)
+- Version: 3.1.3 (af9c1c268520a29adf98cad5138dafe612b3d318, 2025)
- License: BSD-3-Clause and IJG
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define C_LOSSLESS_SUPPORTED /* Lossless JPEG? */
+//#define C_LOSSLESS_SUPPORTED /* Lossless JPEG? */
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
@@ -259,7 +261,7 @@ typedef int boolean;
Files extracted from upstream source:
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define D_LOSSLESS_SUPPORTED /* Lossless JPEG? */
+//#define D_LOSSLESS_SUPPORTED /* Lossless JPEG? */
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
diff --git a/thirdparty/libjpeg-turbo/src/turbojpeg.c b/thirdparty/libjpeg-turbo/src/turbojpeg.c
index 45fc0f954c..d514da43d2 100644
index 23dbe6bb75..969174f72e 100644
--- a/thirdparty/libjpeg-turbo/src/turbojpeg.c
+++ b/thirdparty/libjpeg-turbo/src/turbojpeg.c
@@ -1196,9 +1196,6 @@ bailout:

View File

@@ -1,16 +1,3 @@
diff --git a/thirdparty/README.md b/thirdparty/README.md
index c22ef77af7..52b635df05 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -539,7 +539,7 @@ Patches:
## libjpeg-turbo
- Upstream: https://github.com/libjpeg-turbo/libjpeg-turbo
-- Version: 3.1.0 (20ade4dea9589515a69793e447a6c6220b464535, 2024)
+- Version: 3.1.3 (af9c1c268520a29adf98cad5138dafe612b3d318, 2025)
- License: BSD-3-Clause and IJG
Files extracted from upstream source:
diff --git a/thirdparty/libjpeg-turbo/src/turbojpeg-mp.c b/thirdparty/libjpeg-turbo/src/turbojpeg-mp.c
index 6fecc5cb80..21d26536c1 100644
--- a/thirdparty/libjpeg-turbo/src/turbojpeg-mp.c
@@ -288,20 +275,10 @@ index 6fecc5cb80..21d26536c1 100644
#undef _JSAMPROW
#undef _buffer
diff --git a/thirdparty/libjpeg-turbo/src/turbojpeg.c b/thirdparty/libjpeg-turbo/src/turbojpeg.c
index 45fc0f954c..969174f72e 100644
index d514da43d2..969174f72e 100644
--- a/thirdparty/libjpeg-turbo/src/turbojpeg.c
+++ b/thirdparty/libjpeg-turbo/src/turbojpeg.c
@@ -1196,9 +1196,6 @@ bailout:
#define BITS_IN_JSAMPLE 12
#include "turbojpeg-mp.c"
#undef BITS_IN_JSAMPLE
-#define BITS_IN_JSAMPLE 16
-#include "turbojpeg-mp.c"
-#undef BITS_IN_JSAMPLE
/* TurboJPEG 1.2+ */
DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
@@ -3094,48 +3091,3 @@ bailout:
@@ -3091,48 +3091,3 @@ bailout:
free(sizes);
return retval;
}

View File

@@ -6,10 +6,10 @@
#define JPEG_LIB_VERSION 62
/* libjpeg-turbo version */
#define LIBJPEG_TURBO_VERSION 3.1.0
#define LIBJPEG_TURBO_VERSION 3.1.3
/* libjpeg-turbo version in integer form */
#define LIBJPEG_TURBO_VERSION_NUMBER 3001000
#define LIBJPEG_TURBO_VERSION_NUMBER 3001003
/* Support arithmetic encoding when using 8-bit samples */
#define C_ARITH_CODING_SUPPORTED 1
@@ -21,8 +21,15 @@
#define MEM_SRCDST_SUPPORTED 1
/* Use accelerated SIMD routines when using 8-bit samples */
// Godot: Disabled for simplicity of compiling the library cross-platform.
// Could be enabled if it's confirmed to be worth the effort.
//#define WITH_SIMD 1
// Godot: Disable those as they're for forcing different SIMD CPU support
// via environment variables, that's super niche and we don't build with SIMD.
#define NO_GETENV
#define NO_PUTENV
/* This version of libjpeg-turbo supports run-time selection of data precision,
* so BITS_IN_JSAMPLE is no longer used to specify the data precision at build
* time. However, some downstream software expects the macro to be defined.

View File

@@ -1,25 +1,22 @@
// Originally generated by libjpeg-turbo's cmake build, then modified to support multiple platforms.
/* libjpeg-turbo build number */
#define BUILD "20250317"
#define BUILD "Godot"
/* How to hide global symbols. */
#ifndef HIDDEN
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
#define HIDDEN __attribute__((visibility("hidden")))
#else
#define HIDDEN
#endif
#if defined(__GNUC__)
#define HIDDEN __attribute__((visibility("hidden")))
#else
#define HIDDEN
#endif
/* Compiler's inline keyword */
#undef inline
/* How to obtain function inlining. */
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
#define INLINE __inline__ __attribute__((always_inline))
#if defined(_MSC_VER)
#define INLINE __forceinline
#elif defined(__GNUC__)
#define INLINE __inline__ __attribute__((always_inline))
#else
#define INLINE inline
#define INLINE inline
#endif
/* How to obtain thread-local storage */
@@ -33,7 +30,7 @@
#define PACKAGE_NAME "libjpeg-turbo"
/* Version number of package */
#define VERSION "3.1.0"
#define VERSION "3.1.3"
/* The size of `size_t', as computed by sizeof. */
#if defined(__SIZEOF_SIZE_T__)
@@ -52,7 +49,9 @@
#endif
/* Define to 1 if you have the <intrin.h> header file. */
/* #undef HAVE_INTRIN_H */
#if defined(_MSC_VER)
#define HAVE_INTRIN_H
#endif
#if defined(_MSC_VER) && defined(HAVE_INTRIN_H)
#if (SIZEOF_SIZE_T == 8)
@@ -97,6 +96,8 @@
#define D_ARITH_CODING_SUPPORTED 1
/* Use accelerated SIMD routines. */
// Godot: Disabled for simplicity of compiling the library cross-platform.
// Could be enabled if it's confirmed to be worth the effort.
//#define WITH_SIMD 1
#endif