update shuttlerc, fix vwdw lock update_position
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / bluebanana / bluebananaconfig.C
1 /*
2  * Cinelerra :: Blue Banana - color modification plugin for Cinelerra-CV
3  * Copyright (C) 2012-2013 Monty <monty@xiph.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #include "clip.h"
22 #include "bluebananaconfig.h"
23 #include "units.h"
24
25 #include <math.h>
26
27 BluebananaConfig::BluebananaConfig() {
28   op = 0;
29   mark = 0;
30   active = 1;
31   use_mask = 0;
32   capture_mask = 1; // has no effect if use_mask is off
33   invert_selection = 0;
34
35   Hsel_active=1;
36   Hsel_lo=0;
37   Hsel_hi=360;
38   Hsel_over=36;
39
40   Ssel_active=1;
41   Ssel_lo=0;
42   Ssel_hi=100;
43   Ssel_over=10;
44
45   Vsel_active=1;
46   Vsel_lo=0;
47   Vsel_hi=100;
48   Vsel_over=10;
49
50   Fsel_active=0;
51   Fsel_erode=0;
52   Fsel_lo=-2;
53   Fsel_mid=0;
54   Fsel_hi=2;
55   Fsel_over=5;
56
57   Hadj_active=0;
58   Hadj_val=0;
59
60   Sadj_active=0;
61   Sadj_lo=0;
62   Sadj_gamma=1;
63   Sadj_hi=100;
64
65   Vadj_active=0;
66   Vadj_lo=0;
67   Vadj_gamma=1;
68   Vadj_hi=100;
69
70   Radj_active=0;
71   Radj_lo=0;
72   Radj_gamma=1;
73   Radj_hi=100;
74
75   Gadj_active=0;
76   Gadj_lo=0;
77   Gadj_gamma=1;
78   Gadj_hi=100;
79
80   Badj_active=0;
81   Badj_lo=0;
82   Badj_gamma=1;
83   Badj_hi=100;
84
85   Oadj_active=0;
86   Oadj_val=100;
87   Aadj_active=0;
88   Aadj_val=100;
89
90 }
91
92 int BluebananaConfig::equivalent(BluebananaConfig &that) {
93   if(active != that.active) return 0;
94   // mark is no an auto
95   if(op != that.op) return 0;
96   if(use_mask != that.use_mask) return 0;
97   if(capture_mask != that.capture_mask) return 0;
98   if(invert_selection != that.invert_selection) return 0;
99
100   if(Hsel_active != that.Hsel_active) return 0;
101   if(Hsel_lo != that.Hsel_lo) return 0;
102   if(Hsel_hi != that.Hsel_hi) return 0;
103   if(Hsel_over != that.Hsel_over) return 0;
104
105   if(Ssel_active != that.Ssel_active) return 0;
106   if(Ssel_lo != that.Ssel_lo) return 0;
107   if(Ssel_hi != that.Ssel_hi) return 0;
108   if(Ssel_over != that.Ssel_over) return 0;
109
110   if(Vsel_active != that.Vsel_active) return 0;
111   if(Vsel_lo != that.Vsel_lo) return 0;
112   if(Vsel_hi != that.Vsel_hi) return 0;
113   if(Vsel_over != that.Vsel_over) return 0;
114
115   if(Fsel_active != that.Fsel_active) return 0;
116   if(Fsel_erode != that.Fsel_erode) return 0;
117   if(Fsel_lo != that.Fsel_lo) return 0;
118   if(Fsel_mid != that.Fsel_mid) return 0;
119   if(Fsel_hi != that.Fsel_hi) return 0;
120   if(Fsel_over != that.Fsel_over) return 0;
121
122   if(Hadj_active != that.Hadj_active) return 0;
123   if(Hadj_val != that.Hadj_val) return 0;
124
125   if(Oadj_active != that.Oadj_active) return 0;
126   if(Oadj_val != that.Oadj_val) return 0;
127   if(Aadj_active != that.Aadj_active) return 0;
128   if(Aadj_val != that.Aadj_val) return 0;
129
130   if(Sadj_active != that.Sadj_active) return 0;
131   if(Sadj_gamma != that.Sadj_gamma) return 0;
132   if(Sadj_lo != that.Sadj_lo) return 0;
133   if(Sadj_hi != that.Sadj_hi) return 0;
134
135   if(Vadj_active != that.Vadj_active) return 0;
136   if(Vadj_gamma != that.Vadj_gamma) return 0;
137   if(Vadj_lo != that.Vadj_lo) return 0;
138   if(Vadj_hi != that.Vadj_hi) return 0;
139
140   if(Radj_active != that.Radj_active) return 0;
141   if(Radj_gamma != that.Radj_gamma) return 0;
142   if(Radj_lo != that.Radj_lo) return 0;
143   if(Radj_hi != that.Radj_hi) return 0;
144
145   if(Gadj_active != that.Gadj_active) return 0;
146   if(Gadj_gamma != that.Gadj_gamma) return 0;
147   if(Gadj_lo != that.Gadj_lo) return 0;
148   if(Gadj_hi != that.Gadj_hi) return 0;
149
150   if(Badj_active != that.Badj_active) return 0;
151   if(Badj_gamma != that.Badj_gamma) return 0;
152   if(Badj_lo != that.Badj_lo) return 0;
153   if(Badj_hi != that.Badj_hi) return 0;
154
155   return 1;
156 }
157
158 void BluebananaConfig::copy_from(BluebananaConfig &that) {
159   mark = that.mark;
160   op = that.op;
161   active = that.active;
162   use_mask = that.use_mask;
163   capture_mask = that.capture_mask;
164   invert_selection = that.invert_selection;
165
166   Hsel_active = that.Hsel_active;
167   Hsel_lo = that.Hsel_lo;
168   Hsel_hi = that.Hsel_hi;
169   Hsel_over = that.Hsel_over;
170   Ssel_active = that.Ssel_active;
171   Ssel_lo = that.Ssel_lo;
172   Ssel_hi = that.Ssel_hi;
173   Ssel_over = that.Ssel_over;
174   Vsel_active = that.Vsel_active;
175   Vsel_lo = that.Vsel_lo;
176   Vsel_hi = that.Vsel_hi;
177   Vsel_over = that.Vsel_over;
178   Fsel_active = that.Fsel_active;
179   Fsel_erode = that.Fsel_erode;
180   Fsel_lo = that.Fsel_lo;
181   Fsel_mid = that.Fsel_mid;
182   Fsel_hi = that.Fsel_hi;
183   Fsel_over = that.Fsel_over;
184
185   Hadj_active = that.Hadj_active;
186   Hadj_val = that.Hadj_val;
187
188   Sadj_active = that.Sadj_active;
189   Sadj_gamma = that.Sadj_gamma;
190   Sadj_lo = that.Sadj_lo;
191   Sadj_hi = that.Sadj_hi;
192
193   Vadj_active = that.Vadj_active;
194   Vadj_gamma = that.Vadj_gamma;
195   Vadj_lo = that.Vadj_lo;
196   Vadj_hi = that.Vadj_hi;
197
198   Radj_active = that.Radj_active;
199   Radj_gamma = that.Radj_gamma;
200   Radj_lo = that.Radj_lo;
201   Radj_hi = that.Radj_hi;
202
203   Gadj_active = that.Gadj_active;
204   Gadj_gamma = that.Gadj_gamma;
205   Gadj_lo = that.Gadj_lo;
206   Gadj_hi = that.Gadj_hi;
207
208   Badj_active = that.Badj_active;
209   Badj_gamma = that.Badj_gamma;
210   Badj_lo = that.Badj_lo;
211   Badj_hi = that.Badj_hi;
212
213   Oadj_active = that.Oadj_active;
214   Oadj_val = that.Oadj_val;
215   Aadj_active = that.Aadj_active;
216   Aadj_val = that.Aadj_val;
217 }
218
219 void BluebananaConfig::interpolate(BluebananaConfig &prev,
220                                    BluebananaConfig &next,
221                                    int64_t prev_frame,
222                                    int64_t next_frame,
223                                    int64_t current_frame) {
224
225   double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
226   double prev_scale = 1.0 - next_scale;
227
228   op = prev.op;
229   active = prev.active;
230   use_mask = prev.use_mask;
231   capture_mask = prev.capture_mask;
232   invert_selection = prev.invert_selection;
233
234   Hsel_active = prev.Hsel_active;
235   Ssel_active = prev.Ssel_active;
236   Vsel_active = prev.Vsel_active;
237   Fsel_active = prev.Fsel_active;
238   Fsel_erode = prev.Fsel_erode;
239   Hadj_active = prev.Hadj_active;
240   Sadj_active = prev.Sadj_active;
241   Vadj_active = prev.Vadj_active;
242   Radj_active = prev.Radj_active;
243   Gadj_active = prev.Gadj_active;
244   Badj_active = prev.Badj_active;
245   Oadj_active = prev.Oadj_active;
246
247   Hsel_lo = ( prev.Hsel_lo*prev_scale + next.Hsel_lo*next_scale);
248   Hsel_hi = ( prev.Hsel_hi*prev_scale + next.Hsel_hi*next_scale);
249   Hsel_over = ( prev.Hsel_over*prev_scale + next.Hsel_over*next_scale);
250
251   Ssel_lo = ( prev.Ssel_lo*prev_scale + next.Ssel_lo*next_scale);
252   Ssel_hi = ( prev.Ssel_hi*prev_scale + next.Ssel_hi*next_scale);
253   Ssel_over = ( prev.Ssel_over*prev_scale + next.Ssel_over*next_scale);
254
255   Vsel_lo = ( prev.Vsel_lo*prev_scale + next.Vsel_lo*next_scale);
256   Vsel_hi = ( prev.Vsel_hi*prev_scale + next.Vsel_hi*next_scale);
257   Vsel_over = ( prev.Vsel_over*prev_scale + next.Vsel_over*next_scale);
258
259   Fsel_lo = ( prev.Fsel_lo*prev_scale + next.Fsel_lo*next_scale);
260   Fsel_mid = ( prev.Fsel_mid*prev_scale + next.Fsel_mid*next_scale);
261   Fsel_hi = ( prev.Fsel_hi*prev_scale + next.Fsel_hi*next_scale);
262   Fsel_over = ( prev.Fsel_over*prev_scale + next.Fsel_over*next_scale);
263
264   Hadj_val = ( prev.Hadj_val*prev_scale + next.Hadj_val*next_scale);
265   Oadj_val = ( prev.Oadj_val*prev_scale + next.Oadj_val*next_scale);
266   Aadj_val = ( prev.Aadj_val*prev_scale + next.Aadj_val*next_scale);
267
268   Sadj_gamma = ( prev.Sadj_gamma*prev_scale + next.Sadj_gamma*next_scale);
269   Sadj_lo = ( prev.Sadj_lo*prev_scale + next.Sadj_lo*next_scale);
270   Sadj_hi = ( prev.Sadj_hi*prev_scale + next.Sadj_hi*next_scale);
271
272   Vadj_gamma = ( prev.Vadj_gamma*prev_scale + next.Vadj_gamma*next_scale);
273   Vadj_lo = ( prev.Vadj_lo*prev_scale + next.Vadj_lo*next_scale);
274   Vadj_hi = ( prev.Vadj_hi*prev_scale + next.Vadj_hi*next_scale);
275
276   Radj_gamma = ( prev.Radj_gamma*prev_scale + next.Radj_gamma*next_scale);
277   Radj_lo = ( prev.Radj_lo*prev_scale + next.Radj_lo*next_scale);
278   Radj_hi = ( prev.Radj_hi*prev_scale + next.Radj_hi*next_scale);
279
280   Gadj_gamma = ( prev.Gadj_gamma*prev_scale + next.Gadj_gamma*next_scale);
281   Gadj_lo = ( prev.Gadj_lo*prev_scale + next.Gadj_lo*next_scale);
282   Gadj_hi = ( prev.Gadj_hi*prev_scale + next.Gadj_hi*next_scale);
283
284   Badj_gamma = ( prev.Badj_gamma*prev_scale + next.Badj_gamma*next_scale);
285   Badj_lo = ( prev.Badj_lo*prev_scale + next.Badj_lo*next_scale);
286   Badj_hi = ( prev.Badj_hi*prev_scale + next.Badj_hi*next_scale);
287 }
288
289
290