Commit d1e674fe authored by michael's avatar michael

dither scaling coefficients so they add up to 1.0


git-svn-id: file:///var/local/repositories/mplayer/trunk/postproc@11124 b3059339-0415-0410-9bf9-f77b7e298cf2
parent a8f881ea
...@@ -1084,8 +1084,10 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out ...@@ -1084,8 +1084,10 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
for(i=0; i<dstW; i++) for(i=0; i<dstW; i++)
{ {
int j; int j;
double error=0;
double sum=0; double sum=0;
double scale= one; double scale= one;
for(j=0; j<filterSize; j++) for(j=0; j<filterSize; j++)
{ {
sum+= filter[i*filterSize + j]; sum+= filter[i*filterSize + j];
...@@ -1093,7 +1095,10 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out ...@@ -1093,7 +1095,10 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
scale/= sum; scale/= sum;
for(j=0; j<*outFilterSize; j++) 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;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment