Skip to main content

Crate basisu

Crate basisu 

Source
Expand description

A complete, bit-exact pure-Rust Basis Universal transcoder.

Open a .ktx2 or .basis Basis Universal texture and transcode any image level to a GPU format. For every supported target the output matches the canonical Basis Universal transcoder byte for byte.

use basisu::{Transcoder, TargetFormat, DecodeFlags};
let bytes = std::fs::read("texture.ktx2").unwrap();
let tex = Transcoder::new(&bytes).unwrap();
let astc = tex.transcode(0, TargetFormat::Astc4x4Rgba, DecodeFlags::NONE).unwrap();

The Transcoder high-level API is the stable surface. The lower-level codec modules are exposed (currently pub) for power users and the conformance harness; they are not yet covered by semver stability.

Without the default std feature the crate is #![no_std] (it still needs alloc); the zstd feature implies std.

Structs§

DecodeFlags
Decode behavior flags. Values match basist::basisd_decode_flags; combine with |.
GlobalCodebook
A shared ETC1S codebook lifted out of one Basis texture to decode “global codebook” .basis files that reference it.
ImageLevelInfo
Dimensions and block counts of one image level.
Transcoder
A parsed + prepared Basis Universal texture, ready to transcode.
VideoState
Cross-frame decode state for ETC1S video.

Enums§

AstcBlock
An ASTC LDR block footprint: the 14 block sizes the format defines, in basis_tex_format declaration order (cASTC_LDR_4x4 = 19 .. cASTC_LDR_12x12 = 32). Every block is 16 bytes regardless of footprint; larger footprints trade quality for fewer bits per texel.
Error
Transcode failures.
SourceFormat
The Basis source codec a container carries.
Supercompression
The KTX2 supercompression scheme applied to level data.
TargetFormat
A GPU texture format to transcode to. Values match basist::transcoder_texture_format.

Functions§

is_format_supported
Whether target can be transcoded from source.