[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47698] branches/soc-2011-tomato/source/ blender/compositor/operations: Make keying clamping operation complex so it might directly access input buffer

Sergey Sharybin sergey.vfx at gmail.com
Sun Jun 10 20:15:41 CEST 2012


Revision: 47698
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47698
Author:   nazgul
Date:     2012-06-10 18:15:28 +0000 (Sun, 10 Jun 2012)
Log Message:
-----------
Make keying clamping operation complex so it might directly access input buffer

Seems to give quite noticeable speedup, but there's sometimes strange artifacts
showing as darker lines placed in along some kind of tiles.
Not sure what causes them yet.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
    branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.h

Modified: branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.cpp	2012-06-10 17:41:04 UTC (rev 47697)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.cpp	2012-06-10 18:15:28 UTC (rev 47698)
@@ -36,29 +36,30 @@
 	this->clipBlack = 0.0f;
 	this->clipWhite = 1.0f;
 
-	this->pixelReader = NULL;
+	this->setComplex(true);
 }
 
-void KeyingClipOperation::initExecution()
+void *KeyingClipOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
 {
-	this->pixelReader = this->getInputSocketReader(0);
-}
+	void *buffer = getInputOperation(0)->initializeTileData(rect, memoryBuffers);
 
-void KeyingClipOperation::deinitExecution()
-{
-	this->pixelReader = NULL;
+	return buffer;
 }
 
-void KeyingClipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
 {
 	const int delta = 3;
 
-	float pixelColor[4];
-	int width = this->getWidth(), height = this->getHeight();
+	MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+	float *buffer = inputBuffer->getBuffer();
+
+	int bufferWidth = inputBuffer->getWidth();
+	int bufferHeight = inputBuffer->getHeight();
+
 	int count_black = 0, count_white = 0;
 	int i, j;
 
-	this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers);
+	int srcIndex = (y * bufferWidth + x) * 4;
 
 	for (i = -delta + 1; i < delta; i++) {
 		for (j = -delta + 1; j < delta; j++) {
@@ -67,20 +68,18 @@
 			if (i == 0 && j == 0)
 				continue;
 
-			if (cx >= 0 && cx < width && cy >= 0 && cy < height) {
-				float value[4];
+			if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) {
+				int bufferIndex = (cy * bufferWidth + cx) * 4;
 
-				this->pixelReader->read(value, cx, cy, sampler, inputBuffers);
-
-				if (value[0] < 0.4f)
+				if (buffer[bufferIndex] < 0.4f)
 					count_black++;
-				else if (value[0] > 0.6f)
+				else if (buffer[bufferIndex] > 0.6f)
 					count_white++;
 			}
 		}
 	}
 
-	color[0] = pixelColor[0];
+	color[0] = buffer[srcIndex];
 
 	if (count_black >= 22 || count_white >= 22) {
 		if (color[0] < this->clipBlack)

Modified: branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.h
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.h	2012-06-10 17:41:04 UTC (rev 47697)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.h	2012-06-10 18:15:28 UTC (rev 47698)
@@ -31,20 +31,18 @@
   */
 class KeyingClipOperation : public NodeOperation {
 protected:
-	SocketReader *pixelReader;
 	float clipBlack;
 	float clipWhite;
 
 public:
 	KeyingClipOperation();
 
-	void initExecution();
-	void deinitExecution();
-
 	void setClipBlack(float value) {this->clipBlack = value;}
 	void setClipWhite(float value) {this->clipWhite = value;}
 
-	void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+	void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+	void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
 };
 
 #endif




More information about the Bf-blender-cvs mailing list