== compositor ==
authorPeter Schlaile <peter@schlaile.de>
Sun, 29 Jul 2012 15:48:38 +0000 (15:48 +0000)
committerPeter Schlaile <peter@schlaile.de>
Sun, 29 Jul 2012 15:48:38 +0000 (15:48 +0000)
This adds an inpaint node to blender.

In case, you don't know, inpainting does this:
http://en.wikipedia.org/wiki/Inpainting

It's use cases in blender are

* wire removal
* green screen background reconstruction

The node isn't tile based (for fundamental reasons), but very fast,
since it first builds a manhatten distance map and after that performs
color convolution only on the edges.

That's something, one should probably add also to the dilate node (in
step mode) to make it perform a lot better for dilate iterations greater
than 3.

It will bring it's computing time from O(n^3) down to O(n^2).
Take a look here for the details:
http://ostermiller.org/dilate_and_erode.html )

17 files changed:
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/node.c
source/blender/compositor/CMakeLists.txt
source/blender/compositor/intern/COM_Converter.cpp
source/blender/compositor/nodes/COM_InpaintNode.cpp [new file with mode: 0644]
source/blender/compositor/nodes/COM_InpaintNode.h [new file with mode: 0644]
source/blender/compositor/operations/COM_InpaintOperation.cpp [new file with mode: 0644]
source/blender/compositor/operations/COM_InpaintOperation.h [new file with mode: 0644]
source/blender/editors/space_node/drawnode.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_nodetree_types.h
source/blender/nodes/CMakeLists.txt
source/blender/nodes/NOD_composite.h
source/blender/nodes/composite/nodes/node_composite_inpaint.c [new file with mode: 0644]

index 7bd9f75b2dd3314c6b4ab9edea68b71bf40e30e9..4d6e0cbc9005ac31fa90db6b0e4dd96a006230c3 100644 (file)
@@ -661,6 +661,7 @@ void                        ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
 #define CMP_NODE_KEYINGSCREEN          269
 #define CMP_NODE_KEYING                        270
 #define CMP_NODE_TRACKPOS              271
+#define CMP_NODE_INPAINT                272
 
 #define CMP_NODE_GLARE         301
 #define CMP_NODE_TONEMAP       302
index 86124ed932e9c43eacc20a9e1c011c3d82342075..555d95acf881de2b8a468f7a75412def02a11ea0 100644 (file)
@@ -3,6 +3,10 @@ Import ('env')
 import os
 
 sources = env.Glob('intern/*.c')
+sources.remove('intern' + os.sep + 'mask_rasterize.c')
+sources.remove('intern' + os.sep + 'mask.c')
+
+sources_mask = env.Glob('intern/mask*.c')
 
 incs = '. #/intern/guardedalloc #/intern/memutil'
 incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager'
@@ -117,7 +121,10 @@ if env['WITH_BF_INTERNATIONAL']:
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
     incs += ' ' + env['BF_PTHREADS_INC']
 
+
 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
     env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25]) #, cc_compileflags = env['CCFLAGS'].append('/WX') )
 else:
     env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [166,25,0] )
+
+env.BlenderLib ( libname = 'bf_blenkernel_mask', sources = sources_mask, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [200,25,0] )
index 56b1c0a17e864450bf9633d5535220d7f6e2faef..937015c0cac9045ec2c786b428d58397b8d8a436 100644 (file)
@@ -1892,6 +1892,7 @@ static void registerCompositNodes(bNodeTreeType *ttype)
        register_node_type_cmp_bilateralblur(ttype);
        register_node_type_cmp_vecblur(ttype);
        register_node_type_cmp_dilateerode(ttype);
+       register_node_type_cmp_inpaint(ttype);
        register_node_type_cmp_defocus(ttype);
        
        register_node_type_cmp_valtorgb(ttype);
index 870e379b3436781e8e0a4bcfcc78af8c78a19ab7..4dc111cebd2692b05227b87990afe6d3906c5f85 100644 (file)
@@ -286,6 +286,8 @@ set(SRC
        nodes/COM_FilterNode.h
        nodes/COM_DilateErodeNode.cpp
        nodes/COM_DilateErodeNode.h
+       nodes/COM_InpaintNode.cpp
+       nodes/COM_InpaintNode.h
        nodes/COM_BlurNode.cpp
        nodes/COM_BlurNode.h
        nodes/COM_BokehBlurNode.cpp
@@ -590,6 +592,8 @@ set(SRC
        operations/COM_ConvolutionEdgeFilterOperation.cpp
        operations/COM_DilateErodeOperation.cpp
        operations/COM_DilateErodeOperation.h
+       operations/COM_InpaintOperation.cpp
+       operations/COM_InpaintOperation.h
        operations/COM_GlareThresholdOperation.cpp
        operations/COM_GlareThresholdOperation.h
        operations/COM_GlareBaseOperation.cpp
index 37d38261ea56bb469c7fdbd240445e28a9d7d73a..24c3c36b79e347cbe2a8cced0b867733041967f8 100644 (file)
@@ -74,6 +74,7 @@
 #include "COM_HueSaturationValueNode.h"
 #include "COM_IDMaskNode.h"
 #include "COM_ImageNode.h"
+#include "COM_InpaintNode.h"
 #include "COM_InvertNode.h"
 #include "COM_KeyingNode.h"
 #include "COM_KeyingScreenNode.h"
@@ -303,6 +304,9 @@ Node *Converter::convert(bNode *b_node, bool fast)
                case CMP_NODE_DILATEERODE:
                        node = new DilateErodeNode(b_node);
                        break;
+               case CMP_NODE_INPAINT:
+                       node = new InpaintNode(b_node);
+                       break;
                case CMP_NODE_LENSDIST:
                        node = new LensDistortionNode(b_node);
                        break;
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.cpp b/source/blender/compositor/nodes/COM_InpaintNode.cpp
new file mode 100644 (file)
index 0000000..e90a392
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, 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: Peter Schlaile
+ *             Jeroen Bakker 
+ *             Monique Dewanchand
+ */
+
+#include "COM_InpaintNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_InpaintOperation.h"
+#include "BLI_math.h"
+
+InpaintNode::InpaintNode(bNode *editorNode) : Node(editorNode)
+{
+       /* pass */
+}
+
+void InpaintNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+       
+       bNode *editorNode = this->getbNode();
+
+       /* if (editorNode->custom1 == CMP_NODE_INPAINT_SIMPLE) { */
+       if (true) {
+               InpaintSimpleOperation *operation = new InpaintSimpleOperation();
+               operation->setbNode(editorNode);
+               operation->setIterations(editorNode->custom2);
+               this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
+               this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+               graph->addOperation(operation);
+       }
+}
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.h b/source/blender/compositor/nodes/COM_InpaintNode.h
new file mode 100644 (file)
index 0000000..5837b97
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, 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: Peter Schlaile
+ *             Jeroen Bakker 
+ *             Monique Dewanchand
+ */
+
+#ifndef _COM_InpaintNode_h_
+#define _COM_InpaintNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief InpaintNode
+ * @ingroup Node
+ */
+class InpaintNode : public Node {
+public:
+       InpaintNode(bNode *editorNode);
+       void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
new file mode 100644 (file)
index 0000000..2d7bb8a
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2011, 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: Peter Schlaile
+ *             Jeroen Bakker 
+ *             Monique Dewanchand
+ */
+
+#include "COM_InpaintOperation.h"
+#include "BLI_math.h"
+#include "COM_OpenCLDevice.h"
+
+// Inpaint (simple convolve using average of known pixels)
+InpaintSimpleOperation::InpaintSimpleOperation() : NodeOperation()
+{
+       this->addInputSocket(COM_DT_COLOR);
+       this->addOutputSocket(COM_DT_COLOR);
+       this->setComplex(true);
+       this->m_inputImageProgram = NULL;
+       this->pixelorder = NULL;
+       this->manhatten_distance = NULL;
+       this->m_cached_buffer = NULL;
+       this->cached_buffer_ready = false;
+}
+void InpaintSimpleOperation::initExecution()
+{
+       this->m_inputImageProgram = this->getInputSocketReader(0);
+
+       this->m_cached_buffer = NULL;
+       this->pixelorder = NULL;
+       this->manhatten_distance = NULL;
+       this->m_cached_buffer = NULL;
+       this->cached_buffer_ready = false;
+
+       this->initMutex();
+}
+
+void InpaintSimpleOperation::clamp_xy(int & x, int & y) 
+{
+       int width = this->getWidth();
+       int height = this->getHeight();
+
+       if (x < 0) {
+               x = 0;
+       }
+       if (x >= width) {
+               x = width-1;
+       }
+       if (y < 0) {
+               y = 0;
+       }
+       if (y >= height) {
+               y = height -1;
+       }
+}
+
+float InpaintSimpleOperation::get(int x, int y, int component) 
+{
+       int width = this->getWidth();
+
+       clamp_xy(x, y);
+       return this->m_cached_buffer[
+               y * width * COM_NUMBER_OF_CHANNELS 
+               + x * COM_NUMBER_OF_CHANNELS + component];
+}
+
+void InpaintSimpleOperation::set(int x, int y, int component, float v) 
+{
+       int width = this->getWidth();
+
+       this->m_cached_buffer[
+               y * width * COM_NUMBER_OF_CHANNELS 
+               + x * COM_NUMBER_OF_CHANNELS + component] = v;
+}
+
+int InpaintSimpleOperation::mdist(int x, int y) 
+{
+       int width = this->getWidth();
+       clamp_xy(x, y);
+       return this->manhatten_distance[y * width + x];
+}
+
+bool InpaintSimpleOperation::next_pixel(int & x,int & y, int & curr, int iters) 
+{
+       int width = this->getWidth();
+
+       if (curr >= area_size) {
+               return false;
+       }
+       
+       int r = this->pixelorder[curr++];
+
+       x = r % width;
+       y = r / width;
+
+       if (mdist(x, y) > iters) {
+               return false;
+       }
+       
+       return true;
+}
+
+void InpaintSimpleOperation::calc_manhatten_distance() 
+{
+       int width = this->getWidth();
+       int height = this->getHeight();
+       short * m = this->manhatten_distance = new short[width*height];
+       int offsets[width+height+1];
+
+       memset(offsets, 0, sizeof(offsets));
+
+       for (int j = 0; j < height; j++) {
+               for (int i = 0; i < width; i++) {
+                       int r = 0;
+                       if (get(i, j, 3) < 1.0) {
+                               r = width + height;
+                               if (i > 0) 
+                                       r = MIN2(r, m[j*width+i-1]+1);
+                               if (j > 0) 
+                                       r = MIN2(r, m[(j-1)*width+i]+1);
+                       }
+                       m[j*width+i] = r;
+               }
+       }
+       
+       for (int j = height-1; j >= 0; j--) {
+               for (int i = width; i >= 0; i--) {
+                       int r = m[j*width+i];
+                       
+                       if (i + 1 < width) 
+                               r = MIN2(r, m[j*width+i+1]+1);
+                       if (j + 1 < height) 
+                               r = MIN2(r, m[(j+1)*width+i]+1);
+                       
+                       m[j*width+i] = r;
+                       
+                       offsets[r]++;
+               }
+       }
+       
+       offsets[0] = 0;
+       
+       for (int i = 1; i < width + height + 1; i++) {
+               offsets[i] += offsets[i-1];
+       }
+       
+       area_size = offsets[width+height];
+       pixelorder = new int[area_size];
+       
+       for (int i = 0; i < width * height; i++) {
+               if (m[i] > 0) {
+                       pixelorder[offsets[m[i]-1]++] = i;
+               }
+       }
+}
+
+void InpaintSimpleOperation::pix_step(int x, int y)
+{
+       int d = this->mdist(x, y);
+
+       float n = 0;
+
+       float pix[3];
+
+       memset(pix, 0, sizeof(pix));
+
+       for (int dx = -1; dx <= 1; dx++) {
+               for (int dy = -1; dy <= 1; dy++) {
+                       if (dx != 0 && dy != 0 && 
+                           this->mdist(x + dx, y + dy) < d) {
+                               float weight = 1.0f / sqrt(2);
+
+                               if (dx == 0 || dy == 0) {
+                                       weight = 1;
+                               }
+                               
+                               for (int c = 0; c < 3; c++) {
+                                       float fk = this->get(x + dx, y + dy, c);
+
+                                       pix[c] += fk * weight;
+                               }
+                               n += weight;
+                       }
+               }
+       }
+
+       for (int c = 0; c < 3; c++) {
+               this->set(x, y, c, pix[c] / n);
+       }
+}
+
+void *InpaintSimpleOperation::initializeTileData(rcti *rect)
+{
+       if (this->cached_buffer_ready) {
+               return this->m_cached_buffer;
+       }
+       lockMutex();
+       if (!this->cached_buffer_ready) {
+               MemoryBuffer * buf = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
+
+               this->m_cached_buffer = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS];
+               memcpy(this->m_cached_buffer, buf->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
+
+               calc_manhatten_distance();
+
+               int curr = 0;
+               int x,y;
+
+       
+               while (next_pixel(x, y, curr, this->m_iterations)) {
+                       pix_step(x, y);
+               }
+               this->cached_buffer_ready = true;
+       }
+
+       unlockMutex();
+       return this->m_cached_buffer;
+}
+
+void InpaintSimpleOperation::executePixel(float *color, int x, int y, void *data)
+{
+       for (int c = 0; c < 3; c++) {
+               color[c] = get(x,y,c);
+       }
+       color[3] = 1.0f;
+}
+
+void InpaintSimpleOperation::deinitExecution()
+{
+       this->m_inputImageProgram = NULL;
+       this->deinitMutex();
+       if (this->m_cached_buffer) {
+               delete this->m_cached_buffer;
+               this->m_cached_buffer = NULL;
+       }
+
+       if (this->pixelorder) {
+               delete this->pixelorder;
+               this->pixelorder = NULL;
+       }
+
+       if (this->manhatten_distance) {
+               delete this->manhatten_distance;
+               this->manhatten_distance = NULL;
+       }
+       this->cached_buffer_ready = false;
+}
+
+bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+       if (this->cached_buffer_ready) {
+               return false;
+       } else {
+               rcti newInput;
+       
+               newInput.xmax = getWidth();
+               newInput.xmin = 0;
+               newInput.ymax = getHeight();
+               newInput.ymin = 0;
+       
+               return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+       }
+}
+
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.h b/source/blender/compositor/operations/COM_InpaintOperation.h
new file mode 100644 (file)
index 0000000..8ba41a3
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2011, 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: Peter Schlaile
+ *             Jeroen Bakker 
+ *             Monique Dewanchand
+ */
+
+#ifndef _COM_InpaintOperation_h
+#define _COM_InpaintOperation_h
+#include "COM_NodeOperation.h"
+
+class InpaintSimpleOperation : public NodeOperation {
+protected:
+       /**
+        * Cached reference to the inputProgram
+        */
+       SocketReader *m_inputImageProgram;
+       
+       int m_iterations;
+       
+       float *m_cached_buffer;
+       bool cached_buffer_ready;
+
+       int * pixelorder;
+       int area_size;
+       short * manhatten_distance;
+public:
+       InpaintSimpleOperation();
+       
+       /**
+        * the inner loop of this program
+        */
+       void executePixel(float *color, int x, int y, void *data);
+       
+       /**
+        * Initialize the execution
+        */
+       void initExecution();
+       
+       void *initializeTileData(rcti *rect);
+       /**
+        * Deinitialize the execution
+        */
+       void deinitExecution();
+       
+       void setIterations(int iterations) { this->m_iterations = iterations; }
+       
+       bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+private:
+       void calc_manhatten_distance();
+       void clamp_xy(int & x, int & y);
+       float get(int x, int y, int component);
+       void set(int x, int y, int component, float v);
+       int mdist(int x, int y);
+       bool next_pixel(int & x,int & y, int & curr, int iters);
+       void pix_step(int x, int y);
+};
+
+
+#endif
index e83185591fa8453744792fcba7da0c9a8027f4d3..ebaccdc7fb54282bafb60c17a22b5963f92228df 100644 (file)
@@ -1829,6 +1829,11 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C)
        }
 }
 
+static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+       uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
+}
+
 static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
        uiLayout *col;
@@ -2681,6 +2686,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
                case CMP_NODE_DILATEERODE:
                        ntype->uifunc = node_composit_buts_dilateerode;
                        break;
+               case CMP_NODE_INPAINT:
+                       ntype->uifunc = node_composit_buts_inpaint;
+                       break;
                case CMP_NODE_OUTPUT_FILE:
                        ntype->uifunc = node_composit_buts_file_output;
                        ntype->uifuncbut = node_composit_buts_file_output_details;
index c935382bff62b2f413be3ed08b700f2194344d44..e7954c083fe1e872cbf31a9a0a35ebc3d879aad3 100644 (file)
@@ -374,6 +374,10 @@ enum {
        CMP_NODE_DILATEERODE_DISTANCE_FEATHER = 3
 };
 
+enum {
+       CMP_NODE_INPAINT_SIMPLE               = 0
+};
+
 enum {
        CMP_NODEFLAG_MASK_AA          = (1 << 0),
        CMP_NODEFLAG_MASK_NO_FEATHER  = (1 << 1),
index 74adb25d9945b4cc61ecdcd71b70add23778f9f3..8e387dd4eba5998e52e22aca11a289e5ebe4fb25 100644 (file)
@@ -141,6 +141,7 @@ extern StructRNA RNA_CompositorNodeHueSat;
 extern StructRNA RNA_CompositorNodeIDMask;
 extern StructRNA RNA_CompositorNodeDoubleEdgeMask;
 extern StructRNA RNA_CompositorNodeImage;
+extern StructRNA RNA_CompositorNodeInpaint;
 extern StructRNA RNA_CompositorNodeInvert;
 extern StructRNA RNA_CompositorNodeLensdist;
 extern StructRNA RNA_CompositorNodeLevels;
index ae376bad7204370ecb2ab7a04a122626cf3c1a7a..2220aee3f3e8eb977262d833a3a211f275a5852c 100644 (file)
@@ -2145,6 +2145,26 @@ static void def_cmp_dilate_erode(StructRNA *srna)
        RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
+static void def_cmp_inpaint(StructRNA *srna)
+{
+       PropertyRNA *prop;
+
+/*
+       prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+
+       RNA_def_property_enum_sdna(prop, NULL, "custom1");
+       RNA_def_property_enum_items(prop, type_items);
+       RNA_def_property_ui_text(prop, "Type", "Type of inpaint algorithm");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+*/
+       
+       prop = RNA_def_property(srna, "distance", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "custom2");
+       RNA_def_property_range(prop, 1, 100000);
+       RNA_def_property_ui_text(prop, "Distance", "Distance to inpaint (number of iterations)");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
 static void def_cmp_scale(StructRNA *srna)
 {
        PropertyRNA *prop;
index a4837a88b1722a4562b306061f7c0dcf54e912a4..494f147f6d9e203050d4ab18022c0f5590b3e956 100644 (file)
@@ -121,6 +121,7 @@ DefNode( CompositorNode, CMP_NODE_TRANSLATE,      0,                      "TRANS
 DefNode( CompositorNode, CMP_NODE_ZCOMBINE,       def_cmp_zcombine,       "ZCOMBINE",       Zcombine,         "Z Combine",         ""              )
 DefNode( CompositorNode, CMP_NODE_COMBRGBA,       0,                      "COMBRGBA",       CombRGBA,         "Combine RGBA",      ""              )
 DefNode( CompositorNode, CMP_NODE_DILATEERODE,    def_cmp_dilate_erode,   "DILATEERODE",    DilateErode,      "Dilate/Erode",      ""              )
+DefNode( CompositorNode, CMP_NODE_INPAINT,    def_cmp_inpaint,   "INPAINT",    Inpaint,      "Inpaint",      ""              )
 DefNode( CompositorNode, CMP_NODE_ROTATE,         def_cmp_rotate,         "ROTATE",         Rotate,           "Rotate",            ""              )
 DefNode( CompositorNode, CMP_NODE_SCALE,          def_cmp_scale,          "SCALE",          Scale,            "Scale",             ""              )
 DefNode( CompositorNode, CMP_NODE_SEPYCCA,        def_cmp_ycc,            "SEPYCCA",        SepYCCA,          "Separate YCCA",     ""              )
index e8dd4acb63b46499d6423cfff85fcefe569b5aa3..d95751af82f6ee493809f549c9071ecd2190b6a1 100644 (file)
@@ -74,6 +74,7 @@ set(SRC
        composite/nodes/node_composite_huecorrect.c
        composite/nodes/node_composite_idMask.c
        composite/nodes/node_composite_image.c
+       composite/nodes/node_composite_inpaint.c
        composite/nodes/node_composite_invert.c
        composite/nodes/node_composite_keyingscreen.c
        composite/nodes/node_composite_keying.c
index 3b4fa49ea05f0f12c126894d74a0c828b4958963..92e547288c90c427b6799f4a0c22745f29816160 100644 (file)
@@ -80,6 +80,7 @@ void register_node_type_cmp_dblur(struct bNodeTreeType *ttype);
 void register_node_type_cmp_bilateralblur(struct bNodeTreeType *ttype);
 void register_node_type_cmp_vecblur(struct bNodeTreeType *ttype);
 void register_node_type_cmp_dilateerode(struct bNodeTreeType *ttype);
+void register_node_type_cmp_inpaint(struct bNodeTreeType *ttype);
 void register_node_type_cmp_defocus(struct bNodeTreeType *ttype);
 
 void register_node_type_cmp_valtorgb(struct bNodeTreeType *ttype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_inpaint.c b/source/blender/nodes/composite/nodes/node_composite_inpaint.c
new file mode 100644 (file)
index 0000000..e792ef0
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/composite/nodes/node_composite_inpaint.c
+ *  \ingroup cmpnodes
+ */
+
+
+#include "node_composite_util.h"
+
+
+/* **************** Inpaint/ ******************** */
+
+static bNodeSocketTemplate cmp_node_inpaint_in[] = {
+       {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+       {   -1, 0, ""   }
+};
+static bNodeSocketTemplate cmp_node_inpaint_out[] = {
+       {SOCK_RGBA, 0, N_("Image")},
+       {   -1, 0, ""   }
+};
+
+static void node_composit_exec_inpaint(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
+{
+}
+
+void register_node_type_cmp_inpaint(bNodeTreeType *ttype)
+{
+       static bNodeType ntype;
+       
+       node_type_base(ttype, &ntype, CMP_NODE_INPAINT, "Inpaint", NODE_CLASS_OP_FILTER, NODE_OPTIONS);
+       node_type_socket_templates(&ntype, cmp_node_inpaint_in, cmp_node_inpaint_out);
+       node_type_size(&ntype, 130, 100, 320);
+       node_type_exec(&ntype, node_composit_exec_inpaint);
+
+       nodeRegisterType(ttype, &ntype);
+}