igor ru.po
[goodguy/history.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   mark = 0;
29   active = 1;
30   use_mask = 0;
31   capture_mask = 1; // has no effect if use_mask is off
32   invert_selection = 0;
33
34   Hsel_active=1;
35   Hsel_lo=0;
36   Hsel_hi=360;
37   Hsel_over=36;
38
39   Ssel_active=1;
40   Ssel_lo=0;
41   Ssel_hi=100;
42   Ssel_over=10;
43
44   Vsel_active=1;
45   Vsel_lo=0;
46   Vsel_hi=100;
47   Vsel_over=10;
48
49   Fsel_active=0;
50   Fsel_erode=0;
51   Fsel_lo=-2;
52   Fsel_mid=0;
53   Fsel_hi=2;
54   Fsel_over=5;
55
56   Hadj_active=0;
57   Hadj_val=0;
58
59   Sadj_active=0;
60   Sadj_lo=0;
61   Sadj_gamma=1;
62   Sadj_hi=100;
63
64   Vadj_active=0;
65   Vadj_lo=0;
66   Vadj_gamma=1;
67   Vadj_hi=100;
68
69   Radj_active=0;
70   Radj_lo=0;
71   Radj_gamma=1;
72   Radj_hi=100;
73
74   Gadj_active=0;
75   Gadj_lo=0;
76   Gadj_gamma=1;
77   Gadj_hi=100;
78
79   Badj_active=0;
80   Badj_lo=0;
81   Badj_gamma=1;
82   Badj_hi=100;
83
84   Oadj_active=0;
85   Oadj_val=100;
86   Aadj_active=0;
87   Aadj_val=100;
88
89 }
90
91 int BluebananaConfig::equivalent(BluebananaConfig &that) {
92   if(active != that.active) return 0;
93   // mark is no an auto
94   if(use_mask != that.use_mask) return 0;
95   if(capture_mask != that.capture_mask) return 0;
96   if(invert_selection != that.invert_selection) return 0;
97
98   if(Hsel_active != that.Hsel_active) return 0;
99   if(Hsel_lo != that.Hsel_lo) return 0;
100   if(Hsel_hi != that.Hsel_hi) return 0;
101   if(Hsel_over != that.Hsel_over) return 0;
102
103   if(Ssel_active != that.Ssel_active) return 0;
104   if(Ssel_lo != that.Ssel_lo) return 0;
105   if(Ssel_hi != that.Ssel_hi) return 0;
106   if(Ssel_over != that.Ssel_over) return 0;
107
108   if(Vsel_active != that.Vsel_active) return 0;
109   if(Vsel_lo != that.Vsel_lo) return 0;
110   if(Vsel_hi != that.Vsel_hi) return 0;
111   if(Vsel_over != that.Vsel_over) return 0;
112
113   if(Fsel_active != that.Fsel_active) return 0;
114   if(Fsel_erode != that.Fsel_erode) return 0;
115   if(Fsel_lo != that.Fsel_lo) return 0;
116   if(Fsel_mid != that.Fsel_mid) return 0;
117   if(Fsel_hi != that.Fsel_hi) return 0;
118   if(Fsel_over != that.Fsel_over) return 0;
119
120   if(Hadj_active != that.Hadj_active) return 0;
121   if(Hadj_val != that.Hadj_val) return 0;
122
123   if(Oadj_active != that.Oadj_active) return 0;
124   if(Oadj_val != that.Oadj_val) return 0;
125   if(Aadj_active != that.Aadj_active) return 0;
126   if(Aadj_val != that.Aadj_val) return 0;
127
128   if(Sadj_active != that.Sadj_active) return 0;
129   if(Sadj_gamma != that.Sadj_gamma) return 0;
130   if(Sadj_lo != that.Sadj_lo) return 0;
131   if(Sadj_hi != that.Sadj_hi) return 0;
132
133   if(Vadj_active != that.Vadj_active) return 0;
134   if(Vadj_gamma != that.Vadj_gamma) return 0;
135   if(Vadj_lo != that.Vadj_lo) return 0;
136   if(Vadj_hi != that.Vadj_hi) return 0;
137
138   if(Radj_active != that.Radj_active) return 0;
139   if(Radj_gamma != that.Radj_gamma) return 0;
140   if(Radj_lo != that.Radj_lo) return 0;
141   if(Radj_hi != that.Radj_hi) return 0;
142
143   if(Gadj_active != that.Gadj_active) return 0;
144   if(Gadj_gamma != that.Gadj_gamma) return 0;
145   if(Gadj_lo != that.Gadj_lo) return 0;
146   if(Gadj_hi != that.Gadj_hi) return 0;
147
148   if(Badj_active != that.Badj_active) return 0;
149   if(Badj_gamma != that.Badj_gamma) return 0;
150   if(Badj_lo != that.Badj_lo) return 0;
151   if(Badj_hi != that.Badj_hi) return 0;
152
153   return 1;
154 }
155
156 void BluebananaConfig::copy_from(BluebananaConfig &that) {
157   mark = that.mark;
158   active = that.active;
159   use_mask = that.use_mask;
160   capture_mask = that.capture_mask;
161   invert_selection = that.invert_selection;
162
163   Hsel_active = that.Hsel_active;
164   Hsel_lo = that.Hsel_lo;
165   Hsel_hi = that.Hsel_hi;
166   Hsel_over = that.Hsel_over;
167   Ssel_active = that.Ssel_active;
168   Ssel_lo = that.Ssel_lo;
169   Ssel_hi = that.Ssel_hi;
170   Ssel_over = that.Ssel_over;
171   Vsel_active = that.Vsel_active;
172   Vsel_lo = that.Vsel_lo;
173   Vsel_hi = that.Vsel_hi;
174   Vsel_over = that.Vsel_over;
175   Fsel_active = that.Fsel_active;
176   Fsel_erode = that.Fsel_erode;
177   Fsel_lo = that.Fsel_lo;
178   Fsel_mid = that.Fsel_mid;
179   Fsel_hi = that.Fsel_hi;
180   Fsel_over = that.Fsel_over;
181
182   Hadj_active = that.Hadj_active;
183   Hadj_val = that.Hadj_val;
184
185   Sadj_active = that.Sadj_active;
186   Sadj_gamma = that.Sadj_gamma;
187   Sadj_lo = that.Sadj_lo;
188   Sadj_hi = that.Sadj_hi;
189
190   Vadj_active = that.Vadj_active;
191   Vadj_gamma = that.Vadj_gamma;
192   Vadj_lo = that.Vadj_lo;
193   Vadj_hi = that.Vadj_hi;
194
195   Radj_active = that.Radj_active;
196   Radj_gamma = that.Radj_gamma;
197   Radj_lo = that.Radj_lo;
198   Radj_hi = that.Radj_hi;
199
200   Gadj_active = that.Gadj_active;
201   Gadj_gamma = that.Gadj_gamma;
202   Gadj_lo = that.Gadj_lo;
203   Gadj_hi = that.Gadj_hi;
204
205   Badj_active = that.Badj_active;
206   Badj_gamma = that.Badj_gamma;
207   Badj_lo = that.Badj_lo;
208   Badj_hi = that.Badj_hi;
209
210   Oadj_active = that.Oadj_active;
211   Oadj_val = that.Oadj_val;
212 }
213
214 void BluebananaConfig::interpolate(BluebananaConfig &prev,
215                                    BluebananaConfig &next,
216                                    int64_t prev_frame,
217                                    int64_t next_frame,
218                                    int64_t current_frame) {
219
220   double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
221   double prev_scale = 1.0 - next_scale;
222
223   active = prev.active;
224   use_mask = prev.use_mask;
225   capture_mask = prev.capture_mask;
226   invert_selection = prev.invert_selection;
227
228   Hsel_active = prev.Hsel_active;
229   Ssel_active = prev.Ssel_active;
230   Vsel_active = prev.Vsel_active;
231   Fsel_active = prev.Fsel_active;
232   Fsel_erode = prev.Fsel_erode;
233   Hadj_active = prev.Hadj_active;
234   Sadj_active = prev.Sadj_active;
235   Vadj_active = prev.Vadj_active;
236   Radj_active = prev.Radj_active;
237   Gadj_active = prev.Gadj_active;
238   Badj_active = prev.Badj_active;
239   Oadj_active = prev.Oadj_active;
240
241   Hsel_lo = ( prev.Hsel_lo*prev_scale + next.Hsel_lo*next_scale);
242   Hsel_hi = ( prev.Hsel_hi*prev_scale + next.Hsel_hi*next_scale);
243   Hsel_over = ( prev.Hsel_over*prev_scale + next.Hsel_over*next_scale);
244
245   Ssel_lo = ( prev.Ssel_lo*prev_scale + next.Ssel_lo*next_scale);
246   Ssel_hi = ( prev.Ssel_hi*prev_scale + next.Ssel_hi*next_scale);
247   Ssel_over = ( prev.Ssel_over*prev_scale + next.Ssel_over*next_scale);
248
249   Vsel_lo = ( prev.Vsel_lo*prev_scale + next.Vsel_lo*next_scale);
250   Vsel_hi = ( prev.Vsel_hi*prev_scale + next.Vsel_hi*next_scale);
251   Vsel_over = ( prev.Vsel_over*prev_scale + next.Vsel_over*next_scale);
252
253   Fsel_lo = ( prev.Fsel_lo*prev_scale + next.Fsel_lo*next_scale);
254   Fsel_mid = ( prev.Fsel_mid*prev_scale + next.Fsel_mid*next_scale);
255   Fsel_hi = ( prev.Fsel_hi*prev_scale + next.Fsel_hi*next_scale);
256   Fsel_over = ( prev.Fsel_over*prev_scale + next.Fsel_over*next_scale);
257
258   Hadj_val = ( prev.Hadj_val*prev_scale + next.Hadj_val*next_scale);
259   Oadj_val = ( prev.Oadj_val*prev_scale + next.Oadj_val*next_scale);
260
261   Sadj_gamma = ( prev.Sadj_gamma*prev_scale + next.Sadj_gamma*next_scale);
262   Sadj_lo = ( prev.Sadj_lo*prev_scale + next.Sadj_lo*next_scale);
263   Sadj_hi = ( prev.Sadj_hi*prev_scale + next.Sadj_hi*next_scale);
264
265   Vadj_gamma = ( prev.Vadj_gamma*prev_scale + next.Vadj_gamma*next_scale);
266   Vadj_lo = ( prev.Vadj_lo*prev_scale + next.Vadj_lo*next_scale);
267   Vadj_hi = ( prev.Vadj_hi*prev_scale + next.Vadj_hi*next_scale);
268
269   Radj_gamma = ( prev.Radj_gamma*prev_scale + next.Radj_gamma*next_scale);
270   Radj_lo = ( prev.Radj_lo*prev_scale + next.Radj_lo*next_scale);
271   Radj_hi = ( prev.Radj_hi*prev_scale + next.Radj_hi*next_scale);
272
273   Gadj_gamma = ( prev.Gadj_gamma*prev_scale + next.Gadj_gamma*next_scale);
274   Gadj_lo = ( prev.Gadj_lo*prev_scale + next.Gadj_lo*next_scale);
275   Gadj_hi = ( prev.Gadj_hi*prev_scale + next.Gadj_hi*next_scale);
276
277   Badj_gamma = ( prev.Badj_gamma*prev_scale + next.Badj_gamma*next_scale);
278   Badj_lo = ( prev.Badj_lo*prev_scale + next.Badj_lo*next_scale);
279   Badj_hi = ( prev.Badj_hi*prev_scale + next.Badj_hi*next_scale);
280 }
281
282
283