Repository navigation
Faster lossless WebP: predictors per mode, cost table, hashes once - #73
Merged
Merged
Conversation
- predictRun predicts (encoding) or restores (decoding) a run of pixels with one loop per mode, instead of predict() with a switch per pixel. The encoder's mode search and the decoder's inverse predictor use it. - residual costs come from a 256-entry table instead of branches. - tokenize hashes every pixel pair once instead of on search and insert. Output is identical (VP8L data of 1298 corpus encodes, pixels of 153 WebP decodes). 1920x1080 photo: encoding 1220 -> 735 ms, decoding 95 -> 82 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes lossless WebP faster without changing the output. On a 1920×1080 photo:
Both builds ran alternately in the same run, because the local machine is noisy. On the runner, encoding took 621 ms in the 3.2.1 benchmark.
Changes (
src/codecs/vp8l.ts)predictRun: Predictions now run with one loop per predictor mode, not throughpredict()with aswitchfor every pixel. When encoding it writes a block row's predictions into a buffer; when decoding it restores the pixels in place.inversePredictor.predict()has no callers left and is removed.restorecheck in the loop) measured no faster, so there is only the one function.tokenize: each pixel pair is hashed once into an array, instead of once for the search and again for the insert.Verified
npm testpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ