r1006: configure: Use libx264_pic instead of libx264 if available.
[cinelerra_cv/mob.git] / cinelerra / intautos.C
blobcb8ac8c14d310ad0789743c700062d7a7cda55d3
1 #include "automation.inc"
2 #include "clip.h"
3 #include "intauto.h"
4 #include "intautos.h"
6 IntAutos::IntAutos(EDL *edl, Track *track, int default_)
7  : Autos(edl, track)
9         this->default_ = default_;
10         type = AUTOMATION_TYPE_INT;
13 IntAutos::~IntAutos()
18 Auto* IntAutos::new_auto()
20         IntAuto *result = new IntAuto(edl, this);
21         result->value = default_;
22         return result;
25 int IntAutos::automation_is_constant(int64_t start, int64_t end)
27         Auto *current_auto, *before = 0, *after = 0;
28         int result;
30         result = 1;          // default to constant
31         if(!last && !first) return result; // no automation at all
33 // quickly get autos just outside range 
34         get_neighbors(start, end, &before, &after);
36 // autos before range
37         if(before) 
38                 current_auto = before;   // try first auto
39         else 
40                 current_auto = first;
42 // test autos in range  
43         for( ; result && 
44                 current_auto && 
45                 current_auto->next && 
46                 current_auto->position < end; 
47                 current_auto = current_auto->next)
48         {
49 // not constant
50                 if(((IntAuto*)current_auto->next)->value != ((IntAuto*)current_auto)->value) 
51                         result = 0;
52         }
54         return result;
57 double IntAutos::get_automation_constant(int64_t start, int64_t end)
59         Auto *current_auto, *before = 0, *after = 0;
60         
61 // quickly get autos just outside range 
62         get_neighbors(start, end, &before, &after);
64 // no auto before range so use first
65         if(before)
66                 current_auto = before;
67         else
68                 current_auto = first;
70 // no autos at all so use default value
71         if(!current_auto) current_auto = default_auto;
73         return ((IntAuto*)current_auto)->value;
77 void IntAutos::get_extents(float *min, 
78         float *max,
79         int *coords_undefined,
80         int64_t unit_start,
81         int64_t unit_end)
83         if(!first)
84         {
85                 IntAuto *current = (IntAuto*)default_auto;
86                 if(*coords_undefined)
87                 {
88                         *min = *max = current->value;
89                         *coords_undefined = 0;
90                 }
92                 *min = MIN(current->value, *min);
93                 *max = MAX(current->value, *max);
94         }
96         for(IntAuto *current = (IntAuto*)first; current; current = (IntAuto*)NEXT)
97         {
98                 if(current->position >= unit_start && current->position < unit_end)
99                 {
100                         if(coords_undefined)
101                         {
102                                 *max = *min = current->value;
103                                 *coords_undefined = 0;
104                         }
105                         else
106                         {
107                                 *min = MIN(current->value, *min);
108                                 *max = MAX(current->value, *max);
109                         }
110                 }
111         }
114 void IntAutos::dump()
116         printf("        Default %p: position: %ld value: %d\n", default_auto, default_auto->position, ((IntAuto*)default_auto)->value);
117         for(Auto* current = first; current; current = NEXT)
118         {
119                 printf("        %p position: %ld value: %d\n", current, current->position, ((IntAuto*)current)->value);
120         }