Skip to content

Commit

Permalink
basis_universal: Unbundle jpgd, use our newer copy
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga committed Feb 18, 2024
1 parent 5f05e2b commit 48ed047
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3,582 deletions.
7 changes: 4 additions & 3 deletions modules/basis_universal/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ encoder_sources = [
"basisu_resample_filters.cpp",
"basisu_ssim.cpp",
"basisu_uastc_enc.cpp",
"jpgd.cpp",
"pvpngreader.cpp",
]
encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources]
transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]

# Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC.
if not env.msvc:
env_basisu.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path])
env_basisu.Append(
CPPFLAGS=["-isystem", Dir(thirdparty_dir).path, "-isystem", Dir("#thirdparty/jpeg-compressor").path]
)
else:
env_basisu.Prepend(CPPPATH=[thirdparty_dir])
env_basisu.Prepend(CPPPATH=[thirdparty_dir, "#thirdparty/jpeg-compressor"])

if env["builtin_zstd"]:
env_basisu.Prepend(CPPPATH=["#thirdparty/zstd"])
Expand Down
1 change: 1 addition & 0 deletions modules/basis_universal/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
def can_build(env, platform):
env.module_add_dependencies("basis_universal", ["jpg"])
return True


Expand Down
13 changes: 13 additions & 0 deletions modules/basis_universal/patches/external-jpgd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/thirdparty/basis_universal/encoder/basisu_enc.cpp b/thirdparty/basis_universal/encoder/basisu_enc.cpp
index c431ceaf12..e87dd636a2 100644
--- a/thirdparty/basis_universal/encoder/basisu_enc.cpp
+++ b/thirdparty/basis_universal/encoder/basisu_enc.cpp
@@ -409,7 +409,7 @@ namespace basisu
bool load_jpg(const char *pFilename, image& img)
{
int width = 0, height = 0, actual_comps = 0;
- uint8_t *pImage_data = jpgd::decompress_jpeg_image_from_file(pFilename, &width, &height, &actual_comps, 4, jpgd::jpeg_decoder::cFlagLinearChromaFiltering);
+ uint8_t *pImage_data = jpgd::decompress_jpeg_image_from_file(pFilename, &width, &height, &actual_comps, 4, jpgd::jpeg_decoder::cFlagBoxChromaFiltering);
if (!pImage_data)
return false;

2 changes: 1 addition & 1 deletion thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Files extracted from upstream source:

Files extracted from upstream source:

- `encoder/` and `transcoder/` folders
- `encoder/` and `transcoder/` folders, minus `jpgd.{cpp,h}`
- `LICENSE`

Applied upstream PR https://github.com/BinomialLLC/basis_universal/pull/344 to
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/basis_universal/encoder/basisu_enc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ namespace basisu
bool load_jpg(const char *pFilename, image& img)
{
int width = 0, height = 0, actual_comps = 0;
uint8_t *pImage_data = jpgd::decompress_jpeg_image_from_file(pFilename, &width, &height, &actual_comps, 4, jpgd::jpeg_decoder::cFlagLinearChromaFiltering);
uint8_t *pImage_data = jpgd::decompress_jpeg_image_from_file(pFilename, &width, &height, &actual_comps, 4, jpgd::jpeg_decoder::cFlagBoxChromaFiltering);
if (!pImage_data)
return false;

Expand Down
Loading

0 comments on commit 48ed047

Please sign in to comment.