Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
DXT encoding support #700
This pull requests adds an Encoder and Decoder for the DXT1/3/5 lossy compression formats. It however does not implement any file format that uses DXT compression, like DDS at the moment. Due to this there is currently not a nice way of integrating testing of the decoding/encoding with the current testing infrastructure. I plan to add support for at least one container format to solve this, but since I'm not really familiar with the way the project works I've made the pull request now already to ask for advice on how to proceed with this.
Notes on the encoder/decoder
The encoder is probably not the most performant possible implementation as it brute-forces the best fitting color table per block, but it does result in reasonably high-quality encoding. It's still reasonably fast, taking <0.3 sec to single-threaded encode a noisy 1024x1024 pixel RGBA image, which is the worst case for the algorithm. Images with large flats, small gradients, or limited colorspaces encode much faster.
Since the compression operates purely on a block basis, it would be trivial to speed it up using more threads.
Due to the way DXT blocks work the decoder's scanlines are actually 4 pixels tall.