Commit cd39c36377 for ffmpeg
commit cd39c36377fcdac674fea5905cf633e6b8b8a471
Author: Zhao Zhili <quinkblack@foxmail.com>
Date: Tue Nov 17 22:23:54 2026 +0800
aarch64/vvc: Fix 16-bit overflow in SME2 ALF luma filter
At 12-bit, the narrowed filter sum plus the centre sample can exceed the
signed 16-bit range. The plain add wraps negative and the final clamp
returns 0 instead of the maximum. Use a saturating add.
The VVC ALF checkasm test at seed 922152564 reproduces the mismatch.
diff --git a/libavcodec/aarch64/vvc/inter_sme2.S b/libavcodec/aarch64/vvc/inter_sme2.S
index 6d91b7921a..fcafd875c8 100644
--- a/libavcodec/aarch64/vvc/inter_sme2.S
+++ b/libavcodec/aarch64/vvc/inter_sme2.S
@@ -614,10 +614,10 @@ function ff_vvc_alf_filter_luma_10_sme2, export=1
tbnz x13, #24, 13f
sqrshr z15.h, {z28.d-z31.d}, #10
13:
- add z12.h, z12.h, z6.h
- add z13.h, z13.h, z7.h
- add z14.h, z14.h, z0.h
- add z15.h, z15.h, z3.h
+ sqadd z12.h, z12.h, z6.h
+ sqadd z13.h, z13.h, z7.h
+ sqadd z14.h, z14.h, z0.h
+ sqadd z15.h, z15.h, z3.h
sclamp {z12.h-z15.h}, z9.h, z10.h
st1h z12.h, p0, [x19]
st1h z13.h, p0, [x19, x2, lsl #1]