[FFmpeg-cvslog] r18527 - in trunk/libavcodec/x86: dsputil_mmx.c dsputil_mmx_rnd_template.c

conrad subversion
Wed Apr 15 21:10:16 CEST 2009


Author: conrad
Date: Wed Apr 15 21:10:16 2009
New Revision: 18527

Log:
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.

Modified:
   trunk/libavcodec/x86/dsputil_mmx.c
   trunk/libavcodec/x86/dsputil_mmx_rnd_template.c

Modified: trunk/libavcodec/x86/dsputil_mmx.c
==============================================================================
--- trunk/libavcodec/x86/dsputil_mmx.c	Wed Apr 15 19:29:20 2009	(r18526)
+++ trunk/libavcodec/x86/dsputil_mmx.c	Wed Apr 15 21:10:16 2009	(r18527)
@@ -155,6 +155,7 @@ DECLARE_ALIGNED_16(const double, ff_pd_2
 #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 @@ DECLARE_ALIGNED_16(const double, ff_pd_2
 #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 @@ DECLARE_ALIGNED_16(const double, ff_pd_2
 
 /* 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

Modified: trunk/libavcodec/x86/dsputil_mmx_rnd_template.c
==============================================================================
--- trunk/libavcodec/x86/dsputil_mmx_rnd_template.c	Wed Apr 15 19:29:20 2009	(r18526)
+++ trunk/libavcodec/x86/dsputil_mmx_rnd_template.c	Wed Apr 15 21:10:16 2009	(r18527)
@@ -306,7 +306,7 @@ static void av_unused DEF(avg, pixels4)(
         __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 @@ static void DEF(avg, pixels8)(uint8_t *b
         __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 @@ static void DEF(avg, pixels16)(uint8_t *
         __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 @@ static void DEF(avg, pixels8_x2)(uint8_t
             "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 @@ static av_unused void DEF(avg, pixels8_l
             "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 @@ static void DEF(avg, pixels16_x2)(uint8_
             "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 @@ static av_unused void DEF(avg, pixels16_
             "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 @@ static void DEF(avg, pixels8_y2)(uint8_t
         "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 @@ static void DEF(avg, pixels8_y2)(uint8_t
         "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 @@ static void DEF(avg, pixels8_xy2)(uint8_
         "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 @@ static void DEF(avg, pixels8_xy2)(uint8_
         "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"
 



More information about the ffmpeg-cvslog mailing list