2 * Cinelerra :: Blue Banana - color modification plugin for Cinelerra-CV
3 * Copyright (C) 2012-2013 Monty <monty@xiph.org>
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.
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.
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
22 #include "bluebananaconfig.h"
27 BluebananaConfig::BluebananaConfig() {
32 capture_mask = 1; // has no effect if use_mask is off
92 int BluebananaConfig::equivalent(BluebananaConfig &that) {
93 if(active != that.active) return 0;
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;
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;
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;
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;
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;
122 if(Hadj_active != that.Hadj_active) return 0;
123 if(Hadj_val != that.Hadj_val) return 0;
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;
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;
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;
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;
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;
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;
158 void BluebananaConfig::copy_from(BluebananaConfig &that) {
161 active = that.active;
162 use_mask = that.use_mask;
163 capture_mask = that.capture_mask;
164 invert_selection = that.invert_selection;
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;
185 Hadj_active = that.Hadj_active;
186 Hadj_val = that.Hadj_val;
188 Sadj_active = that.Sadj_active;
189 Sadj_gamma = that.Sadj_gamma;
190 Sadj_lo = that.Sadj_lo;
191 Sadj_hi = that.Sadj_hi;
193 Vadj_active = that.Vadj_active;
194 Vadj_gamma = that.Vadj_gamma;
195 Vadj_lo = that.Vadj_lo;
196 Vadj_hi = that.Vadj_hi;
198 Radj_active = that.Radj_active;
199 Radj_gamma = that.Radj_gamma;
200 Radj_lo = that.Radj_lo;
201 Radj_hi = that.Radj_hi;
203 Gadj_active = that.Gadj_active;
204 Gadj_gamma = that.Gadj_gamma;
205 Gadj_lo = that.Gadj_lo;
206 Gadj_hi = that.Gadj_hi;
208 Badj_active = that.Badj_active;
209 Badj_gamma = that.Badj_gamma;
210 Badj_lo = that.Badj_lo;
211 Badj_hi = that.Badj_hi;
213 Oadj_active = that.Oadj_active;
214 Oadj_val = that.Oadj_val;
215 Aadj_active = that.Aadj_active;
216 Aadj_val = that.Aadj_val;
219 void BluebananaConfig::interpolate(BluebananaConfig &prev,
220 BluebananaConfig &next,
223 int64_t current_frame) {
225 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
226 double prev_scale = 1.0 - next_scale;
229 active = prev.active;
230 use_mask = prev.use_mask;
231 capture_mask = prev.capture_mask;
232 invert_selection = prev.invert_selection;
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;
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);