2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#include "COM_MovieClipNode.h"
24
#include "COM_ExecutionSystem.h"
25
#include "COM_MovieClipOperation.h"
26
#include "COM_SetValueOperation.h"
27
#include "COM_ConvertColorProfileOperation.h"
30
#include "DNA_movieclip_types.h"
31
#include "BKE_movieclip.h"
32
#include "BKE_tracking.h"
33
#include "IMB_imbuf.h"
36
MovieClipNode::MovieClipNode(bNode *editorNode) : Node(editorNode)
41
void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
43
OutputSocket *outputMovieClip = this->getOutputSocket(0);
44
OutputSocket *offsetXMovieClip = this->getOutputSocket(1);
45
OutputSocket *offsetYMovieClip = this->getOutputSocket(2);
46
OutputSocket *scaleMovieClip = this->getOutputSocket(3);
47
OutputSocket *angleMovieClip = this->getOutputSocket(4);
49
bNode *editorNode = this->getbNode();
50
MovieClip *movieClip = (MovieClip *)editorNode->id;
51
MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage;
52
bool cacheFrame = !context->isRendering();
57
ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser);
59
ibuf = BKE_movieclip_get_ibuf_flag(movieClip, movieClipUser, movieClip->flag, MOVIECLIP_CACHE_SKIP);
62
// always connect the output image
63
MovieClipOperation *operation = new MovieClipOperation();
65
addPreviewOperation(graph, context, operation->getOutputSocket());
66
if (outputMovieClip->isConnected()) {
67
outputMovieClip->relinkConnections(operation->getOutputSocket());
70
operation->setMovieClip(movieClip);
71
operation->setMovieClipUser(movieClipUser);
72
operation->setFramenumber(context->getFramenumber());
73
operation->setCacheFrame(cacheFrame);
74
graph->addOperation(operation);
76
MovieTrackingStabilization *stab = &movieClip->tracking.stabilization;
77
float loc[2], scale, angle;
84
if (stab->flag & TRACKING_2D_STABILIZATION) {
85
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, context->getFramenumber());
87
BKE_tracking_stabilization_data_get(&movieClip->tracking, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle);
91
if (offsetXMovieClip->isConnected()) {
92
SetValueOperation *operationSetValue = new SetValueOperation();
93
operationSetValue->setValue(loc[0]);
94
offsetXMovieClip->relinkConnections(operationSetValue->getOutputSocket());
95
graph->addOperation(operationSetValue);
97
if (offsetYMovieClip->isConnected()) {
98
SetValueOperation *operationSetValue = new SetValueOperation();
99
operationSetValue->setValue(loc[1]);
100
offsetYMovieClip->relinkConnections(operationSetValue->getOutputSocket());
101
graph->addOperation(operationSetValue);
103
if (scaleMovieClip->isConnected()) {
104
SetValueOperation *operationSetValue = new SetValueOperation();
105
operationSetValue->setValue(scale);
106
scaleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
107
graph->addOperation(operationSetValue);
109
if (angleMovieClip->isConnected()) {
110
SetValueOperation *operationSetValue = new SetValueOperation();
111
operationSetValue->setValue(angle);
112
angleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
113
graph->addOperation(operationSetValue);