PR #24203 opened by haochenc
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24203
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24203.patch

Arguments passed as 32-bit registers (w2, w3) for lengths and channel
counts are used as 64-bit registers (x2, x3) without proper sign
extension, which can lead to out-of-bounds behavior or incorrectly
populated upper limits. This commit adds explicit sxtw instructions to
ensure inputs are correctly sign-extended.

Signed-off-by: Hao Chen <[email protected]>



>From c752cf182a366f85a8aa614218f609f209905186 Mon Sep 17 00:00:00 2001
From: Hao Chen <[email protected]>
Date: Mon, 17 Aug 2026 17:26:10 +0000
Subject: [PATCH] libswresample/aarch64: Fix sign extension in audio conversion

Arguments passed as 32-bit registers (w2, w3) for lengths and channel
counts are used as 64-bit registers (x2, x3) without proper sign
extension, which can lead to out-of-bounds behavior or incorrectly
populated upper limits. This commit adds explicit sxtw instructions to
ensure inputs are correctly sign-extended.

Signed-off-by: Hao Chen <[email protected]>
---
 libswresample/aarch64/audio_convert_neon.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libswresample/aarch64/audio_convert_neon.S 
b/libswresample/aarch64/audio_convert_neon.S
index 6d789b16d2..d9f9b70699 100644
--- a/libswresample/aarch64/audio_convert_neon.S
+++ b/libswresample/aarch64/audio_convert_neon.S
@@ -24,6 +24,7 @@
 
 function swri_oldapi_conv_flt_to_s16_neon, export=1
 oldapi_conv_flt_to_s16_neon:
+        sxtw            x2,  w2
         subs            x2,  x2,  #8
         ld1             {v0.4s}, [x1],  #16
         fcvtzs          v4.4s,  v0.4s,  #31
@@ -69,6 +70,7 @@ endfunc
 
 function swri_oldapi_conv_fltp_to_s16_2ch_neon, export=1
 oldapi_conv_fltp_to_s16_2ch_neon:
+        sxtw            x2,  w2
         ldp             x4,  x5,  [x1]
         subs            x2,  x2,  #8
         ld1             {v0.4s},  [x4], #16
@@ -132,6 +134,8 @@ oldapi_conv_fltp_to_s16_2ch_neon:
 endfunc
 
 function swri_oldapi_conv_fltp_to_s16_nch_neon, export=1
+        sxtw            x2,  w2
+        sxtw            x3,  w3
         cmp             w3,  #2
         b.eq            oldapi_conv_fltp_to_s16_2ch_neon
         b.gt            1f
-- 
2.52.0

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

Reply via email to