[Bf-blender-cvs] [9fa4d370610] compositor-full-frame: Compositor: Full frame Stabilize 2D node

Manuel Castilla noreply at git.blender.org
Mon Aug 2 23:12:21 CEST 2021


Commit: 9fa4d370610c957a7047630268c012f434212381
Author: Manuel Castilla
Date:   Mon Aug 2 21:48:16 2021 +0200
Branches: compositor-full-frame
https://developer.blender.org/rB9fa4d370610c957a7047630268c012f434212381

Compositor: Full frame Stabilize 2D node

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

M	source/blender/compositor/nodes/COM_Stabilize2dNode.cc

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

diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
index 0262f653d1a..7b2388bebca 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
@@ -22,6 +22,7 @@
 #include "COM_RotateOperation.h"
 #include "COM_ScaleOperation.h"
 #include "COM_SetSamplerOperation.h"
+#include "COM_TransformOperation.h"
 #include "COM_TranslateOperation.h"
 
 #include "BKE_tracking.h"
@@ -42,18 +43,12 @@ void Stabilize2dNode::convertToOperations(NodeConverter &converter,
   NodeInput *imageInput = this->getInputSocket(0);
   MovieClip *clip = (MovieClip *)editorNode->id;
   bool invert = (editorNode->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0;
+  const PixelSampler sampler = (PixelSampler)editorNode->custom1;
 
-  ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation();
-  scaleOperation->setSampler((PixelSampler)editorNode->custom1);
-  RotateOperation *rotateOperation = new RotateOperation();
-  rotateOperation->setDoDegree2RadConversion(false);
-  TranslateOperation *translateOperation = new TranslateOperation();
   MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation();
   MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation();
   MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation();
   MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation();
-  SetSamplerOperation *psoperation = new SetSamplerOperation();
-  psoperation->setSampler((PixelSampler)editorNode->custom1);
 
   scaleAttribute->setAttribute(MCA_SCALE);
   scaleAttribute->setFramenumber(context.getFramenumber());
@@ -79,38 +74,67 @@ void Stabilize2dNode::convertToOperations(NodeConverter &converter,
   converter.addOperation(angleAttribute);
   converter.addOperation(xAttribute);
   converter.addOperation(yAttribute);
-  converter.addOperation(scaleOperation);
-  converter.addOperation(translateOperation);
-  converter.addOperation(rotateOperation);
-  converter.addOperation(psoperation);
 
-  converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
-  converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
-
-  converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
-
-  converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
-  converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
-
-  converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
-
-  if (invert) {
-    // Translate -> Rotate -> Scale.
-    converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0));
-
-    converter.addLink(translateOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
-    converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0));
-
-    converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0));
-  }
-  else {
-    // Scale  -> Rotate -> Translate.
-    converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
-
-    converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
-    converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
-
-    converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
+  switch (context.get_execution_model()) {
+    case eExecutionModel::Tiled: {
+      ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation();
+      scaleOperation->setSampler(sampler);
+      RotateOperation *rotateOperation = new RotateOperation();
+      rotateOperation->setDoDegree2RadConversion(false);
+      TranslateOperation *translateOperation = new TranslateOperation();
+      SetSamplerOperation *psoperation = new SetSamplerOperation();
+      psoperation->setSampler(sampler);
+
+      converter.addOperation(scaleOperation);
+      converter.addOperation(translateOperation);
+      converter.addOperation(rotateOperation);
+      converter.addOperation(psoperation);
+
+      converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
+      converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
+
+      converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
+
+      converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
+      converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
+
+      converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
+
+      if (invert) {
+        // Translate -> Rotate -> Scale.
+        converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0));
+
+        converter.addLink(translateOperation->getOutputSocket(),
+                          rotateOperation->getInputSocket(0));
+        converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0));
+
+        converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0));
+      }
+      else {
+        // Scale  -> Rotate -> Translate.
+        converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
+
+        converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+        converter.addLink(rotateOperation->getOutputSocket(),
+                          translateOperation->getInputSocket(0));
+
+        converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
+      }
+      break;
+    }
+    case eExecutionModel::FullFrame: {
+      TransformOperation *transform_op = new TransformOperation();
+      transform_op->set_sampler(sampler);
+      transform_op->set_convert_rotate_degree_to_rad(false);
+      transform_op->set_invert(invert);
+      converter.addOperation(transform_op);
+      converter.mapInputSocket(imageInput, transform_op->getInputSocket(0));
+      converter.addLink(xAttribute->getOutputSocket(), transform_op->getInputSocket(1));
+      converter.addLink(yAttribute->getOutputSocket(), transform_op->getInputSocket(2));
+      converter.addLink(angleAttribute->getOutputSocket(), transform_op->getInputSocket(3));
+      converter.addLink(scaleAttribute->getOutputSocket(), transform_op->getInputSocket(4));
+      converter.mapOutputSocket(getOutputSocket(), transform_op->getOutputSocket());
+    }
   }
 }



More information about the Bf-blender-cvs mailing list