Fix for interpolation errors on lower-left borders in compositor image

inputs.

http://wiki.blender.org/uploads/4/4c/Compo_image_interpolation_borders.png

Problem is that all image buffer reader nodes (RenderLayer, Image,
MovieClip) were clipping pixel coordinates to 0..N range (N being width
or height respectively). Bilinear interpolation works ok then on the
upper-right borders (x, N) and (N, y), since the last (N-1) pixel fades
out to N (background). But the lower-left (x, 0) and (0, y) borders are
not correctly interpolated because the nodes cut off the negative pixels
before the interpolation function can calculate their value.

To fix this, the interpolation functions are now entirely responsible
for handling "out of range" cases, i.e. setting (0,0,0,0) results for
invalid pixels, while also handling interpolation for borders.
Callers should not do pixel range checks themselves, which also makes
the code simpler. Should not have any real performance penalty,
the interpolation functions do this check anyway, so is probably even
slightly faster.
This commit is contained in:
2013-12-04 11:56:36 +01:00
parent a698709d95
commit 45fc80153a
6 changed files with 65 additions and 32 deletions

View File

@@ -232,6 +232,10 @@ void nearest_interpolation_color(struct ImBuf *in, unsigned char outI[4], float
/* sample area entirely outside image? */
if (x1 < 0 || x1 > in->x - 1 || y1 < 0 || y1 > in->y - 1) {
if (outI)
outI[0] = outI[1] = outI[2] = outI[3] = 0;
if (outF)
outF[0] = outF[1] = outF[2] = outF[3] = 0.0f;
return;
}