PR #26130 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26130
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26130.patch

# Summary of changes

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.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 44e95c880bcb770223643a396b49e54b84839d8a Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Tue, 17 Nov 2026 22:23:54 +0800
Subject: [PATCH] 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.
---
 libavcodec/aarch64/vvc/inter_sme2.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aarch64/vvc/inter_sme2.S 
b/libavcodec/aarch64/vvc/inter_sme2.S
index 6d91b7921ad..fcafd875c85 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]
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to