4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "colorpicker.h"
30 #include "loadbalance.h"
31 #include "pluginvclient.h"
36 class ChromaKeyWindow;
39 CHROMAKEY_POSTPROCESS_NONE,
40 CHROMAKEY_POSTPROCESS_BLUR,
41 CHROMAKEY_POSTPROCESS_DILATE
49 void copy_from(ChromaKeyConfig &src);
50 int equivalent(ChromaKeyConfig &src);
51 void interpolate(ChromaKeyConfig &prev,
52 ChromaKeyConfig &next,
55 int64_t current_frame);
60 // Key color definition
64 // Key shade definition
74 // Spill light compensation
75 float spill_threshold;
79 class ChromaKeyColor : public BC_GenericButton
82 ChromaKeyColor(ChromaKeyHSV *plugin,
93 class ChromaKeyReset : public BC_GenericButton
96 ChromaKeyReset(ChromaKeyHSV *plugin, ChromaKeyWindow *gui, int x, int y);
104 class ChromaKeyMinBrightness : public BC_FSlider
107 ChromaKeyMinBrightness(ChromaKeyHSV *plugin, int x, int y);
109 ChromaKeyHSV *plugin;
112 class ChromaKeyMaxBrightness : public BC_FSlider
115 ChromaKeyMaxBrightness(ChromaKeyHSV *plugin, int x, int y);
117 ChromaKeyHSV *plugin;
120 class ChromaKeySaturation : public BC_FSlider
123 ChromaKeySaturation(ChromaKeyHSV *plugin, int x, int y);
125 ChromaKeyHSV *plugin;
128 class ChromaKeyMinSaturation : public BC_FSlider
131 ChromaKeyMinSaturation(ChromaKeyHSV *plugin, int x, int y);
133 ChromaKeyHSV *plugin;
138 class ChromaKeyTolerance : public BC_FSlider
141 ChromaKeyTolerance(ChromaKeyHSV *plugin, int x, int y);
143 ChromaKeyHSV *plugin;
146 class ChromaKeyInSlope : public BC_FSlider
149 ChromaKeyInSlope(ChromaKeyHSV *plugin, int x, int y);
151 ChromaKeyHSV *plugin;
154 class ChromaKeyOutSlope : public BC_FSlider
157 ChromaKeyOutSlope(ChromaKeyHSV *plugin, int x, int y);
159 ChromaKeyHSV *plugin;
162 class ChromaKeyAlphaOffset : public BC_FSlider
165 ChromaKeyAlphaOffset(ChromaKeyHSV *plugin, int x, int y);
167 ChromaKeyHSV *plugin;
170 class ChromaKeySpillThreshold : public BC_FSlider
173 ChromaKeySpillThreshold(ChromaKeyHSV *plugin, int x, int y);
175 ChromaKeyHSV *plugin;
177 class ChromaKeySpillAmount : public BC_FSlider
180 ChromaKeySpillAmount(ChromaKeyHSV *plugin, int x, int y);
182 ChromaKeyHSV *plugin;
185 class ChromaKeyUseColorPicker : public BC_GenericButton
188 ChromaKeyUseColorPicker(ChromaKeyHSV *plugin, ChromaKeyWindow *gui, int x, int y);
190 ChromaKeyHSV *plugin;
191 ChromaKeyWindow *gui;
195 class ChromaKeyColorThread : public ColorPicker
198 ChromaKeyColorThread(ChromaKeyHSV *plugin, ChromaKeyWindow *gui);
199 int handle_new_color(int output, int alpha);
200 ChromaKeyHSV *plugin;
201 ChromaKeyWindow *gui;
204 class ChromaKeyShowMask : public BC_CheckBox
207 ChromaKeyShowMask(ChromaKeyHSV *plugin, int x, int y);
209 ChromaKeyHSV *plugin;
214 class ChromaKeyWindow : public PluginClientWindow
217 ChromaKeyWindow(ChromaKeyHSV *plugin);
220 void create_objects();
221 void update_sample();
223 void done_event(int result);
225 ChromaKeyColor *color;
226 ChromaKeyUseColorPicker *use_colorpicker;
227 ChromaKeyMinBrightness *min_brightness;
228 ChromaKeyMaxBrightness *max_brightness;
229 ChromaKeySaturation *saturation;
230 ChromaKeyMinSaturation *min_saturation;
231 ChromaKeyTolerance *tolerance;
232 ChromaKeyInSlope *in_slope;
233 ChromaKeyOutSlope *out_slope;
234 ChromaKeyAlphaOffset *alpha_offset;
235 ChromaKeySpillThreshold *spill_threshold;
236 ChromaKeySpillAmount *spill_amount;
237 ChromaKeyShowMask *show_mask;
238 ChromaKeyReset *reset;
239 BC_SubWindow *sample;
240 ChromaKeyHSV *plugin;
241 ChromaKeyColorThread *color_thread;
250 class ChromaKeyServer : public LoadServer
253 ChromaKeyServer(ChromaKeyHSV *plugin);
254 void init_packages();
255 LoadClient* new_client();
256 LoadPackage* new_package();
257 ChromaKeyHSV *plugin;
260 class ChromaKeyPackage : public LoadPackage
267 class ChromaKeyUnit : public LoadClient
270 ChromaKeyUnit(ChromaKeyHSV *plugin, ChromaKeyServer *server);
271 void process_package(LoadPackage *package);
272 template <typename component_type> void process_chromakey(int components, component_type max, bool use_yuv, ChromaKeyPackage *pkg);
273 bool is_same_color(float r, float g, float b, float rk,float bk,float gk, float color_threshold, float light_threshold, int key_main_component);
275 ChromaKeyHSV *plugin;
282 class ChromaKeyHSV : public PluginVClient
285 ChromaKeyHSV(PluginServer *server);
288 PLUGIN_CLASS_MEMBERS(ChromaKeyConfig);
289 int process_buffer(VFrame *frame,
290 int64_t start_position,
294 void save_data(KeyFrame *keyframe);
295 void read_data(KeyFrame *keyframe);
298 VFrame *input, *output;
299 ChromaKeyServer *engine;