r784: Fix to bug 250 by Dan Streetman
[cinelerra_cv/mob.git] / plugins / chromakey-hsv / chromakey.h
blob60cb4802c58b5b0d1124b10c1f2683d509916cfb
1 #ifndef CHROMAKEY_H
2 #define CHROMAKEY_H
7 #include "colorpicker.h"
8 #include "guicast.h"
9 #include "loadbalance.h"
10 #include "pluginvclient.h"
13 class ChromaKey;
14 class ChromaKey;
15 class ChromaKeyWindow;
17 enum {
18 CHROMAKEY_POSTPROCESS_NONE,
19 CHROMAKEY_POSTPROCESS_BLUR,
20 CHROMAKEY_POSTPROCESS_DILATE
23 class ChromaKeyConfig
25 public:
26 ChromaKeyConfig();
28 void copy_from(ChromaKeyConfig &src);
29 int equivalent(ChromaKeyConfig &src);
30 void interpolate(ChromaKeyConfig &prev,
31 ChromaKeyConfig &next,
32 int64_t prev_frame,
33 int64_t next_frame,
34 int64_t current_frame);
35 int get_color();
37 // Output mode
38 bool show_mask;
39 // Key color definition
40 float red;
41 float green;
42 float blue;
43 // Key shade definition
44 float min_brightness;
45 float max_brightness;
46 float saturation;
47 float min_saturation;
48 float tolerance;
49 // Mask feathering
50 float in_slope;
51 float out_slope;
52 float alpha_offset;
53 // Spill light compensation
54 float spill_threshold;
55 float spill_amount;
58 class ChromaKeyColor : public BC_GenericButton
60 public:
61 ChromaKeyColor(ChromaKey *plugin,
62 ChromaKeyWindow *gui,
63 int x,
64 int y);
66 int handle_event();
68 ChromaKey *plugin;
69 ChromaKeyWindow *gui;
73 class ChromaKeyMinBrightness : public BC_FSlider
75 public:
76 ChromaKeyMinBrightness(ChromaKey *plugin, int x, int y);
77 int handle_event();
78 ChromaKey *plugin;
81 class ChromaKeyMaxBrightness : public BC_FSlider
83 public:
84 ChromaKeyMaxBrightness(ChromaKey *plugin, int x, int y);
85 int handle_event();
86 ChromaKey *plugin;
89 class ChromaKeySaturation : public BC_FSlider
91 public:
92 ChromaKeySaturation(ChromaKey *plugin, int x, int y);
93 int handle_event();
94 ChromaKey *plugin;
97 class ChromaKeyMinSaturation : public BC_FSlider
99 public:
100 ChromaKeyMinSaturation(ChromaKey *plugin, int x, int y);
101 int handle_event();
102 ChromaKey *plugin;
107 class ChromaKeyTolerance : public BC_FSlider
109 public:
110 ChromaKeyTolerance(ChromaKey *plugin, int x, int y);
111 int handle_event();
112 ChromaKey *plugin;
115 class ChromaKeyInSlope : public BC_FSlider
117 public:
118 ChromaKeyInSlope(ChromaKey *plugin, int x, int y);
119 int handle_event();
120 ChromaKey *plugin;
123 class ChromaKeyOutSlope : public BC_FSlider
125 public:
126 ChromaKeyOutSlope(ChromaKey *plugin, int x, int y);
127 int handle_event();
128 ChromaKey *plugin;
131 class ChromaKeyAlphaOffset : public BC_FSlider
133 public:
134 ChromaKeyAlphaOffset(ChromaKey *plugin, int x, int y);
135 int handle_event();
136 ChromaKey *plugin;
139 class ChromaKeySpillThreshold : public BC_FSlider
141 public:
142 ChromaKeySpillThreshold(ChromaKey *plugin, int x, int y);
143 int handle_event();
144 ChromaKey *plugin;
146 class ChromaKeySpillAmount : public BC_FSlider
148 public:
149 ChromaKeySpillAmount(ChromaKey *plugin, int x, int y);
150 int handle_event();
151 ChromaKey *plugin;
154 class ChromaKeyUseColorPicker : public BC_GenericButton
156 public:
157 ChromaKeyUseColorPicker(ChromaKey *plugin, ChromaKeyWindow *gui, int x, int y);
158 int handle_event();
159 ChromaKey *plugin;
160 ChromaKeyWindow *gui;
164 class ChromaKeyColorThread : public ColorThread
166 public:
167 ChromaKeyColorThread(ChromaKey *plugin, ChromaKeyWindow *gui);
168 int handle_new_color(int output, int alpha);
169 ChromaKey *plugin;
170 ChromaKeyWindow *gui;
173 class ChromaKeyShowMask : public BC_CheckBox
175 public:
176 ChromaKeyShowMask(ChromaKey *plugin, int x, int y);
177 int handle_event();
178 ChromaKey *plugin;
183 class ChromaKeyWindow : public BC_Window
185 public:
186 ChromaKeyWindow(ChromaKey *plugin, int x, int y);
187 ~ChromaKeyWindow();
189 void create_objects();
190 int close_event();
191 void update_sample();
193 ChromaKeyColor *color;
194 ChromaKeyUseColorPicker *use_colorpicker;
195 ChromaKeyMinBrightness *min_brightness;
196 ChromaKeyMaxBrightness *max_brightness;
197 ChromaKeySaturation *saturation;
198 ChromaKeyMinSaturation *min_saturation;
199 ChromaKeyTolerance *tolerance;
200 ChromaKeyInSlope *in_slope;
201 ChromaKeyOutSlope *out_slope;
202 ChromaKeyAlphaOffset *alpha_offset;
203 ChromaKeySpillThreshold *spill_threshold;
204 ChromaKeySpillAmount *spill_amount;
205 ChromaKeyShowMask *show_mask;
206 BC_SubWindow *sample;
207 ChromaKey *plugin;
208 ChromaKeyColorThread *color_thread;
213 PLUGIN_THREAD_HEADER(ChromaKey, ChromaKeyThread, ChromaKeyWindow)
216 class ChromaKeyServer : public LoadServer
218 public:
219 ChromaKeyServer(ChromaKey *plugin);
220 void init_packages();
221 LoadClient* new_client();
222 LoadPackage* new_package();
223 ChromaKey *plugin;
226 class ChromaKeyPackage : public LoadPackage
228 public:
229 ChromaKeyPackage();
230 int y1, y2;
233 class ChromaKeyUnit : public LoadClient
235 public:
236 ChromaKeyUnit(ChromaKey *plugin, ChromaKeyServer *server);
237 void process_package(LoadPackage *package);
238 template <typename component_type> void process_chromakey(int components, component_type max, bool use_yuv, ChromaKeyPackage *pkg);
239 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);
241 ChromaKey *plugin;
248 class ChromaKey : public PluginVClient
250 public:
251 ChromaKey(PluginServer *server);
252 ~ChromaKey();
254 int process_realtime(VFrame *input, VFrame *output);
255 int is_realtime();
256 char* plugin_title();
257 VFrame* new_picon();
258 int load_configuration();
259 int load_defaults();
260 int save_defaults();
261 void save_data(KeyFrame *keyframe);
262 void read_data(KeyFrame *keyframe);
263 int show_gui();
264 int set_string();
265 void raise_window();
266 void update_gui();
268 ChromaKeyConfig config;
269 VFrame *input, *output;
270 ChromaKeyServer *engine;
271 ChromaKeyThread *thread;
272 Defaults *defaults;
282 #endif