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() {
31 capture_mask = 1; // has no effect if use_mask is off
91 int BluebananaConfig::equivalent(BluebananaConfig &that) {
92 if(active != that.active) return 0;
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;
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;
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;
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;
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;
120 if(Hadj_active != that.Hadj_active) return 0;
121 if(Hadj_val != that.Hadj_val) return 0;
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;
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;
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;
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;
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;
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;
156 void BluebananaConfig::copy_from(BluebananaConfig &that) {
158 active = that.active;
159 use_mask = that.use_mask;
160 capture_mask = that.capture_mask;
161 invert_selection = that.invert_selection;
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;
182 Hadj_active = that.Hadj_active;
183 Hadj_val = that.Hadj_val;
185 Sadj_active = that.Sadj_active;
186 Sadj_gamma = that.Sadj_gamma;
187 Sadj_lo = that.Sadj_lo;
188 Sadj_hi = that.Sadj_hi;
190 Vadj_active = that.Vadj_active;
191 Vadj_gamma = that.Vadj_gamma;
192 Vadj_lo = that.Vadj_lo;
193 Vadj_hi = that.Vadj_hi;
195 Radj_active = that.Radj_active;
196 Radj_gamma = that.Radj_gamma;
197 Radj_lo = that.Radj_lo;
198 Radj_hi = that.Radj_hi;
200 Gadj_active = that.Gadj_active;
201 Gadj_gamma = that.Gadj_gamma;
202 Gadj_lo = that.Gadj_lo;
203 Gadj_hi = that.Gadj_hi;
205 Badj_active = that.Badj_active;
206 Badj_gamma = that.Badj_gamma;
207 Badj_lo = that.Badj_lo;
208 Badj_hi = that.Badj_hi;
210 Oadj_active = that.Oadj_active;
211 Oadj_val = that.Oadj_val;
214 void BluebananaConfig::interpolate(BluebananaConfig &prev,
215 BluebananaConfig &next,
218 int64_t current_frame) {
220 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
221 double prev_scale = 1.0 - next_scale;
223 active = prev.active;
224 use_mask = prev.use_mask;
225 capture_mask = prev.capture_mask;
226 invert_selection = prev.invert_selection;
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;
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);