From 864a24e7b85ef33baaeedb08fc8fc5a2f299a738 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 11 Aug 2017 15:17:47 +0300 Subject: [PATCH] Release GIL in filters --- libImaging/Filter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libImaging/Filter.c b/libImaging/Filter.c index 4c8b81587..d34bbfb85 100644 --- a/libImaging/Filter.c +++ b/libImaging/Filter.c @@ -31,6 +31,7 @@ ImagingExpand(Imaging imIn, int xmargin, int ymargin, int mode) { Imaging imOut; int x, y; + ImagingSectionCookie cookie; if (xmargin < 0 && ymargin < 0) return (Imaging) ImagingError_ValueError("bad kernel size"); @@ -60,11 +61,13 @@ ImagingExpand(Imaging imIn, int xmargin, int ymargin, int mode) EXPAND_LINE(type, image, imIn->ysize-1, ymargin+imIn->ysize+y);\ } + ImagingSectionEnter(&cookie); if (imIn->image8) { EXPAND(UINT8, image8); } else { EXPAND(INT32, image32); } + ImagingSectionLeave(&cookie); ImagingCopyInfo(imOut, imIn); @@ -78,6 +81,7 @@ ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32* kernel, Imaging imOut; int x, y; FLOAT32 sum; + ImagingSectionCookie cookie; if (!im || strcmp(im->mode, "L") != 0) return (Imaging) ImagingError_ModeError(); @@ -131,6 +135,7 @@ ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32* kernel, (int) image[y-2][x+d] * kernel[23] + \ (int) image[y-2][x+d+d] * kernel[24]) + ImagingSectionEnter(&cookie); if (xsize == 3) { /* 3x3 kernel. */ for (x = 0; x < im->xsize; x++) @@ -174,6 +179,7 @@ ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32* kernel, for (x = 0; x < im->xsize; x++) imOut->image8[y][x] = im->image8[y][x]; } + ImagingSectionLeave(&cookie); return imOut; }