Skip to content

Commit 23791f2

Browse files
committed
PR review feedback addressed
Co-authored-by: Rémi Verschelde <[email protected]>
1 parent 8a1f5d7 commit 23791f2

16 files changed

+38
-107
lines changed

COPYRIGHT.txt

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ License: BSD-3-clause
331331

332332
Files: thirdparty/libjpeg-turbo/*
333333
Comment: libjpeg-turbo
334-
Copyright: Copyright (C)2009-2024 D. R. Commander
335-
Copyright (C)2015 Viktor Szathmáry.
334+
Copyright: 2009-2024, D. R. Commander
335+
2015, Viktor Szathmáry.
336336
1991-2020, Thomas G. Lane, Guido Vollbeding
337-
License: TurboJPEG modified BSD-3-clause, IJG License
337+
License: BSD-3-clause and IJG
338338

339339
Files: thirdparty/libktx/*
340340
Comment: KTX
@@ -1685,15 +1685,15 @@ License: HarfBuzz
16851685
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
16861686
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
16871687

1688-
License: IJG License
1688+
License: IJG
16891689
The authors make NO WARRANTY or representation, either express or implied,
16901690
with respect to this software, its quality, accuracy, merchantability, or
16911691
fitness for a particular purpose. This software is provided "AS IS", and you,
16921692
its user, assume the entire risk as to its quality and accuracy.
1693-
1693+
.
16941694
This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
16951695
All Rights Reserved except as specified below.
1696-
1696+
.
16971697
Permission is hereby granted to use, copy, modify, and distribute this
16981698
software (or portions thereof) for any purpose, without fee, subject to these
16991699
conditions:
@@ -1707,16 +1707,16 @@ License: IJG License
17071707
(3) Permission for use of this software is granted only if the user accepts
17081708
full responsibility for any undesirable consequences; the authors accept
17091709
NO LIABILITY for damages of any kind.
1710-
1710+
.
17111711
These conditions apply to any software derived from or based on the IJG code,
17121712
not just to the unmodified library. If you use our work, you ought to
17131713
acknowledge us.
1714-
1714+
.
17151715
Permission is NOT granted for the use of any IJG author's name or company name
17161716
in advertising or publicity relating to this software or products derived from
17171717
it. This software may be referred to only as "the Independent JPEG Group's
17181718
software".
1719-
1719+
.
17201720
We specifically permit and encourage the use of this software as the basis of
17211721
commercial products, provided that all warranty or liability claims are
17221722
assumed by the product vendor.
@@ -2179,34 +2179,6 @@ License: OFL-1.1
21792179
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21802180
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE.
21812181

2182-
License: TurboJPEG modified BSD-3-clause
2183-
Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.<br>
2184-
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
2185-
2186-
Redistribution and use in source and binary forms, with or without
2187-
modification, are permitted provided that the following conditions are met:
2188-
2189-
- Redistributions of source code must retain the above copyright notice,
2190-
this list of conditions and the following disclaimer.
2191-
- Redistributions in binary form must reproduce the above copyright notice,
2192-
this list of conditions and the following disclaimer in the documentation
2193-
and/or other materials provided with the distribution.
2194-
- Neither the name of the libjpeg-turbo Project nor the names of its
2195-
contributors may be used to endorse or promote products derived from this
2196-
software without specific prior written permission.
2197-
2198-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
2199-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2200-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2201-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
2202-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2203-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2204-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2205-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2206-
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2207-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2208-
POSSIBILITY OF SUCH DAMAGE.
2209-
22102182
License: Unicode
22112183
COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later)
22122184
.

modules/jpg/SCsub

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from misc.utility.scons_hints import *
44
Import("env")
55
Import("env_modules")
66

7-
env_jpeg_turbo = env_modules.Clone()
7+
env_jpg = env_modules.Clone()
88

99
thirdparty_obj = []
1010

@@ -72,48 +72,32 @@ thirdparty_sources_bit_dependent = [
7272
"jquant2.c",
7373
]
7474

75-
absent_in_16 = frozenset(
76-
[
77-
"jcdctmgr.c",
78-
"jccoefct.c",
79-
"jdcoefct.c",
80-
"jddctmgr.c",
81-
"jfdctfst.c",
82-
"jfdctint.c",
83-
"jidctflt.c",
84-
"jidctfst.c",
85-
"jidctint.c",
86-
"jidctred.c",
87-
]
88-
)
89-
9075
thirdparty_sources_by_bits = {
9176
8: list(thirdparty_sources_bit_dependent),
9277
12: list(thirdparty_sources_bit_dependent),
93-
16: [x for x in thirdparty_sources_bit_dependent if x not in absent_in_16],
9478
}
9579

9680

9781
def source_paths(files):
9882
return [thirdparty_dir + "/src/" + f for f in files]
9983

10084

101-
env_jpeg_turbo.Prepend(CPPEXTPATH=[thirdparty_dir + "/src"])
85+
env_jpg.Prepend(CPPEXTPATH=[thirdparty_dir + "/src"])
10286

10387

10488
def add_bit_depth(bit_depth: int):
105-
env_bit_depth = env_jpeg_turbo.Clone()
89+
env_bit_depth = env_jpg.Clone()
10690
env_bit_depth.disable_warnings()
10791
env_bit_depth["OBJSUFFIX"] = f"_{bit_depth}{env_bit_depth['OBJSUFFIX']}"
108-
env_bit_depth.AppendUnique(CPPDEFINES=[f"BITS_IN_JSAMPLE={bit_depth}"]) # to unique or not?
92+
env_bit_depth.Append(CPPDEFINES=[f"BITS_IN_JSAMPLE={bit_depth}"])
10993
env_bit_depth.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_by_bits[bit_depth]))
11094

11195

11296
add_bit_depth(8)
11397
add_bit_depth(12)
11498
# add_bit_depth(16)
11599

116-
env_thirdparty = env_jpeg_turbo.Clone()
100+
env_thirdparty = env_jpg.Clone()
117101
env_thirdparty.disable_warnings()
118102
env_thirdparty.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_common))
119103
env.modules_sources += thirdparty_obj
@@ -122,7 +106,7 @@ env.modules_sources += thirdparty_obj
122106

123107
module_obj = []
124108

125-
env_jpeg_turbo.add_source_files(module_obj, "*.cpp")
109+
env_jpg.add_source_files(module_obj, "*.cpp")
126110
env.modules_sources += module_obj
127111

128112
# Needed to force rebuilding the module files when the thirdparty library is updated.

modules/jpg/image_loader_libjpeg_turbo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ Error jpeg_turbo_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer,
5050
const TJCS colorspace = (TJCS)tj3Get(tj_instance, TJPARAM_COLORSPACE);
5151

5252
if (tj3Get(tj_instance, TJPARAM_PRECISION) > 8) {
53-
// proceed anyway and convert to rgb8?
53+
// Proceed anyway and convert to rgb8?
5454
tj3Destroy(tj_instance);
55-
return ERR_UNAVAILABLE; // TODO what return code to use for unsupported image formats?
55+
return ERR_UNAVAILABLE;
5656
}
5757

5858
TJPF tj_pixel_format;
@@ -61,7 +61,7 @@ Error jpeg_turbo_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer,
6161
tj_pixel_format = TJPF_GRAY;
6262
gd_pixel_format = Image::FORMAT_L8;
6363
} else {
64-
// force everything else (RGB, CMYK etc) into RGB8
64+
// Force everything else (RGB, CMYK etc) into RGB8.
6565
tj_pixel_format = TJPF_RGB;
6666
gd_pixel_format = Image::FORMAT_RGB8;
6767
}
@@ -119,7 +119,7 @@ static Vector<uint8_t> _jpeg_turbo_buffer_save_func(const Ref<Image> &p_img, flo
119119
}
120120

121121
if (image->get_format() != Image::FORMAT_RGB8) {
122-
// TODO allow grayscale L8?
122+
// Allow grayscale L8?
123123
image = image->duplicate();
124124
image->convert(Image::FORMAT_RGB8);
125125
}
@@ -142,7 +142,8 @@ static Vector<uint8_t> _jpeg_turbo_buffer_save_func(const Ref<Image> &p_img, flo
142142
ERR_FAIL_V_MSG(output, "Couldn't set jpg subsamples");
143143
}
144144

145-
// TODO set colorspace?
145+
// If the godot image format is `Image::FORMAT_L8` we could set the appropriate
146+
// colour space here rather than defaulting to RGB.
146147

147148
unsigned char *jpeg_buff = NULL;
148149
size_t jpeg_size = 0;

thirdparty/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,20 +488,21 @@ Patches:
488488
## libjpeg-turbo
489489

490490
- Upstream: https://github.com/libjpeg-turbo/libjpeg-turbo
491-
- Version: git (adbb328159b5558e846690c49f9458deccbb0f43, 2025)
492-
- License: TurboJPEG modified BSD-3-Clause, IJG License
491+
- Version: git (20ade4dea9589515a69793e447a6c6220b464535, 2024)
492+
- License: BSD-3-Clause and IJG
493493

494494
Files extracted from upstream source:
495495

496-
- src/*.{c,h} except for:
497-
- cdjpeg.c, cjpeg.c, djpeg,c, example.c, jcdiffct.c jclhuff.c, jclossls.c, jpegtran.c, rdbmp.c, rdcolmap.c, rdgif.c, rdjpgcom.c, rdppm.c, rdswitch.c, rdtarga.c, strtestc, tjbench.c, tjcomp.c, tjdecomp.c, tjtran.c, tjunittest.c, tjutil.c, wrbmp.c, wrgif.c, wrjpgcom.c, wrppm.c, wrtarga.c
496+
- `src/*.{c,h}` except for:
497+
* `cdjpeg.c cjpeg.c djpeg.c example.c jcdiffct.c jclhuff.c jclossls.c jcstest.c jddiffct.c jdlhuff.c jdlossls.c jlossls.h jpegtran.c rdbmp.c rdcolmap.c rdgif.c rdjpgcom.c rdppm.c rdswitch.c rdtarga.c strtest.c tjbench.c tjcomp.c tjdecomp.c tjtran.c tjunittest.c tjutil.c wrbmp.c wrgif.c wrjpgcom.c wrppm.c wrtarga.c`
498498
- `LICENSE.md`
499499
- `README.ijg`
500500

501501
Patches:
502502

503-
- `000-cmake_generated_headers.patch`
504-
- `001-disable-16bitlossless.patch`
503+
- `0001-cmake-generated-headers.patch` (GH-104347)
504+
- `0002-disable-16bitlossless.patch` (GH-104347)
505+
- `0003-remove-bmp-ppm-support.patch` (GH-104347)
505506

506507
## libktx
507508

thirdparty/basis_universal/encoder/basisu_astc_hdr_6x6_enc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace astc_6x6_hdr
1616
{
1717
// Important: The Delta ITP colorspace error metric we use internally makes several assumptions about the nature of the HDR RGB inputs supplied to the encoder.
1818
// This encoder computes colorspace error in the ICtCp (or more accurately the delta ITP, where CT is scaled by .5 vs. ICtCp to become T) colorspace, so getting this correct is important.
19-
// By default the encoder assumes the input is in absolute luminance (in nits or candela per square meter, cd/m²), specified as positive-only linear light RGB, using the REC 709 colorspace gamut (but NOT the sRGB transfer function, i.e. linear light).
19+
// By default the encoder assumes the input is in absolute luminance (in nits or candela per square meter, cd/m²), specified as positive-only linear light RGB, using the REC 709 colorspace gamut (but NOT the sRGB transfer function, i.e. linear light).
2020
// If the m_rec2020_bt2100_color_gamut flag is true, the input colorspace is treated as REC 2020/BT.2100 (which is wider than 709).
2121
// For SDR/LDR->HDR upconversion, the REC 709 sRGB input should be converted to linear light (sRGB->linear) and the resulting normalized linear RGB values scaled by either 80 or 100 nits (the luminance of a typical SDR monitor).
2222
// SDR upconversion to normalized [0,1] (i.e. non-absolute) luminances may work but is not supported because ITP errors will not be predicted correctly.

thirdparty/libjpeg-turbo/patches/000-cmake_generated_headers.patch renamed to thirdparty/libjpeg-turbo/patches/0001-cmake-generated-headers.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ index 0000000000..22ed4b4c32
1212
+#define JPEG_LIB_VERSION 62
1313
+
1414
+/* libjpeg-turbo version */
15-
+#define LIBJPEG_TURBO_VERSION 3.1.1
15+
+#define LIBJPEG_TURBO_VERSION 3.1.0
1616
+
1717
+/* libjpeg-turbo version in integer form */
18-
+#define LIBJPEG_TURBO_VERSION_NUMBER 3001001
18+
+#define LIBJPEG_TURBO_VERSION_NUMBER 3001000
1919
+
2020
+/* Support arithmetic encoding when using 8-bit samples */
2121
+#define C_ARITH_CODING_SUPPORTED 1
File renamed without changes.
File renamed without changes.

thirdparty/libjpeg-turbo/src/jcapimin.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,13 @@ jpeg_finish_compress(j_compress_ptr cinfo)
195195
* all work is being done from the coefficient buffer.
196196
*/
197197
if (cinfo->data_precision <= 8) {
198-
if (cinfo->coef->compress_data == NULL)
199-
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
200198
if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
201199
ERREXIT(cinfo, JERR_CANT_SUSPEND);
202200
} else if (cinfo->data_precision <= 12) {
203-
if (cinfo->coef->compress_data_12 == NULL)
204-
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
205201
if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
206202
ERREXIT(cinfo, JERR_CANT_SUSPEND);
207203
} else {
208204
#ifdef C_LOSSLESS_SUPPORTED
209-
if (cinfo->coef->compress_data_16 == NULL)
210-
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
211205
if (!(*cinfo->coef->compress_data_16) (cinfo, (J16SAMPIMAGE)NULL))
212206
ERREXIT(cinfo, JERR_CANT_SUSPEND);
213207
#else

thirdparty/libjpeg-turbo/src/jcapistd.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ _jpeg_write_scanlines(j_compress_ptr cinfo, _JSAMPARRAY scanlines,
130130
num_lines = rows_left;
131131

132132
row_ctr = 0;
133-
if (cinfo->main->_process_data == NULL)
134-
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
135133
(*cinfo->main->_process_data) (cinfo, scanlines, &row_ctr, num_lines);
136134
cinfo->next_scanline += row_ctr;
137135
return row_ctr;
@@ -189,8 +187,6 @@ _jpeg_write_raw_data(j_compress_ptr cinfo, _JSAMPIMAGE data,
189187
ERREXIT(cinfo, JERR_BUFFER_SIZE);
190188

191189
/* Directly compress the row. */
192-
if (cinfo->coef->_compress_data == NULL)
193-
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
194190
if (!(*cinfo->coef->_compress_data) (cinfo, data)) {
195191
/* If compressor did not consume the whole row, suspend processing. */
196192
return 0;

0 commit comments

Comments
 (0)