diff options
Diffstat (limited to 'source/blender/compositor/nodes/COM_Stabilize2dNode.cc')
-rw-r--r-- | source/blender/compositor/nodes/COM_Stabilize2dNode.cc | 211 |
1 files changed, 113 insertions, 98 deletions
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc index 48eeb337842..9892c4f5c05 100644 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc @@ -25,145 +25,160 @@ namespace blender::compositor { -Stabilize2dNode::Stabilize2dNode(bNode *editorNode) : Node(editorNode) +Stabilize2dNode::Stabilize2dNode(bNode *editor_node) : Node(editor_node) { /* pass */ } -void Stabilize2dNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const +void Stabilize2dNode::convert_to_operations(NodeConverter &converter, + const CompositorContext &context) const { - bNode *editorNode = this->getbNode(); - 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; - - MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation(); - MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation(); - MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation(); - MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation(); - - scaleAttribute->setAttribute(MCA_SCALE); - scaleAttribute->setFramenumber(context.getFramenumber()); - scaleAttribute->setMovieClip(clip); - scaleAttribute->setInvert(invert); - - angleAttribute->setAttribute(MCA_ANGLE); - angleAttribute->setFramenumber(context.getFramenumber()); - angleAttribute->setMovieClip(clip); - angleAttribute->setInvert(invert); - - xAttribute->setAttribute(MCA_X); - xAttribute->setFramenumber(context.getFramenumber()); - xAttribute->setMovieClip(clip); - xAttribute->setInvert(invert); - - yAttribute->setAttribute(MCA_Y); - yAttribute->setFramenumber(context.getFramenumber()); - yAttribute->setMovieClip(clip); - yAttribute->setInvert(invert); - - converter.addOperation(scaleAttribute); - converter.addOperation(angleAttribute); - converter.addOperation(xAttribute); - converter.addOperation(yAttribute); + bNode *editor_node = this->get_bnode(); + NodeInput *image_input = this->get_input_socket(0); + MovieClip *clip = (MovieClip *)editor_node->id; + bool invert = (editor_node->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0; + const PixelSampler sampler = (PixelSampler)editor_node->custom1; + + MovieClipAttributeOperation *scale_attribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *angle_attribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *x_attribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *y_attribute = new MovieClipAttributeOperation(); + + scale_attribute->set_attribute(MCA_SCALE); + scale_attribute->set_framenumber(context.get_framenumber()); + scale_attribute->set_movie_clip(clip); + scale_attribute->set_invert(invert); + + angle_attribute->set_attribute(MCA_ANGLE); + angle_attribute->set_framenumber(context.get_framenumber()); + angle_attribute->set_movie_clip(clip); + angle_attribute->set_invert(invert); + + x_attribute->set_attribute(MCA_X); + x_attribute->set_framenumber(context.get_framenumber()); + x_attribute->set_movie_clip(clip); + x_attribute->set_invert(invert); + + y_attribute->set_attribute(MCA_Y); + y_attribute->set_framenumber(context.get_framenumber()); + y_attribute->set_movie_clip(clip); + y_attribute->set_invert(invert); + + converter.add_operation(scale_attribute); + converter.add_operation(angle_attribute); + converter.add_operation(x_attribute); + converter.add_operation(y_attribute); 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(); + ScaleRelativeOperation *scale_operation = new ScaleRelativeOperation(); + scale_operation->set_sampler(sampler); + RotateOperation *rotate_operation = new RotateOperation(); + rotate_operation->set_do_degree2_rad_conversion(false); + TranslateOperation *translate_operation = new TranslateOperation(); SetSamplerOperation *psoperation = new SetSamplerOperation(); - psoperation->setSampler(sampler); + psoperation->set_sampler(sampler); - converter.addOperation(scaleOperation); - converter.addOperation(translateOperation); - converter.addOperation(rotateOperation); - converter.addOperation(psoperation); + converter.add_operation(scale_operation); + converter.add_operation(translate_operation); + converter.add_operation(rotate_operation); + converter.add_operation(psoperation); - converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1)); - converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2)); + converter.add_link(scale_attribute->get_output_socket(), + scale_operation->get_input_socket(1)); + converter.add_link(scale_attribute->get_output_socket(), + scale_operation->get_input_socket(2)); - converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1)); + converter.add_link(angle_attribute->get_output_socket(), + rotate_operation->get_input_socket(1)); - converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1)); - converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2)); + converter.add_link(x_attribute->get_output_socket(), + translate_operation->get_input_socket(1)); + converter.add_link(y_attribute->get_output_socket(), + translate_operation->get_input_socket(2)); - converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket()); + converter.map_output_socket(get_output_socket(), psoperation->get_output_socket()); if (invert) { /* Translate -> Rotate -> Scale. */ - converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0)); + converter.map_input_socket(image_input, translate_operation->get_input_socket(0)); - converter.addLink(translateOperation->getOutputSocket(), - rotateOperation->getInputSocket(0)); - converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0)); + converter.add_link(translate_operation->get_output_socket(), + rotate_operation->get_input_socket(0)); + converter.add_link(rotate_operation->get_output_socket(), + scale_operation->get_input_socket(0)); - converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0)); + converter.add_link(scale_operation->get_output_socket(), psoperation->get_input_socket(0)); } else { /* Scale -> Rotate -> Translate. */ - converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0)); + converter.map_input_socket(image_input, scale_operation->get_input_socket(0)); - converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); - converter.addLink(rotateOperation->getOutputSocket(), - translateOperation->getInputSocket(0)); + converter.add_link(scale_operation->get_output_socket(), + rotate_operation->get_input_socket(0)); + converter.add_link(rotate_operation->get_output_socket(), + translate_operation->get_input_socket(0)); - converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0)); + converter.add_link(translate_operation->get_output_socket(), + psoperation->get_input_socket(0)); } break; } case eExecutionModel::FullFrame: { - ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation(); - scaleOperation->setSampler(sampler); - RotateOperation *rotateOperation = new RotateOperation(); - rotateOperation->setDoDegree2RadConversion(false); - rotateOperation->set_sampler(sampler); - TranslateOperation *translateOperation = new TranslateCanvasOperation(); - - converter.addOperation(scaleOperation); - converter.addOperation(translateOperation); - converter.addOperation(rotateOperation); - - 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)); + ScaleRelativeOperation *scale_operation = new ScaleRelativeOperation(); + scale_operation->set_sampler(sampler); + RotateOperation *rotate_operation = new RotateOperation(); + rotate_operation->set_do_degree2_rad_conversion(false); + rotate_operation->set_sampler(sampler); + TranslateOperation *translate_operation = new TranslateCanvasOperation(); + + converter.add_operation(scale_operation); + converter.add_operation(translate_operation); + converter.add_operation(rotate_operation); + + converter.add_link(scale_attribute->get_output_socket(), + scale_operation->get_input_socket(1)); + converter.add_link(scale_attribute->get_output_socket(), + scale_operation->get_input_socket(2)); + + converter.add_link(angle_attribute->get_output_socket(), + rotate_operation->get_input_socket(1)); + + converter.add_link(x_attribute->get_output_socket(), + translate_operation->get_input_socket(1)); + converter.add_link(y_attribute->get_output_socket(), + translate_operation->get_input_socket(2)); NodeOperationInput *stabilization_socket = nullptr; if (invert) { /* Translate -> Rotate -> Scale. */ - stabilization_socket = translateOperation->getInputSocket(0); - converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0)); + stabilization_socket = translate_operation->get_input_socket(0); + converter.map_input_socket(image_input, translate_operation->get_input_socket(0)); - converter.addLink(translateOperation->getOutputSocket(), - rotateOperation->getInputSocket(0)); - converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0)); + converter.add_link(translate_operation->get_output_socket(), + rotate_operation->get_input_socket(0)); + converter.add_link(rotate_operation->get_output_socket(), + scale_operation->get_input_socket(0)); - converter.mapOutputSocket(getOutputSocket(), scaleOperation->getOutputSocket()); + converter.map_output_socket(get_output_socket(), scale_operation->get_output_socket()); } else { /* Scale -> Rotate -> Translate. */ - stabilization_socket = scaleOperation->getInputSocket(0); - converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0)); + stabilization_socket = scale_operation->get_input_socket(0); + converter.map_input_socket(image_input, scale_operation->get_input_socket(0)); - converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); - converter.addLink(rotateOperation->getOutputSocket(), - translateOperation->getInputSocket(0)); + converter.add_link(scale_operation->get_output_socket(), + rotate_operation->get_input_socket(0)); + converter.add_link(rotate_operation->get_output_socket(), + translate_operation->get_input_socket(0)); - converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket()); + converter.map_output_socket(get_output_socket(), translate_operation->get_output_socket()); } - xAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket); - yAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket); - scaleAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket); - angleAttribute->set_socket_input_resolution_for_stabilization(stabilization_socket); + x_attribute->set_socket_input_resolution_for_stabilization(stabilization_socket); + y_attribute->set_socket_input_resolution_for_stabilization(stabilization_socket); + scale_attribute->set_socket_input_resolution_for_stabilization(stabilization_socket); + angle_attribute->set_socket_input_resolution_for_stabilization(stabilization_socket); break; } } |