[Mplayer-cvslog] CVS: main/postproc swscale.c,1.132,1.133

Michael Niedermayer CVS michael at mplayerhq.hu
Wed Oct 15 14:09:03 CEST 2003


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

Modified Files:
	swscale.c 
Log Message:
dither scaling coefficients so they add up to 1.0


Index: swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- swscale.c	15 Oct 2003 11:21:54 -0000	1.132
+++ swscale.c	15 Oct 2003 12:08:31 -0000	1.133
@@ -1084,8 +1084,10 @@
 	for(i=0; i<dstW; i++)
 	{
 		int j;
+		double error=0;
 		double sum=0;
 		double scale= one;
+
 		for(j=0; j<filterSize; j++)
 		{
 			sum+= filter[i*filterSize + j];
@@ -1093,7 +1095,10 @@
 		scale/= sum;
 		for(j=0; j<*outFilterSize; j++)
 		{
-			(*outFilter)[i*(*outFilterSize) + j]= (int)(filter[i*filterSize + j]*scale + 0.5);
+			double v= filter[i*filterSize + j]*scale + error;
+			int intV= floor(v + 0.5);
+			(*outFilter)[i*(*outFilterSize) + j]= intV;
+			error = v - intV;
 		}
 	}
 	



More information about the MPlayer-cvslog mailing list