mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
simpler coefficients calculation in ImagingResampleHorizontal_8bpc
This commit is contained in:
parent
d3749ccc7c
commit
7722d00daf
|
@ -103,11 +103,11 @@ ImagingPrecompute(int inSize, int outSize, struct filter *filterp,
|
|||
return 0;
|
||||
|
||||
/* coefficient buffer */
|
||||
kk = malloc(outSize * kmax * sizeof(double));
|
||||
kk = calloc(outSize * kmax, sizeof(double));
|
||||
if ( ! kk)
|
||||
return 0;
|
||||
|
||||
xbounds = malloc(outSize * 2 * sizeof(int));
|
||||
xbounds = calloc(outSize * 2, sizeof(int));
|
||||
if ( ! xbounds) {
|
||||
free(kk);
|
||||
return 0;
|
||||
|
@ -159,20 +159,15 @@ ImagingResampleHorizontal_8bpc(Imaging imIn, int xsize, struct filter *filterp)
|
|||
return (Imaging) ImagingError_MemoryError();
|
||||
}
|
||||
|
||||
kk = malloc(xsize * kmax * sizeof(int));
|
||||
kk = calloc(xsize * kmax, sizeof(int));
|
||||
if ( ! kk) {
|
||||
free(xbounds);
|
||||
free(prekk);
|
||||
return (Imaging) ImagingError_MemoryError();
|
||||
}
|
||||
|
||||
for (xx = 0; xx < xsize; xx++) {
|
||||
xmin = xbounds[xx * 2 + 0];
|
||||
xmax = xbounds[xx * 2 + 1];
|
||||
k = &kk[xx * kmax];
|
||||
for (x = 0; x < xmax - xmin; x++) {
|
||||
k[x] = (int) floor(0.5 + prekk[xx * kmax + x] * (1 << PRECISION_BITS));
|
||||
}
|
||||
for (x = 0; x < xsize * kmax; x++) {
|
||||
kk[x] = (int) (0.5 + prekk[x] * (1 << PRECISION_BITS));
|
||||
}
|
||||
|
||||
free(prekk);
|
||||
|
|
Loading…
Reference in New Issue
Block a user