[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47734] branches/soc-2011-tomato/source/ blender/compositor: Fixed area of interest for black/white clipping, so now there should be no
Sergey Sharybin
sergey.vfx at gmail.com
Mon Jun 11 12:25:33 CEST 2012
Revision: 47734
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47734
Author: nazgul
Date: 2012-06-11 10:25:28 +0000 (Mon, 11 Jun 2012)
Log Message:
-----------
Fixed area of interest for black/white clipping, so now there should be no
artifacts in the boundaries of tiles.
Also added test blur operation which could potentially give better results
than gaussian blur for keying. Not user yet, to enable uncomment like
with USE_GAUSSIAN_BLUR in file COM_KeyingNode.cpp.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt
branches/soc-2011-tomato/source/blender/compositor/nodes/COM_KeyingNode.cpp
branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.h
branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingOperation.cpp
branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingOperation.h
Added Paths:
-----------
branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.h
Modified: branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt 2012-06-11 10:14:46 UTC (rev 47733)
+++ branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt 2012-06-11 10:25:28 UTC (rev 47734)
@@ -328,6 +328,8 @@
nodes/COM_KeyingScreenNode.h
operations/COM_KeyingOperation.cpp
operations/COM_KeyingOperation.h
+ operations/COM_KeyingBlurOperation.cpp
+ operations/COM_KeyingBlurOperation.h
operations/COM_KeyingScreenOperation.cpp
operations/COM_KeyingScreenOperation.h
operations/COM_KeyingDespillOperation.cpp
Modified: branches/soc-2011-tomato/source/blender/compositor/nodes/COM_KeyingNode.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/nodes/COM_KeyingNode.cpp 2012-06-11 10:14:46 UTC (rev 47733)
+++ branches/soc-2011-tomato/source/blender/compositor/nodes/COM_KeyingNode.cpp 2012-06-11 10:25:28 UTC (rev 47734)
@@ -26,6 +26,7 @@
#include "COM_ExecutionSystem.h"
#include "COM_KeyingOperation.h"
+#include "COM_KeyingBlurOperation.h"
#include "COM_KeyingDespillOperation.h"
#include "COM_KeyingClipOperation.h"
@@ -40,6 +41,8 @@
#include "COM_SetAlphaOperation.h"
+// #define USE_GAUSSIAN_BLUR
+
KeyingNode::KeyingNode(bNode *editorNode): Node(editorNode)
{
}
@@ -69,6 +72,7 @@
addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
}
else {
+#ifdef USE_GAUSSIAN_BLUR
SetValueOperation *setValueOperation = new SetValueOperation();
setValueOperation->setValue(1.0f);
graph->addOperation(setValueOperation);
@@ -81,6 +85,15 @@
addLink(graph, setValueOperation->getOutputSocket(0), blurOperation->getInputSocket(1));
addLink(graph, blurOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
graph->addOperation(blurOperation);
+#else
+ KeyingBlurOperation *blurOperation = new KeyingBlurOperation();
+
+ blurOperation->setSize(size);
+
+ addLink(graph, separateOperation->getOutputSocket(0), blurOperation->getInputSocket(0));
+ addLink(graph, blurOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
+ graph->addOperation(blurOperation);
+#endif
}
}
@@ -96,6 +109,7 @@
OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size)
{
+#ifdef USE_GAUSSIAN_BLUR
memset(&postBlurData, 0, sizeof(postBlurData));
postBlurData.sizex = size;
@@ -116,6 +130,17 @@
graph->addOperation(blurOperation);
return blurOperation->getOutputSocket();
+#else
+ KeyingBlurOperation *blurOperation = new KeyingBlurOperation();
+
+ blurOperation->setSize(size);
+
+ addLink(graph, postBLurInput, blurOperation->getInputSocket(0));
+
+ graph->addOperation(blurOperation);
+
+ return blurOperation->getOutputSocket();
+#endif
}
OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance)
Copied: branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp (from rev 47729, branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.cpp)
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp 2012-06-11 10:25:28 UTC (rev 47734)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_KeyingBlurOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+KeyingBlurOperation::KeyingBlurOperation(): NodeOperation()
+{
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+
+ this->size = 0.0f;
+
+ this->setComplex(true);
+}
+
+void *KeyingBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+ void *buffer = getInputOperation(0)->initializeTileData(rect, memoryBuffers);
+
+ return buffer;
+}
+
+void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+ MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ float *buffer = inputBuffer->getBuffer();
+
+ int bufferWidth = inputBuffer->getWidth();
+ int bufferHeight = inputBuffer->getHeight();
+
+ int i, j, count = 0;
+
+ float average = 0.0f;
+
+ for (i = -this->size + 1; i < this->size; i++) {
+ for (j = -this->size + 1; j < this->size; j++) {
+ int cx = x + j, cy = y + i;
+
+ if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) {
+ int bufferIndex = (cy * bufferWidth + cx) * 4;
+
+ average += buffer[bufferIndex];
+ count++;
+ }
+ }
+ }
+
+ average /= (float) count;
+
+ color[0] = average;
+}
+
+bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newInput;
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
Copied: branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.h (from rev 47729, branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.h)
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.h (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingBlurOperation.h 2012-06-11 10:25:28 UTC (rev 47734)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#ifndef _COM_KeyingBlurOperation_h
+#define _COM_KeyingBlurOperation_h
+
+#include "COM_NodeOperation.h"
+
+/**
+ * Class with implementation of bluring for keying node
+ */
+class KeyingBlurOperation : public NodeOperation {
+protected:
+ int size;
+
+public:
+ KeyingBlurOperation();
+
+ void setSize(float value) {this->size = value;}
+
+ void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+
+#endif
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-11 10:14:46 UTC (rev 47733)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.cpp 2012-06-11 10:25:28 UTC (rev 47734)
@@ -90,3 +90,15 @@
color[0] = (color[0] - this->clipBlack) / (this->clipWhite - this->clipBlack);
}
}
+
+bool KeyingClipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newInput;
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
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-11 10:14:46 UTC (rev 47733)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingClipOperation.h 2012-06-11 10:25:28 UTC (rev 47734)
@@ -43,6 +43,8 @@
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
};
#endif
Modified: branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingOperation.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingOperation.cpp 2012-06-11 10:14:46 UTC (rev 47733)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_KeyingOperation.cpp 2012-06-11 10:25:28 UTC (rev 47734)
@@ -101,3 +101,15 @@
color[0] = distance;
}
}
+
+bool KeyingOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newInput;
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list