Repository navigation
opencodecs 0.7.2 is about speed. We measured opencodecs against Apple's ImageIO, NVIDIA's GPU codecs, and the Intel and AMD media engines. Most of the gaps those measurements exposed were in opencodecs itself, and they are closed here for every platform. Every decode returns exactly the same output as 0.7.1.
Faster everywhere
| Change | Example |
|---|---|
| AVIF decode converts YUV to RGB on several threads | 4096 x 3072 4:2:0: 149 to 58 ms |
| PNG decode inflates in one libdeflate call, and the defilters stop waiting on the byte just written | 4096 x 4096 16-bit gray: 155 to 79 ms |
| gzip decode goes through libdeflate | 256 MiB on macOS: 438 to 367 ms (text), 807 to 646 ms (less compressible data) |
New opencodecs.decode_batch decodes many zstd, deflate or LZ4 chunks in a few native calls |
256 MiB of 64 KiB zstd chunks: 28 ms, against 179 ms one Python call per chunk |
| Local zarr and OME-Zarr arrays of zstd chunks read, decompress and place in native code, in parallel by default | full 256 MiB read: 511 to 45 ms |
| HEIF decode gives libheif's HEVC decoder its thread count | untiled 4096 x 3072: 288 to 78 ms |
| HTJ2K decode splits a multi-tile codestream and decodes the tiles in parallel | 16 tiles: 118 to 13.5 ms |
AVIF encode now defaults to speed 6. Before, it used libavif's library default, which is libaom's slowest search. The new default is about 50 times faster: 0.5 s instead of 22 s for a 12-megapixel photo. Files are about 10% larger at equal perceived quality. SSIMULACRA2 and Butteraugli scores, on photographs and on microscopy, show no perceptible difference. libavif's own avifenc also defaults to 6. imagecodecs keeps speed 0, so this is a deliberate difference from it; pass speed=0 to match imagecodecs.
Opt-in hardware backends. None of these is ever used unless you ask for it by name:
backend="nvimgcodec"runs JPEG, JPEG 2000 and HTJ2K on an NVIDIA GPU. An HTJ2K lossless decode is 9x faster, or 16x into pinned memory, and lossless decodes match the CPU path exactly.backend="nvvideocodec"runs HEIF decode on NVIDIA's video decoder (NVDEC) and AVIF/HEIF encode on its video encoder (NVENC). Decoded pixels match libheif exactly, except in 10- and 12-bit 4:2:0 and 4:2:2 files: there about 1 sample in 100,000 can differ by 1 from the libheif 1.21.0 these wheels bundle, which rounds one default color matrix; newer libheif agrees with the GPU exactly. Tested on Ada (RTX 4090) and Blackwell (RTX 5060 Ti), which also decodes HEVC 4:2:2. The encodes are a fast mode: 14 ms for AVIF, with larger files.backend="imageio"decodes HEIF on Apple's media engine on macOS: 10 to 19x faster on large single-picture files.
Install the NVIDIA dependencies with pip install 'opencodecs[gpu]'. Importing opencodecs loads none of these packages. A backend that cannot run raises an error instead of falling back to the CPU, and the first call in a process costs about a second.
Measured and not added: Intel Quick Sync and AMD VCN through VA-API, and NVIDIA's nvCOMP. The reasons are in CHANGES.rst.
The full list is in CHANGES.rst.