diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-01 14:36:28 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-02 11:39:50 +0400 |
commit | 957b945a186f51ff6e27fe829b4090fb1e625b4e (patch) | |
tree | 55bc243387cacaea391dcff2c9c0f0e74ca7f3f1 /source/blender/compositor/operations/COM_KeyingBlurOperation.cpp | |
parent | db62a808692aafb4ed3282d1b2b76894a8b71d38 (diff) |
Compositor: Simplify logic in keying blur operation
Diffstat (limited to 'source/blender/compositor/operations/COM_KeyingBlurOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_KeyingBlurOperation.cpp | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp index 9fb9efe4fc7..ddc09ecb483 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp @@ -49,37 +49,27 @@ void *KeyingBlurOperation::initializeTileData(rcti *rect) void KeyingBlurOperation::executePixel(float output[4], int x, int y, void *data) { MemoryBuffer *inputBuffer = (MemoryBuffer *)data; + const int bufferWidth = inputBuffer->getWidth(); float *buffer = inputBuffer->getBuffer(); - - int bufferWidth = inputBuffer->getWidth(); - int bufferHeight = inputBuffer->getHeight(); - - int i, count = 0; - + int count = 0; float average = 0.0f; if (this->m_axis == 0) { - for (i = -this->m_size + 1; i < this->m_size; i++) { - int cx = x + i; - - if (cx >= 0 && cx < bufferWidth) { - int bufferIndex = (y * bufferWidth + cx) * 4; - - average += buffer[bufferIndex]; - count++; - } + const int start = max(0, x - this->m_size + 1), + end = min(bufferWidth, x + this->m_size); + for (int cx = start; cx < end; ++cx) { + int bufferIndex = (y * bufferWidth + cx) * 4; + average += buffer[bufferIndex]; + count++; } } else { - for (i = -this->m_size + 1; i < this->m_size; i++) { - int cy = y + i; - - if (cy >= 0 && cy < bufferHeight) { - int bufferIndex = (cy * bufferWidth + x) * 4; - - average += buffer[bufferIndex]; - count++; - } + const int start = max(0, y - this->m_size + 1), + end = min(inputBuffer->getHeight(), y + this->m_size); + for (int cy = start; cy < end; ++cy) { + int bufferIndex = (cy * bufferWidth + x) * 4; + average += buffer[bufferIndex]; + count++; } } |