Skip to content

faster GIF decoding - #62

Merged
matmen merged 1 commit into
masterfrom
faster-gif
Oct 16, 2026
Merged

matmen merged 1 commit into
masterfrom
faster-gif

Conversation

@matmen

@matmen matmen commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Faster GIF decoding:

  • Frame indices become RGBA through a table of the 256 colors, with transparent and missing entries resolved once. Each pixel is written as one 32-bit value instead of four bytes after a bounds check.
  • LZW strings are written without checking every byte against the end of the image, except when a string runs past it.

Identical results: still and animated decoding, plus the GIF and APNG encoders on the decoded frames, checked against master on 1593 images (1970 results, 0 different).

Speed: decoding the benchmark's 101-frame GIF takes about 29% less time.

@matmen matmen added this to the v3.2.0 milestone Oct 16, 2026
@matmen matmen self-assigned this Oct 16, 2026
@matmen matmen added the enhancement New feature or request label Oct 16, 2026
- Frame indices become RGBA through a table of the 256 colors (transparent and missing entries resolved once),
  written as one 32-bit value per pixel instead of four bytes after a table bounds check.
- LZW strings are written without checking every byte against the end of the image, unless the string runs
  past it.

The results are bit-identical: still and animated decoding (and the GIF and APNG encoders on the decoded
frames) checked against master on 1593 images. The benchmark's 101 frame GIF decodes about 25% faster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
@matmen
matmen merged commit 6b80937 into master Oct 16, 2026
13 checks passed
@matmen
matmen deleted the faster-gif branch October 16, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant