Credit Andrew - updating patches for FFmpeg 7.0 as needed since 6.1, now at 7.0,...
[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         ChromaKeyFText *threshold_text;
201         ChromaKeyFSlider *threshold_slider;
202         ChromaKeyClr *threshold_Clr;
203
204         ChromaKeyUseValue *use_value;
205         ChromaKeyUseColorPicker *use_colorpicker;
206
207         ChromaKeyFText *slope_text;
208         ChromaKeyFSlider *slope_slider;
209         ChromaKeyClr *slope_Clr;
210
211         ChromaKeyReset *reset;
212         ChromaKeyDefaultSettings *default_settings;
213         BC_SubWindow *sample;
214         ChromaKey *plugin;
215         ChromaKeyColorThread *color_thread;
216 };
217
218
219
220
221
222 class ChromaKeyServer : public LoadServer
223 {
224 public:
225         ChromaKeyServer(ChromaKey *plugin);
226         void init_packages();
227         LoadClient* new_client();
228         LoadPackage* new_package();
229         ChromaKey *plugin;
230 };
231
232 class ChromaKeyPackage : public LoadPackage
233 {
234 public:
235         ChromaKeyPackage();
236         int y1, y2;
237 };
238
239 class ChromaKeyUnit : public LoadClient
240 {
241 public:
242         ChromaKeyUnit(ChromaKey *plugin, ChromaKeyServer *server);
243         void process_package(LoadPackage *package);
244         ChromaKey *plugin;
245 };
246
247
248
249
250 class ChromaKey : public PluginVClient
251 {
252 public:
253         ChromaKey(PluginServer *server);
254         ~ChromaKey();
255
256         PLUGIN_CLASS_MEMBERS(ChromaKeyConfig)
257         int process_buffer(VFrame *frame,
258                 int64_t start_position,
259                 double frame_rate);
260         int handle_opengl();
261         int is_realtime();
262         void save_data(KeyFrame *keyframe);
263         void read_data(KeyFrame *keyframe);
264         void update_gui();
265
266         VFrame *input, *output;
267         ChromaKeyServer *engine;
268 };
269
270
271
272
273
274
275
276
277 #endif
278
279
280
281
282
283
284