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.4.tar.gz (176.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.4-cp313-cp313-win_amd64.whl (78.2 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

File details

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

File metadata

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

File hashes

Hashes for astc_decomp_faster-1.1.4.tar.gz
Algorithm Hash digest
SHA256 9c2ae34a897dd6a6d82e990208c9b1e2999262e5118609e349fdd401d79062bb
MD5 ddcb41ca82832f622424251a6c38bc78
BLAKE2b-256 31fc8f863b84df329e96d65d2694eecaa2be622ebc902f96f2c91098b3f6bdbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b0483248323cf1ef27ec7aa22f201c881e321d02c0137eaddac574437d59e552
MD5 0c78ad84c0ba02f7a6ca0f6bb699b3c4
BLAKE2b-256 7bb5f05aacce57a798ddde8115ab47dc140b39ca107f23dca718741b901e4100

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 573f563ba62ac71972bf3078e5ed5a96ac46c1181e69276960626ada85cdfaf7
MD5 02423709481eb8a53939e2d4c06ba2eb
BLAKE2b-256 48f2cab98bef8ecabb5324a48409a0159f748c4d2cc39c05cf17ad95d8142122

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 27200d0ab1b824df701290044b26cfb38639920566a9828c963030513bc129a7
MD5 889bcb9dc5ec4ee15246b9cffa3ac889
BLAKE2b-256 6ebf7b444a2eaea5b848b5966d3ffd6c7a9e17642afe6942ab0bf7f6b4f220d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for astc_decomp_faster-1.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d74743a94e70d3edb174b1e73335896dddf81954aafe65739d7769829252d60a
MD5 cd1bafbc85647506c18a977bd20358a8
BLAKE2b-256 66b6f6663953c72e3fbf5a88a4be22faeba2e7606fc91b5ec1cd2e49a9e8bf2d

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