Repository navigation
Apply the luma AC sharpening in the vectorized WebP quantizer - #3234
Merged
JimBobSquarePants merged 3 commits intoOct 27, 2026
Merged
Conversation
The AVX2 and SSE4.1 paths of QuantEnc.QuantizeBlock computed abs(in) + sharpen but discarded the sum, so they quantized without the luma AC sharpening bias that the scalar path applies. Lossy output therefore depended on the CPU: x64 machines with SSE4.1 produced a different bitstream from the scalar path used on ARM64 or with hardware intrinsics disabled. Assign the sums back so every path quantizes the same value. Lossy output is now byte-identical with AVX2, with SSE4.1 only and without hardware intrinsics, and the lossy-with-alpha size bounds no longer need a separate value for ARM64.
4 tasks done
4 tasks done
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.
Prerequisites
Description
The AVX2 and SSE4.1 WebP quantizers discarded the sharpening additions. They now quantize
abs(input) + sharpen, matching the scalar path and libwebp. This removes a CPU-dependent difference in luma AC quantization.The existing SIMD paths and buffers remain in use. Assembly shows one additional AVX2 word addition or two additional SSE word additions. The compiler removed the discarded additions from the original code. This fix therefore adds the required arithmetic to the executed code.
The coefficient regression checks fixed levels and reconstructed values from the local libwebp source. It runs with the available intrinsics, without AVX2, and without hardware intrinsics. Its comments describe the calculation and coefficient order. The scalar test name now states that hardware intrinsics are disabled.
The two alpha encoding tests now use one size bound across architectures. The bounds are 64,060 bytes without alpha compression and 16,240 bytes with alpha compression. These were already the ARM64 bounds and match the corrected x64 output. Pixel-comparison tolerances and reference images are unchanged.
No test inputs are encoded or patched at runtime. Image tests use the existing stored
Png/transparency.png. The quantizer tests use fixed coefficient arrays. No data-integrity policy changed.Verification
V4 backport: #3257.
Fixes #3246