Skip to content

sharpyuv: prevent 16-bit signed wraparound in UpdateRGB and RGB-to-Y - #22

Closed
PRAVIN-952006 wants to merge 1 commit into
webmproject:mainfrom
PRAVIN-952006:fix-sharpyuv-16bit-wraparound
Closed

PRAVIN-952006 wants to merge 1 commit into
webmproject:mainfrom
PRAVIN-952006:fix-sharpyuv-16bit-wraparound

Conversation

@PRAVIN-952006

Copy link
Copy Markdown
Contributor

Summary

  • Widens SharpYuvUpdateRGB_{C,SSE2,AVX2,NEON} to 32-bit signed arithmetic with saturation to int16_t bounds ([-32768, 32767]), preventing 16-bit signed wraparound.
  • Uses saturating 16-bit addition (_mm_adds_epi16) in SharpYuvUpdateY_{SSE2,AVX2}.
  • Widens RGB + W additions to 32-bit in RGBToY_{AVX2,NEON} before conversion so SIMD paths stay bit-exact with SharpYuvUpdateRGB_C.

Verification

  • Built on Apple Silicon ARM64 (Apple Clang 17, -O2 -Wall -Wextra -Werror) with 0 warnings.
  • Verified ARM64 NEON parity (mismatches=0 vs scalar C) under ASan + UBSan with 0 diagnostics.

Widen SharpYuvUpdateRGB_{C,SSE2,AVX2,NEON} to 32-bit signed arithmetic
with saturation to int16_t bounds, use saturating 16-bit addition in
UpdateY_{SSE2,AVX2}, and widen RGB+W additions to 32-bit in
RGBToY_{AVX2,NEON} to match scalar C behavior without 16-bit wraparound.
@PRAVIN-952006

Copy link
Copy Markdown
Contributor Author

Closing mirror PR — submitted to Chromium Gerrit per CONTRIBUTING.md: https://chromium-review.googlesource.com/c/webm/libwebp/+/8869770

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.

1 participant