From bc0f896a47d7b2dcd6f9fc1fff88f6a25b248f8a Mon Sep 17 00:00:00 2001 From: homm Date: Wed, 19 Nov 2014 13:59:11 +0300 Subject: [PATCH] rename Antialias and stretch to resample --- CHANGES.rst | 2 +- _imaging.c | 2 +- libImaging/Imaging.h | 2 +- libImaging/{Antialias.c => Resample.c} | 26 ++++++-------------------- setup.py | 2 +- 5 files changed, 10 insertions(+), 24 deletions(-) rename libImaging/{Antialias.c => Resample.c} (93%) diff --git a/CHANGES.rst b/CHANGES.rst index 1b4826451..45589c7d6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,7 +18,7 @@ Changelog (Pillow) - Use PyQt4 if it has already been imported, otherwise prefer PyQt5. #1003 [AurelienBallier] -- Speedup stretch implementation up to 2.5 times. #977 +- Speedup resample implementation up to 2.5 times. #977 [homm] - Speed up rotation by using cache aware loops, added transpose to rotations. #994 diff --git a/_imaging.c b/_imaging.c index a84350cf2..299e88662 100644 --- a/_imaging.c +++ b/_imaging.c @@ -1531,7 +1531,7 @@ _resize(ImagingObject* self, PyObject* args) a, filter, 1); } else { - imOut = ImagingStretch(imIn, xsize, ysize, filter); + imOut = ImagingResample(imIn, xsize, ysize, filter); } return PyImagingNew(imOut); diff --git a/libImaging/Imaging.h b/libImaging/Imaging.h index 694a15c21..95957bb9d 100644 --- a/libImaging/Imaging.h +++ b/libImaging/Imaging.h @@ -290,7 +290,7 @@ extern Imaging ImagingRotate( extern Imaging ImagingRotate90(Imaging imOut, Imaging imIn); extern Imaging ImagingRotate180(Imaging imOut, Imaging imIn); extern Imaging ImagingRotate270(Imaging imOut, Imaging imIn); -extern Imaging ImagingStretch(Imaging imIn, int xsize, int ysize, int filter); +extern Imaging ImagingResample(Imaging imIn, int xsize, int ysize, int filter); extern Imaging ImagingTranspose(Imaging imOut, Imaging imIn); extern Imaging ImagingTransposeToNew(Imaging imIn); extern Imaging ImagingTransformPerspective( diff --git a/libImaging/Antialias.c b/libImaging/Resample.c similarity index 93% rename from libImaging/Antialias.c rename to libImaging/Resample.c index d6b10c431..69c32beba 100644 --- a/libImaging/Antialias.c +++ b/libImaging/Resample.c @@ -2,7 +2,7 @@ * The Python Imaging Library * $Id$ * - * pilopen antialiasing support + * Pillow image resamling support * * history: * 2002-03-09 fl Created (for PIL 1.1.3) @@ -17,8 +17,6 @@ #include -/* resampling filters (from antialias.py) */ - struct filter { float (*filter)(float x); float support; @@ -42,15 +40,6 @@ static inline float antialias_filter(float x) static struct filter ANTIALIAS = { antialias_filter, 3.0 }; -static inline float nearest_filter(float x) -{ - if (-0.5 <= x && x < 0.5) - return 1.0; - return 0.0; -} - -static struct filter NEAREST = { nearest_filter, 0.5 }; - static inline float bilinear_filter(float x) { if (x < 0.0) @@ -106,7 +95,7 @@ static float inline i2f(int v) { return (float) v; } Imaging -ImagingStretchHorizontal(Imaging imIn, int xsize, int filter) +ImagingResampleHorizontal(Imaging imIn, int xsize, int filter) { ImagingSectionCookie cookie; Imaging imOut; @@ -119,9 +108,6 @@ ImagingStretchHorizontal(Imaging imIn, int xsize, int filter) /* check filter */ switch (filter) { - case IMAGING_TRANSFORM_NEAREST: - filterp = &NEAREST; - break; case IMAGING_TRANSFORM_ANTIALIAS: filterp = &ANTIALIAS; break; @@ -152,7 +138,7 @@ ImagingStretchHorizontal(Imaging imIn, int xsize, int filter) /* maximum number of coofs */ kmax = (int) ceil(support) * 2 + 1; - /* coefficient buffer (with rounding safety margin) */ + /* coefficient buffer */ kk = malloc(xsize * kmax * sizeof(float)); if ( ! kk) return (Imaging) ImagingError_MemoryError(); @@ -294,7 +280,7 @@ ImagingStretchHorizontal(Imaging imIn, int xsize, int filter) Imaging -ImagingStretch(Imaging imIn, int xsize, int ysize, int filter) +ImagingResample(Imaging imIn, int xsize, int ysize, int filter) { Imaging imTemp1, imTemp2, imTemp3; Imaging imOut; @@ -306,7 +292,7 @@ ImagingStretch(Imaging imIn, int xsize, int ysize, int filter) return (Imaging) ImagingError_ModeError(); /* two-pass resize, first pass */ - imTemp1 = ImagingStretchHorizontal(imIn, xsize, filter); + imTemp1 = ImagingResampleHorizontal(imIn, xsize, filter); if ( ! imTemp1) return NULL; @@ -317,7 +303,7 @@ ImagingStretch(Imaging imIn, int xsize, int ysize, int filter) return NULL; /* second pass */ - imTemp3 = ImagingStretchHorizontal(imTemp2, ysize, filter); + imTemp3 = ImagingResampleHorizontal(imTemp2, ysize, filter); ImagingDelete(imTemp2); if ( ! imTemp3) return NULL; diff --git a/setup.py b/setup.py index 2d8cafa34..ff50867d5 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ _IMAGING = ( "decode", "encode", "map", "display", "outline", "path") _LIB_IMAGING = ( - "Access", "AlphaComposite", "Antialias", "Bands", "BitDecode", "Blend", + "Access", "AlphaComposite", "Resample", "Bands", "BitDecode", "Blend", "Chops", "Convert", "ConvertYCbCr", "Copy", "Crc32", "Crop", "Dib", "Draw", "Effects", "EpsEncode", "File", "Fill", "Filter", "FliDecode", "Geometry", "GetBBox", "GifDecode", "GifEncode", "HexDecode",