diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-06-06 20:15:53 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-06-06 20:15:53 +0000 |
commit | 2b647ac8c91c95e7f2a94f52e3561f09e6a99d48 (patch) | |
tree | c6c4956492a10f2b67b3425e7823bc14811bf5ac /libavcodec/imgresample.c | |
parent | 23854cadeceb28053643cbc707e75feebbd94b61 (diff) | |
download | ffmpeg-2b647ac8c91c95e7f2a94f52e3561f09e6a99d48.tar.gz |
fix normalization
Originally committed as revision 3203 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/imgresample.c')
-rw-r--r-- | libavcodec/imgresample.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libavcodec/imgresample.c b/libavcodec/imgresample.c index dc5ccf93bd..da57ad773f 100644 --- a/libavcodec/imgresample.c +++ b/libavcodec/imgresample.c @@ -545,7 +545,7 @@ static void component_resample(ImgReSampleContext *s, static void build_filter(int16_t *filter, float factor) { int ph, i, v; - float x, y, tab[NB_TAPS], norm, mult; + float x, y, tab[NB_TAPS], norm, mult, target; /* if upsampling, only need to interpolate, no filter */ if (factor > 1.0) @@ -571,10 +571,13 @@ static void build_filter(int16_t *filter, float factor) } /* normalize so that an uniform color remains the same */ - mult = (float)(1 << FILTER_BITS) / norm; + target= 1 << FILTER_BITS; for(i=0;i<NB_TAPS;i++) { - v = (int)(tab[i] * mult); + mult = target / norm; + v = lrintf(tab[i] * mult); filter[ph * NB_TAPS + i] = v; + norm -= tab[i]; + target -= v; } } } |