[FFmpeg-devel] [PATCH 1/2] checkasm: add sbrdsp tests

James Almer jamrial at gmail.com
Fri Jun 30 04:53:06 EEST 2017


On 6/29/2017 10:14 PM, Henrik Gramner wrote:
> On Fri, Jun 30, 2017 at 1:58 AM, Michael Niedermayer
> <michael at niedermayer.cc> wrote:
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x0000000000684919 in ff_sbr_hf_gen_sse ()
> 
>>    0x0000000000684909 <ff_sbr_hf_gen_sse+25>:   sub    %r9,%r8
> 
>> => 0x0000000000684919 <ff_sbr_hf_gen_sse+41>:   movaps (%rsi,%r8,1),%xmm0
> 
>> r9             0xdeadbeef00000080       -2401053092612145024
> 
> Another case of a 32-bit int being used as part of a 64-bit operation.

I can't reproduce it on my ArchLinux x86_64 environment for some reason,
but based on what you said i assume the attached patch should fix it.
-------------- next part --------------
From f4646091b450b7c4c5479fbb4163ef89615a4a8d Mon Sep 17 00:00:00 2001
From: James Almer <jamrial at gmail.com>
Date: Thu, 29 Jun 2017 22:51:04 -0300
Subject: [PATCH] x86/sbrdsp: zero extend start and end gprs in
 ff_sbr_hf_gen_sse

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/x86/sbrdsp.asm | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/x86/sbrdsp.asm b/libavcodec/x86/sbrdsp.asm
index d0f774b277..c716184b14 100644
--- a/libavcodec/x86/sbrdsp.asm
+++ b/libavcodec/x86/sbrdsp.asm
@@ -149,19 +149,19 @@ cglobal sbr_hf_gen, 4,4,8, X_high, X_low, alpha0, alpha1, BW, S, E
     ; start and end 6th and 7th args on stack
     mov        r2d, Sm
     mov        r3d, Em
-%define  start r2q
-%define  end   r3q
+    DEFINE_ARGS X_high, X_low, start, end
 %else
 ; BW does not actually occupy a register, so shift by 1
-%define  start BWq
-%define  end   Sq
+    DEFINE_ARGS X_high, X_low, alpha0, alpha1, start, end
+    movsxd  startq, startd
+    movsxd    endq, endd
 %endif
-    sub      start, end          ; neg num of loops
-    lea    X_highq, [X_highq + end*2*4]
-    lea     X_lowq, [X_lowq  + end*2*4 - 2*2*4]
-    shl      start, 3            ; offset from num loops
+    sub     startq, endq         ; neg num of loops
+    lea    X_highq, [X_highq + endq*2*4]
+    lea     X_lowq, [X_lowq  + endq*2*4 - 2*2*4]
+    shl     startq, 3            ; offset from num loops
 
-    mova        m0, [X_lowq + start]
+    mova        m0, [X_lowq + startq]
     shufps      m3, m3, q1111
     shufps      m4, m4, q1111
     xorps       m3, [ps_mask]
@@ -169,7 +169,7 @@ cglobal sbr_hf_gen, 4,4,8, X_high, X_low, alpha0, alpha1, BW, S, E
     shufps      m2, m2, q0000
     xorps       m4, [ps_mask]
 .loop2:
-    movu        m7, [X_lowq + start + 8]        ; BbCc
+    movu        m7, [X_lowq + startq + 8]       ; BbCc
     mova        m6, m0
     mova        m5, m7
     shufps      m0, m0, q2301                   ; aAbB
@@ -179,12 +179,12 @@ cglobal sbr_hf_gen, 4,4,8, X_high, X_low, alpha0, alpha1, BW, S, E
     mulps       m6, m2
     mulps       m5, m1
     addps       m7, m0
-    mova        m0, [X_lowq + start +16]        ; CcDd
+    mova        m0, [X_lowq + startq + 16]      ; CcDd
     addps       m7, m0
     addps       m6, m5
     addps       m7, m6
-    mova  [X_highq + start], m7
-    add     start, 16
+    mova  [X_highq + startq], m7
+    add     startq, 16
     jnz         .loop2
     RET
 
-- 
2.13.0



More information about the ffmpeg-devel mailing list