changeset 330:54d86f074a4b libavcodec

rounding bugfix
author michaelni
date Sun, 21 Apr 2002 22:41:49 +0000
parents 5cc47d0ba53e
children 853e1eb30468
files i386/motion_est_mmx.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/i386/motion_est_mmx.c	Sun Apr 21 21:18:17 2002 +0000
+++ b/i386/motion_est_mmx.c	Sun Apr 21 22:41:49 2002 +0000
@@ -19,6 +19,7 @@
  * mostly by Michael Niedermayer <michaelni@gmx.at>
  */
 #include "../dsputil.h"
+#include "../mangle.h"
 
 static const __attribute__ ((aligned(8))) UINT64 round_tab[3]={
 0x0000000000000000,
@@ -26,6 +27,8 @@
 0x0002000200020002,
 };
 
+static __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
+
 static inline void sad8_mmx(UINT8 *blk1, UINT8 *blk2, int stride, int h)
 {
     int len= -(stride<<h);
@@ -115,6 +118,7 @@
     int len= -(stride<<h);
     asm volatile(
         ".balign 16			\n\t"
+        "movq "MANGLE(bone)", %%mm5	\n\t"
         "1:				\n\t" 
         "movq (%1, %%eax), %%mm0	\n\t"
         "movq (%2, %%eax), %%mm2	\n\t"
@@ -122,6 +126,7 @@
         "movq 1(%2, %%eax), %%mm3	\n\t"
         "pavgb %%mm2, %%mm0		\n\t"
         "pavgb %%mm1, %%mm3		\n\t"
+        "psubusb %%mm5, %%mm3		\n\t"
         "pavgb %%mm3, %%mm0		\n\t"
         "movq (%3, %%eax), %%mm2	\n\t"
         "psadbw %%mm2, %%mm0		\n\t"
@@ -132,6 +137,7 @@
         "movq 1(%2, %%eax), %%mm4	\n\t"
         "pavgb %%mm3, %%mm1		\n\t"
         "pavgb %%mm4, %%mm2		\n\t"
+        "psubusb %%mm5, %%mm2		\n\t"
         "pavgb %%mm1, %%mm2		\n\t"
         "movq (%3, %%eax), %%mm1	\n\t"
         "psadbw %%mm1, %%mm2		\n\t"