Skip to main content

ASTC decoder for PIL (just faster)

Project description

bconstanzo: this is a fork of K0lb3's work focused on improving performance by adding some Cython magic (types, which took a bit of effort to get right). Since it completely removes python from the hot loop (and almost all of the decompression function) it achieves some nice speedups (6-8 times faster). Any bottlenecks would then be inside the C++ functions, or your compilers ability to optimize said code.

The main reason I'm making this fork is that iLEAPP had the astc_decomp module as a bottleneck at the time of release, and I worked a couple of weeks into improving it. There may be better alternatives for ASTC decompression out there.

K0lb3's original readme follows:

ASTC_Decomp

An ASTC decoder for PIL.

The decoder uses richgel999/astc_dec to decompress the ASTC blocks.

Installation

  • Cython required

PIP

pip install astc_decomp

Manual

python setup.py install

Usage

Arguments

  • block_width: - Block width, in pixels.
  • block_height: - Block height, in pixels.
  • is_srgb: - If isSRGB is true, the spec requires the decoder to scale the LDR 8-bit endpoints to 16-bit before interpolation slightly differently, which will lead to different outputs. So be sure to set it correctly (ideally it should match whatever the encoder did). (optional arg, default : False)

PIL.Image decoder

from PIL import Image
import astc_decomp 
#needs to be imported once in the active code, so that the codec can register itself

astc_data : bytes
block_width : int
block_height : int
is_srgb : bool = False
img = Image.frombytes('RGBA', size, astc_data, 'astc', (block_width, block_height, is_srgb))

raw decoder

from astc_decomp import decompress_astc

# ASTC to RGBA
rgba_data = decompress_astc(astc_data : bytes, width : int, height : int, block_width : int, block_height : int, is_srgb : bool = False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astc_decomp_faster-1.1.5.tar.gz (175.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

astc_decomp_faster-1.1.5-cp314-cp314-win_amd64.whl (80.4 kB view details)

Uploaded CPython 3.14Windows x86-64

astc_decomp_faster-1.1.5-cp314-cp314-macosx_10_15_universal2.whl (186.8 kB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

astc_decomp_faster-1.1.5-cp313-cp313-win_amd64.whl (78.2 kB view details)

Uploaded CPython 3.13Windows x86-64

astc_decomp_faster-1.1.5-cp313-cp313-macosx_10_13_universal2.whl (185.8 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

astc_decomp_faster-1.1.5-cp312-cp312-win_amd64.whl (78.4 kB view details)

Uploaded CPython 3.12Windows x86-64

astc_decomp_faster-1.1.5-cp312-cp312-macosx_10_13_universal2.whl (187.2 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

astc_decomp_faster-1.1.5-cp311-cp311-win_amd64.whl (77.9 kB view details)

Uploaded CPython 3.11Windows x86-64

astc_decomp_faster-1.1.5-cp311-cp311-macosx_10_9_universal2.whl (185.7 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

astc_decomp_faster-1.1.5-cp310-cp310-win_amd64.whl (77.7 kB view details)

Uploaded CPython 3.10Windows x86-64

astc_decomp_faster-1.1.5-cp310-cp310-macosx_10_9_universal2.whl (186.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file astc_decomp_faster-1.1.5.tar.gz.

File metadata

  • Download URL: astc_decomp_faster-1.1.5.tar.gz
  • Upload date:
  • Size: 175.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for astc_decomp_faster-1.1.5.tar.gz
Algorithm Hash digest
SHA256 c84865c97231996a9a4f12c9f4d676633808afe62f4df230dfd740ee7d3054b4
MD5 1c2ec2c173a472aef5790618f731fb18
BLAKE2b-256 460c9175a74d7dfb5743b027b97dc15127802d882cb1154b779fe857801ca325

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 10be93c238843d09eb1bbf7fc92f66dd8f969dfc9fc216896a44da2856e291f2
MD5 326e605f58be12219d527bd4af43f943
BLAKE2b-256 7232ac3afcf24ad65e20ca01a35296c366650eb3b282c16e7d9d11ed2f5c9698

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 ca7678b90a4fe580df1841c18d7d620a5693329f8fb645f98eb7f90b22b15227
MD5 651b71eafaba8dc620c36fb94c1f3460
BLAKE2b-256 000d34a1b77c62a95a9261191b8b6a16f6dee2c26368457fec9d63b7b55b2bea

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f91d99ed5604e866c2753f1ab0d2b3d30c555937ff2505c785a62c4648606e41
MD5 381e2fed07bc0b154fde35b63fd669c0
BLAKE2b-256 de47723e65635ba67bffcdadd2de71aacf10c0ffd3057c83a16ffc884dbca5c0

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 27a43bfffeff9ce8811b89badb3f5a6663f5386f6f7e9da6aef534e8ec292405
MD5 40ab0ae5ceade6790c19d39d9308669a
BLAKE2b-256 6bbffc568756e12a14f84b7431caa07ba05c2e4785876c4652edef92cb0efc0f

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 641ff01c06904e61f3c257d7587e3757905adfe63c1e2a869ee3d3b8222cea69
MD5 b1066ef2c67937b02908da4fc66556f0
BLAKE2b-256 791f8cf34d28a39342627511cce88121f8a41c8d0190909b44d3f6bfcb8c50ae

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 94eeca992bdfe4a33b666e097452b532936e7cad061bd2f313f8271fca0eb1ea
MD5 b222a87128d855f8cbb2f572be85140a
BLAKE2b-256 40b17754fef6cf79a6e02fe644786de4506d13fb6c246c2f27e842c946ea7def

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3f08e6ae79c4729a0f7d98b36d38eb2ac23eac353bc7dd071591784a871abe64
MD5 2ef0987a499a71f2cc09e13f73b4c3e3
BLAKE2b-256 f8713ae34336b3e0e63eb9003eaec31a59d4e9f493f46e34d16b0b95451d9709

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b88967cf84a24b0730182762eeba518b4f500c2422b3fcb0d5a33016ab24fc45
MD5 ec89648986cba855dd2a1017dacfb705
BLAKE2b-256 78ca6c2506ac957a6ea03d9624f5eb7847305628a5818bd53e2bd8db79e785f6

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a2a832fa3f9809d27177df36769944230044a3f1456c25e924406d02da10d472
MD5 f329e7dd39cd9e5e9f348933bfd410ce
BLAKE2b-256 2f8ad3ae5062c421e97a2431559d63fde7d47a0ee0563aeb6cf6adaeb90fca72

See more details on using hashes here.

File details

Details for the file astc_decomp_faster-1.1.5-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.5-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 853ec21004e02bab157262964b4aafcf6f85ef6afbacad387b5151d7c9e6bca4
MD5 1f323e3b0a5e73fa045268d64315439e
BLAKE2b-256 a2d648e424a84b29e0e9b9c17aa9f7aae3a3678b38477775183474d9f0a52074

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page