[Mplayer-cvslog] CVS: main/postproc rgb2rgb.c,1.43,1.44 rgb2rgb_template.c,1.44,1.45 rgb2rgb.h,1.17,1.18

Michael Niedermayer michael at mplayer.dev.hu
Mon Mar 25 17:35:27 CET 2002


Update of /cvsroot/mplayer/main/postproc
In directory mplayer:/var/tmp.root/cvs-serv25165

Modified Files:
	rgb2rgb.c rgb2rgb_template.c rgb2rgb.h 
Log Message:
byte interleaving for mga
untested (no g200 mga or whatever i would need ...)
experimental sse2 version (even less tested as no p4 either ...)
sse2 version would need 16-byte aligned src & dst else sig11
sse2 version is disabled by default


Index: rgb2rgb.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/rgb2rgb.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- rgb2rgb.c	3 Mar 2002 13:33:40 -0000	1.43
+++ rgb2rgb.c	25 Mar 2002 16:35:24 -0000	1.44
@@ -409,3 +409,21 @@
 		rgb24toyv12_C(src, ydst, udst, vdst, width,  height, lumStride, chromStride, srcStride);
 #endif
 }
+
+void interleaveBytes(uint8_t *src1, uint8_t *src2, uint8_t *dst,
+		     int width, int height, int src1Stride, int src2Stride, int dstStride)
+{
+#ifdef CAN_COMPILE_X86_ASM
+	// ordered per speed fasterst first
+	if(gCpuCaps.hasMMX2)
+		interleaveBytes_MMX2(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride);
+	else if(gCpuCaps.has3DNow)
+		interleaveBytes_3DNow(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride);
+	else if(gCpuCaps.hasMMX)
+		interleaveBytes_MMX(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride);
+	else
+		interleaveBytes_C(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride);
+#else
+		interleaveBytes_C(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride);
+#endif
+}

Index: rgb2rgb_template.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/rgb2rgb_template.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- rgb2rgb_template.c	3 Mar 2002 13:33:40 -0000	1.44
+++ rgb2rgb_template.c	25 Mar 2002 16:35:24 -0000	1.45
@@ -1197,3 +1197,83 @@
 		src  += srcStride;
 	}
 }
+
+void RENAME(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest,
+			    int width, int height, int src1Stride, int src2Stride, int dstStride){
+	int h;
+
+	for(h=0; h < height; h++)
+	{
+		int w;
+
+#ifdef HAVE_MMX
+#ifdef HAVE_SSE2
+		asm(
+			"xorl %%eax, %%eax		\n\t"
+			"1:				\n\t"
+			PREFETCH" 64(%1, %%eax)		\n\t"
+			PREFETCH" 64(%2, %%eax)		\n\t"
+			"movdqa (%1, %%eax), %%xmm0	\n\t"
+			"movdqa (%1, %%eax), %%xmm1	\n\t"
+			"movdqa (%2, %%eax), %%xmm2	\n\t"
+			"punpcklbw %%xmm2, %%xmm0	\n\t"
+			"punpckhbw %%xmm2, %%xmm1	\n\t"
+			"movntdq %%xmm0, (%0, %%eax, 2)	\n\t"
+			"movntdq %%xmm1, 16(%0, %%eax, 2)\n\t"
+			"addl $16, %%eax			\n\t"
+			"cmpl %3, %%eax			\n\t"
+			" jb 1b				\n\t"
+			::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
+			: "memory", "%eax"
+		);
+#else
+		asm(
+			"xorl %%eax, %%eax		\n\t"
+			"1:				\n\t"
+			PREFETCH" 64(%1, %%eax)		\n\t"
+			PREFETCH" 64(%2, %%eax)		\n\t"
+			"movq (%1, %%eax), %%mm0	\n\t"
+			"movq 8(%1, %%eax), %%mm2	\n\t"
+			"movq %%mm0, %%mm1		\n\t"
+			"movq %%mm2, %%mm3		\n\t"
+			"movq (%2, %%eax), %%mm4	\n\t"
+			"movq 8(%2, %%eax), %%mm5	\n\t"
+			"punpcklbw %%mm4, %%mm0		\n\t"
+			"punpckhbw %%mm4, %%mm1		\n\t"
+			"punpcklbw %%mm5, %%mm2		\n\t"
+			"punpckhbw %%mm5, %%mm3		\n\t"
+			MOVNTQ" %%mm0, (%0, %%eax, 2)	\n\t"
+			MOVNTQ" %%mm1, 8(%0, %%eax, 2)	\n\t"
+			MOVNTQ" %%mm2, 16(%0, %%eax, 2)	\n\t"
+			MOVNTQ" %%mm3, 24(%0, %%eax, 2)	\n\t"
+			"addl $16, %%eax			\n\t"
+			"cmpl %3, %%eax			\n\t"
+			" jb 1b				\n\t"
+			::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
+			: "memory", "%eax"
+		);
+#endif
+		for(w= (width&(~15)); w < width; w++)
+		{
+			dest[2*w+0] = src1[w];
+			dest[2*w+1] = src2[w];
+		}
+#else
+		for(w=0; w < width; w++)
+		{
+			dest[2*w+0] = src1[w];
+			dest[2*w+1] = src2[w];
+		}
+#endif
+		dest += dstStride;
+                src1 += src1Stride;
+                src2 += src2Stride;
+	}
+#ifdef HAVE_MMX
+	asm(
+		EMMS" \n\t"
+		SFENCE" \n\t"
+		::: "memory"
+		);
+#endif
+}

Index: rgb2rgb.h
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/rgb2rgb.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- rgb2rgb.h	20 Dec 2001 17:30:59 -0000	1.17
+++ rgb2rgb.h	25 Mar 2002 16:35:24 -0000	1.18
@@ -34,6 +34,10 @@
 	unsigned int width, unsigned int height,
 	unsigned int lumStride, unsigned int chromStride, unsigned int srcStride);
 
+extern void interleaveBytes(uint8_t *src1, uint8_t *src2, uint8_t *dst,
+			    int width, int height, int src1Stride, int src2Stride, int dstStride);
+	
+
 #define MODE_RGB  0x1
 #define MODE_BGR  0x2
 




More information about the MPlayer-cvslog mailing list