texture2ddecoder ![Build Status] ![Latest Version] ![Docs] ![LicenseMIT] ![LicenseAPACHE]

A pure Rust no-std texture decoder for the following formats: - ATC - Adreno Texture Compression (detailed paper) - ASTC - Adaptive Scalable Texture Compression - BCn - Block Compression - ETC - Ericsson Texture Compression - PVRTC - PowerVR Texture Compression - (WIP) Crunch & Unity's Crunch

Features

alloc (optional, default)

Functions

Provides a decode function for each format, as well as a block decode function all formats besides PVRTC. Besides some exceptions, the signature of the decode functions is as follows: rust fn decode_format(data: &[u8], width: usize, height: usize, image: &mut [u32]) -> Result<(), &'static str> // data: the compressed data, expected to be width * height / block_size in size // width: the width of the image // height: the height of the image // image: the buffer to write the decoded image to, expected to be width * height in size fn decode_format_block(data: &[u8], outbuf: &mut [u32]) -> Result<(), &'static str> // data: the compressed data (block), expected to be block_size in size // outbuf: the buffer to write the decoded image to, expected to be block_size in size The exceptions are: - ASTC: the (block) decode function takes the block size as an additional parameter - BC6: there are two additional decode functions for the signed and unsigned variants - PVRTC: the decode function takes the block size as an additional parameter, and there are two additional decode functions for the 2bpp and 4bpp variants To make these excetions easier to use, there are helper functions to enable decode functions with identical arguments and returns. Here is a list of the formats and their corresponding functions: - ATC - decodeatcrgb4 - decodeatcrgb4block - decodeatcrgba8 - decodeatcrgba8block - ASTC - decodeastc - decodeastcblock - various decodeastc(block)xy functions, where x and y are the block size - BCn - decodebc1 - decodebc1block - decodebc3 - decodebc3block - decodebc4 - decodebc4block - decodebc5 - decodebc5block - decodebc6 - decodebc6block - decodebc6signed - decodebc6blocksigned - decodebc6unsigned - decodebc6blockunsigned - decodebc7 - decodebc7block - ETC - decodeetc1 - decodeetc1block - decodeetc2rgb - decodeetc2rgbblock - decodeetc2rgba1 - decodeetc2rgba1block - decodeetc2rgba8 - decodeetc2rgba8block - decodeeacr - decodeeacrblock - decodeeacrsigned - decodeeacrsignedblock - decodeeacrg - decodeeacrgblock - PVRTC - decodepvrtc - decodepvrtc2bpp - decodepvrtc4bpp

Roadmap

Format Progress

License & Credits

This crate itself is dual-licensed under MIT + Apache2.

The texture compression codecs themselves have following licenses: | Codec | License | Source | |----------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------| | ATC | MIT | Perfare/AssetStudio - Texture2DDecoderNative/atc.cpp | | ASTC | MIT* | Ishotihadus/mikunyan - ext/decoders/native/astc.c | | BCn | MIT* | Perfare/AssetStudio - Texture2DDecoderNative/bcn.cpp | | ETC | MIT* | Ishotihadus/mikunyan - ext/decoders/native/etc.c | | f16 | MIT | Maratyszcza/FP16 | | PVRTC | MIT* | Ishotihadus/mikunyan - ext/decoders/native/pvrtc.c | | Crunch | PUBLIC DOMAIN | BinomialLLC/crunch | | Crunch (Unity) | ZLIB | Unity-Technologies/crunch | * in doubt if these are the original source and have not just taken/adopted the code from somewhere else