Revision 2b647ac8

View differences:

libavcodec/imgresample.c
545 545
static void build_filter(int16_t *filter, float factor)
546 546
{
547 547
    int ph, i, v;
548
    float x, y, tab[NB_TAPS], norm, mult;
548
    float x, y, tab[NB_TAPS], norm, mult, target;
549 549

  
550 550
    /* if upsampling, only need to interpolate, no filter */
551 551
    if (factor > 1.0)
......
571 571
        }
572 572

  
573 573
        /* normalize so that an uniform color remains the same */
574
        mult = (float)(1 << FILTER_BITS) / norm;
574
        target= 1 << FILTER_BITS;
575 575
        for(i=0;i<NB_TAPS;i++) {
576
            v = (int)(tab[i] * mult);
576
            mult = target / norm;
577
            v = lrintf(tab[i] * mult);
577 578
            filter[ph * NB_TAPS + i] = v;
579
            norm -= tab[i];
580
            target -= v;
578 581
        }
579 582
    }
580 583
}

Also available in: Unified diff