[Bf-blender-cvs] [957b945] master: Compositor: Simplify logic in keying blur operation

Sergey Sharybin noreply at git.blender.org
Thu Oct 2 09:40:37 CEST 2014


Commit: 957b945a186f51ff6e27fe829b4090fb1e625b4e
Author: Sergey Sharybin
Date:   Wed Oct 1 16:36:28 2014 +0600
Branches: master
https://developer.blender.org/rB957b945a186f51ff6e27fe829b4090fb1e625b4e

Compositor: Simplify logic in keying blur operation

===================================================================

M	source/blender/compositor/operations/COM_KeyingBlurOperation.cpp

===================================================================

diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
index 9fb9efe..ddc09ec 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++;
 		}
 	}




More information about the Bf-blender-cvs mailing list