changeset 2798:ee2cd36a81a2

Code cleanup - emms is not required when MMX block is commented out. Special notes for Michael Niedermayer: Are you still here? If you don't like for(cond;cond;cond) C-constructions and prefer asm ones: "jb 1b" then use .align 16 pseudo assembler instructions else loops rather will be not aligned on correct boundary. (16 it's for K7 for pent should be 8). Your parts have a lot such lacks.
author nick
date Sat, 10 Nov 2001 18:40:49 +0000
parents 4c9966c2b2ed
children 0d7fd1655a89
files libvo/osd.c libvo/osd_template.c
diffstat 2 files changed, 32 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/osd.c	Sat Nov 10 18:06:59 2001 +0000
+++ b/libvo/osd.c	Sat Nov 10 18:40:49 2001 +0000
@@ -6,6 +6,7 @@
 
 #include "config.h"
 #include "osd.h"
+#include "../mmx_defs.h"
 
 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
     int y;
@@ -79,12 +80,13 @@
     int y;
     for(y=0;y<h;y++){
         register int x;
-//	printf("%d, %d, %d\n", (int)src&31, (int)srca%31, (int)dstbase&31);
-#ifdef HAVE_MMXFIXME
-/*	asm(
+#ifdef ARCH_X86
+#if 0 /*def HAVE_MMX2*/
+	asm volatile(
 		"pxor %%mm7, %%mm7		\n\t"
 		"xorl %%eax, %%eax		\n\t"
 		"pcmpeqb %%mm6, %%mm6		\n\t" // F..F
+		".align 16\n\t"
 		"1:				\n\t"
 		"movq (%0, %%eax, 4), %%mm0	\n\t" // dstbase
 		"movq %%mm0, %%mm1		\n\t"
@@ -106,18 +108,20 @@
 		"punpcklbw %%mm2, %%mm2		\n\t" // src AABBCCDD
 		"punpcklbw %%mm2, %%mm2		\n\t" // src AAAABBBB
 		"paddb %%mm2, %%mm0		\n\t"
-		"movq %%mm0, (%0, %%eax, 4)	\n\t"
+		MOVNTQ" %%mm0, (%0, %%eax, 4)	\n\t"
 		"addl $2, %%eax			\n\t"
 		"cmpl %3, %%eax			\n\t"
 		" jb 1b				\n\t"
 
 		:: "r" (dstbase), "r" (srca), "r" (src), "r" (w)
 		: "%eax"
-		);*/
-	asm(
+		);
+#else /* 0 HAVE_MMX2*/
+	asm volatile(
 		"xorl %%eax, %%eax		\n\t"
 		"xorl %%ebx, %%ebx		\n\t"
 		"xorl %%edx, %%edx		\n\t"
+		".align 16\n\t"
 		"1:				\n\t"
 		"movb (%1, %%eax), %%bl		\n\t"
 		"cmpb $0, %%bl			\n\t"
@@ -148,7 +152,8 @@
 		:: "r" (dstbase), "r" (srca), "r" (src), "m" (w)
 		: "%eax", "%ebx", "%ecx", "%edx"
 		);
-#else //HAVE_MMX
+#endif /* 0 HAVE_MMX*/
+#else /*non x86 arch*/
         for(x=0;x<w;x++){
             if(srca[x]){
 #ifdef FAST_OSD
@@ -160,17 +165,15 @@
 #endif
             }
         }
-#endif // !HAVE_MMX
+#endif /* arch_x86 */
         src+=srcstride;
         srca+=srcstride;
         dstbase+=dststride;
     }
-#ifdef HAVE_3DNOW
-	asm("femms\n\t");
-#elif defined (HAVE_MMX)
-	asm("emms\n\t");
+#if 0 /*def HAVE_MMX2*/
+	asm volatile(SFENCE:::"memory");
+	asm volatile(EMMS:::"memory");
 #endif
-
     return;
 }
 
--- a/libvo/osd_template.c	Sat Nov 10 18:06:59 2001 +0000
+++ b/libvo/osd_template.c	Sat Nov 10 18:40:49 2001 +0000
@@ -6,6 +6,7 @@
 
 #include "config.h"
 #include "osd.h"
+#include "../mmx_defs.h"
 
 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){
     int y;
@@ -79,12 +80,13 @@
     int y;
     for(y=0;y<h;y++){
         register int x;
-//	printf("%d, %d, %d\n", (int)src&31, (int)srca%31, (int)dstbase&31);
-#ifdef HAVE_MMXFIXME
-/*	asm(
+#ifdef ARCH_X86
+#if 0 /*def HAVE_MMX2*/
+	asm volatile(
 		"pxor %%mm7, %%mm7		\n\t"
 		"xorl %%eax, %%eax		\n\t"
 		"pcmpeqb %%mm6, %%mm6		\n\t" // F..F
+		".align 16\n\t"
 		"1:				\n\t"
 		"movq (%0, %%eax, 4), %%mm0	\n\t" // dstbase
 		"movq %%mm0, %%mm1		\n\t"
@@ -106,18 +108,20 @@
 		"punpcklbw %%mm2, %%mm2		\n\t" // src AABBCCDD
 		"punpcklbw %%mm2, %%mm2		\n\t" // src AAAABBBB
 		"paddb %%mm2, %%mm0		\n\t"
-		"movq %%mm0, (%0, %%eax, 4)	\n\t"
+		MOVNTQ" %%mm0, (%0, %%eax, 4)	\n\t"
 		"addl $2, %%eax			\n\t"
 		"cmpl %3, %%eax			\n\t"
 		" jb 1b				\n\t"
 
 		:: "r" (dstbase), "r" (srca), "r" (src), "r" (w)
 		: "%eax"
-		);*/
-	asm(
+		);
+#else /* 0 HAVE_MMX2*/
+	asm volatile(
 		"xorl %%eax, %%eax		\n\t"
 		"xorl %%ebx, %%ebx		\n\t"
 		"xorl %%edx, %%edx		\n\t"
+		".align 16\n\t"
 		"1:				\n\t"
 		"movb (%1, %%eax), %%bl		\n\t"
 		"cmpb $0, %%bl			\n\t"
@@ -148,7 +152,8 @@
 		:: "r" (dstbase), "r" (srca), "r" (src), "m" (w)
 		: "%eax", "%ebx", "%ecx", "%edx"
 		);
-#else //HAVE_MMX
+#endif /* 0 HAVE_MMX*/
+#else /*non x86 arch*/
         for(x=0;x<w;x++){
             if(srca[x]){
 #ifdef FAST_OSD
@@ -160,17 +165,15 @@
 #endif
             }
         }
-#endif // !HAVE_MMX
+#endif /* arch_x86 */
         src+=srcstride;
         srca+=srcstride;
         dstbase+=dststride;
     }
-#ifdef HAVE_3DNOW
-	asm("femms\n\t");
-#elif defined (HAVE_MMX)
-	asm("emms\n\t");
+#if 0 /*def HAVE_MMX2*/
+	asm volatile(SFENCE:::"memory");
+	asm volatile(EMMS:::"memory");
 #endif
-
     return;
 }