Skip to content

[V4] Apply luma AC sharpening in the SIMD WebP quantizer - #3257

Merged
JimBobSquarePants merged 2 commits into
release/4.1.xfrom
fix/webp-quantizer-sharpening-v4
Oct 27, 2026
Merged

JimBobSquarePants merged 2 commits into
release/4.1.xfrom
fix/webp-quantizer-sharpening-v4

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Backports #3234 to release/4.1.x.

The AVX2 and SSE4.1 WebP quantizers discarded the sharpening additions. They now include that bias before quantization, matching the scalar path and local libwebp. The existing SIMD paths and buffers remain in use.

The regression checks fixed coefficient levels and reconstructed values from libwebp. It runs with the available intrinsics, without AVX2, and without hardware intrinsics. The existing alpha encoding tests use the same size bounds on every architecture. Those bounds already applied to the scalar path on ARM64.

Tests use the existing stored PNG inputs and fixed coefficient arrays. No images are generated as test inputs. No tolerance, reference image, or data-integrity policy changed.

Release verification: all 472 WebP tests pass on .NET 8 and .NET 10. Main also passes its WebP tests. Native comparison, original-code failure reproduction and assembly checks are recorded in #3234.

Fixes #3246

jafin and others added 2 commits October 27, 2026 16:41
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.
@JimBobSquarePants
JimBobSquarePants marked this pull request as ready for review October 27, 2026 06:58
@JimBobSquarePants
JimBobSquarePants merged commit fa206e0 into release/4.1.x Oct 27, 2026
11 checks passed
@JimBobSquarePants
JimBobSquarePants deleted the fix/webp-quantizer-sharpening-v4 branch October 27, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lossy WebP output differs between the SIMD and scalar paths: the vectorized quantizer skips luma AC sharpening

2 participants