simpler coefficients calculation in ImagingResampleHorizontal_8bpc

This commit is contained in:
homm 2016-05-09 14:33:14 +02:00
parent d3749ccc7c
commit 7722d00daf

View File

@ -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);