Skip to content

faster lossless WebP encoding - #65

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

matmen merged 1 commit into
masterfrom
faster-webp

Conversation

@matmen

@matmen matmen commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Faster lossless WebP encoding:

  • Hash-chain candidates are skipped without measuring the match when they can't win. The chain runs from near to far, so a candidate that's no closer than the best match only wins by being longer, and it can't be longer if it differs right after the best length. This is the same check zlib uses.
  • The left and above references are checked directly, instead of through an array created for every pixel.
  • The per-channel helpers of the predictors (select and the clamped ones) and the residual cost are unrolled.

Identical results: files are byte-identical, checked against master on 1593 images (2828 results, 0 different).

Speed: encoding a 1920×1080 photo takes 9–15% less time. The changelog says about 15%.

@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
- Hash chain candidates are skipped without measuring the match when they can't win: the chain runs from near
  to far, so a candidate no closer than the best one only wins by being longer, which it can't be if it differs
  right after the best length (zlib's check).
- The left and above references are checked directly instead of through an array created for every pixel.
- The per-channel helpers of the predictors (select, the clamped ones) and the residual cost are unrolled.

The files are byte-identical: lossless encoding checked against master on 1593 images. Encoding a 1920×1080
photo is about 15% faster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
@matmen
matmen merged commit 8fa8efd into master Oct 16, 2026
13 checks passed
@matmen
matmen deleted the faster-webp branch October 16, 2026 07:17
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