mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 13:28:03 +02:00
Correct an off-by-one in the reflection of the convolution index.
Currently the convolution code uses the formula 2*(N-1)-n to reflect the index n when n is greater than or equal to N. This is wrong as n=N -> 2*(N-1)-N = N-2 instead of N-1. Furthermore when the image is small, e.g. at the highest levels of the pyramid, this causes the code to index before the start of the array and causes valgrind to issue a warning.
This commit is contained in:
parent
789aada06b
commit
14cab8b020
1 changed files with 2 additions and 2 deletions
|
|
@ -46,8 +46,8 @@ convolve (lpyramid_t *pyramid, float *a, float *b)
|
|||
ny=y+j;
|
||||
if (nx<0) nx=-nx;
|
||||
if (ny<0) ny=-ny;
|
||||
if (nx>=width) nx=2*(width-1)-nx;
|
||||
if (ny>=height) ny=2*(height-1)-ny;
|
||||
if (nx>=width) nx=2*width - nx - 1;
|
||||
if (ny>=height) ny=2*height - ny - 1;
|
||||
a[index] += Kernel[i+2] * Kernel[j+2] * b[ny * width + nx];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue