[FFmpeg-cvslog] lavc/x86/hevc_add_res: Fix overflow in ADD_RES_MMX_4_8

Linjie Fu git at videolan.org
Fri Mar 27 14:42:06 EET 2020


ffmpeg | branch: master | Linjie Fu <linjie.fu at intel.com> | Thu Mar  5 15:47:37 2020 +0800| [0da14ed09e557bd672881d35fd47c2d18df4ad4e] | committer: Anton Khirnov

lavc/x86/hevc_add_res: Fix overflow in ADD_RES_MMX_4_8

Fix overflow for coeff -32768 in function ADD_RES_MMX_4_8 with no
performance drop.

./checkasm --test=hevc_add_res --bench

Mainline:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_4x4_8_mmxext: 15.5

Add overflow test case:
  - hevc_add_res.add_residual [FAILED]

After:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_4x4_8_mmxext: 15.0

Signed-off-by: Xu Guangxin <guangxin.xu at intel.com>
Signed-off-by: Linjie Fu <linjie.fu at intel.com>
Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0da14ed09e557bd672881d35fd47c2d18df4ad4e
---

 libavcodec/x86/hevc_add_res.asm | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/x86/hevc_add_res.asm b/libavcodec/x86/hevc_add_res.asm
index 36d4d8e2e2..249c607a85 100644
--- a/libavcodec/x86/hevc_add_res.asm
+++ b/libavcodec/x86/hevc_add_res.asm
@@ -30,27 +30,26 @@ cextern pw_1023
 %macro ADD_RES_MMX_4_8 0
     mova              m0, [r1]
     mova              m2, [r1+8]
-    pxor              m1, m1
-    pxor              m3, m3
-    psubw             m1, m0
-    psubw             m3, m2
-    packuswb          m0, m2
-    packuswb          m1, m3
 
-    movd              m2, [r0]
+    movd              m1, [r0]
     movd              m3, [r0+r2]
-    punpckldq         m2, m3
-    paddusb           m0, m2
-    psubusb           m0, m1
+    punpcklbw         m1, m4
+    punpcklbw         m3, m4
+
+    paddsw            m0, m1
+    paddsw            m2, m3
+    packuswb          m0, m4
+    packuswb          m2, m4
+
     movd            [r0], m0
-    psrlq             m0, 32
-    movd         [r0+r2], m0
+    movd         [r0+r2], m2
 %endmacro
 
 
 INIT_MMX mmxext
 ; void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, int16_t *res, ptrdiff_t stride)
 cglobal hevc_add_residual_4_8, 3, 3, 6
+    pxor              m4, m4
     ADD_RES_MMX_4_8
     add               r1, 16
     lea               r0, [r0+r2*2]



More information about the ffmpeg-cvslog mailing list