diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-10-15 16:08:31 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-10-15 16:08:31 +0400 |
commit | ff490720135b7b3d2e7e33cce8f6bc843e4333ab (patch) | |
tree | 6df7450088444d02c3380fd7f79605a0b4efb30b /postproc | |
parent | 379a20360c6f3e3d449dd8fc478d639ce9e61cdc (diff) |
dither scaling coefficients so they add up to 1.0
Originally committed as revision 11124 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
Diffstat (limited to 'postproc')
-rw-r--r-- | postproc/swscale.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/postproc/swscale.c b/postproc/swscale.c index e911a6467d..d46e6167dc 100644 --- a/postproc/swscale.c +++ b/postproc/swscale.c @@ -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; } } |