9eacd28424f7bca40f54a2592e513e88d5d21142
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / chromakey / chromakey.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef CHROMAKEY_H
23 #define CHROMAKEY_H
24
25
26
27
28 #include "colorpicker.h"
29 #include "guicast.h"
30 #include "theme.h"
31 #include "loadbalance.h"
32 #include "pluginvclient.h"
33
34 #define RESET_DEFAULT_SETTINGS 10
35 #define RESET_ALL               0
36 #define RESET_RGB               1
37 #define RESET_SLOPE             2
38 #define RESET_THRESHOLD         3
39
40 #define MIN_VALUE   0.00
41 #define MAX_VALUE 100.00
42
43 class ChromaKey;
44 class ChromaKey;
45 class ChromaKeyWindow;
46 class ChromaKeyFText;
47 class ChromaKeyFSlider;
48 class ChromaKeyReset;
49 class ChromaKeyDefaultSettings;
50 class ChromaKeyClr;
51
52 class ChromaKeyConfig
53 {
54 public:
55         ChromaKeyConfig();
56         void reset(int clear);
57         void copy_from(ChromaKeyConfig &src);
58         int equivalent(ChromaKeyConfig &src);
59         void interpolate(ChromaKeyConfig &prev,
60                 ChromaKeyConfig &next,
61                 int64_t prev_frame,
62                 int64_t next_frame,
63                 int64_t current_frame);
64         int get_color();
65
66         float red;
67         float green;
68         float blue;
69         float threshold;
70         float slope;
71         int use_value;
72 };
73
74 class ChromaKeyColor : public BC_GenericButton
75 {
76 public:
77         ChromaKeyColor(ChromaKey *plugin,
78                 ChromaKeyWindow *gui,
79                 int x,
80                 int y);
81
82         int handle_event();
83
84         ChromaKey *plugin;
85         ChromaKeyWindow *gui;
86 };
87
88 class ChromaKeyThreshold : public BC_FSlider
89 {
90 public:
91         ChromaKeyThreshold(ChromaKey *plugin, int x, int y);
92         int handle_event();
93         ChromaKey *plugin;
94 };
95 class ChromaKeySlope : public BC_FSlider
96 {
97 public:
98         ChromaKeySlope(ChromaKey *plugin, int x, int y);
99         int handle_event();
100         ChromaKey *plugin;
101 };
102 class ChromaKeyUseValue : public BC_CheckBox
103 {
104 public:
105         ChromaKeyUseValue(ChromaKey *plugin, int x, int y);
106         int handle_event();
107         ChromaKey *plugin;
108 };
109
110 class ChromaKeyFText : public BC_TumbleTextBox
111 {
112 public:
113         ChromaKeyFText(ChromaKey *plugin, ChromaKeyWindow *gui,
114                 ChromaKeyFSlider *slider, float *output, int x, int y, float min, float max);
115         ~ChromaKeyFText();
116         int handle_event();
117         ChromaKey *plugin;
118         ChromaKeyWindow *gui;
119         ChromaKeyFSlider *slider;
120         float *output;
121         float min, max;
122 };
123
124 class ChromaKeyFSlider : public BC_FSlider
125 {
126 public:
127         ChromaKeyFSlider(ChromaKey *plugin,
128                 ChromaKeyFText *text, float *output, int x, int y,
129                 float min, float max, int w);
130         ~ChromaKeyFSlider();
131         int handle_event();
132         ChromaKey *plugin;
133         ChromaKeyFText *text;
134         float *output;
135 };
136
137 class ChromaKeyClr : public BC_Button
138 {
139 public:
140         ChromaKeyClr(ChromaKey *plugin, ChromaKeyWindow *gui, int x, int y, int clear);
141         ~ChromaKeyClr();
142         int handle_event();
143         ChromaKey *plugin;
144         ChromaKeyWindow *gui;
145         int clear;
146 };
147
148 class ChromaKeyReset : public BC_GenericButton
149 {
150 public:
151         ChromaKeyReset(ChromaKey *plugin, ChromaKeyWindow *gui, int x, int y);
152         int handle_event();
153         ChromaKey *plugin;
154         ChromaKeyWindow *gui;
155 };
156
157 class ChromaKeyDefaultSettings : public BC_GenericButton
158 {
159 public:
160         ChromaKeyDefaultSettings(ChromaKey *plugin, ChromaKeyWindow *gui, int x, int y, int w);
161         ~ChromaKeyDefaultSettings();
162         int handle_event();
163         ChromaKey *plugin;
164         ChromaKeyWindow *gui;
165 };
166
167 class ChromaKeyUseColorPicker : public BC_GenericButton
168 {
169 public:
170         ChromaKeyUseColorPicker(ChromaKey *plugin, ChromaKeyWindow *gui, int x, int y);
171         int handle_event();
172         ChromaKey *plugin;
173         ChromaKeyWindow *gui;
174 };
175
176
177 class ChromaKeyColorThread : public ColorPicker
178 {
179 public:
180         ChromaKeyColorThread(ChromaKey *plugin, ChromaKeyWindow *gui);
181         int handle_new_color(int output, int alpha);
182         ChromaKey *plugin;
183         ChromaKeyWindow *gui;
184 };
185
186
187 class ChromaKeyWindow : public PluginClientWindow
188 {
189 public:
190         ChromaKeyWindow(ChromaKey *plugin);
191         ~ChromaKeyWindow();
192
193         void create_objects();
194         void update_gui(int clear);
195         void update_sample();
196         void done_event(int result);
197
198         ChromaKeyColor *color;
199
200         ChromaKeyThreshold *threshold;
201         ChromaKeyFText *threshold_text;
202         ChromaKeyFSlider *threshold_slider;
203         ChromaKeyClr *threshold_Clr;
204
205         ChromaKeyUseValue *use_value;
206         ChromaKeyUseColorPicker *use_colorpicker;
207
208         ChromaKeySlope *slope;
209         ChromaKeyFText *slope_text;
210         ChromaKeyFSlider *slope_slider;
211         ChromaKeyClr *slope_Clr;
212
213         ChromaKeyReset *reset;
214         ChromaKeyDefaultSettings *default_settings;
215         BC_SubWindow *sample;
216         ChromaKey *plugin;
217         ChromaKeyColorThread *color_thread;
218 };
219
220
221
222
223
224 class ChromaKeyServer : public LoadServer
225 {
226 public:
227         ChromaKeyServer(ChromaKey *plugin);
228         void init_packages();
229         LoadClient* new_client();
230         LoadPackage* new_package();
231         ChromaKey *plugin;
232 };
233
234 class ChromaKeyPackage : public LoadPackage
235 {
236 public:
237         ChromaKeyPackage();
238         int y1, y2;
239 };
240
241 class ChromaKeyUnit : public LoadClient
242 {
243 public:
244         ChromaKeyUnit(ChromaKey *plugin, ChromaKeyServer *server);
245         void process_package(LoadPackage *package);
246         ChromaKey *plugin;
247 };
248
249
250
251
252 class ChromaKey : public PluginVClient
253 {
254 public:
255         ChromaKey(PluginServer *server);
256         ~ChromaKey();
257
258         PLUGIN_CLASS_MEMBERS(ChromaKeyConfig)
259         int process_buffer(VFrame *frame,
260                 int64_t start_position,
261                 double frame_rate);
262         int handle_opengl();
263         int is_realtime();
264         void save_data(KeyFrame *keyframe);
265         void read_data(KeyFrame *keyframe);
266         void update_gui();
267
268         VFrame *input, *output;
269         ChromaKeyServer *engine;
270 };
271
272
273
274
275
276
277
278
279 #endif
280
281
282
283
284
285
286