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
89 int BluebananaConfig::equivalent(BluebananaConfig &that) {
90 if(active != that.active) return 0;
92 if(use_mask != that.use_mask) return 0;
93 if(capture_mask != that.capture_mask) return 0;
94 if(invert_selection != that.invert_selection) return 0;
96 if(Hsel_active != that.Hsel_active) return 0;
97 if(Hsel_lo != that.Hsel_lo) return 0;
98 if(Hsel_hi != that.Hsel_hi) return 0;
99 if(Hsel_over != that.Hsel_over) return 0;
101 if(Ssel_active != that.Ssel_active) return 0;
102 if(Ssel_lo != that.Ssel_lo) return 0;
103 if(Ssel_hi != that.Ssel_hi) return 0;
104 if(Ssel_over != that.Ssel_over) return 0;
106 if(Vsel_active != that.Vsel_active) return 0;
107 if(Vsel_lo != that.Vsel_lo) return 0;
108 if(Vsel_hi != that.Vsel_hi) return 0;
109 if(Vsel_over != that.Vsel_over) return 0;
111 if(Fsel_active != that.Fsel_active) return 0;
112 if(Fsel_erode != that.Fsel_erode) return 0;
113 if(Fsel_lo != that.Fsel_lo) return 0;
114 if(Fsel_mid != that.Fsel_mid) return 0;
115 if(Fsel_hi != that.Fsel_hi) return 0;
116 if(Fsel_over != that.Fsel_over) return 0;
118 if(Hadj_active != that.Hadj_active) return 0;
119 if(Hadj_val != that.Hadj_val) return 0;
121 if(Oadj_active != that.Oadj_active) return 0;
122 if(Oadj_val != that.Oadj_val) return 0;
124 if(Sadj_active != that.Sadj_active) return 0;
125 if(Sadj_gamma != that.Sadj_gamma) return 0;
126 if(Sadj_lo != that.Sadj_lo) return 0;
127 if(Sadj_hi != that.Sadj_hi) return 0;
129 if(Vadj_active != that.Vadj_active) return 0;
130 if(Vadj_gamma != that.Vadj_gamma) return 0;
131 if(Vadj_lo != that.Vadj_lo) return 0;
132 if(Vadj_hi != that.Vadj_hi) return 0;
134 if(Radj_active != that.Radj_active) return 0;
135 if(Radj_gamma != that.Radj_gamma) return 0;
136 if(Radj_lo != that.Radj_lo) return 0;
137 if(Radj_hi != that.Radj_hi) return 0;
139 if(Gadj_active != that.Gadj_active) return 0;
140 if(Gadj_gamma != that.Gadj_gamma) return 0;
141 if(Gadj_lo != that.Gadj_lo) return 0;
142 if(Gadj_hi != that.Gadj_hi) return 0;
144 if(Badj_active != that.Badj_active) return 0;
145 if(Badj_gamma != that.Badj_gamma) return 0;
146 if(Badj_lo != that.Badj_lo) return 0;
147 if(Badj_hi != that.Badj_hi) return 0;
152 void BluebananaConfig::copy_from(BluebananaConfig &that) {
154 active = that.active;
155 use_mask = that.use_mask;
156 capture_mask = that.capture_mask;
157 invert_selection = that.invert_selection;
159 Hsel_active = that.Hsel_active;
160 Hsel_lo = that.Hsel_lo;
161 Hsel_hi = that.Hsel_hi;
162 Hsel_over = that.Hsel_over;
163 Ssel_active = that.Ssel_active;
164 Ssel_lo = that.Ssel_lo;
165 Ssel_hi = that.Ssel_hi;
166 Ssel_over = that.Ssel_over;
167 Vsel_active = that.Vsel_active;
168 Vsel_lo = that.Vsel_lo;
169 Vsel_hi = that.Vsel_hi;
170 Vsel_over = that.Vsel_over;
171 Fsel_active = that.Fsel_active;
172 Fsel_erode = that.Fsel_erode;
173 Fsel_lo = that.Fsel_lo;
174 Fsel_mid = that.Fsel_mid;
175 Fsel_hi = that.Fsel_hi;
176 Fsel_over = that.Fsel_over;
178 Hadj_active = that.Hadj_active;
179 Hadj_val = that.Hadj_val;
181 Sadj_active = that.Sadj_active;
182 Sadj_gamma = that.Sadj_gamma;
183 Sadj_lo = that.Sadj_lo;
184 Sadj_hi = that.Sadj_hi;
186 Vadj_active = that.Vadj_active;
187 Vadj_gamma = that.Vadj_gamma;
188 Vadj_lo = that.Vadj_lo;
189 Vadj_hi = that.Vadj_hi;
191 Radj_active = that.Radj_active;
192 Radj_gamma = that.Radj_gamma;
193 Radj_lo = that.Radj_lo;
194 Radj_hi = that.Radj_hi;
196 Gadj_active = that.Gadj_active;
197 Gadj_gamma = that.Gadj_gamma;
198 Gadj_lo = that.Gadj_lo;
199 Gadj_hi = that.Gadj_hi;
201 Badj_active = that.Badj_active;
202 Badj_gamma = that.Badj_gamma;
203 Badj_lo = that.Badj_lo;
204 Badj_hi = that.Badj_hi;
206 Oadj_active = that.Oadj_active;
207 Oadj_val = that.Oadj_val;
210 void BluebananaConfig::interpolate(BluebananaConfig &prev,
211 BluebananaConfig &next,
214 int64_t current_frame) {
216 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
217 double prev_scale = 1.0 - next_scale;
219 active = prev.active;
220 use_mask = prev.use_mask;
221 capture_mask = prev.capture_mask;
222 invert_selection = prev.invert_selection;
224 Hsel_active = prev.Hsel_active;
225 Ssel_active = prev.Ssel_active;
226 Vsel_active = prev.Vsel_active;
227 Fsel_active = prev.Fsel_active;
228 Fsel_erode = prev.Fsel_erode;
229 Hadj_active = prev.Hadj_active;
230 Sadj_active = prev.Sadj_active;
231 Vadj_active = prev.Vadj_active;
232 Radj_active = prev.Radj_active;
233 Gadj_active = prev.Gadj_active;
234 Badj_active = prev.Badj_active;
235 Oadj_active = prev.Oadj_active;
237 Hsel_lo = ( prev.Hsel_lo*prev_scale + next.Hsel_lo*next_scale);
238 Hsel_hi = ( prev.Hsel_hi*prev_scale + next.Hsel_hi*next_scale);
239 Hsel_over = ( prev.Hsel_over*prev_scale + next.Hsel_over*next_scale);
241 Ssel_lo = ( prev.Ssel_lo*prev_scale + next.Ssel_lo*next_scale);
242 Ssel_hi = ( prev.Ssel_hi*prev_scale + next.Ssel_hi*next_scale);
243 Ssel_over = ( prev.Ssel_over*prev_scale + next.Ssel_over*next_scale);
245 Vsel_lo = ( prev.Vsel_lo*prev_scale + next.Vsel_lo*next_scale);
246 Vsel_hi = ( prev.Vsel_hi*prev_scale + next.Vsel_hi*next_scale);
247 Vsel_over = ( prev.Vsel_over*prev_scale + next.Vsel_over*next_scale);
249 Fsel_lo = ( prev.Fsel_lo*prev_scale + next.Fsel_lo*next_scale);
250 Fsel_mid = ( prev.Fsel_mid*prev_scale + next.Fsel_mid*next_scale);
251 Fsel_hi = ( prev.Fsel_hi*prev_scale + next.Fsel_hi*next_scale);
252 Fsel_over = ( prev.Fsel_over*prev_scale + next.Fsel_over*next_scale);
254 Hadj_val = ( prev.Hadj_val*prev_scale + next.Hadj_val*next_scale);
255 Oadj_val = ( prev.Oadj_val*prev_scale + next.Oadj_val*next_scale);
257 Sadj_gamma = ( prev.Sadj_gamma*prev_scale + next.Sadj_gamma*next_scale);
258 Sadj_lo = ( prev.Sadj_lo*prev_scale + next.Sadj_lo*next_scale);
259 Sadj_hi = ( prev.Sadj_hi*prev_scale + next.Sadj_hi*next_scale);
261 Vadj_gamma = ( prev.Vadj_gamma*prev_scale + next.Vadj_gamma*next_scale);
262 Vadj_lo = ( prev.Vadj_lo*prev_scale + next.Vadj_lo*next_scale);
263 Vadj_hi = ( prev.Vadj_hi*prev_scale + next.Vadj_hi*next_scale);
265 Radj_gamma = ( prev.Radj_gamma*prev_scale + next.Radj_gamma*next_scale);
266 Radj_lo = ( prev.Radj_lo*prev_scale + next.Radj_lo*next_scale);
267 Radj_hi = ( prev.Radj_hi*prev_scale + next.Radj_hi*next_scale);
269 Gadj_gamma = ( prev.Gadj_gamma*prev_scale + next.Gadj_gamma*next_scale);
270 Gadj_lo = ( prev.Gadj_lo*prev_scale + next.Gadj_lo*next_scale);
271 Gadj_hi = ( prev.Gadj_hi*prev_scale + next.Gadj_hi*next_scale);
273 Badj_gamma = ( prev.Badj_gamma*prev_scale + next.Badj_gamma*next_scale);
274 Badj_lo = ( prev.Badj_lo*prev_scale + next.Badj_lo*next_scale);
275 Badj_hi = ( prev.Badj_hi*prev_scale + next.Badj_hi*next_scale);