Skip to content

Compressor Definitions and Classes

Rich Geldreich edited this page Feb 26, 2026 · 156 revisions

Note

Page Under Construction

This documentation is up to date as of Basis Universal v2.1.

Table of Contents

The compression library, located in the encoder subdirectory, defines the classes needed to compress .KTX2 or .basis files, given one or more LDR/SDR or HDR images. This document describes the key classes and types needed to directly call the C++ compressor, bypassing the higher level (and less capable) C API. The tradeoff: the C++ API has sharper edges, and is more difficult to use because of all the codecs and file formats we've added to the system over time while also keeping backwards API compatibility.

Intro

Compressor Global Initialization

The function basisu::basisu_encoder_init() in encoder/basisu_enc.h MUST be called before using any other functions or classes inside the compression library or the transcoder module (transcoder/basisu_transcoder.cpp). It must be allowed to complete and return before calling anything else inside the library or the transcoder module.

This function will also initialize the transcoder by calling basist::basisu_transcoder_init();.

This function is mutexed with std::lock_guard and std::mutex.

Clone this wiki locally