Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2013-12-04 14:56:36 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2013-12-04 15:09:13 +0400
commit45fc80153a40fb01db6b1e25b4ab575a06a331b8 (patch)
tree898972a78c5074ef1fc3f4f90c9f9791225c538f /source/blender/compositor/operations/COM_RenderLayersProg.cpp
parenta698709d956f01ff4a2a1c0d27450c6880dd2ad5 (diff)
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.
Diffstat (limited to 'source/blender/compositor/operations/COM_RenderLayersProg.cpp')
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index 2c2a4c6f180..f72af2780d7 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -75,13 +75,15 @@ void RenderLayersBaseProg::initExecution()
void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, PixelSampler sampler)
{
unsigned int offset;
- int ix, iy;
int width = this->getWidth(), height = this->getHeight();
switch (sampler) {
- case COM_PS_NEAREST:
- ix = x;
- iy = y;
+ case COM_PS_NEAREST: {
+ int ix = x;
+ int iy = y;
+ if (ix < 0 || iy < 0 || ix >= width || iy >= height)
+ break;
+
offset = (iy * width + ix) * this->m_elementsize;
if (this->m_elementsize == 1)
@@ -90,8 +92,8 @@ void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, Pi
copy_v3_v3(output, &this->m_inputBuffer[offset]);
else
copy_v4_v4(output, &this->m_inputBuffer[offset]);
-
break;
+ }
case COM_PS_BILINEAR:
BLI_bilinear_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
@@ -137,7 +139,7 @@ void RenderLayersBaseProg::executePixelSampled(float output[4], float x, float y
int iy = y;
#endif
- if (this->m_inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) {
+ if (this->m_inputBuffer == NULL) {
zero_v4(output);
}
else {