~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to source/blender/compositor/nodes/COM_MovieClipNode.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2011, Blender Foundation.
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 *
 
18
 * Contributor: 
 
19
 *              Jeroen Bakker 
 
20
 *              Monique Dewanchand
 
21
 */
 
22
 
 
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"
 
28
 
 
29
extern "C" {
 
30
        #include "DNA_movieclip_types.h"
 
31
        #include "BKE_movieclip.h"
 
32
        #include "BKE_tracking.h"
 
33
        #include "IMB_imbuf.h"
 
34
}
 
35
 
 
36
MovieClipNode::MovieClipNode(bNode *editorNode) : Node(editorNode)
 
37
{
 
38
        /* pass */
 
39
}
 
40
 
 
41
void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 
42
{
 
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);
 
48
        
 
49
        bNode *editorNode = this->getbNode();
 
50
        MovieClip *movieClip = (MovieClip *)editorNode->id;
 
51
        MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage;
 
52
        bool cacheFrame = !context->isRendering();
 
53
 
 
54
        ImBuf *ibuf = NULL;
 
55
        if (movieClip) {
 
56
                if (cacheFrame)
 
57
                        ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser);
 
58
                else
 
59
                        ibuf = BKE_movieclip_get_ibuf_flag(movieClip, movieClipUser, movieClip->flag, MOVIECLIP_CACHE_SKIP);
 
60
        }
 
61
        
 
62
        // always connect the output image
 
63
        MovieClipOperation *operation = new MovieClipOperation();
 
64
        
 
65
        addPreviewOperation(graph, context, operation->getOutputSocket());
 
66
        if (outputMovieClip->isConnected()) {
 
67
                outputMovieClip->relinkConnections(operation->getOutputSocket());
 
68
        }
 
69
 
 
70
        operation->setMovieClip(movieClip);
 
71
        operation->setMovieClipUser(movieClipUser);
 
72
        operation->setFramenumber(context->getFramenumber());
 
73
        operation->setCacheFrame(cacheFrame);
 
74
        graph->addOperation(operation);
 
75
 
 
76
        MovieTrackingStabilization *stab = &movieClip->tracking.stabilization;
 
77
        float loc[2], scale, angle;
 
78
        loc[0] = 0.0f;
 
79
        loc[1] = 0.0f;
 
80
        scale = 1.0f;
 
81
        angle = 0.0f;
 
82
 
 
83
        if (ibuf) {
 
84
                if (stab->flag & TRACKING_2D_STABILIZATION) {
 
85
                        int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, context->getFramenumber());
 
86
 
 
87
                        BKE_tracking_stabilization_data_get(&movieClip->tracking, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle);
 
88
                }
 
89
        }
 
90
        
 
91
        if (offsetXMovieClip->isConnected()) {
 
92
                SetValueOperation *operationSetValue = new SetValueOperation();
 
93
                operationSetValue->setValue(loc[0]);
 
94
                offsetXMovieClip->relinkConnections(operationSetValue->getOutputSocket());
 
95
                graph->addOperation(operationSetValue);
 
96
        }
 
97
        if (offsetYMovieClip->isConnected()) {
 
98
                SetValueOperation *operationSetValue = new SetValueOperation();
 
99
                operationSetValue->setValue(loc[1]);
 
100
                offsetYMovieClip->relinkConnections(operationSetValue->getOutputSocket());
 
101
                graph->addOperation(operationSetValue);
 
102
        }
 
103
        if (scaleMovieClip->isConnected()) {
 
104
                SetValueOperation *operationSetValue = new SetValueOperation();
 
105
                operationSetValue->setValue(scale);
 
106
                scaleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
 
107
                graph->addOperation(operationSetValue);
 
108
        }
 
109
        if (angleMovieClip->isConnected()) {
 
110
                SetValueOperation *operationSetValue = new SetValueOperation();
 
111
                operationSetValue->setValue(angle);
 
112
                angleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
 
113
                graph->addOperation(operationSetValue);
 
114
        }
 
115
 
 
116
        if (ibuf) {
 
117
                IMB_freeImBuf(ibuf);
 
118
        }
 
119
}