]> git.sesse.net Git - vlc/blobdiff - modules/codec/xvmc/motion_comp_mmx.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / codec / xvmc / motion_comp_mmx.c
index bb614931571a37c4bdcc979362f67931a1a8e496..5b68a290e452917eb2f90a7bc811b3e67a8bf8a3 100644 (file)
@@ -67,175 +67,175 @@ static inline void mmx_zero_reg ()
 }
 
 static inline void mmx_average_2_U8 (uint8_t * dest, const uint8_t * src1,
-                                    const uint8_t * src2)
+                     const uint8_t * src2)
 {
     /* *dest = (*src1 + *src2 + 1)/ 2; */
 
-    movq_m2r (*src1, mm1);     /* load 8 src1 bytes */
-    movq_r2r (mm1, mm2);       /* copy 8 src1 bytes */
+    movq_m2r (*src1, mm1);    /* load 8 src1 bytes */
+    movq_r2r (mm1, mm2);    /* copy 8 src1 bytes */
 
-    movq_m2r (*src2, mm3);     /* load 8 src2 bytes */
-    movq_r2r (mm3, mm4);       /* copy 8 src2 bytes */
+    movq_m2r (*src2, mm3);    /* load 8 src2 bytes */
+    movq_r2r (mm3, mm4);    /* copy 8 src2 bytes */
 
-    pxor_r2r (mm1, mm3);       /* xor src1 and src2 */
-    pand_m2r (mask1, mm3);     /* mask lower bits */
-    psrlq_i2r (1, mm3);                /* /2 */
-    por_r2r (mm2, mm4);                /* or src1 and src2 */
-    psubb_r2r (mm3, mm4);      /* subtract subresults */
-    movq_r2m (mm4, *dest);     /* store result in dest */
+    pxor_r2r (mm1, mm3);    /* xor src1 and src2 */
+    pand_m2r (mask1, mm3);    /* mask lower bits */
+    psrlq_i2r (1, mm3);        /* /2 */
+    por_r2r (mm2, mm4);        /* or src1 and src2 */
+    psubb_r2r (mm3, mm4);    /* subtract subresults */
+    movq_r2m (mm4, *dest);    /* store result in dest */
 }
 
 static inline void mmx_interp_average_2_U8 (uint8_t * dest,
-                                           const uint8_t * src1,
-                                           const uint8_t * src2)
+                        const uint8_t * src1,
+                        const uint8_t * src2)
 {
     /* *dest = (*dest + (*src1 + *src2 + 1)/ 2 + 1)/ 2; */
 
-    movq_m2r (*dest, mm1);     /* load 8 dest bytes */
-    movq_r2r (mm1, mm2);       /* copy 8 dest bytes */
+    movq_m2r (*dest, mm1);    /* load 8 dest bytes */
+    movq_r2r (mm1, mm2);    /* copy 8 dest bytes */
 
-    movq_m2r (*src1, mm3);     /* load 8 src1 bytes */
-    movq_r2r (mm3, mm4);       /* copy 8 src1 bytes */
+    movq_m2r (*src1, mm3);    /* load 8 src1 bytes */
+    movq_r2r (mm3, mm4);    /* copy 8 src1 bytes */
 
-    movq_m2r (*src2, mm5);     /* load 8 src2 bytes */
-    movq_r2r (mm5, mm6);       /* copy 8 src2 bytes */
+    movq_m2r (*src2, mm5);    /* load 8 src2 bytes */
+    movq_r2r (mm5, mm6);    /* copy 8 src2 bytes */
 
-    pxor_r2r (mm3, mm5);       /* xor src1 and src2 */
-    pand_m2r (mask1, mm5);     /* mask lower bits */
-    psrlq_i2r (1, mm5);                /* /2 */
-    por_r2r (mm4, mm6);                /* or src1 and src2 */
-    psubb_r2r (mm5, mm6);      /* subtract subresults */
-    movq_r2r (mm6, mm5);       /* copy subresult */
+    pxor_r2r (mm3, mm5);    /* xor src1 and src2 */
+    pand_m2r (mask1, mm5);    /* mask lower bits */
+    psrlq_i2r (1, mm5);        /* /2 */
+    por_r2r (mm4, mm6);        /* or src1 and src2 */
+    psubb_r2r (mm5, mm6);    /* subtract subresults */
+    movq_r2r (mm6, mm5);    /* copy subresult */
 
-    pxor_r2r (mm1, mm5);       /* xor srcavg and dest */
-    pand_m2r (mask1, mm5);     /* mask lower bits */
-    psrlq_i2r (1, mm5);                /* /2 */
-    por_r2r (mm2, mm6);                /* or srcavg and dest */
-    psubb_r2r (mm5, mm6);      /* subtract subresults */
-    movq_r2m (mm6, *dest);     /* store result in dest */
+    pxor_r2r (mm1, mm5);    /* xor srcavg and dest */
+    pand_m2r (mask1, mm5);    /* mask lower bits */
+    psrlq_i2r (1, mm5);        /* /2 */
+    por_r2r (mm2, mm6);        /* or srcavg and dest */
+    psubb_r2r (mm5, mm6);    /* subtract subresults */
+    movq_r2m (mm6, *dest);    /* store result in dest */
 }
 
 static inline void mmx_average_4_U8 (uint8_t * dest, const uint8_t * src1,
-                                    const uint8_t * src2,
-                                    const uint8_t * src3,
-                                    const uint8_t * src4)
+                     const uint8_t * src2,
+                     const uint8_t * src3,
+                     const uint8_t * src4)
 {
     /* *dest = (*src1 + *src2 + *src3 + *src4 + 2)/ 4; */
 
-    movq_m2r (*src1, mm1);     /* load 8 src1 bytes */
-    movq_r2r (mm1, mm2);       /* copy 8 src1 bytes */
+    movq_m2r (*src1, mm1);    /* load 8 src1 bytes */
+    movq_r2r (mm1, mm2);    /* copy 8 src1 bytes */
 
-    punpcklbw_r2r (mm0, mm1);  /* unpack low src1 bytes */
-    punpckhbw_r2r (mm0, mm2);  /* unpack high src1 bytes */
+    punpcklbw_r2r (mm0, mm1);    /* unpack low src1 bytes */
+    punpckhbw_r2r (mm0, mm2);    /* unpack high src1 bytes */
 
-    movq_m2r (*src2, mm3);     /* load 8 src2 bytes */
-    movq_r2r (mm3, mm4);       /* copy 8 src2 bytes */
+    movq_m2r (*src2, mm3);    /* load 8 src2 bytes */
+    movq_r2r (mm3, mm4);    /* copy 8 src2 bytes */
 
-    punpcklbw_r2r (mm0, mm3);  /* unpack low src2 bytes */
-    punpckhbw_r2r (mm0, mm4);  /* unpack high src2 bytes */
+    punpcklbw_r2r (mm0, mm3);    /* unpack low src2 bytes */
+    punpckhbw_r2r (mm0, mm4);    /* unpack high src2 bytes */
 
-    paddw_r2r (mm3, mm1);      /* add lows */
-    paddw_r2r (mm4, mm2);      /* add highs */
+    paddw_r2r (mm3, mm1);    /* add lows */
+    paddw_r2r (mm4, mm2);    /* add highs */
 
     /* now have partials in mm1 and mm2 */
 
-    movq_m2r (*src3, mm3);     /* load 8 src3 bytes */
-    movq_r2r (mm3, mm4);       /* copy 8 src3 bytes */
+    movq_m2r (*src3, mm3);    /* load 8 src3 bytes */
+    movq_r2r (mm3, mm4);    /* copy 8 src3 bytes */
 
-    punpcklbw_r2r (mm0, mm3);  /* unpack low src3 bytes */
-    punpckhbw_r2r (mm0, mm4);  /* unpack high src3 bytes */
+    punpcklbw_r2r (mm0, mm3);    /* unpack low src3 bytes */
+    punpckhbw_r2r (mm0, mm4);    /* unpack high src3 bytes */
 
-    paddw_r2r (mm3, mm1);      /* add lows */
-    paddw_r2r (mm4, mm2);      /* add highs */
+    paddw_r2r (mm3, mm1);    /* add lows */
+    paddw_r2r (mm4, mm2);    /* add highs */
 
-    movq_m2r (*src4, mm5);     /* load 8 src4 bytes */
-    movq_r2r (mm5, mm6);       /* copy 8 src4 bytes */
+    movq_m2r (*src4, mm5);    /* load 8 src4 bytes */
+    movq_r2r (mm5, mm6);    /* copy 8 src4 bytes */
 
-    punpcklbw_r2r (mm0, mm5);  /* unpack low src4 bytes */
-    punpckhbw_r2r (mm0, mm6);  /* unpack high src4 bytes */
+    punpcklbw_r2r (mm0, mm5);    /* unpack low src4 bytes */
+    punpckhbw_r2r (mm0, mm6);    /* unpack high src4 bytes */
 
-    paddw_r2r (mm5, mm1);      /* add lows */
-    paddw_r2r (mm6, mm2);      /* add highs */
+    paddw_r2r (mm5, mm1);    /* add lows */
+    paddw_r2r (mm6, mm2);    /* add highs */
 
     /* now have subtotal in mm1 and mm2 */
 
     paddw_m2r (round4, mm1);
-    psraw_i2r (2, mm1);                /* /4 */
+    psraw_i2r (2, mm1);        /* /4 */
     paddw_m2r (round4, mm2);
-    psraw_i2r (2, mm2);                /* /4 */
+    psraw_i2r (2, mm2);        /* /4 */
 
-    packuswb_r2r (mm2, mm1);   /* pack (w/ saturation) */
-    movq_r2m (mm1, *dest);     /* store result in dest */
+    packuswb_r2r (mm2, mm1);    /* pack (w/ saturation) */
+    movq_r2m (mm1, *dest);    /* store result in dest */
 }
 
 static inline void mmx_interp_average_4_U8 (uint8_t * dest,
-                                           const uint8_t * src1,
-                                           const uint8_t * src2,
-                                           const uint8_t * src3,
-                                           const uint8_t * src4)
+                        const uint8_t * src1,
+                        const uint8_t * src2,
+                        const uint8_t * src3,
+                        const uint8_t * src4)
 {
     /* *dest = (*dest + (*src1 + *src2 + *src3 + *src4 + 2)/ 4 + 1)/ 2; */
 
-    movq_m2r (*src1, mm1);     /* load 8 src1 bytes */
-    movq_r2r (mm1, mm2);       /* copy 8 src1 bytes */
+    movq_m2r (*src1, mm1);    /* load 8 src1 bytes */
+    movq_r2r (mm1, mm2);    /* copy 8 src1 bytes */
 
-    punpcklbw_r2r (mm0, mm1);  /* unpack low src1 bytes */
-    punpckhbw_r2r (mm0, mm2);  /* unpack high src1 bytes */
+    punpcklbw_r2r (mm0, mm1);    /* unpack low src1 bytes */
+    punpckhbw_r2r (mm0, mm2);    /* unpack high src1 bytes */
 
-    movq_m2r (*src2, mm3);     /* load 8 src2 bytes */
-    movq_r2r (mm3, mm4);       /* copy 8 src2 bytes */
+    movq_m2r (*src2, mm3);    /* load 8 src2 bytes */
+    movq_r2r (mm3, mm4);    /* copy 8 src2 bytes */
 
-    punpcklbw_r2r (mm0, mm3);  /* unpack low src2 bytes */
-    punpckhbw_r2r (mm0, mm4);  /* unpack high src2 bytes */
+    punpcklbw_r2r (mm0, mm3);    /* unpack low src2 bytes */
+    punpckhbw_r2r (mm0, mm4);    /* unpack high src2 bytes */
 
-    paddw_r2r (mm3, mm1);      /* add lows */
-    paddw_r2r (mm4, mm2);      /* add highs */
+    paddw_r2r (mm3, mm1);    /* add lows */
+    paddw_r2r (mm4, mm2);    /* add highs */
 
     /* now have partials in mm1 and mm2 */
 
-    movq_m2r (*src3, mm3);     /* load 8 src3 bytes */
-    movq_r2r (mm3, mm4);       /* copy 8 src3 bytes */
+    movq_m2r (*src3, mm3);    /* load 8 src3 bytes */
+    movq_r2r (mm3, mm4);    /* copy 8 src3 bytes */
 
-    punpcklbw_r2r (mm0, mm3);  /* unpack low src3 bytes */
-    punpckhbw_r2r (mm0, mm4);  /* unpack high src3 bytes */
+    punpcklbw_r2r (mm0, mm3);    /* unpack low src3 bytes */
+    punpckhbw_r2r (mm0, mm4);    /* unpack high src3 bytes */
 
-    paddw_r2r (mm3, mm1);      /* add lows */
-    paddw_r2r (mm4, mm2);      /* add highs */
+    paddw_r2r (mm3, mm1);    /* add lows */
+    paddw_r2r (mm4, mm2);    /* add highs */
 
-    movq_m2r (*src4, mm5);     /* load 8 src4 bytes */
-    movq_r2r (mm5, mm6);       /* copy 8 src4 bytes */
+    movq_m2r (*src4, mm5);    /* load 8 src4 bytes */
+    movq_r2r (mm5, mm6);    /* copy 8 src4 bytes */
 
-    punpcklbw_r2r (mm0, mm5);  /* unpack low src4 bytes */
-    punpckhbw_r2r (mm0, mm6);  /* unpack high src4 bytes */
+    punpcklbw_r2r (mm0, mm5);    /* unpack low src4 bytes */
+    punpckhbw_r2r (mm0, mm6);    /* unpack high src4 bytes */
 
-    paddw_r2r (mm5, mm1);      /* add lows */
-    paddw_r2r (mm6, mm2);      /* add highs */
+    paddw_r2r (mm5, mm1);    /* add lows */
+    paddw_r2r (mm6, mm2);    /* add highs */
 
     paddw_m2r (round4, mm1);
-    psraw_i2r (2, mm1);                /* /4 */
+    psraw_i2r (2, mm1);        /* /4 */
     paddw_m2r (round4, mm2);
-    psraw_i2r (2, mm2);                /* /4 */
+    psraw_i2r (2, mm2);        /* /4 */
 
     /* now have subtotal/4 in mm1 and mm2 */
 
-    movq_m2r (*dest, mm3);     /* load 8 dest bytes */
-    movq_r2r (mm3, mm4);       /* copy 8 dest bytes */
+    movq_m2r (*dest, mm3);    /* load 8 dest bytes */
+    movq_r2r (mm3, mm4);    /* copy 8 dest bytes */
 
-    packuswb_r2r (mm2, mm1);   /* pack (w/ saturation) */
-    movq_r2r (mm1,mm2);                /* copy subresult */
+    packuswb_r2r (mm2, mm1);    /* pack (w/ saturation) */
+    movq_r2r (mm1,mm2);        /* copy subresult */
 
-    pxor_r2r (mm1, mm3);       /* xor srcavg and dest */
-    pand_m2r (mask1, mm3);     /* mask lower bits */
-    psrlq_i2r (1, mm3);                /* /2 */
-    por_r2r (mm2, mm4);                /* or srcavg and dest */
-    psubb_r2r (mm3, mm4);      /* subtract subresults */
-    movq_r2m (mm4, *dest);     /* store result in dest */
+    pxor_r2r (mm1, mm3);    /* xor srcavg and dest */
+    pand_m2r (mask1, mm3);    /* mask lower bits */
+    psrlq_i2r (1, mm3);        /* /2 */
+    por_r2r (mm2, mm4);        /* or srcavg and dest */
+    psubb_r2r (mm3, mm4);    /* subtract subresults */
+    movq_r2m (mm4, *dest);    /* store result in dest */
 }
 
 /*-----------------------------------------------------------------------*/
 
 static inline void MC_avg_mmx (const int width, int height, uint8_t * dest,
-                              const uint8_t * ref, const int stride)
+                   const uint8_t * ref, const int stride)
 {
     mmx_zero_reg ();
 
@@ -252,13 +252,13 @@ static inline void MC_avg_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_avg_o_16_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_avg_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_avg_o_8_mmx (uint8_t * dest, const uint8_t * ref,
-                           int stride, int height)
+                int stride, int height)
 {
     MC_avg_mmx (8, height, dest, ref, stride);
 }
@@ -266,19 +266,19 @@ static void MC_avg_o_8_mmx (uint8_t * dest, const uint8_t * ref,
 /*-----------------------------------------------------------------------*/
 
 static inline void MC_put_mmx (const int width, int height, uint8_t * dest,
-                              const uint8_t * ref, const int stride)
+                   const uint8_t * ref, const int stride)
 {
     mmx_zero_reg ();
 
     do
     {
-        movq_m2r (* ref, mm1); /* load 8 ref bytes */
-        movq_r2m (mm1,* dest); /* store 8 bytes at curr */
+        movq_m2r (* ref, mm1);    /* load 8 ref bytes */
+        movq_r2m (mm1,* dest);    /* store 8 bytes at curr */
 
         if( width == 16 )
         {
-            movq_m2r (* (ref+8), mm1); /* load 8 ref bytes */
-            movq_r2m (mm1,* (dest+8)); /* store 8 bytes at curr */
+            movq_m2r (* (ref+8), mm1);    /* load 8 ref bytes */
+            movq_r2m (mm1,* (dest+8));    /* store 8 bytes at curr */
         }
         dest += stride;
         ref += stride;
@@ -286,13 +286,13 @@ static inline void MC_put_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_put_o_16_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_put_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_put_o_8_mmx (uint8_t * dest, const uint8_t * ref,
-                           int stride, int height)
+                int stride, int height)
 {
     MC_put_mmx (8, height, dest, ref, stride);
 }
@@ -301,7 +301,7 @@ static void MC_put_o_8_mmx (uint8_t * dest, const uint8_t * ref,
 
 /* Half pixel interpolation in the x direction */
 static inline void MC_avg_x_mmx (const int width, int height, uint8_t * dest,
-                                const uint8_t * ref, const int stride)
+                 const uint8_t * ref, const int stride)
 {
     mmx_zero_reg ();
 
@@ -318,13 +318,13 @@ static inline void MC_avg_x_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_avg_x_16_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_avg_x_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_avg_x_8_mmx (uint8_t * dest, const uint8_t * ref,
-                           int stride, int height)
+                int stride, int height)
 {
     MC_avg_x_mmx (8, height, dest, ref, stride);
 }
@@ -332,7 +332,7 @@ static void MC_avg_x_8_mmx (uint8_t * dest, const uint8_t * ref,
 /*-----------------------------------------------------------------------*/
 
 static inline void MC_put_x_mmx (const int width, int height, uint8_t * dest,
-                                const uint8_t * ref, const int stride)
+                 const uint8_t * ref, const int stride)
 {
     mmx_zero_reg ();
 
@@ -349,13 +349,13 @@ static inline void MC_put_x_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_put_x_16_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_put_x_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_put_x_8_mmx (uint8_t * dest, const uint8_t * ref,
-                           int stride, int height)
+                int stride, int height)
 {
     MC_put_x_mmx (8, height, dest, ref, stride);
 }
@@ -363,7 +363,7 @@ static void MC_put_x_8_mmx (uint8_t * dest, const uint8_t * ref,
 /*-----------------------------------------------------------------------*/
 
 static inline void MC_avg_xy_mmx (const int width, int height, uint8_t * dest,
-                                 const uint8_t * ref, const int stride)
+                  const uint8_t * ref, const int stride)
 {
     const uint8_t * ref_next = ref + stride;
 
@@ -384,13 +384,13 @@ static inline void MC_avg_xy_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_avg_xy_16_mmx (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_avg_xy_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_avg_xy_8_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_avg_xy_mmx (8, height, dest, ref, stride);
 }
@@ -398,7 +398,7 @@ static void MC_avg_xy_8_mmx (uint8_t * dest, const uint8_t * ref,
 /*-----------------------------------------------------------------------*/
 
 static inline void MC_put_xy_mmx (const int width, int height, uint8_t * dest,
-                                 const uint8_t * ref, const int stride)
+                  const uint8_t * ref, const int stride)
 {
     const uint8_t * ref_next = ref + stride;
 
@@ -418,13 +418,13 @@ static inline void MC_put_xy_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_put_xy_16_mmx (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_put_xy_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_put_xy_8_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_put_xy_mmx (8, height, dest, ref, stride);
 }
@@ -432,7 +432,7 @@ static void MC_put_xy_8_mmx (uint8_t * dest, const uint8_t * ref,
 /*-----------------------------------------------------------------------*/
 
 static inline void MC_avg_y_mmx (const int width, int height, uint8_t * dest,
-                                const uint8_t * ref, const int stride)
+                 const uint8_t * ref, const int stride)
 {
     const uint8_t * ref_next = ref + stride;
 
@@ -452,13 +452,13 @@ static inline void MC_avg_y_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_avg_y_16_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_avg_y_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_avg_y_8_mmx (uint8_t * dest, const uint8_t * ref,
-                           int stride, int height)
+                int stride, int height)
 {
     MC_avg_y_mmx (8, height, dest, ref, stride);
 }
@@ -466,7 +466,7 @@ static void MC_avg_y_8_mmx (uint8_t * dest, const uint8_t * ref,
 /*-----------------------------------------------------------------------*/
 
 static inline void MC_put_y_mmx (const int width, int height, uint8_t * dest,
-                                const uint8_t * ref, const int stride)
+                 const uint8_t * ref, const int stride)
 {
     const uint8_t * ref_next = ref + stride;
 
@@ -486,13 +486,13 @@ static inline void MC_put_y_mmx (const int width, int height, uint8_t * dest,
 }
 
 static void MC_put_y_16_mmx (uint8_t * dest, const uint8_t * ref,
-                            int stride, int height)
+                 int stride, int height)
 {
     MC_put_y_mmx (16, height, dest, ref, stride);
 }
 
 static void MC_put_y_8_mmx (uint8_t * dest, const uint8_t * ref,
-                           int stride, int height)
+                int stride, int height)
 {
     MC_put_y_mmx (8, height, dest, ref, stride);
 }
@@ -502,20 +502,20 @@ MPEG2_MC_EXTERN (mmx)
 
 /* CPU_MMXEXT/CPU_3DNOW adaptation layer */
 
-#define pavg_r2r(src,dest)             \
-do {                                   \
-    if (cpu == CPU_MMXEXT)             \
-       pavgb_r2r (src, dest);          \
-    else                               \
-       pavgusb_r2r (src, dest);        \
+#define pavg_r2r(src,dest)        \
+do {                    \
+    if (cpu == CPU_MMXEXT)        \
+    pavgb_r2r (src, dest);        \
+    else                \
+    pavgusb_r2r (src, dest);    \
 } while (0)
 
-#define pavg_m2r(src,dest)             \
-do {                                   \
-    if (cpu == CPU_MMXEXT)             \
-       pavgb_m2r (src, dest);          \
-    else                               \
-       pavgusb_m2r (src, dest);        \
+#define pavg_m2r(src,dest)        \
+do {                    \
+    if (cpu == CPU_MMXEXT)        \
+    pavgb_m2r (src, dest);        \
+    else                \
+    pavgusb_m2r (src, dest);    \
 } while (0)
 
 
@@ -523,7 +523,7 @@ do {                                        \
 
 
 static inline void MC_put1_8 (int height, uint8_t * dest, const uint8_t * ref,
-                             const int stride)
+                  const int stride)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -534,7 +534,7 @@ static inline void MC_put1_8 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_put1_16 (int height, uint8_t * dest, const uint8_t * ref,
-                              const int stride)
+                   const int stride)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -547,7 +547,7 @@ static inline void MC_put1_16 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_avg1_8 (int height, uint8_t * dest, const uint8_t * ref,
-                             const int stride, const int cpu)
+                  const int stride, const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -559,7 +559,7 @@ static inline void MC_avg1_8 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_avg1_16 (int height, uint8_t * dest, const uint8_t * ref,
-                              const int stride, const int cpu)
+                   const int stride, const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -574,8 +574,8 @@ static inline void MC_avg1_16 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_put2_8 (int height, uint8_t * dest, const uint8_t * ref,
-                             const int stride, const int offset,
-                             const int cpu)
+                  const int stride, const int offset,
+                  const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -587,8 +587,8 @@ static inline void MC_put2_8 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_put2_16 (int height, uint8_t * dest, const uint8_t * ref,
-                              const int stride, const int offset,
-                              const int cpu)
+                   const int stride, const int offset,
+                   const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -603,8 +603,8 @@ static inline void MC_put2_16 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_avg2_8 (int height, uint8_t * dest, const uint8_t * ref,
-                             const int stride, const int offset,
-                             const int cpu)
+                  const int stride, const int offset,
+                  const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -617,8 +617,8 @@ static inline void MC_avg2_8 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_avg2_16 (int height, uint8_t * dest, const uint8_t * ref,
-                              const int stride, const int offset,
-                              const int cpu)
+                   const int stride, const int offset,
+                   const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -637,7 +637,7 @@ static inline void MC_avg2_16 (int height, uint8_t * dest, const uint8_t * ref,
 static mmx_t mask_one = {0x0101010101010101LL};
 
 static inline void MC_put4_8 (int height, uint8_t * dest, const uint8_t * ref,
-                             const int stride, const int cpu)
+                  const int stride, const int cpu)
 {
     movq_m2r (*ref, mm0);
     movq_m2r (*(ref+1), mm1);
@@ -670,13 +670,13 @@ static inline void MC_put4_8 (int height, uint8_t * dest, const uint8_t * ref,
         movq_r2m (mm0, *dest);
         dest += stride;
 
-        movq_r2r (mm6, mm7);   /* unroll ! */
-        movq_r2r (mm2, mm0);   /* unroll ! */
+        movq_r2r (mm6, mm7);    /* unroll ! */
+        movq_r2r (mm2, mm0);    /* unroll ! */
     } while (--height);
 }
 
 static inline void MC_put4_16 (int height, uint8_t * dest, const uint8_t * ref,
-                              const int stride, const int cpu)
+                   const int stride, const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -722,7 +722,7 @@ static inline void MC_put4_16 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_avg4_8 (int height, uint8_t * dest, const uint8_t * ref,
-                             const int stride, const int cpu)
+                  const int stride, const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -751,7 +751,7 @@ static inline void MC_avg4_8 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static inline void MC_avg4_16 (int height, uint8_t * dest, const uint8_t * ref,
-                              const int stride, const int cpu)
+                   const int stride, const int cpu)
 {
     do {
         movq_m2r (*ref, mm0);
@@ -801,97 +801,97 @@ static inline void MC_avg4_16 (int height, uint8_t * dest, const uint8_t * ref,
 }
 
 static void MC_avg_o_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_avg1_16 (height, dest, ref, stride, CPU_MMXEXT);
 }
 
 static void MC_avg_o_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_avg1_8 (height, dest, ref, stride, CPU_MMXEXT);
 }
 
 static void MC_put_o_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_put1_16 (height, dest, ref, stride);
 }
 
 static void MC_put_o_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_put1_8 (height, dest, ref, stride);
 }
 
 static void MC_avg_x_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_avg2_16 (height, dest, ref, stride, 1, CPU_MMXEXT);
 }
 
 static void MC_avg_x_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_avg2_8 (height, dest, ref, stride, 1, CPU_MMXEXT);
 }
 
 static void MC_put_x_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_put2_16 (height, dest, ref, stride, 1, CPU_MMXEXT);
 }
 
 static void MC_put_x_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_put2_8 (height, dest, ref, stride, 1, CPU_MMXEXT);
 }
 
 static void MC_avg_y_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_avg2_16 (height, dest, ref, stride, stride, CPU_MMXEXT);
 }
 
 static void MC_avg_y_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_avg2_8 (height, dest, ref, stride, stride, CPU_MMXEXT);
 }
 
 static void MC_put_y_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_put2_16 (height, dest, ref, stride, stride, CPU_MMXEXT);
 }
 
 static void MC_put_y_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_put2_8 (height, dest, ref, stride, stride, CPU_MMXEXT);
 }
 
 static void MC_avg_xy_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                                int stride, int height)
+                 int stride, int height)
 {
     MC_avg4_16 (height, dest, ref, stride, CPU_MMXEXT);
 }
 
 static void MC_avg_xy_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_avg4_8 (height, dest, ref, stride, CPU_MMXEXT);
 }
 
 static void MC_put_xy_16_mmxext (uint8_t * dest, const uint8_t * ref,
-                                int stride, int height)
+                 int stride, int height)
 {
     MC_put4_16 (height, dest, ref, stride, CPU_MMXEXT);
 }
 
 static void MC_put_xy_8_mmxext (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_put4_8 (height, dest, ref, stride, CPU_MMXEXT);
 }
@@ -899,97 +899,97 @@ static void MC_put_xy_8_mmxext (uint8_t * dest, const uint8_t * ref,
 MPEG2_MC_EXTERN (mmxext)
 
 static void MC_avg_o_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_avg1_16 (height, dest, ref, stride, CPU_3DNOW);
 }
 
 static void MC_avg_o_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_avg1_8 (height, dest, ref, stride, CPU_3DNOW);
 }
 
 static void MC_put_o_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_put1_16 (height, dest, ref, stride);
 }
 
 static void MC_put_o_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_put1_8 (height, dest, ref, stride);
 }
 
 static void MC_avg_x_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_avg2_16 (height, dest, ref, stride, 1, CPU_3DNOW);
 }
 
 static void MC_avg_x_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_avg2_8 (height, dest, ref, stride, 1, CPU_3DNOW);
 }
 
 static void MC_put_x_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_put2_16 (height, dest, ref, stride, 1, CPU_3DNOW);
 }
 
 static void MC_put_x_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_put2_8 (height, dest, ref, stride, 1, CPU_3DNOW);
 }
 
 static void MC_avg_y_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_avg2_16 (height, dest, ref, stride, stride, CPU_3DNOW);
 }
 
 static void MC_avg_y_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_avg2_8 (height, dest, ref, stride, stride, CPU_3DNOW);
 }
 
 static void MC_put_y_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_put2_16 (height, dest, ref, stride, stride, CPU_3DNOW);
 }
 
 static void MC_put_y_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                             int stride, int height)
+                  int stride, int height)
 {
     MC_put2_8 (height, dest, ref, stride, stride, CPU_3DNOW);
 }
 
 static void MC_avg_xy_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_avg4_16 (height, dest, ref, stride, CPU_3DNOW);
 }
 
 static void MC_avg_xy_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_avg4_8 (height, dest, ref, stride, CPU_3DNOW);
 }
 
 static void MC_put_xy_16_3dnow (uint8_t * dest, const uint8_t * ref,
-                               int stride, int height)
+                int stride, int height)
 {
     MC_put4_16 (height, dest, ref, stride, CPU_3DNOW);
 }
 
 static void MC_put_xy_8_3dnow (uint8_t * dest, const uint8_t * ref,
-                              int stride, int height)
+                   int stride, int height)
 {
     MC_put4_8 (height, dest, ref, stride, CPU_3DNOW);
 }