Skip to content

Commit 8e28778

Browse files
Use libjpeg-turbo for improved jpg compatibility and speed
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
1 parent cc94898 commit 8e28778

File tree

131 files changed

+50879
-5274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+50879
-5274
lines changed

COPYRIGHT.txt

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,18 @@ Comment: Jolt Physics
324324
Copyright: 2021, Jorrit Rouwe
325325
License: Expat
326326

327-
Files: thirdparty/jpeg-compressor/*
328-
Comment: jpeg-compressor
329-
Copyright: 2012, Rich Geldreich
330-
License: public-domain or Apache-2.0
331-
332327
Files: thirdparty/libbacktrace/*
333328
Comment: libbacktrace
334329
Copyright: 2012-2021, Free Software Foundation, Inc.
335330
License: BSD-3-clause
336331

332+
Files: thirdparty/libjpeg-turbo/*
333+
Comment: libjpeg-turbo
334+
Copyright: 2009-2024, D. R. Commander
335+
2015, Viktor Szathmáry.
336+
1991-2020, Thomas G. Lane, Guido Vollbeding
337+
License: BSD-3-clause and IJG
338+
337339
Files: thirdparty/libktx/*
338340
Comment: KTX
339341
Copyright: 2013-2020, Mark Callow
@@ -1683,6 +1685,42 @@ License: HarfBuzz
16831685
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
16841686
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
16851687

1688+
License: IJG
1689+
The authors make NO WARRANTY or representation, either express or implied,
1690+
with respect to this software, its quality, accuracy, merchantability, or
1691+
fitness for a particular purpose. This software is provided "AS IS", and you,
1692+
its user, assume the entire risk as to its quality and accuracy.
1693+
.
1694+
This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
1695+
All Rights Reserved except as specified below.
1696+
.
1697+
Permission is hereby granted to use, copy, modify, and distribute this
1698+
software (or portions thereof) for any purpose, without fee, subject to these
1699+
conditions:
1700+
(1) If any part of the source code for this software is distributed, then this
1701+
README file must be included, with this copyright and no-warranty notice
1702+
unaltered; and any additions, deletions, or changes to the original files
1703+
must be clearly indicated in accompanying documentation.
1704+
(2) If only executable code is distributed, then the accompanying
1705+
documentation must state that "this software is based in part on the work of
1706+
the Independent JPEG Group".
1707+
(3) Permission for use of this software is granted only if the user accepts
1708+
full responsibility for any undesirable consequences; the authors accept
1709+
NO LIABILITY for damages of any kind.
1710+
.
1711+
These conditions apply to any software derived from or based on the IJG code,
1712+
not just to the unmodified library. If you use our work, you ought to
1713+
acknowledge us.
1714+
.
1715+
Permission is NOT granted for the use of any IJG author's name or company name
1716+
in advertising or publicity relating to this software or products derived from
1717+
it. This software may be referred to only as "the Independent JPEG Group's
1718+
software".
1719+
.
1720+
We specifically permit and encourage the use of this software as the basis of
1721+
commercial products, provided that all warranty or liability claims are
1722+
assumed by the product vendor.
1723+
16861724
License: MPL-2.0
16871725
Mozilla Public License Version 2.0
16881726
==================================

SConstruct

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ opts.Add(BoolVariable("builtin_glslang", "Use the built-in glslang library", Tru
276276
opts.Add(BoolVariable("builtin_graphite", "Use the built-in Graphite library", True))
277277
opts.Add(BoolVariable("builtin_harfbuzz", "Use the built-in HarfBuzz library", True))
278278
opts.Add(BoolVariable("builtin_icu4c", "Use the built-in ICU library", True))
279+
opts.Add(BoolVariable("builtin_libjpeg_turbo", "Use the built-in libjpeg-turbo library", True))
279280
opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True))
280281
opts.Add(BoolVariable("builtin_libpng", "Use the built-in libpng library", True))
281282
opts.Add(BoolVariable("builtin_libtheora", "Use the built-in libtheora library", True))

misc/error_suppressions/tsan.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ deadlock:modules/text_server_adv/text_server_adv.cpp
66
deadlock:modules/text_server_fb/text_server_fb.cpp
77
race:modules/navigation_2d/nav_map_2d.cpp
88
race:modules/navigation_3d/nav_map_3d.cpp
9+
race:thirdparty/thorvg/src/loaders/external_jpg/tvgJpgLoader.cpp

misc/error_suppressions/ubsan.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ float-divide-by-zero:thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp
66
function:thirdparty/embree/common/sys/thread.cpp
77
function:thirdparty/embree/kernels/common/accel.h
88
function:thirdparty/xatlas/xatlas.cpp
9+
implicit-integer-sign-change:thirdparty/basis_universal/encoder/jpgd.cpp
910
implicit-integer-sign-change:thirdparty/basis_universal/transcoder/basisu_astc_helpers.h
1011
implicit-integer-sign-change:thirdparty/embree/common/lexers/../sys/ref.h
1112
implicit-integer-sign-change:thirdparty/embree/common/lexers/tokenstream.cpp
@@ -38,7 +39,6 @@ implicit-integer-sign-change:thirdparty/icu4c/common/unicode/unistr.h
3839
implicit-integer-sign-change:thirdparty/icu4c/common/unistr.cpp
3940
implicit-integer-sign-change:thirdparty/icu4c/common/uresbund.cpp
4041
implicit-integer-sign-change:thirdparty/icu4c/common/ustrtrns.cpp
41-
implicit-integer-sign-change:thirdparty/jpeg-compressor/jpgd.cpp
4242
implicit-integer-sign-change:thirdparty/libogg/bitwise.c
4343
implicit-integer-sign-change:thirdparty/libvorbis/info.c
4444
implicit-integer-sign-change:thirdparty/libvorbis/sharedbook.c

modules/basis_universal/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ if basisu_encoder:
3838
"basisu_ssim.cpp",
3939
"basisu_uastc_enc.cpp",
4040
"basisu_uastc_hdr_4x4_enc.cpp",
41+
"jpgd.cpp",
4142
"pvpngreader.cpp",
4243
]
4344
encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources]
@@ -47,7 +48,6 @@ transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]
4748
env_basisu.Prepend(CPPEXTPATH=[thirdparty_dir])
4849

4950
if basisu_encoder:
50-
env_basisu.Prepend(CPPEXTPATH=["#thirdparty/jpeg-compressor"])
5151
env_basisu.Prepend(CPPEXTPATH=["#thirdparty/tinyexr"])
5252

5353
if env["builtin_zstd"]:

modules/basis_universal/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def can_build(env, platform):
22
if env.editor_build: # Encoder dependencies
3-
env.module_add_dependencies("basis_universal", ["jpg", "tinyexr"])
3+
env.module_add_dependencies("basis_universal", ["tinyexr"])
44
return True
55

66

modules/jpg/SCsub

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,99 @@ Import("env_modules")
66

77
env_jpg = env_modules.Clone()
88

9-
# Thirdparty source files
10-
119
thirdparty_obj = []
1210

13-
# Not unbundled for now as they are not commonly available as shared library
14-
thirdparty_dir = "#thirdparty/jpeg-compressor/"
15-
thirdparty_sources = [
16-
"jpgd.cpp",
17-
"jpge.cpp",
11+
thirdparty_dir = "#thirdparty/libjpeg-turbo"
12+
13+
thirdparty_sources_common = [
14+
"jaricom.c",
15+
"jcapimin.c",
16+
"jcarith.c",
17+
"jchuff.c",
18+
"jcicc.c",
19+
"jcinit.c",
20+
"jcmarker.c",
21+
"jcmaster.c",
22+
"jcomapi.c",
23+
"jcparam.c",
24+
"jcphuff.c",
25+
"jctrans.c",
26+
"jdapimin.c",
27+
"jdarith.c",
28+
"jdatadst.c",
29+
"jdatadst-tj.c",
30+
"jdatasrc.c",
31+
"jdatasrc-tj.c",
32+
"jdhuff.c",
33+
"jdicc.c",
34+
"jdinput.c",
35+
"jdmarker.c",
36+
"jdmaster.c",
37+
"jdphuff.c",
38+
"jdtrans.c",
39+
"jerror.c",
40+
"jfdctflt.c",
41+
"jmemmgr.c",
42+
"jmemnobs.c",
43+
"jpeg_nbits.c",
44+
"transupp.c",
45+
"turbojpeg.c",
46+
]
47+
48+
thirdparty_sources_bit_dependent = [
49+
"jcapistd.c",
50+
"jccoefct.c",
51+
"jccolor.c",
52+
"jcdctmgr.c",
53+
"jcmainct.c",
54+
"jcprepct.c",
55+
"jcsample.c",
56+
"jdcoefct.c",
57+
"jdcolor.c",
58+
"jdapistd.c",
59+
"jddctmgr.c",
60+
"jdmainct.c",
61+
"jdmerge.c",
62+
"jdpostct.c",
63+
"jdsample.c",
64+
"jfdctfst.c",
65+
"jfdctint.c",
66+
"jidctflt.c",
67+
"jidctfst.c",
68+
"jidctint.c",
69+
"jidctred.c",
70+
"jutils.c",
71+
"jquant1.c",
72+
"jquant2.c",
1873
]
19-
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
2074

21-
env_jpg.Prepend(CPPEXTPATH=[thirdparty_dir])
75+
thirdparty_sources_by_bits = {
76+
8: list(thirdparty_sources_bit_dependent),
77+
12: list(thirdparty_sources_bit_dependent),
78+
}
79+
80+
81+
def source_paths(files):
82+
return [thirdparty_dir + "/src/" + f for f in files]
83+
84+
85+
env_jpg.Prepend(CPPEXTPATH=[thirdparty_dir + "/src"])
86+
87+
88+
def add_bit_depth(bit_depth: int):
89+
env_bit_depth = env_jpg.Clone()
90+
env_bit_depth.disable_warnings()
91+
env_bit_depth["OBJSUFFIX"] = f"_{bit_depth}{env_bit_depth['OBJSUFFIX']}"
92+
env_bit_depth.Append(CPPDEFINES=[f"BITS_IN_JSAMPLE={bit_depth}"])
93+
env_bit_depth.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_by_bits[bit_depth]))
94+
95+
96+
add_bit_depth(8)
97+
add_bit_depth(12)
2298

2399
env_thirdparty = env_jpg.Clone()
24100
env_thirdparty.disable_warnings()
25-
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
101+
env_thirdparty.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_common))
26102
env.modules_sources += thirdparty_obj
27103

28104
# Godot source files

0 commit comments

Comments
 (0)