[MPlayer-cvslog] r20605 - in trunk/libswscale: swscale.c swscale_template.c

lucabe subversion at mplayerhq.hu
Thu Nov 2 10:01:02 CET 2006


Author: lucabe
Date: Thu Nov  2 10:01:01 2006
New Revision: 20605

Modified:
   trunk/libswscale/swscale.c
   trunk/libswscale/swscale_template.c

Log:
Add support for conversions from the rgb565 and rgb555 formats


Modified: trunk/libswscale/swscale.c
==============================================================================
--- trunk/libswscale/swscale.c	(original)
+++ trunk/libswscale/swscale.c	Thu Nov  2 10:01:01 2006
@@ -109,7 +109,7 @@
 
 #define isSupportedIn(x)  ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422\
 			|| (x)==PIX_FMT_RGB32|| (x)==PIX_FMT_BGR24|| (x)==PIX_FMT_BGR565|| (x)==PIX_FMT_BGR555\
-			|| (x)==PIX_FMT_BGR32|| (x)==PIX_FMT_RGB24\
+			|| (x)==PIX_FMT_BGR32|| (x)==PIX_FMT_RGB24|| (x)==PIX_FMT_RGB565|| (x)==PIX_FMT_RGB555\
 			|| (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P\
 			|| (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE\
 			|| (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P)

Modified: trunk/libswscale/swscale_template.c
==============================================================================
--- trunk/libswscale/swscale_template.c	(original)
+++ trunk/libswscale/swscale_template.c	Thu Nov  2 10:01:01 2006
@@ -2246,6 +2246,77 @@
 	}
 }
 
+static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+	int i;
+	for(i=0; i<width; i++)
+	{
+		int d= ((uint16_t*)src)[i];
+		int r= d&0x1F;
+		int g= (d>>5)&0x3F;
+		int b= (d>>11)&0x1F;
+
+		dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16;
+	}
+}
+
+static inline void RENAME(rgb16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+	int i;
+	for(i=0; i<width; i++)
+	{
+		int d0= ((uint32_t*)src1)[i];
+		int d1= ((uint32_t*)src2)[i];
+		
+		int dl= (d0&0x07E0F81F) + (d1&0x07E0F81F);
+		int dh= ((d0>>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F);
+
+		int dh2= (dh>>11) + (dh<<21);
+		int d= dh2 + dl;
+
+		int r= d&0x7F;
+		int b= (d>>11)&0x7F;
+		int g= d>>21;
+		dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128;
+		dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128;
+	}
+}
+
+static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, int width)
+{
+	int i;
+	for(i=0; i<width; i++)
+	{
+		int d= ((uint16_t*)src)[i];
+		int r= d&0x1F;
+		int g= (d>>5)&0x1F;
+		int b= (d>>10)&0x1F;
+
+		dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
+	}
+}
+
+static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
+{
+	int i;
+	for(i=0; i<width; i++)
+	{
+		int d0= ((uint32_t*)src1)[i];
+		int d1= ((uint32_t*)src2)[i];
+		
+		int dl= (d0&0x03E07C1F) + (d1&0x03E07C1F);
+		int dh= ((d0>>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F);
+
+		int dh2= (dh>>11) + (dh<<21);
+		int d= dh2 + dl;
+
+		int g= d&0x7F;
+		int r= (d>>10)&0x7F;
+		int b= d>>21;
+		dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128;
+		dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128;
+	}
+}
 
 // Bilinear / Bicubic scaling
 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
@@ -2477,6 +2548,16 @@
 	RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
 	src= formatConvBuffer;
     }
+    else if(srcFormat==PIX_FMT_RGB565)
+    {
+	RENAME(rgb16ToY)(formatConvBuffer, src, srcW);
+	src= formatConvBuffer;
+    }
+    else if(srcFormat==PIX_FMT_RGB555)
+    {
+	RENAME(rgb15ToY)(formatConvBuffer, src, srcW);
+	src= formatConvBuffer;
+    }
 
 #ifdef HAVE_MMX
 	// use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
@@ -2672,6 +2753,18 @@
 	src1= formatConvBuffer;
 	src2= formatConvBuffer+2048;
     }
+    else if(srcFormat==PIX_FMT_RGB565)
+    {
+	RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+	src1= formatConvBuffer;
+	src2= formatConvBuffer+2048;
+    }
+    else if(srcFormat==PIX_FMT_RGB555)
+    {
+	RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
+	src1= formatConvBuffer;
+	src2= formatConvBuffer+2048;
+    }
     else if(isGray(srcFormat))
     {
     	return;



More information about the MPlayer-cvslog mailing list