no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / zoomblur / zoomblur.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 ZOOMBLUR_H
23 #define ZOOMBLUR_H
24
25
26 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
28 #include "clip.h"
29 #include "bchash.h"
30 #include "filexml.h"
31 #include "keyframe.h"
32 #include "language.h"
33 #include "loadbalance.h"
34 #include "pluginvclient.h"
35 #include "theme.h"
36 #include "vframe.h"
37
38 #define RESET_DEFAULT_SETTINGS 10
39 #define RESET_ALL     0
40 #define RESET_XSLIDER 1
41 #define RESET_YSLIDER 2
42 #define RESET_RADIUS  3
43 #define RESET_STEPS   4
44
45 #define XY_MIN       0
46 #define XY_MAX     100
47 #define RADIUS_MAX 100
48 #define STEPS_MIN    1
49 #define STEPS_MAX  100
50
51 class ZoomBlurMain;
52 class ZoomBlurWindow;
53 class ZoomBlurEngine;
54 class ZoomBlurIText;
55 class ZoomBlurISlider;
56 class ZoomBlurToggle;
57 class ZoomBlurReset;
58 class ZoomBlurDefaultSettings;
59 class ZoomBlurClr;
60
61
62
63 class ZoomBlurConfig
64 {
65 public:
66         ZoomBlurConfig();
67
68         void reset(int clear);
69         int equivalent(ZoomBlurConfig &that);
70         void copy_from(ZoomBlurConfig &that);
71         void interpolate(ZoomBlurConfig &prev,
72                 ZoomBlurConfig &next,
73                 long prev_frame,
74                 long next_frame,
75                 long current_frame);
76
77         int x;
78         int y;
79         int radius;
80         int steps;
81         int r;
82         int g;
83         int b;
84         int a;
85 };
86
87
88
89
90 class ZoomBlurIText : public BC_TumbleTextBox
91 {
92 public:
93         ZoomBlurIText(ZoomBlurWindow *window, ZoomBlurMain *plugin,
94                 ZoomBlurISlider *slider, int *output, int x, int y, int min, int max);
95         ~ZoomBlurIText();
96         int handle_event();
97         ZoomBlurWindow *window;
98         ZoomBlurMain *plugin;
99         ZoomBlurISlider *slider;
100         int *output;
101         int min, max;
102 };
103
104 class ZoomBlurISlider : public BC_ISlider
105 {
106 public:
107         ZoomBlurISlider(ZoomBlurMain *plugin,
108                 ZoomBlurIText *text, int *output, int x, int y,
109                 int min, int max, int w);
110         ~ZoomBlurISlider();
111         int handle_event();
112         ZoomBlurMain *plugin;
113         ZoomBlurIText *text;
114         int *output;
115 };
116
117 class ZoomBlurToggle : public BC_CheckBox
118 {
119 public:
120         ZoomBlurToggle(ZoomBlurMain *plugin,
121                 int x,
122                 int y,
123                 int *output,
124                 char *string);
125         int handle_event();
126         ZoomBlurMain *plugin;
127         int *output;
128 };
129
130 class ZoomBlurWindow : public PluginClientWindow
131 {
132 public:
133         ZoomBlurWindow(ZoomBlurMain *plugin);
134         ~ZoomBlurWindow();
135
136         void create_objects();
137         void update_gui(int clear);
138
139         ZoomBlurIText *x_text;
140         ZoomBlurISlider *x_slider;
141         ZoomBlurClr *x_Clr;
142
143         ZoomBlurIText *y_text;
144         ZoomBlurISlider *y_slider;
145         ZoomBlurClr *y_Clr;
146
147         ZoomBlurIText *radius_text;
148         ZoomBlurISlider *radius_slider;
149         ZoomBlurClr *radius_Clr;
150
151         ZoomBlurIText *steps_text;
152         ZoomBlurISlider *steps_slider;
153         ZoomBlurClr *steps_Clr;
154
155         ZoomBlurToggle *r, *g, *b, *a;
156         ZoomBlurMain *plugin;
157         ZoomBlurReset *reset;
158         ZoomBlurDefaultSettings *default_settings;
159 };
160
161 class ZoomBlurReset : public BC_GenericButton
162 {
163 public:
164         ZoomBlurReset(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y);
165         ~ZoomBlurReset();
166         int handle_event();
167         ZoomBlurMain *plugin;
168         ZoomBlurWindow *window;
169 };
170
171 class ZoomBlurDefaultSettings : public BC_GenericButton
172 {
173 public:
174         ZoomBlurDefaultSettings(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y, int w);
175         ~ZoomBlurDefaultSettings();
176         int handle_event();
177         ZoomBlurMain *plugin;
178         ZoomBlurWindow *window;
179 };
180
181
182 class ZoomBlurClr : public BC_Button
183 {
184 public:
185         ZoomBlurClr(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y, int clear);
186         ~ZoomBlurClr();
187         int handle_event();
188         ZoomBlurMain *plugin;
189         ZoomBlurWindow *window;
190         int clear;
191 };
192
193
194
195 // Output coords for a layer of blurring
196 // Used for OpenGL only
197 class ZoomBlurLayer
198 {
199 public:
200         ZoomBlurLayer() {};
201         float x1, y1, x2, y2;
202 };
203
204 class ZoomBlurMain : public PluginVClient
205 {
206 public:
207         ZoomBlurMain(PluginServer *server);
208         ~ZoomBlurMain();
209
210         int process_buffer(VFrame *frame,
211                 int64_t start_position,
212                 double frame_rate);
213         int is_realtime();
214         void save_data(KeyFrame *keyframe);
215         void read_data(KeyFrame *keyframe);
216         void update_gui();
217         int handle_opengl();
218
219         PLUGIN_CLASS_MEMBERS(ZoomBlurConfig)
220
221         void delete_tables();
222         VFrame *input, *output, *temp;
223         ZoomBlurEngine *engine;
224         int **scale_y_table;
225         int **scale_x_table;
226         ZoomBlurLayer *layer_table;
227         int table_entries;
228         int need_reconfigure;
229 // The accumulation buffer is needed because 8 bits isn't precise enough
230         unsigned char *accum;
231 };
232
233 class ZoomBlurPackage : public LoadPackage
234 {
235 public:
236         ZoomBlurPackage();
237         int y1, y2;
238 };
239
240 class ZoomBlurUnit : public LoadClient
241 {
242 public:
243         ZoomBlurUnit(ZoomBlurEngine *server, ZoomBlurMain *plugin);
244         void process_package(LoadPackage *package);
245         ZoomBlurEngine *server;
246         ZoomBlurMain *plugin;
247 };
248
249 class ZoomBlurEngine : public LoadServer
250 {
251 public:
252         ZoomBlurEngine(ZoomBlurMain *plugin,
253                 int total_clients,
254                 int total_packages);
255         void init_packages();
256         LoadClient* new_client();
257         LoadPackage* new_package();
258         ZoomBlurMain *plugin;
259 };
260
261
262 #endif