changeset 19173:dbdc58b6e9bb

a tiny bit of cleanup
author michael
date Mon, 24 Jul 2006 10:48:54 +0000
parents bae6c99a99cc
children ee1dbf3d5029
files libswscale/swscale_template.c
diffstat 1 files changed, 84 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/libswscale/swscale_template.c	Mon Jul 24 10:36:06 2006 +0000
+++ b/libswscale/swscale_template.c	Mon Jul 24 10:48:54 2006 +0000
@@ -186,6 +186,7 @@
 			: "%eax", "%ebx", "%ecx", "%edx", "%esi"
 */
 #define YSCALEYUV2PACKEDX \
+	asm volatile(\
 		"xor %%"REG_a", %%"REG_a"	\n\t"\
 		ASMALIGN16\
 		"nop				\n\t"\
@@ -226,7 +227,15 @@
 		"test %%"REG_S", %%"REG_S"	\n\t"\
 		" jnz 2b			\n\t"\
 
+#define YSCALEYUV2PACKEDX_END\
+        :: "r" (&c->redDither), \
+            "m" (dummy), "m" (dummy), "m" (dummy),\
+            "r" (dest), "m" (dstW)\
+        : "%"REG_a, "%"REG_d, "%"REG_S\
+        );
+
 #define YSCALEYUV2PACKEDX_ACCURATE \
+	asm volatile(\
 		"xor %%"REG_a", %%"REG_a"	\n\t"\
 		ASMALIGN16\
 		"nop				\n\t"\
@@ -319,8 +328,7 @@
                 "movq  "U_TEMP"(%0), %%mm3      \n\t"\
                 "movq  "V_TEMP"(%0), %%mm4      \n\t"\
 
-#define YSCALEYUV2RGBX(YSCALEYUV2PACKEDX) \
-		YSCALEYUV2PACKEDX\
+#define YSCALEYUV2RGBX \
 		"psubw "U_OFFSET"(%0), %%mm3	\n\t" /* (U-128)8*/\
 		"psubw "V_OFFSET"(%0), %%mm4	\n\t" /* (V-128)8*/\
 		"movq %%mm3, %%mm2		\n\t" /* (U-128)8*/\
@@ -1031,19 +1039,76 @@
     if(c->flags & SWS_ACCURATE_RND){
                 switch(c->dstFormat){
                 case IMGFMT_BGR32:
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX_ACCURATE)
+                                YSCALEYUV2PACKEDX_ACCURATE
+				YSCALEYUV2RGBX
 				WRITEBGR32(%4, %5, %%REGa)
 
+                                YSCALEYUV2PACKEDX_END
+                        return;
+                case IMGFMT_BGR24:
+                                YSCALEYUV2PACKEDX_ACCURATE
+				YSCALEYUV2RGBX
+				"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize
+				"add %4, %%"REG_b"			\n\t"
+				WRITEBGR24(%%REGb, %5, %%REGa)
+
+
 			:: "r" (&c->redDither), 
 			   "m" (dummy), "m" (dummy), "m" (dummy),
 			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
+			: "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx
 			);
                         return;
-                case IMGFMT_BGR24:
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX_ACCURATE)
+                case IMGFMT_BGR15:
+                                YSCALEYUV2PACKEDX_ACCURATE
+				YSCALEYUV2RGBX
+		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+#ifdef DITHER1XBPP
+				"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+				"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
+				"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+#endif
+
+				WRITEBGR15(%4, %5, %%REGa)
+                                YSCALEYUV2PACKEDX_END
+                        return;
+                case IMGFMT_BGR16:
+                                YSCALEYUV2PACKEDX_ACCURATE
+				YSCALEYUV2RGBX
+		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+#ifdef DITHER1XBPP
+				"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
+				"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
+				"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+#endif
+
+				WRITEBGR16(%4, %5, %%REGa)
+                                YSCALEYUV2PACKEDX_END
+                        return;
+                case IMGFMT_YUY2:
+				YSCALEYUV2PACKEDX_ACCURATE
+		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
+
+				"psraw $3, %%mm3		\n\t"
+				"psraw $3, %%mm4		\n\t"
+				"psraw $3, %%mm1		\n\t"
+				"psraw $3, %%mm7		\n\t"
+				WRITEYUY2(%4, %5, %%REGa)
+                                YSCALEYUV2PACKEDX_END
+                        return;
+                }
+    }else{
+	switch(c->dstFormat)
+	{
+	case IMGFMT_BGR32:
+                                YSCALEYUV2PACKEDX
+				YSCALEYUV2RGBX
+				WRITEBGR32(%4, %5, %%REGa)
+                                YSCALEYUV2PACKEDX_END
+		return;
+	case IMGFMT_BGR24:
+                                YSCALEYUV2PACKEDX
+				YSCALEYUV2RGBX
 				"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize
 				"add %4, %%"REG_b"			\n\t"
 				WRITEBGR24(%%REGb, %5, %%REGa)
@@ -1053,10 +1118,10 @@
 			   "r" (dest), "m" (dstW)
 			: "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx
 			);
-                        return;
-                case IMGFMT_BGR15:
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX_ACCURATE)
+		return;
+	case IMGFMT_BGR15:
+                                YSCALEYUV2PACKEDX
+				YSCALEYUV2RGBX
 		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
 				"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
@@ -1065,16 +1130,11 @@
 #endif
 
 				WRITEBGR15(%4, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
-			);
-                        return;
-                case IMGFMT_BGR16:
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX_ACCURATE)
+                                YSCALEYUV2PACKEDX_END
+		return;
+	case IMGFMT_BGR16:
+                                YSCALEYUV2PACKEDX
+				YSCALEYUV2RGBX
 		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
 				"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
@@ -1083,105 +1143,9 @@
 #endif
 
 				WRITEBGR16(%4, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
-			);
-                        return;
-                case IMGFMT_YUY2:
-			asm volatile(
-				YSCALEYUV2PACKEDX_ACCURATE
-		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-
-				"psraw $3, %%mm3		\n\t"
-				"psraw $3, %%mm4		\n\t"
-				"psraw $3, %%mm1		\n\t"
-				"psraw $3, %%mm7		\n\t"
-				WRITEYUY2(%4, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
-			);
-                        return;
-                }
-    }else{
-	switch(c->dstFormat)
-	{
-	case IMGFMT_BGR32:
-		{
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX)
-				WRITEBGR32(%4, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
-			);
-		}
-		return;
-	case IMGFMT_BGR24:
-		{
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX)
-				"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize
-				"add %4, %%"REG_b"			\n\t"
-				WRITEBGR24(%%REGb, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx
-			);
-		}
-		return;
-	case IMGFMT_BGR15:
-		{
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX)
-		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
-				"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
-				"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
-				"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
-#endif
-
-				WRITEBGR15(%4, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
-			);
-		}
-		return;
-	case IMGFMT_BGR16:
-		{
-			asm volatile(
-				YSCALEYUV2RGBX(YSCALEYUV2PACKEDX)
-		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
-				"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
-				"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
-				"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
-#endif
-
-				WRITEBGR16(%4, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
-			);
-		}
+                                YSCALEYUV2PACKEDX_END
 		return;
 	case IMGFMT_YUY2:
-		{
-			asm volatile(
 				YSCALEYUV2PACKEDX
 		/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 
@@ -1190,13 +1154,7 @@
 				"psraw $3, %%mm1		\n\t"
 				"psraw $3, %%mm7		\n\t"
 				WRITEYUY2(%4, %5, %%REGa)
-
-			:: "r" (&c->redDither), 
-			   "m" (dummy), "m" (dummy), "m" (dummy),
-			   "r" (dest), "m" (dstW)
-			: "%"REG_a, "%"REG_d, "%"REG_S
-			);
-		}
+                                YSCALEYUV2PACKEDX_END
 		return;
         }
     }