r1006: configure: Use libx264_pic instead of libx264 if available.
[cinelerra_cv/mob.git] / cinelerra / vautomation.C
bloba6d8ee17a941eaa3d4985057a0eaa0af5c7fbe74
1 #include "clip.h"
2 #include "colors.h"
3 #include "edl.h"
4 #include "edlsession.h"
5 #include "floatauto.h"
6 #include "floatautos.h"
7 #include "intauto.h"
8 #include "intautos.h"
9 #include "maskautos.h"
10 #include "overlayframe.inc"
11 #include "transportque.inc"
12 #include "vautomation.h"
15 VAutomation::VAutomation(EDL *edl, Track *track)
16  : Automation(edl, track)
22 VAutomation::~VAutomation()
27 int VAutomation::create_objects()
29         Automation::create_objects();
31         autos[AUTOMATION_FADE] = new FloatAutos(edl, track, 100);
32         autos[AUTOMATION_FADE]->create_objects();
34         autos[AUTOMATION_MODE] = new IntAutos(edl, track, TRANSFER_NORMAL);
35         autos[AUTOMATION_MODE]->create_objects();
37         autos[AUTOMATION_MASK] = new MaskAutos(edl, track);
38         autos[AUTOMATION_MASK]->create_objects();
40         autos[AUTOMATION_CAMERA_X] = new FloatAutos(edl, track, 0.0);
41         autos[AUTOMATION_CAMERA_X]->create_objects();
43         autos[AUTOMATION_CAMERA_Y] = new FloatAutos(edl, track, 0.0);
44         autos[AUTOMATION_CAMERA_Y]->create_objects();
46         autos[AUTOMATION_PROJECTOR_X] = new FloatAutos(edl, track, 0.0);
47         autos[AUTOMATION_PROJECTOR_X]->create_objects();
49         autos[AUTOMATION_PROJECTOR_Y] = new FloatAutos(edl, track, 0.0);
50         autos[AUTOMATION_PROJECTOR_Y]->create_objects();
52         autos[AUTOMATION_CAMERA_Z] = new FloatAutos(edl, track, 1.0);
53         autos[AUTOMATION_CAMERA_Z]->create_objects();
55         autos[AUTOMATION_PROJECTOR_Z] = new FloatAutos(edl, track, 1.0);
56         autos[AUTOMATION_PROJECTOR_Z]->create_objects();
58 //      autos[AUTOMATION_NUDGE] = new FloatAutos(edl, track, 0.0);
59 //      autos[AUTOMATION_NUDGE]->create_objects();
61         for(int i = 0; i < AUTOMATION_TOTAL; i++)
62                 if (autos[i]) 
63                 {
64                         autos[i]->autoidx = i;
65                         autos[i]->autogrouptype = autogrouptype(i, autos[i]->track);
66                 }
68         return 0;
71 int VAutomation::direct_copy_possible(int64_t start, int direction)
73         int64_t end = (direction == PLAY_FORWARD) ? (start + 1) : (start - 1);
75         if(!Automation::direct_copy_possible(start, direction))
76                 return 0;
78 // Automation is constant
79         double constant;
80         if(((FloatAutos*)autos[AUTOMATION_FADE])->automation_is_constant(
81                 start, 1, direction, constant))
82         {
83                 if(!EQUIV(constant, 100))
84                         return 0;
85         }
86         else
87 // Automation varies
88                 return 0;
90 // Track must not be muted
91         if(autos[AUTOMATION_MUTE]->automation_is_constant(start, end))
92         {
93                 if(autos[AUTOMATION_MUTE]->get_automation_constant(start, end) > 0)
94                         return 0;
95         }
96         else
97                 return 0;
99 // Projector must be centered.
100         FloatAuto *previous = 0, *next = 0;
101         float z = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Z])->get_value(
102                 start, direction, previous, next);
103         if(!EQUIV(z, 1)) return 0;
105         previous = 0;
106         next = 0;
107         float x = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_X])->get_value(start,
108                                 direction,
109                                 previous, 
110                                 next);
111         if(!EQUIV(x, 0)) return 0;
112         previous = 0;
113         next = 0;
114         float y = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Y])->get_value(start,
115                                 direction,
116                                 previous, 
117                                 next);
118         if(!EQUIV(y, 0)) return 0;
123 // Camera must be centered
124         previous = 0;
125         next = 0;
126         z = ((FloatAutos*)autos[AUTOMATION_CAMERA_Z])->get_value(
127                 start, 
128                 direction, 
129                 previous, 
130                 next);
131         if(!EQUIV(z, 1)) return 0;
135         previous = 0;
136         next = 0;
137         x = ((FloatAutos*)autos[AUTOMATION_CAMERA_X])->get_value(start,
138                                 direction,
139                                 previous, 
140                                 next);
141         if(!EQUIV(x, 0)) return 0;
143         previous = 0;
144         next = 0;
145         y = ((FloatAutos*)autos[AUTOMATION_CAMERA_Y])->get_value(start,
146                                 direction,
147                                 previous, 
148                                 next);
150         if(!EQUIV(y, 0)) return 0;
152 // No mask must exist
153         if(((MaskAutos*)autos[AUTOMATION_MASK])->mask_exists(start, direction))
154                 return 0;
156         return 1;
159 void VAutomation::get_projector(float *x, 
160         float *y, 
161         float *z, 
162         int64_t position,
163         int direction)
165         FloatAuto *before, *after;
166         before = 0;
167         after = 0;
168         *x = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_X])->get_value(position,
169                 direction,
170                 before,
171                 after);
172         before = 0;
173         after = 0;
174         *y = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Y])->get_value(position,
175                 direction,
176                 before,
177                 after);
178         before = 0;
179         after = 0;
180         *z = ((FloatAutos*)autos[AUTOMATION_PROJECTOR_Z])->get_value(position,
181                 direction,
182                 before,
183                 after);
187 void VAutomation::get_camera(float *x, 
188         float *y, 
189         float *z, 
190         int64_t position,
191         int direction)
193         FloatAuto *before, *after;
194         before = 0;
195         after = 0;
196         *x = ((FloatAutos*)autos[AUTOMATION_CAMERA_X])->get_value(position,
197                 direction,
198                 before,
199                 after);
200         before = 0;
201         after = 0;
202         *y = ((FloatAutos*)autos[AUTOMATION_CAMERA_Y])->get_value(position,
203                 direction,
204                 before,
205                 after);
206         before = 0;
207         after = 0;
208         *z = ((FloatAutos*)autos[AUTOMATION_CAMERA_Z])->get_value(position,
209                 direction,
210                 before,
211                 after);