From 220e2a02eb60f4f864db5836a53ceb8712396e28 Mon Sep 17 00:00:00 2001 From: Nicolas Robidoux Date: Wed, 12 Jan 2011 20:32:11 +0000 Subject: [PATCH] attempt at speeding up float bilinear: one less flop in coefficient computation --- libvips/resample/interpolate.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libvips/resample/interpolate.c b/libvips/resample/interpolate.c index 86664728..2a3b4431 100644 --- a/libvips/resample/interpolate.c +++ b/libvips/resample/interpolate.c @@ -9,7 +9,7 @@ * - tiny speedups * 7/1/11 * - don't use tables for bilinear on float data for a small speedup - * (thanks Nicolas) + * (thanks Nicolas Robidoux) * 12/1/11 * - faster, more accuarate uchar bilinear (thanks Nicolas) */ @@ -362,16 +362,15 @@ G_DEFINE_TYPE( VipsInterpolateBilinear, vips_interpolate_bilinear, #define BILINEAR_FLOAT( TYPE ) { \ TYPE *tq = (TYPE *) out; \ \ - float X = x - ix; \ - float Y = y - iy; \ - \ - float Xd = 1.0 - X; \ + float Y = y - iy; \ + float X = x - ix; \ + \ float Yd = 1.0 - Y; \ - \ - float c1 = Xd * Yd; \ - float c2 = X * Yd; \ - float c3 = Xd * Y; \ - float c4 = X * Y; \ + \ + float c4 = Y * X; \ + float c2 = Yd * X; \ + float c3 = Y - c4; \ + float c1 = Yd - c2; \ \ const TYPE *tp1 = (TYPE *) p1; \ const TYPE *tp2 = (TYPE *) p2; \