Commit 5eb2c186 authored by michael's avatar michael

fix normalization


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3203 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 04bad157
......@@ -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;
}
}
}
......
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