4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "edlsession.h"
27 #include "floatauto.h"
28 #include "floatautos.h"
31 #include "maskautos.h"
32 #include "overlayframe.inc"
33 #include "transportque.inc"
34 #include "vautomation.h"
37 VAutomation::VAutomation(EDL *edl, Track *track)
38 : Automation(edl, track)
44 VAutomation::~VAutomation()
49 void VAutomation::create_objects()
51 Automation::create_objects();
53 autos[AUTOMATION_FADE] = new FloatAutos(edl, track, 100);
54 autos[AUTOMATION_FADE]->create_objects();
56 autos[AUTOMATION_SPEED] = new FloatAutos(edl, track, 1.);
57 autos[AUTOMATION_SPEED]->create_objects();
58 ((FloatAutos*)autos[AUTOMATION_SPEED])->set_float_min(SPEED_MIN);
60 autos[AUTOMATION_MODE] = new IntAutos(edl, track, TRANSFER_NORMAL);
61 autos[AUTOMATION_MODE]->create_objects();
63 autos[AUTOMATION_MASK] = new MaskAutos(edl, track);
64 autos[AUTOMATION_MASK]->create_objects();
66 autos[AUTOMATION_CAMERA_X] = new FloatAutos(edl, track, 0.0);
67 autos[AUTOMATION_CAMERA_X]->create_objects();
69 autos[AUTOMATION_CAMERA_Y] = new FloatAutos(edl, track, 0.0);
70 autos[AUTOMATION_CAMERA_Y]->create_objects();
72 autos[AUTOMATION_PROJECTOR_X] = new FloatAutos(edl, track, 0.0);
73 autos[AUTOMATION_PROJECTOR_X]->create_objects();
75 autos[AUTOMATION_PROJECTOR_Y] = new FloatAutos(edl, track, 0.0);
76 autos[AUTOMATION_PROJECTOR_Y]->create_objects();
78 autos[AUTOMATION_CAMERA_Z] = new FloatAutos(edl, track, 1.0);
79 autos[AUTOMATION_CAMERA_Z]->create_objects();
81 autos[AUTOMATION_PROJECTOR_Z] = new FloatAutos(edl, track, 1.0);
82 autos[AUTOMATION_PROJECTOR_Z]->create_objects();
83 for(int i = 0; i < AUTOMATION_TOTAL; i++) {
84 if( !autos[i] ) continue;
85 autos[i]->autoidx = i;
86 autos[i]->autogrouptype = autogrouptype(i, autos[i]->track);
90 int VAutomation::direct_copy_possible(int64_t start, int direction)
92 int64_t end = (direction == PLAY_FORWARD) ? (start + 1) : (start - 1);
94 if(!Automation::direct_copy_possible(start, direction))
97 // Automation is constant
99 if(((FloatAutos*)autos[AUTOMATION_FADE])->automation_is_constant(
100 start, end, direction, constant))
102 if(!EQUIV(constant, 100))
109 // Track must not be muted
110 if(autos[AUTOMATION_MUTE]->automation_is_constant(start, end))
112 if(autos[AUTOMATION_MUTE]->get_automation_constant(start, end) > 0)
118 // Projector must be centered.
119 FloatAuto *previous = 0, *next = 0;
120 float z = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Z])->
121 get_value(start, direction, previous, next);
122 if(!EQUIV(z, 1)) return 0;
126 float x = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_X])->
127 get_value(start, direction, previous, next);
128 if(!EQUIV(x, 0)) return 0;
131 float y = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Y])->
132 get_value(start, direction, previous, next);
133 if(!EQUIV(y, 0)) return 0;
138 // Camera must be centered
141 z = ((FloatAutos*)autos[AUTOMATION_CAMERA_Z])->
142 get_value(start, direction, previous, next);
143 if(!EQUIV(z, 1)) return 0;
149 x = ((FloatAutos*)autos[AUTOMATION_CAMERA_X])->
150 get_value(start, direction, previous, next);
151 if(!EQUIV(x, 0)) return 0;
155 y = ((FloatAutos*)autos[AUTOMATION_CAMERA_Y])->
156 get_value(start, direction, previous, next);
158 if(!EQUIV(y, 0)) return 0;
160 // No mask must exist
161 if(((MaskAutos*)autos[AUTOMATION_MASK])->mask_exists(start, direction))
167 void VAutomation::get_projector(float *x,
173 FloatAuto *before, *after;
176 *x = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_X])->
177 get_value(position, direction, before, after);
180 *y = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Y])->
181 get_value(position, direction, before, after);
184 *z = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Z])->
185 get_value(position, direction, before, after);
189 void VAutomation::get_camera(float *x,
195 FloatAuto *before, *after;
198 *x = ((FloatAutos*)autos[AUTOMATION_CAMERA_X])->
199 get_value(position, direction, before, after);
202 *y = ((FloatAutos*)autos[AUTOMATION_CAMERA_Y])->
203 get_value(position, direction, before, after);
206 *z = ((FloatAutos*)autos[AUTOMATION_CAMERA_Z])->
207 get_value(position, direction, before, after);