[Mplayer-cvslog] CVS: main/postproc rgb2rgb.c,1.22,1.23 rgb2rgb.h,1.9,1.10

Nick Kurshev nick at mplayer.dev.hu
Mon Nov 5 18:36:30 CET 2001


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

Modified Files:
	rgb2rgb.c rgb2rgb.h 
Log Message:
Well - old algorithms and new stuff rgb24to16(15)

Index: rgb2rgb.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/rgb2rgb.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- rgb2rgb.c	5 Nov 2001 08:37:27 -0000	1.22
+++ rgb2rgb.c	5 Nov 2001 17:35:14 -0000	1.23
@@ -18,7 +18,7 @@
 static const uint64_t mask15s  __attribute__((aligned(8))) = 0xFFE0FFE0FFE0FFE0ULL;
 #endif
 
-void rgb24to32(const uint8_t *src,uint8_t *dst,uint32_t src_size)
+void rgb24to32(const uint8_t *src,uint8_t *dst,unsigned src_size)
 {
   uint8_t *dest = dst;
   const uint8_t *s = src;
@@ -64,7 +64,7 @@
   }
 }
 
-void rgb32to24(const uint8_t *src,uint8_t *dst,uint32_t src_size)
+void rgb32to24(const uint8_t *src,uint8_t *dst,unsigned src_size)
 {
   uint8_t *dest = dst;
   const uint8_t *s = src;
@@ -123,7 +123,7 @@
  MMX2, 3DNOW optimization by Nick Kurshev
  32bit c version, and and&add trick by Michael Niedermayer
 */
-void rgb15to16(const uint8_t *src,uint8_t *dst,uint32_t src_size)
+void rgb15to16(const uint8_t *src,uint8_t *dst,unsigned src_size)
 {
 #ifdef HAVE_MMX
   register const char* s=src+src_size;
@@ -168,8 +168,8 @@
      *( d1++ )=( x&0x001F )|( ( x&0x7FE0 )<<1 );
    }
 #else
-	const uint32_t *s1=( uint32_t * )src;
-	uint32_t *d1=( uint32_t * )dst;
+	const unsigned *s1=( unsigned * )src;
+	unsigned *d1=( unsigned * )dst;
 	int i;
 	int size= src_size>>2;
 	for(i=0; i<size; i++)
@@ -186,23 +186,23 @@
 /**
  * Pallete is assumed to contain bgr32
  */
-void palette8torgb32(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette)
+void palette8torgb32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
 {
-	uint32_t i;
+	unsigned i;
 	for(i=0; i<num_pixels; i++)
-		((uint32_t *)dst)[i] = ((uint32_t *)palette)[ src[i] ];
+		((unsigned *)dst)[i] = ((unsigned *)palette)[ src[i] ];
 }
 
 /**
  * Pallete is assumed to contain bgr32
  */
-void palette8torgb24(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette)
+void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
 {
-	uint32_t i;
+	unsigned i;
 /*
 	writes 1 byte o much and might cause alignment issues on some architectures?
 	for(i=0; i<num_pixels; i++)
-		((uint32_t *)(&dst[i*3])) = ((uint32_t *)palette)[ src[i] ];
+		((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ];
 */
 	for(i=0; i<num_pixels; i++)
 	{
@@ -214,9 +214,9 @@
 	}
 }
 
-void rgb32to16(const uint8_t *src, uint8_t *dst, uint32_t num_pixels)
+void rgb32to16(const uint8_t *src, uint8_t *dst, unsigned src_size)
 {
-	uint32_t i;
+	unsigned i,num_pixels=src_size/4;
 	for(i=0; i<num_pixels; i+=4)
 	{
 		const int b= src[i+0];
@@ -227,9 +227,9 @@
 	}
 }
 
-void rgb32to15(const uint8_t *src, uint8_t *dst, uint32_t num_pixels)
+void rgb32to15(const uint8_t *src, uint8_t *dst, unsigned src_size)
 {
-	uint32_t i;
+	unsigned i,num_pixels=src_size/4;
 	for(i=0; i<num_pixels; i+=4)
 	{
 		const int b= src[i+0];
@@ -240,13 +240,38 @@
 	}
 }
 
+void rgb24to16(const uint8_t *src, uint8_t *dst, unsigned src_size)
+{
+	unsigned i,num_pixels=src_size/3;
+	for(i=0; i<num_pixels; i+=3)
+	{
+		const int b= src[i+0];
+		const int g= src[i+1];
+		const int r= src[i+2];
+
+		((uint16_t *)dst)[i]= (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
+	}
+}
+
+void rgb24to15(const uint8_t *src, uint8_t *dst, unsigned src_size)
+{
+	unsigned i,num_pixels=src_size/3;
+	for(i=0; i<num_pixels; i+=3)
+	{
+		const int b= src[i+0];
+		const int g= src[i+1];
+		const int r= src[i+2];
+
+		((uint16_t *)dst)[i]= (b>>3) | ((g&0xF8)<<3) | ((r&0xF8)<<7);
+	}
+}
 
 /**
  * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette
  */
-void palette8torgb16(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette)
+void palette8torgb16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
 {
-	uint32_t i;
+	unsigned i;
 	for(i=0; i<num_pixels; i++)
 		((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ];
 }
@@ -254,9 +279,9 @@
 /**
  * Pallete is assumed to contain bgr15, see rgb32to15 to convert the palette
  */
-void palette8torgb15(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette)
+void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
 {
-	uint32_t i;
+	unsigned i;
 	for(i=0; i<num_pixels; i++)
 		((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ];
 }
@@ -264,7 +289,7 @@
  *
  * num_pixels must be a multiple of 16 for the MMX version
  */
-void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, uint32_t num_pixels)
+void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, unsigned num_pixels)
 {
 #ifdef HAVE_MMX
 	asm volatile(
@@ -315,7 +340,7 @@
 #endif
 }
 
-void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, uint32_t num_pixels)
+void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned num_pixels)
 {
 #ifdef HAVE_MMX
 	asm volatile(

Index: rgb2rgb.h
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/rgb2rgb.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- rgb2rgb.h	5 Nov 2001 08:37:27 -0000	1.9
+++ rgb2rgb.h	5 Nov 2001 17:35:14 -0000	1.10
@@ -7,19 +7,22 @@
 #ifndef RGB2RGB_INCLUDED
 #define RGB2RGB_INCLUDED
 
-extern void rgb24to32(const uint8_t *src,uint8_t *dst,uint32_t src_size);
-extern void rgb32to24(const uint8_t *src,uint8_t *dst,uint32_t src_size);
-extern void rgb15to16(const uint8_t *src,uint8_t *dst,uint32_t src_size);
-extern void rgb32to16(const uint8_t *src,uint8_t *dst,uint32_t num_pixels);
-extern void rgb32to15(const uint8_t *src,uint8_t *dst,uint32_t num_pixels);
+extern void rgb24to32(const uint8_t *src,uint8_t *dst,unsigned src_size);
+extern void rgb32to24(const uint8_t *src,uint8_t *dst,unsigned src_size);
+extern void rgb15to16(const uint8_t *src,uint8_t *dst,unsigned src_size);
+extern void rgb32to16(const uint8_t *src,uint8_t *dst,unsigned num_pixels);
+extern void rgb32to15(const uint8_t *src,uint8_t *dst,unsigned num_pixels);
+extern void rgb24to16(const uint8_t *src,uint8_t *dst,unsigned num_pixels);
+extern void rgb24to15(const uint8_t *src,uint8_t *dst,unsigned num_pixels);
 
-extern void palette8torgb32(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette);
-extern void palette8torgb16(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette);
-extern void palette8torgb15(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette);
-extern void palette8torgb24(const uint8_t *src, uint8_t *dst, uint32_t num_pixels, const uint8_t *palette);
 
-extern void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, uint32_t num_pixels);
-extern void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, uint32_t num_pixels);
+extern void palette8torgb32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette);
+extern void palette8torgb16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette);
+extern void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette);
+extern void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette);
+
+extern void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, unsigned num_pixels);
+extern void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned num_pixels);
 
 
 #endif




More information about the MPlayer-cvslog mailing list