Merge pull request #2670 from uploadcare/threaded-filter

Release GIL in filters
This commit is contained in:
Alexander Karpinsky 2017-08-12 23:51:08 +03:00 committed by GitHub
commit bbe07d4f49

View File

@ -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();
@ -134,6 +138,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++)
@ -177,6 +182,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;
}