Commit Graph
1427 Commits
Author SHA1 Message Date
Richard GeldreichandClaude Opus 5.5 918d658f95 webgl encoder: accept mainScriptUrlOrBlob in threaded builds (Emscripten 6.0.x)
Newer Emscripten (6.0.x) no longer includes mainScriptUrlOrBlob in its default INCOMING_MODULE_JS_API,
so the threaded encoder loaded via importScripts() in ktx2_studio/encode-worker.js ignored it and the
pthread pool never came up (the worker hangs while loading). Add it explicitly (Emscripten's default list
plus mainScriptUrlOrBlob), as in the development tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 14:51:35 -04:00
Rich Geldreich 254c5b8ed1 Merge pull request #474 from ben-polinsky/csp-no-dynamic-execution
Add opt-in WebGL builds that work under a strict CSP (no `unsafe-eval`)
2026-10-23 14:48:47 -04:00
Ben Polinsky b15211474d Add opt-in WebGL builds that do not use eval()/new Function()
With the default DYNAMIC_EXECUTION=1, embind generates its invokers at
runtime with new Function(). A Content-Security-Policy without
'unsafe-eval' blocks this, so the transcoder and encoder fail to start
with an EvalError.

Add two CMake options to webgl/transcoder and webgl/encoder:

- NO_DYNAMIC_EXECUTION (default OFF) adds -s DYNAMIC_EXECUTION=0.
- EMBIND_AOT (default ON, only used with NO_DYNAMIC_EXECUTION) adds
  -s EMBIND_AOT=1. This generates the invokers at build time, so
  embind calls stay as fast as with the default build.

The default build does not change. The .wasm output is byte-identical
in all configurations; only the JS glue changes.

Fixes #464
2026-10-19 09:51:05 -04:00
Ben Polinsky 25e094e81d Fix missing cPackUASTC* constants in the WebGL encoder
The cPackUASTC* values are members of an anonymous enum. embind's
constant() registers a constant against the type of its value, and no
binding exists for an anonymous enum type. embind therefore waits for
that type forever, and the constants never appear on the module.
Module.cPackUASTCLevelDefault and the others are undefined in the
shipped basis_encoder.js.

Cast the values to uint32_t so that they bind as plain numbers.
EMBIND_AOT=1 makes this a link error ("Missing binding for type"), so
this change is also necessary to build the encoder with that flag.
2026-10-19 09:51:05 -04:00
Richard Geldreich 1706f948a2 Adding HDR source parm nullptr check
Fixing typo that could lead to a null pointer deref
2026-10-16 03:31:44 -04:00
Rich Geldreich 99f52d63aa Update README.md 2026-09-01 00:08:12 -04:00
Rich Geldreich c9d3f9a643 Update README.md 2026-09-01 00:05:16 -04:00
Rich Geldreich a9acd00363 Remove outdated codec specification links from README
Removed links to XUASTC and XUBC7 LDR specifications.
2026-09-01 00:04:06 -04:00
Rich Geldreich 31fddf4894 Update README.md 2026-09-01 00:03:41 -04:00
Rich Geldreich 480511eb98 Update README with HDR formats transcoding details
Added information about HDR formats transcoding to BC6H.
2026-09-01 00:02:05 -04:00
Rich Geldreich 41a69c394c Update README.md 2026-09-01 00:01:10 -04:00
Rich Geldreich 6f5256c287 Fix formatting issues in README.md 2026-08-31 23:58:54 -04:00
Rich Geldreich 8c93c71860 Update README.md 2026-08-31 23:58:40 -04:00
Rich Geldreich 64f686dd37 Update README.md 2026-08-31 23:56:17 -04:00
Rich Geldreich 3fe4dfa3bc Clarify animated texture reference in README
Updated text for clarity and consistency in the README.
2026-08-31 23:55:47 -04:00
Rich Geldreich 10814a0efa Update README.md 2026-08-31 23:55:11 -04:00
Rich Geldreich 75c4d13abe Update README.md 2026-08-31 23:51:09 -04:00
Rich Geldreich c7f90c991f Update UASTC HDR 6x6 Intermediate link in README 2026-08-31 23:50:51 -04:00
Rich Geldreich 1e9b43689d Update README.md 2026-08-31 23:50:17 -04:00
Rich Geldreich f227f5f7e9 Update UASTC LDR 4x4 description with link 2026-08-31 23:49:58 -04:00
Rich Geldreich 54034c2e64 Update ETC1S description with hyperlink 2026-08-31 23:49:25 -04:00
Rich Geldreich 6136d38196 Update README.md 2026-08-31 23:48:59 -04:00
Rich Geldreich 930325fca3 Revise XUASTC LDR 4x4-12x12 description in README
Updated the description of the XUASTC LDR 4x4-12x12 codec for clarity and conciseness.
2026-08-31 23:48:42 -04:00
Rich Geldreich ef799ff1ca Update README.md 2026-08-31 23:47:57 -04:00
Rich Geldreich 69441680ef Update README.md 2026-08-31 23:47:17 -04:00
Richard Geldreich 4ac36eab9b setting g_xbc7_dc_quant_per_weight_bits to const (very minor fix) 2026-08-31 03:48:15 -04:00
Rich Geldreich f9ebbd80ae Update README to remove v2.50 documentation note
Removed note about ongoing documentation for v2.50.
2026-08-27 23:58:13 -04:00
Rich Geldreich 9bebe16726 Merge pull request #458 from vkedwardli/fix/netbsd
Fix float overload deduction on NetBSD
v2_50
2026-07-22 14:36:49 -04:00
Rich Geldreich 5f6a0a0ca6 Merge pull request #463 from BinomialLLC/fix-ktx2-level-uncomp-msg
KTX2: fix wrong error message for oversized level uncompressed length
2026-07-18 22:28:39 -04:00
Richard GeldreichandClaude Opus 4.8 28ab277db8 KTX2: fix wrong error message for oversized level uncompressed length
The sanity check on a level's m_uncompressed_byte_length (>= 2 GiB)
logged "Invalid level offset (too large)", which names the wrong field.
Correct it to "Invalid level uncompressed byte length (too large)".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 22:24:57 -04:00
Rich Geldreich d77f9308e2 Merge pull request #462 from BinomialLLC/webgl-build-clean-slow
webgl/build.sh: run make clean on --clean, add --slow serial option
2026-07-18 19:45:32 -04:00
Richard GeldreichandClaude Opus 4.8 018cc67cd0 webgl: add --slow option to build.sh for a serial build
--slow uses `make -j1` (one file at a time, the classic manual `make`)
instead of the default `make -j$(nproc)`. Useful for readable output or
constrained machines; parallel remains the default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 19:37:52 -04:00
Richard GeldreichandClaude Opus 4.8 b512234dff webgl: build.sh --clean runs 'make clean' before wiping the CMake cache
For a more thorough clean, --clean now runs `make clean` (removing the
build outputs and object files via the existing build system) before
deleting CMakeCache.txt/CMakeFiles and reconfiguring.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 19:33:48 -04:00
Rich Geldreich edfa1fc3a4 Merge pull request #461 from BinomialLLC/ktx2-init-range-checks
webgl: add build.sh to build the transcoder/encoder
2026-07-18 19:15:31 -04:00
Richard GeldreichandClaude Opus 4.8 fcab97d371 webgl: add build.sh to build the transcoder/encoder with Emscripten
Convenience script (place: webgl/build.sh) that runs emcmake/cmake/make
in webgl/transcoder/build and webgl/encoder/build. Stops on the first
error (set -euo pipefail), builds both by default or a named target
(transcoder/encoder), supports --clean and -D... cmake pass-through, is
runnable from any directory, and auto-sources emsdk if emcmake is not on
PATH.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 19:05:54 -04:00
Rich Geldreich 368e2a5122 Merge pull request #460 from BinomialLLC/ktx2-init-range-checks
previewers: free rgbBuf with free() instead of delete
2026-07-18 18:55:48 -04:00
Richard GeldreichandClaude Opus 4.8 3b0017e677 previewers: free rgbBuf with free() instead of delete
BasisThumbProvider::GetThumbnail() allocates rgbBuf with malloc() but
freed it with delete, which is a mismatched-allocator (and delete on a
void*) undefined behavior. Use free() to match the allocation, as is
already done for the sibling 'data' buffer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 18:38:36 -04:00
Rich Geldreich 399927dc36 Merge pull request #459 from BinomialLLC/ktx2-init-range-checks
Ktx2 init range checks
2026-07-18 18:18:14 -04:00
Richard Geldreich 38168767f4 rebuilt artifacts 2026-07-18 18:11:39 -04:00
Richard GeldreichandClaude Opus 4.8 57a0a0b4c6 previewers: regenerate single-file transcoder with KTX2/Zstd enabled
Regenerate contrib/previewers/lib/basisu_transcoder.cpp from the current
transcoder sources with the single_file_transcoder combine.py script,
replacing a long-stale copy. KTX2 and Zstd are enabled.

Only the Basis Universal sources are amalgamated; Zstd is kept as an
ordinary #include "../zstd/zstd.h" (via combine.py's -k option) rather
than being inlined, and zstd/zstd.c is compiled and linked separately,
so Zstd is neither touched nor duplicated.

Update the previewers project to build the current (C++17) transcoder:
- set LanguageStandard to stdcpp17 (the transcoder uses inline variables
  and other C++17 features);
- define NOMINMAX (the Windows shell headers, included before the
  transcoder, otherwise define min/max macros that break the
  std::numeric_limits<>::max() calls);
- add the zstd directory to the include paths and compile
  ..\..\..\zstd\zstd.c as a separate compilation unit.

The DLL builds for Debug/Release, x64 and Win32. The previewer still
only registers .basis files; enabling KTX2/Zstd just makes the
transcoder compile cleanly out of the box.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 17:59:57 -04:00
Richard GeldreichandClaude Opus 4.8 f2497f14d6 KTX2 transcoder: build with BASISD_SUPPORT_KTX2 disabled
Two things prevented the transcoder from compiling with
BASISD_SUPPORT_KTX2 set to 0:

- ktx2_image_level_info was defined inside the #if BASISD_SUPPORT_KTX2
  block, but dds_transcoder::get_image_level_info() takes it by
  reference and is compiled unconditionally. Move the struct ahead of
  that block so it is always defined; it has no KTX2-specific members.

- The "#include ../zstd/zstd.h" was nested inside #if BASISD_SUPPORT_KTX2,
  but the Zstd decompressor (zstd_decompress()) is compiled whenever
  BASISD_SUPPORT_KTX2_ZSTD is set, independent of KTX2 (Zstd is also used
  by other codecs). With KTX2 off but Zstd on, the ZSTD_* symbols were
  referenced without the header being included. Gate the include on
  BASISD_SUPPORT_KTX2_ZSTD alone, matching where the symbols are used.

BASISD_SUPPORT_KTX2_ZSTD still defaults to 1 (unchanged). The default
build (KTX2 and Zstd both enabled) is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 17:20:38 -04:00
Richard GeldreichandClaude Opus 4.8 3454230543 KTX2: overflow-safe range checks and input bounds in ktx2_transcoder::init
The KTX2 level and supercompression-global-data (SGD) offset/length
fields are full 64-bit values read from the file. init() validated them
with "offset + length > m_data_size", where the addition can wrap around
and incorrectly pass for out-of-range values. Rewrite both checks as
"offset > m_data_size || length > (uint64_t)m_data_size - offset", which
cannot overflow (offset is confirmed <= m_data_size before the
subtraction, so it can't underflow either). The result is identical to
the original for every in-range input.

Also in init():
- Reject a level whose byte_length is 0. This case already logged an
  error but fell through without returning false.
- Add KTX2_MAX_SUPPORTED_LAYER_COUNT (65535) and reject files whose
  layer_count exceeds it, mirroring KTX2_MAX_SUPPORTED_LEVEL_COUNT, so
  layer_count * face_count * level_count stays bounded.

read_slice_offset_len_global_data(): compute image_count in 64-bit,
verify m_sgd_byte_length == image_count * descriptor_size before sizing
the descriptor array, and use try_resize() (returns false on failure)
instead of resize() (which aborts the process) so an out-of-range count
fails cleanly instead of attempting an oversized allocation. Also
compute image_count in 64-bit in decompress_etc1s_global_data().

Valid files are handled exactly as before.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 16:47:58 -04:00
Edward Li 6546e407eb Fix float overload deduction on NetBSD 2026-07-14 22:01:58 +08:00
Richard Geldreich 1b33fd5098 Adding Cache-Control to dev web server to disable browser caching 2026-07-05 21:38:40 -04:00
Richard Geldreich 0f540010c5 adding channel weights comment 2026-07-05 21:37:48 -04:00
Richard Geldreich 20ed781c4b updating comment 2026-07-03 23:01:13 -04:00
Richard Geldreich dc86b2cdbf comment fix 2026-07-03 22:51:04 -04:00
Richard Geldreich fc3a67a5c0 comment fix 2026-07-03 22:45:41 -04:00
Richard Geldreich a73f8b80ed rebuilt 2026-07-03 22:18:21 -04:00
Richard Geldreich b0c0216d7e per-channel weight parameter rename (discovered during documentation pass) 2026-07-03 22:13:18 -04:00