1
mirror of https://github.com/mpv-player/mpv synced 2025-01-24 19:37:30 +01:00

dither scaling coefficients so they add up to 1.0

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11124 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
michael 2003-10-15 12:08:31 +00:00
parent f9bb7a21e5
commit fa12a92799

View File

@ -1084,8 +1084,10 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
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 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *out
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;
}
}