changeset 11123:b41af00e8c17

dither scaling coefficients so they add up to 1.0
author michael
date Wed, 15 Oct 2003 12:08:31 +0000
parents c552fe6acbaa
children b5bffec1a657
files postproc/swscale.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/postproc/swscale.c	Wed Oct 15 11:21:54 2003 +0000
+++ b/postproc/swscale.c	Wed Oct 15 12:08:31 2003 +0000
@@ -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;
 		}
 	}