changeset 9445:41245484dc0b libavcodec

avg_ pixel functions need to use (dst+pix+1)>>1 to average with existing pixels, not (dst+pix)>>1. This makes the mmx functions bitexact with the C functions.
author conrad
date Wed, 15 Apr 2009 19:10:16 +0000
parents fe17033a79ed
children 1a3865d1b049
files x86/dsputil_mmx.c x86/dsputil_mmx_rnd_template.c
diffstat 2 files changed, 22 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/x86/dsputil_mmx.c	Wed Apr 15 06:23:40 2009 +0000
+++ b/x86/dsputil_mmx.c	Wed Apr 15 19:10:16 2009 +0000
@@ -155,6 +155,7 @@
 #define SET_RND  MOVQ_WONE
 #define PAVGBP(a, b, c, d, e, f)        PAVGBP_MMX_NO_RND(a, b, c, d, e, f)
 #define PAVGB(a, b, c, e)               PAVGB_MMX_NO_RND(a, b, c, e)
+#define OP_AVG(a, b, c, e)              PAVGB_MMX(a, b, c, e)
 
 #include "dsputil_mmx_rnd_template.c"
 
@@ -176,17 +177,20 @@
 #undef SET_RND
 #undef PAVGBP
 #undef PAVGB
+#undef OP_AVG
 
 /***********************************/
 /* 3Dnow specific */
 
 #define DEF(x) x ## _3dnow
 #define PAVGB "pavgusb"
+#define OP_AVG PAVGB
 
 #include "dsputil_mmx_avg_template.c"
 
 #undef DEF
 #undef PAVGB
+#undef OP_AVG
 
 /***********************************/
 /* MMX2 specific */
@@ -195,11 +199,13 @@
 
 /* Introduced only in MMX2 set */
 #define PAVGB "pavgb"
+#define OP_AVG PAVGB
 
 #include "dsputil_mmx_avg_template.c"
 
 #undef DEF
 #undef PAVGB
+#undef OP_AVG
 
 #define put_no_rnd_pixels16_mmx put_pixels16_mmx
 #define put_no_rnd_pixels8_mmx put_pixels8_mmx
--- a/x86/dsputil_mmx_rnd_template.c	Wed Apr 15 06:23:40 2009 +0000
+++ b/x86/dsputil_mmx_rnd_template.c	Wed Apr 15 19:10:16 2009 +0000
@@ -306,7 +306,7 @@
         __asm__ volatile(
              "movd  %0, %%mm0           \n\t"
              "movd  %1, %%mm1           \n\t"
-             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
+             OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
              "movd  %%mm2, %0           \n\t"
              :"+m"(*block)
              :"m"(*pixels)
@@ -326,7 +326,7 @@
         __asm__ volatile(
              "movq  %0, %%mm0           \n\t"
              "movq  %1, %%mm1           \n\t"
-             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
+             OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
              "movq  %%mm2, %0           \n\t"
              :"+m"(*block)
              :"m"(*pixels)
@@ -345,11 +345,11 @@
         __asm__ volatile(
              "movq  %0, %%mm0           \n\t"
              "movq  %1, %%mm1           \n\t"
-             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
+             OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
              "movq  %%mm2, %0           \n\t"
              "movq  8%0, %%mm0          \n\t"
              "movq  8%1, %%mm1          \n\t"
-             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
+             OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
              "movq  %%mm2, 8%0          \n\t"
              :"+m"(*block)
              :"m"(*pixels)
@@ -370,7 +370,7 @@
             "movq  1%1, %%mm1           \n\t"
             "movq  %0, %%mm3            \n\t"
             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-            PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
+            OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
             "movq  %%mm0, %0            \n\t"
             :"+m"(*block)
             :"m"(*pixels)
@@ -390,7 +390,7 @@
             "movq  %2, %%mm1            \n\t"
             "movq  %0, %%mm3            \n\t"
             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-            PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
+            OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
             "movq  %%mm0, %0            \n\t"
             :"+m"(*dst)
             :"m"(*src1), "m"(*src2)
@@ -411,13 +411,13 @@
             "movq  1%1, %%mm1           \n\t"
             "movq  %0, %%mm3            \n\t"
             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-            PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
+            OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
             "movq  %%mm0, %0            \n\t"
             "movq  8%1, %%mm0           \n\t"
             "movq  9%1, %%mm1           \n\t"
             "movq  8%0, %%mm3           \n\t"
             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-            PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
+            OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
             "movq  %%mm0, 8%0           \n\t"
             :"+m"(*block)
             :"m"(*pixels)
@@ -437,13 +437,13 @@
             "movq  %2, %%mm1            \n\t"
             "movq  %0, %%mm3            \n\t"
             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-            PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
+            OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
             "movq  %%mm0, %0            \n\t"
             "movq  8%1, %%mm0           \n\t"
             "movq  8%2, %%mm1           \n\t"
             "movq  8%0, %%mm3           \n\t"
             PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-            PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
+            OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
             "movq  %%mm0, 8%0           \n\t"
             :"+m"(*dst)
             :"m"(*src1), "m"(*src2)
@@ -466,9 +466,9 @@
         "movq   (%1, %%"REG_a"), %%mm2  \n\t"
         PAVGBP(%%mm1, %%mm0, %%mm4,   %%mm2, %%mm1, %%mm5)
         "movq   (%2), %%mm3             \n\t"
-        PAVGB(%%mm3, %%mm4, %%mm0, %%mm6)
+        OP_AVG(%%mm3, %%mm4, %%mm0, %%mm6)
         "movq   (%2, %3), %%mm3         \n\t"
-        PAVGB(%%mm3, %%mm5, %%mm1, %%mm6)
+        OP_AVG(%%mm3, %%mm5, %%mm1, %%mm6)
         "movq   %%mm0, (%2)             \n\t"
         "movq   %%mm1, (%2, %3)         \n\t"
         "add    %%"REG_a", %1           \n\t"
@@ -478,9 +478,9 @@
         "movq   (%1, %%"REG_a"), %%mm0  \n\t"
         PAVGBP(%%mm1, %%mm2, %%mm4,   %%mm0, %%mm1, %%mm5)
         "movq   (%2), %%mm3             \n\t"
-        PAVGB(%%mm3, %%mm4, %%mm2, %%mm6)
+        OP_AVG(%%mm3, %%mm4, %%mm2, %%mm6)
         "movq   (%2, %3), %%mm3         \n\t"
-        PAVGB(%%mm3, %%mm5, %%mm1, %%mm6)
+        OP_AVG(%%mm3, %%mm5, %%mm1, %%mm6)
         "movq   %%mm2, (%2)             \n\t"
         "movq   %%mm1, (%2, %3)         \n\t"
         "add    %%"REG_a", %1           \n\t"
@@ -533,7 +533,7 @@
         "packuswb  %%mm5, %%mm4         \n\t"
                 "pcmpeqd %%mm2, %%mm2   \n\t"
                 "paddb %%mm2, %%mm2     \n\t"
-                PAVGB(%%mm3, %%mm4, %%mm5, %%mm2)
+                OP_AVG(%%mm3, %%mm4, %%mm5, %%mm2)
                 "movq   %%mm5, (%2, %%"REG_a")  \n\t"
         "add    %3, %%"REG_a"                \n\t"
 
@@ -557,7 +557,7 @@
         "packuswb  %%mm1, %%mm0         \n\t"
                 "pcmpeqd %%mm2, %%mm2   \n\t"
                 "paddb %%mm2, %%mm2     \n\t"
-                PAVGB(%%mm3, %%mm0, %%mm1, %%mm2)
+                OP_AVG(%%mm3, %%mm0, %%mm1, %%mm2)
                 "movq   %%mm1, (%2, %%"REG_a")  \n\t"
         "add    %3, %%"REG_a"           \n\t"