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>
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>
Added 'simple.cpp' which does the bare mimimum to confirm the amalgamation worked (compiled and run after the combine step). Split the embedded .basis files from the Emscripten test so they can be shared. Fixed an error in the creation script (which caused it to always fail). Corrected the syntax for the unused functions (tested with older, less forgiving compilers).
Added the work-in-progress resource pane (to hold the file details, number of mips, etc.). The Windows project shares the transcoder with the (future) Mac previewer.
Transcoder enums changed recently, so updated these. Switched to using the 'single file' transcoder (committed) so this will always build regardless of changes.
Renamed the generated file to be the same as the non-amalgamated file, updating the script (and docs) accordinly. Added an example of generated amalgamated header and source.
Added -x option to the script to exclude files, then used it to exclude the large BC7 mode 6 tables. Added mipmap transcoding to the example for completeness.
Exposed the ASTC transcoder. Improved the Emscripten example and tested on ASTC and ETC hardware. Workaround for usused functions and consts when disabling various transcode options.