Repository navigation
Speed up WebP and JPEG XL, and follow the libwebp rules - #3293
Merged
Merged
Conversation
- JPEG XL lossless: port the libjxl effort 1 fast lossless mode (global per-channel tree, YCoCg, sampled histograms, bounded code lengths, zero runs, palette detection), with SIMD field operators. - JPEG XL entropy: SIMD token count and 64-bit field writer for the general sample streams. - WebP: codec performance work and simplification. - Shared: vector helpers (variable shifts with SSE fallbacks, gather), modular forward YCoCg, hybrid integer 0/0/0 vector split, tests.
- Analysis histogram: Vp8Histogram.BinOperator with one CountBins traversal; zero bins counted with a vector compare and popcount. - Mode trials: exact early-outs with Vp8ModeScore.GetScoreBound in the I4, I16 and UV searches. A mode whose header and distortion already reach the best score skips its spectral distortion and rate. - I4 predictors DC, HE, HD and HU: packed rows stored by ref. - Update shared-infrastructure to the latest main. The encoded bytes are identical to the previous build.
An IFD without the YCbCrSubSampling tag now uses 2, 2, the TIFF 6.0 default, not 1, 1. The value is never null, so the null checks in the parser, the decoder and the YCbCr readers are removed.
The token loop gets the output buffer once for each call, not once for each flushed byte, and both bit writers are sealed. The scalar 4x4 vertical predictor needs no scratch. The alpha encoder selects its filter as libwebp does, records it in the ALPH header, and keeps compressed data of equal size.
- Decode the lossy alpha rows per macroblock row, as libwebp does. - Merge equal segments and give unused segments the base quantizer, as libwebp does. - Quantize groups of blocks with 16-bit lanes for 256-bit and 512-bit vectors. - Saturate frame delays that the WebP, GIF, APNG and AVIF fields cannot hold. - Add XML docs to the undocumented members of the touched files. - Replace bitstream builders and pixel loops in the tests with fixtures and image comparers. - Update the WebP benchmark results.
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.
Summary
This PR makes the WebP codec faster than libwebp in each benchmark layout. The output follows the libwebp rules. It also speeds up JPEG XL and fixes the TIFF YCbCr subsampling default.
WebP
Other codecs
Tests
Benchmarks
Ratio to libwebp (Magick). A value below 1.00 means ImageSharp is faster.
The BenchmarkDotNet tables are in the results blocks of
EncodeWebp.csandDecodeWebp.cs.