r864: Merge 2.1:
[cinelerra_cv/ct.git] / plugins / chromakeyhsv / chromakey.h
blob4453e297bd9c34e6b0ad468166f572c791ff99e0
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 ChromaKeyHSV;
14 class ChromaKeyHSV;
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(ChromaKeyHSV *plugin,
62 ChromaKeyWindow *gui,
63 int x,
64 int y);
66 int handle_event();
68 ChromaKeyHSV *plugin;
69 ChromaKeyWindow *gui;
73 class ChromaKeyMinBrightness : public BC_FSlider
75 public:
76 ChromaKeyMinBrightness(ChromaKeyHSV *plugin, int x, int y);
77 int handle_event();
78 ChromaKeyHSV *plugin;
81 class ChromaKeyMaxBrightness : public BC_FSlider
83 public:
84 ChromaKeyMaxBrightness(ChromaKeyHSV *plugin, int x, int y);
85 int handle_event();
86 ChromaKeyHSV *plugin;
89 class ChromaKeySaturation : public BC_FSlider
91 public:
92 ChromaKeySaturation(ChromaKeyHSV *plugin, int x, int y);
93 int handle_event();
94 ChromaKeyHSV *plugin;
97 class ChromaKeyMinSaturation : public BC_FSlider
99 public:
100 ChromaKeyMinSaturation(ChromaKeyHSV *plugin, int x, int y);
101 int handle_event();
102 ChromaKeyHSV *plugin;
107 class ChromaKeyTolerance : public BC_FSlider
109 public:
110 ChromaKeyTolerance(ChromaKeyHSV *plugin, int x, int y);
111 int handle_event();
112 ChromaKeyHSV *plugin;
115 class ChromaKeyInSlope : public BC_FSlider
117 public:
118 ChromaKeyInSlope(ChromaKeyHSV *plugin, int x, int y);
119 int handle_event();
120 ChromaKeyHSV *plugin;
123 class ChromaKeyOutSlope : public BC_FSlider
125 public:
126 ChromaKeyOutSlope(ChromaKeyHSV *plugin, int x, int y);
127 int handle_event();
128 ChromaKeyHSV *plugin;
131 class ChromaKeyAlphaOffset : public BC_FSlider
133 public:
134 ChromaKeyAlphaOffset(ChromaKeyHSV *plugin, int x, int y);
135 int handle_event();
136 ChromaKeyHSV *plugin;
139 class ChromaKeySpillThreshold : public BC_FSlider
141 public:
142 ChromaKeySpillThreshold(ChromaKeyHSV *plugin, int x, int y);
143 int handle_event();
144 ChromaKeyHSV *plugin;
146 class ChromaKeySpillAmount : public BC_FSlider
148 public:
149 ChromaKeySpillAmount(ChromaKeyHSV *plugin, int x, int y);
150 int handle_event();
151 ChromaKeyHSV *plugin;
154 class ChromaKeyUseColorPicker : public BC_GenericButton
156 public:
157 ChromaKeyUseColorPicker(ChromaKeyHSV *plugin, ChromaKeyWindow *gui, int x, int y);
158 int handle_event();
159 ChromaKeyHSV *plugin;
160 ChromaKeyWindow *gui;
164 class ChromaKeyColorThread : public ColorThread
166 public:
167 ChromaKeyColorThread(ChromaKeyHSV *plugin, ChromaKeyWindow *gui);
168 int handle_new_color(int output, int alpha);
169 ChromaKeyHSV *plugin;
170 ChromaKeyWindow *gui;
173 class ChromaKeyShowMask : public BC_CheckBox
175 public:
176 ChromaKeyShowMask(ChromaKeyHSV *plugin, int x, int y);
177 int handle_event();
178 ChromaKeyHSV *plugin;
183 class ChromaKeyWindow : public BC_Window
185 public:
186 ChromaKeyWindow(ChromaKeyHSV *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 ChromaKeyHSV *plugin;
208 ChromaKeyColorThread *color_thread;
215 PLUGIN_THREAD_HEADER(ChromaKeyHSV, ChromaKeyThread, ChromaKeyWindow)
218 class ChromaKeyServer : public LoadServer
220 public:
221 ChromaKeyServer(ChromaKeyHSV *plugin);
222 void init_packages();
223 LoadClient* new_client();
224 LoadPackage* new_package();
225 ChromaKeyHSV *plugin;
228 class ChromaKeyPackage : public LoadPackage
230 public:
231 ChromaKeyPackage();
232 int y1, y2;
235 class ChromaKeyUnit : public LoadClient
237 public:
238 ChromaKeyUnit(ChromaKeyHSV *plugin, ChromaKeyServer *server);
239 void process_package(LoadPackage *package);
240 template <typename component_type> void process_chromakey(int components, component_type max, bool use_yuv, ChromaKeyPackage *pkg);
241 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);
243 ChromaKeyHSV *plugin;
250 class ChromaKeyHSV : public PluginVClient
252 public:
253 ChromaKeyHSV(PluginServer *server);
254 ~ChromaKeyHSV();
256 int process_buffer(VFrame *frame,
257 int64_t start_position,
258 double frame_rate);
259 int is_realtime();
260 char* plugin_title();
261 VFrame* new_picon();
262 int load_configuration();
263 int load_defaults();
264 int save_defaults();
265 void save_data(KeyFrame *keyframe);
266 void read_data(KeyFrame *keyframe);
267 int show_gui();
268 int set_string();
269 void raise_window();
270 void update_gui();
272 ChromaKeyConfig config;
273 VFrame *input, *output;
274 ChromaKeyServer *engine;
275 ChromaKeyThread *thread;
276 BC_Hash *defaults;
286 #endif