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,
94 class ChromaKeyMinBrightness : public BC_FSlider
97 ChromaKeyMinBrightness(ChromaKeyHSV *plugin, int x, int y);
102 class ChromaKeyMaxBrightness : public BC_FSlider
105 ChromaKeyMaxBrightness(ChromaKeyHSV *plugin, int x, int y);
107 ChromaKeyHSV *plugin;
110 class ChromaKeySaturation : public BC_FSlider
113 ChromaKeySaturation(ChromaKeyHSV *plugin, int x, int y);
115 ChromaKeyHSV *plugin;
118 class ChromaKeyMinSaturation : public BC_FSlider
121 ChromaKeyMinSaturation(ChromaKeyHSV *plugin, int x, int y);
123 ChromaKeyHSV *plugin;
128 class ChromaKeyTolerance : public BC_FSlider
131 ChromaKeyTolerance(ChromaKeyHSV *plugin, int x, int y);
133 ChromaKeyHSV *plugin;
136 class ChromaKeyInSlope : public BC_FSlider
139 ChromaKeyInSlope(ChromaKeyHSV *plugin, int x, int y);
141 ChromaKeyHSV *plugin;
144 class ChromaKeyOutSlope : public BC_FSlider
147 ChromaKeyOutSlope(ChromaKeyHSV *plugin, int x, int y);
149 ChromaKeyHSV *plugin;
152 class ChromaKeyAlphaOffset : public BC_FSlider
155 ChromaKeyAlphaOffset(ChromaKeyHSV *plugin, int x, int y);
157 ChromaKeyHSV *plugin;
160 class ChromaKeySpillThreshold : public BC_FSlider
163 ChromaKeySpillThreshold(ChromaKeyHSV *plugin, int x, int y);
165 ChromaKeyHSV *plugin;
167 class ChromaKeySpillAmount : public BC_FSlider
170 ChromaKeySpillAmount(ChromaKeyHSV *plugin, int x, int y);
172 ChromaKeyHSV *plugin;
175 class ChromaKeyUseColorPicker : public BC_GenericButton
178 ChromaKeyUseColorPicker(ChromaKeyHSV *plugin, ChromaKeyWindow *gui, int x, int y);
180 ChromaKeyHSV *plugin;
181 ChromaKeyWindow *gui;
185 class ChromaKeyColorThread : public ColorPicker
188 ChromaKeyColorThread(ChromaKeyHSV *plugin, ChromaKeyWindow *gui);
189 int handle_new_color(int output, int alpha);
190 ChromaKeyHSV *plugin;
191 ChromaKeyWindow *gui;
194 class ChromaKeyShowMask : public BC_CheckBox
197 ChromaKeyShowMask(ChromaKeyHSV *plugin, int x, int y);
199 ChromaKeyHSV *plugin;
204 class ChromaKeyWindow : public PluginClientWindow
207 ChromaKeyWindow(ChromaKeyHSV *plugin);
210 void create_objects();
211 void update_sample();
212 void done_event(int result);
214 ChromaKeyColor *color;
215 ChromaKeyUseColorPicker *use_colorpicker;
216 ChromaKeyMinBrightness *min_brightness;
217 ChromaKeyMaxBrightness *max_brightness;
218 ChromaKeySaturation *saturation;
219 ChromaKeyMinSaturation *min_saturation;
220 ChromaKeyTolerance *tolerance;
221 ChromaKeyInSlope *in_slope;
222 ChromaKeyOutSlope *out_slope;
223 ChromaKeyAlphaOffset *alpha_offset;
224 ChromaKeySpillThreshold *spill_threshold;
225 ChromaKeySpillAmount *spill_amount;
226 ChromaKeyShowMask *show_mask;
227 BC_SubWindow *sample;
228 ChromaKeyHSV *plugin;
229 ChromaKeyColorThread *color_thread;
238 class ChromaKeyServer : public LoadServer
241 ChromaKeyServer(ChromaKeyHSV *plugin);
242 void init_packages();
243 LoadClient* new_client();
244 LoadPackage* new_package();
245 ChromaKeyHSV *plugin;
248 class ChromaKeyPackage : public LoadPackage
255 class ChromaKeyUnit : public LoadClient
258 ChromaKeyUnit(ChromaKeyHSV *plugin, ChromaKeyServer *server);
259 void process_package(LoadPackage *package);
260 template <typename component_type> void process_chromakey(int components, component_type max, bool use_yuv, ChromaKeyPackage *pkg);
261 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);
263 ChromaKeyHSV *plugin;
270 class ChromaKeyHSV : public PluginVClient
273 ChromaKeyHSV(PluginServer *server);
276 PLUGIN_CLASS_MEMBERS(ChromaKeyConfig);
277 int process_buffer(VFrame *frame,
278 int64_t start_position,
282 void save_data(KeyFrame *keyframe);
283 void read_data(KeyFrame *keyframe);
286 VFrame *input, *output;
287 ChromaKeyServer *engine;