[Mplayer-cvslog] CVS: main/postproc swscale.c,1.110,1.111 swscale_template.c,1.91,1.92

Michael Niedermayer CVS michael at mplayerhq.hu
Thu Jan 23 10:35:26 CET 2003


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

Modified Files:
	swscale.c swscale_template.c 
Log Message:
UYVY input


Index: swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -r1.110 -r1.111
--- swscale.c	4 Nov 2002 15:56:38 -0000	1.110
+++ swscale.c	23 Jan 2003 09:35:22 -0000	1.111
@@ -17,7 +17,7 @@
 */
 
 /*
-  supported Input formats: YV12, I420/IYUV, YUY2, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09
+  supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09
   supported output formats: YV12, I420/IYUV, YUY2, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09
   {BGR,RGB}{1,4,8,15,16} support dithering
   
@@ -105,11 +105,11 @@
 //FIXME replace this with something faster
 #define isPlanarYUV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_YVU9 \
 			|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P)
-#define isYUV(x)       ((x)==IMGFMT_YUY2 || isPlanarYUV(x))
+#define isYUV(x)       ((x)==IMGFMT_UYVY || (x)==IMGFMT_YUY2 || isPlanarYUV(x))
 #define isGray(x)      ((x)==IMGFMT_Y800)
 #define isRGB(x)       (((x)&IMGFMT_RGB_MASK)==IMGFMT_RGB)
 #define isBGR(x)       (((x)&IMGFMT_BGR_MASK)==IMGFMT_BGR)
-#define isSupportedIn(x)  ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_YUY2 \
+#define isSupportedIn(x)  ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY\
 			|| (x)==IMGFMT_BGR32|| (x)==IMGFMT_BGR24|| (x)==IMGFMT_BGR16|| (x)==IMGFMT_BGR15\
 			|| (x)==IMGFMT_RGB32|| (x)==IMGFMT_RGB24\
 			|| (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9\
@@ -118,7 +118,7 @@
 			|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P\
 			|| isRGB(x) || isBGR(x)\
 			|| (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9)
-#define isPacked(x)    ((x)==IMGFMT_YUY2 || isRGB(x) || isBGR(x))
+#define isPacked(x)    ((x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY ||isRGB(x) || isBGR(x))
 
 #define RGB2YUV_SHIFT 16
 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
@@ -1904,6 +1904,7 @@
 
 static void getSubSampleFactors(int *h, int *v, int format){
 	switch(format){
+	case IMGFMT_UYVY:
 	case IMGFMT_YUY2:
 		*h=1;
 		*v=0;

Index: swscale_template.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale_template.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- swscale_template.c	23 Nov 2002 10:58:05 -0000	1.91
+++ swscale_template.c	23 Jan 2003 09:35:22 -0000	1.92
@@ -1476,6 +1476,69 @@
 #endif
 }
 
+//this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses
+static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, int width)
+{
+#ifdef HAVE_MMX
+	asm volatile(
+		"movl %0, %%eax			\n\t"
+		"1:				\n\t"
+		"movq (%1, %%eax,2), %%mm0	\n\t"
+		"movq 8(%1, %%eax,2), %%mm1	\n\t"
+		"psrlw $8, %%mm0		\n\t"
+		"psrlw $8, %%mm1		\n\t"
+		"packuswb %%mm1, %%mm0		\n\t"
+		"movq %%mm0, (%2, %%eax)	\n\t"
+		"addl $8, %%eax			\n\t"
+		" js 1b				\n\t"
+		: : "g" (-width), "r" (src+width*2), "r" (dst+width)
+		: "%eax"
+	);
+#else
+	int i;
+	for(i=0; i<width; i++)
+		dst[i]= src[2*i+1];
+#endif
+}
+
+static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
+	asm volatile(
+		"movq "MANGLE(bm01010101)", %%mm4\n\t"
+		"movl %0, %%eax			\n\t"
+		"1:				\n\t"
+		"movq (%1, %%eax,4), %%mm0	\n\t"
+		"movq 8(%1, %%eax,4), %%mm1	\n\t"
+		"movq (%2, %%eax,4), %%mm2	\n\t"
+		"movq 8(%2, %%eax,4), %%mm3	\n\t"
+		PAVGB(%%mm2, %%mm0)
+		PAVGB(%%mm3, %%mm1)
+		"pand %%mm4, %%mm0		\n\t"
+		"pand %%mm4, %%mm1		\n\t"
+		"packuswb %%mm1, %%mm0		\n\t"
+		"movq %%mm0, %%mm1		\n\t"
+		"psrlw $8, %%mm0		\n\t"
+		"pand %%mm4, %%mm1		\n\t"
+		"packuswb %%mm0, %%mm0		\n\t"
+		"packuswb %%mm1, %%mm1		\n\t"
+		"movd %%mm0, (%4, %%eax)	\n\t"
+		"movd %%mm1, (%3, %%eax)	\n\t"
+		"addl $4, %%eax			\n\t"
+		" js 1b				\n\t"
+		: : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width)
+		: "%eax"
+	);
+#else
+	int i;
+	for(i=0; i<width; i++)
+	{
+		dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1;
+		dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1;
+	}
+#endif
+}
+
 static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width)
 {
 #ifdef HAVE_MMXFIXME
@@ -2113,6 +2176,11 @@
 	RENAME(yuy2ToY)(formatConvBuffer, src, srcW);
 	src= formatConvBuffer;
     }
+    else if(srcFormat==IMGFMT_UYVY)
+    {
+	RENAME(uyvyToY)(formatConvBuffer, src, srcW);
+	src= formatConvBuffer;
+    }
     else if(srcFormat==IMGFMT_BGR32)
     {
 	RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
@@ -2262,6 +2330,12 @@
     if(srcFormat==IMGFMT_YUY2)
     {
 	RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+	src1= formatConvBuffer;
+	src2= formatConvBuffer+2048;
+    }
+    else if(srcFormat==IMGFMT_UYVY)
+    {
+	RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
 	src1= formatConvBuffer;
 	src2= formatConvBuffer+2048;
     }



More information about the MPlayer-cvslog mailing list