From 5048956ff02ec6d84aed2f79c65e4c130adf6e43 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 17 Aug 2017 17:47:35 -0700 Subject: Keep bsinc filter quality more consistent between scales This generates the filters using the proper size and scale. The 'a' divisor should represent the +/- sample range (and thus be a whole number), with the number of sample points being double that. Increasing the filter size to a multiple of 4 (for SIMD) can be done by padding in 0s afterward. --- utils/bsincgen.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'utils/bsincgen.c') diff --git a/utils/bsincgen.c b/utils/bsincgen.c index 87bdd662..138f7a68 100644 --- a/utils/bsincgen.c +++ b/utils/bsincgen.c @@ -161,11 +161,9 @@ static void BsiGenerateTables() for(si = 0; si < BSINC_SCALE_COUNT; si++) { const double scale = scaleBase + (scaleRange * si / (BSINC_SCALE_COUNT - 1)); - const double a = MinDouble(BSINC_POINTS_MIN, BSINC_POINTS_MIN / (2.0 * scale)); - int m = 2 * (int)floor(a); - - // Make sure the number of points is a multiple of 4 (for SSE). - m += ~(m - 1) & 3; + const double a = MinDouble(floor(BSINC_POINTS_MIN / (2.0 * scale)), + BSINC_POINTS_MIN); + int m = 2 * (int)a; mt[si] = m; at[si] = a; @@ -241,6 +239,10 @@ static void BsiGenerateTables() } } + // Make sure the number of points is a multiple of 4 (for SIMD). + for(si = 0; si < BSINC_SCALE_COUNT; si++) + mt[si] = (mt[si]+3) & ~3; + // Calculate the table size. i = 0; for(si = 0; si < BSINC_SCALE_COUNT; si++) @@ -331,8 +333,8 @@ static void Sinc4GenerateTables(void) const double scaleBase = width / 2.0; const double scaleRange = 1.0 - scaleBase; const double scale = scaleBase + scaleRange; - const double a = MinDouble(4.0, 4.0 / (2.0*scale)); - const int m = 2 * (int)floor(a); + const double a = MinDouble(4.0, floor(4.0 / (2.0*scale))); + const int m = 2 * (int)a; const int l = (m/2) - 1; int pi; for(pi = 0;pi < FRACTIONONE;pi++) -- cgit v1.2.3