123 Commits

Author SHA1 Message Date
Richard Geldreich
16d7d1460d - Adding max supported texture size (16K) check to KTX2 header parser 2026-04-20 03:15:49 -04:00
Richard Geldreich
882abb5320 - .basis transcoder class now validates the basis_slice_desc structs to ensure the original (unpadded) dimensions are valid, not too large (beyond 16K on either dimension), and are in sync with the slice's block dimensions. All methods that parse the slice desc structs now validate the contents first.
- basisu_lowlevel_etc1s_transcoder::transcode_slice(): Added PVRTC temp buf malloc buffer size sanity checking

Thanks to Canxuepiao Jian for the report.
2026-04-20 03:00:32 -04:00
Richard Geldreich
7dac9fb464 Adding BASISU_DISABLE_ANDROID_ASTC_DECOMP cmake option: if 1, the android ASTC decoder .cpp file is entirely eliminated and we emulate its functionality internally. 2026-04-06 13:53:50 -04:00
Richard Geldreich
1bdd35aad2 expanding this table by 1 entry to 256 entries total to silence static analysis - in reality, the access can mathematically never go beyond the original size 255 array, but it's best to be safe 2026-03-23 21:01:14 -04:00
Mauro Deryckere
10602cdc8e Add missing #include <exception> for std::terminate
container_abort() calls std::terminate() but the file does not include <exception>. This compiles on most toolchains today because other headers transitively pull it in, but fails on Android NDK r28 (Clang 19) with C++23 where the transitive include no longer happens.
Same class of issue as #395 (missing <ctype.h> in this file).
2026-03-19 16:12:44 +01:00
Richard Geldreich
c606cef87c Fixing 2 issues found via artificial encoder fuzzing, impacting the ASTC HDR 6x6/UASTC HDR 6x6i codec:
- 3 subset CEM 7/11 partition compression needs to check for rare failures
- adding clamp to bc6h encoder's smooth block weight index assigner (assign_weights_simple_4)
2026-03-06 17:20:37 -05:00
Richard Geldreich
49c61520c4 adding comment 2026-03-02 00:13:13 -05:00
Richard Geldreich
58e3afbaba fixing potential overflow problem in KTX2 header parser 2026-02-28 22:11:21 -05:00
Richard Geldreich
b71d417e18 minor fix to assert range check in bc6hf so basist::MAX_HALF_FLOAT is encodable (this can't happen in our normal ASTC HDR path, as values this large can't normally be encoded) 2026-02-28 21:12:50 -05:00
Richard Geldreich
e5e4081f30 adding comments 2026-02-28 21:10:40 -05:00
Richard Geldreich
81a4186404 v2.1 update for KTX-Software and Khronos file format KTX2 compatibility.
This update impacts the UASTC HDR 4x4, UASTC HDR 6x6i, and XUASTC LDR formats. New KTX2 files in these specific formats using v2.1 can't be loaded using v2.0, however we've kept backwards compatibility with all of our previously written KTX2 files. (v2.1 can transcode all previously written files.)
This is part of our effort to be compatible with Khronos's specification.
bc6hf encoder's smooth block path updated to handle inputs with texels close to MAX_HALF_FLOAT.
Adding command line options to basisu tool so it can write either v2.0 or v1.6 compatible UASTC HDR 6x6i files. The default is v1.6.
Updating WebGL KTX2 testbed so on ASTC devices it automatically switches between sRGB or linear internal formats for the created texture.
2026-02-24 20:35:11 -05:00
Richard Geldreich
396b242fb7 Fixing BASISD_SUPPORT_KTX2_ZSTD macro so it can be set to 0 - this disables XUASTC Zstd/hybrid profiles for encoding 2026-01-28 13:35:52 -05:00
Richard Geldreich
e93d3beb36 merging v2.0 from xuastc_private 2026-01-19 01:59:54 -05:00
Richard Geldreich
ea6778b2b5 adding new files 2026-01-19 01:59:35 -05:00
Richard Geldreich
204d7525ad fixing merge issues 2025-11-21 21:30:58 -05:00
Aaron Franke
f3a63a3f54 Remove trailing space characters 2025-11-21 11:52:38 -08:00
Richard Geldreich
196db8cbe2 Merging as much of PR #408 as we safely can.
PR 408's cmakelists.txt file has too many issues (OpenCL breaks on Windows/OSX) and changing our options to have the "BASISU_" prefix will break upstream builds.
2025-11-06 13:19:40 -05:00
Richard Geldreich
e8855f8840 Compiler warning fixes.
Cleaning up handling of 8-byte lengths/offsets in KTX2 files. (In practice, we don't currently accept files this large anyway.)
2025-09-20 10:10:08 -04:00
Richard Geldreich
ca56dbbaff Fixing minor compile issue introduced in merged PR 2025-09-05 22:23:31 -04:00
Rich Geldreich
87a1e1fbe6 Merge pull request #400 from zeux/transcoder-unity-build
Fix CMake Unity builds
2025-09-05 22:18:54 -04:00
Richard Geldreich
dfcfe7bf19 clang warning fix 2025-09-05 21:13:22 -04:00
Arseny Kapoulkine
f12efae6f9 Fix CMake Unity builds
transcoder/basisu_astc_helpers.h has a pragma once, but it is also an
implementation header (when ASTC_HELPERS_IMPLEMENTATION is defined).

pragma once is not necessary here as the header has a separate ifdef
guard, and it blocks attempts to compile Basis as a CMake Unity build
(CMAKE_UNITY_BUILD=ON) or as a single-translation unit non-CMake build
if the helpers header has been included earlier in the TU, as the second
inclusion with implementation defined doesn't actually include the
header.
2025-08-17 10:33:16 -07:00
Richard Geldreich
100ace82d2 emcc warning fixes, fixing warnings in WASM cmakelists.txt files, changing ETC1S encoder to use std::map vs. std::unordered_map for hopefully more cross platform determinism 2025-06-24 17:22:05 -04:00
Rich Geldreich
e62d9a3af0 Merge pull request #387 from Chubercik/ambiguity_fix
Fix ambiguous calls to `safe_shift_left()` in `basisu_containers.h`
2025-06-18 21:38:26 -04:00
Rémi Verschelde
40288583c7 Add missing ctype.h include for transcoder/basisu_containers_impl.h
The file uses `isdigit` and `isalpha` from `ctype.h`, and recent MSVC seems
to require it explicitly.
2025-05-07 23:16:28 +02:00
Jakub Marcowski
b738655c40 Fix ambiguous calls to safe_shift_left() in basisu_containers.h
Explicitly cast 1 to `uint64_t` to resolve overload ambiguity between `safe_shift_left(uint32_t, uint32_t)` and `safe_shift_left(uint64_t, uint32_t)`.
2025-03-11 18:35:04 +01:00
Richard Geldreich
1ba75b4e34 ASTC 6x6 HDR/6x6 HDR intermediate update 2025-01-21 11:01:08 -05:00
Richard Geldreich
8318d0c1b8 UASTC HDR merge 2024-09-10 14:38:10 -04:00
Richard Geldreich
ec5396c49c UASTC HDR merge 2024-09-10 14:37:21 -04:00
Richard Geldreich
ad9386a4a1 Minor fix to two accessors so they return refs vs. copies. 2023-04-26 23:17:50 -04:00
Rich Geldreich
80a07ff3b1 Merge pull request #325 from past-due/trivially_copyable
Allow defining BASISU_HAVE_STD_TRIVIALLY_COPYABLE
2023-04-07 13:24:21 -04:00
Rich Geldreich
8903f6d698 Merge pull request #260 from lexaknyazev/patch-1
Disallow all-zero-length Huffman tables
2022-12-11 05:00:57 -05:00
past-due
4dc6a8c666 Allow defining BASISU_HAVE_STD_TRIVIALLY_COPYABLE
To force std::is_trivially_copyable
2022-09-15 15:37:05 -04:00
Rich Geldreich
1f4b564ae0 Merge pull request #281 from cwoffenden/invalid-char
Minor: invalid char triggers Unicode error
2022-02-24 22:48:49 -08:00
Richard Geldreich
7a2094b807 Adding SAN option to CMakeLists.txt, to make it easier to use clang's address/undefined behavior sanitizer on codebase
Fixing overflow issue on extreme colors in color_distance().
Explicitly disabling unaligned addressing in miniz and transcoder when UBSAN is enabled
Disabling a needless optimization in transcoder causing ubsan issues (that could have easily been worked around in a different way, but it was an unnecessary optimization to begin with)
Rebuild wasm builds
2022-02-24 19:45:01 -05:00
Richard Geldreich
deeb5acb56 v1.16 release: OpenCL support, removing global selector palette code (it was unused/dead code), ETC1S encoding optimizations, -parallel command line option 2022-01-28 08:32:54 -05:00
Richard Geldreich
fcbd0e7df1 New files 2022-01-28 08:30:40 -05:00
Carl Woffenden
d7b22b6c1c Replaced invalid char 2022-01-19 16:24:32 +01:00
Alexey Knyazev
52214ab28d Disallow all-zero-length Huffman tables 2021-10-24 01:59:32 +04:00
Carl Woffenden
f5722a8025 Removed/moved unused vars
Relates to issue #230
2021-05-31 14:46:12 +02:00
Rich Geldreich
ee610c914e Fixing tabs 2021-04-13 00:29:01 -04:00
Rich Geldreich
7f0a00afe1 Adding KTX2 transcoding/encoding/decompression to PNG/KTX1 support to the transcoder, encoder, JavaScript wrappers. This is also adding Zstandard to the repo, which is optional. Set BASISD_SUPPORT_KTX2_ZSTD=0 when compiling the encoder/transcoder to disable it, or from cmake set KTX2_ZSTANDARD=FALSE. 2021-04-12 13:30:45 -04:00
Rich Geldreich
041ad47c27 - Global codebook related fixes
- Minor fix to basisu_frontend::optimize_selector_codebook() so the new_selector_cluster_indices array is initialized correctly. (The backend doesn't use this array so no harm was being done.)
2021-03-31 00:01:52 -04:00
Rich Geldreich
bf13257528 Merge branch 'branch' 2021-03-30 14:53:22 -04:00
Rich Geldreich
053ed374b4 In progress global codebook changes 2021-03-30 14:51:26 -04:00
Rich Geldreich
8fccf9e799 Merge pull request #219 from lexaknyazev/patch-1
Fix UASTC to EAC RG11 green channel selection
2021-03-30 14:14:45 -04:00
Rich Geldreich
bd2756a617 Merge pull request #218 from JCash/android-compile-fix
Android compile fix
2021-03-30 14:09:15 -04:00
Rich Geldreich
2fd9aec037 Merge pull request #220 from JCash/basisu-min-max
Replaced std::min/std::max with basisu::minimum/basisu::maximum
2021-03-30 14:06:56 -04:00
JCash
2c0c038ffe Renamed to minimum/maximum 2021-03-30 19:17:50 +02:00
JCash
03cca3778e Replaced std::min/std::max with basisu::min/basisu::max
Removed use of NOMINMAX
2021-03-30 18:44:07 +02:00