Skip to content

Commit c722aae

Browse files
authored
Do not precompute horizontal coefficients if not horizontal resizing (#9543)
2 parents fcf033b + abb9b20 commit c722aae

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

src/libImaging/Resample.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -726,19 +726,10 @@ ImagingResampleInner(
726726
need_horizontal = xsize != imIn->xsize || box[0] || box[2] != xsize;
727727
need_vertical = ysize != imIn->ysize || box[1] || box[3] != ysize;
728728

729-
ksize_horiz = precompute_coeffs(
730-
imIn->xsize, box[0], box[2], xsize, filterp, &bounds_horiz, &kk_horiz
731-
);
732-
if (!ksize_horiz) {
733-
return NULL;
734-
}
735-
736729
ksize_vert = precompute_coeffs(
737730
imIn->ysize, box[1], box[3], ysize, filterp, &bounds_vert, &kk_vert
738731
);
739732
if (!ksize_vert) {
740-
free(bounds_horiz);
741-
free(kk_horiz);
742733
return NULL;
743734
}
744735

@@ -749,6 +740,15 @@ ImagingResampleInner(
749740

750741
/* two-pass resize, horizontal pass */
751742
if (need_horizontal) {
743+
ksize_horiz = precompute_coeffs(
744+
imIn->xsize, box[0], box[2], xsize, filterp, &bounds_horiz, &kk_horiz
745+
);
746+
if (!ksize_horiz) {
747+
free(bounds_vert);
748+
free(kk_vert);
749+
return NULL;
750+
}
751+
752752
// Shift bounds for vertical pass
753753
for (i = 0; i < ysize; i++) {
754754
bounds_vert[i * 2] -= ybox_first;
@@ -768,10 +768,6 @@ ImagingResampleInner(
768768
return NULL;
769769
}
770770
imOut = imIn = imTemp;
771-
} else {
772-
// Free in any case
773-
free(bounds_horiz);
774-
free(kk_horiz);
775771
}
776772

777773
/* vertical pass */

0 commit comments

Comments
 (0)