Skip to content

Commit 2ce4eae

Browse files
matmenclaude
andcommitted
WebP lossless encoder: prefix groups, color cache size, lazy matches
The VP8L encoder (lossless WebPs and the alpha of lossy ones) now - groups the main image's 16x16 blocks by their symbols (k-means by the bits their clusters' codes would take, 4-16 groups, from the blocks farthest apart) and writes an entropy image with a prefix group each, if that is estimated to be smaller; - picks the color cache's size (0-10 bits) by the estimated bits of the literals and hits, all sizes in one pass; - delays a match by a pixel if the next one starts a longer one; - tries predicting images of 17-256 colors instead of indexing them, and doesn't subtract green from images without red and blue (alpha planes). Sizes vs cwebp: lossless 113.7% -> 107.2% (5 images), lossy alpha at effort 2 113% -> 94%, at effort 4 134% -> 111%; every file decodes exactly in dwebp. Lossless encoding takes about 65% longer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lfv41PqHEGbU7SLg5onpG1
1 parent 1adf0d3 commit 2ce4eae

2 files changed

Lines changed: 357 additions & 66 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
effort 1 (3.5% at effort 2) and within 1-4% of `cjxl -e 7`'s (up to 9% for screenshots); effort 0 is within 1.5%
1414
of `cjxl -e 3`. A 1920x1080 photo takes about 1 s at effort 0, 5 s at effort 1, 10 s at effort 2.
1515

16+
### Improvements
17+
18+
- Lossless WebPs (and the alpha of lossy ones) are smaller: the encoder groups blocks of 16 pixels by their
19+
statistics (prefix codes per group, like libwebp's entropy image), picks the color cache's size, delays matches by a
20+
pixel where the next one is longer, and predicts images of up to 256 colors instead of indexing them where that's
21+
smaller (smooth alpha). Lossless files are about 6% smaller (within about 7% of cwebp's), the alpha of lossy ones
22+
about 17% (at the default effort smaller than cwebp's). Lossless encoding takes about 65% longer.
23+
1624
### Fixes
1725

1826
- `AVIFEncodeOptions` is exported (with the new `JXLEncodeOptions`).

0 commit comments

Comments
 (0)