From: nicolas Date: Mon, 20 Sep 2010 20:28:38 +0000 (+0000) Subject: PIL should be MagickRealType + Bohman uses one less trig call X-Git-Tag: 7.0.1-0~8845 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4f7b4aade90904aef12da73b556ba43d79a5a12;p=imagemagick PIL should be MagickRealType + Bohman uses one less trig call --- diff --git a/ChangeLog b/ChangeLog index 2934ae3b1..a84238b36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-09-20 6.6.4-5 Nicolas Robidoux + * Modified "magick/resize.c" so that PIL is a MagickRealType number. Earlier, + some computations were needlessly done in long double precision because PIL + forced an automatic upcast wherever it appeared. + * Modified "magick/resize.c" so that Bohman uses one trig call + one sqrt call + instead of two trig calls. + 2010-09-20 6.6.4-5 Anthony Thyssen * modified "magick/resample.c" to allow use of either EWA or HQEWA (default) * Removed LanczosFast from supported filters (SincFast*SincFast is faster) diff --git a/magick/resize.c b/magick/resize.c index be12f16e8..3457f0038 100644 --- a/magick/resize.c +++ b/magick/resize.c @@ -133,7 +133,7 @@ static MagickRealType % */ -#define MagickPIL 3.14159265358979323846264338327950288420L +#define MagickPIL ((MagickRealType) 3.14159265358979323846264338327950288420L) static MagickRealType Bessel(const MagickRealType x, const ResizeFilter *magick_unused(resize_filter)) @@ -168,9 +168,13 @@ static MagickRealType Bohman(const MagickRealType x, /* Bohman: 2rd Order cosine windowing function: (1-x) cos(pi x) + sin(pi x) / pi. + Refactored by Nicolas Robidoux to one trig call, one sqrt call, + and 7 flops, taking advantage of the fact that the support of + Bohman is 1 (so that we know that sin(pi x) >= 0). */ - const double pix = (double) (MagickPIL*x); - return((MagickRealType) ((1.0-x)*cos(pix)+(1.0/MagickPIL)*sin(pix))); + const double cospix = cos((double) (MagickPIL*x)); + const double sinpix = sqrt(1.0-cospix*cospix); + return((MagickRealType) ((1.0-x)*cospix+(1.0/MagickPIL)*sinpix)); } static MagickRealType Box(const MagickRealType x,