a39cde3e52a8d6626e862f4c1c396daad9aca43e
[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 "vframe.h"
36
37 #define RESET_DEFAULT_SETTINGS 10
38 #define RESET_ALL     0
39 #define RESET_XSLIDER 1
40 #define RESET_YSLIDER 2
41 #define RESET_RADIUS  3
42 #define RESET_STEPS   4
43
44 class ZoomBlurMain;
45 class ZoomBlurWindow;
46 class ZoomBlurEngine;
47 class ZoomBlurReset;
48 class ZoomBlurDefaultSettings;
49 class ZoomBlurSliderClr;
50
51
52
53 class ZoomBlurConfig
54 {
55 public:
56         ZoomBlurConfig();
57
58         void reset(int clear);
59         int equivalent(ZoomBlurConfig &that);
60         void copy_from(ZoomBlurConfig &that);
61         void interpolate(ZoomBlurConfig &prev,
62                 ZoomBlurConfig &next,
63                 long prev_frame,
64                 long next_frame,
65                 long current_frame);
66
67         int x;
68         int y;
69         int radius;
70         int steps;
71         int r;
72         int g;
73         int b;
74         int a;
75 };
76
77
78
79 class ZoomBlurSize : public BC_ISlider
80 {
81 public:
82         ZoomBlurSize(ZoomBlurMain *plugin,
83                 int x,
84                 int y,
85                 int *output,
86                 int min,
87                 int max);
88         int handle_event();
89         ZoomBlurMain *plugin;
90         int *output;
91 };
92
93 class ZoomBlurToggle : public BC_CheckBox
94 {
95 public:
96         ZoomBlurToggle(ZoomBlurMain *plugin,
97                 int x,
98                 int y,
99                 int *output,
100                 char *string);
101         int handle_event();
102         ZoomBlurMain *plugin;
103         int *output;
104 };
105
106 class ZoomBlurWindow : public PluginClientWindow
107 {
108 public:
109         ZoomBlurWindow(ZoomBlurMain *plugin);
110         ~ZoomBlurWindow();
111
112         void create_objects();
113         void update_gui(int clear);
114
115         ZoomBlurSize *x, *y, *radius, *steps;
116         ZoomBlurToggle *r, *g, *b, *a;
117         ZoomBlurMain *plugin;
118         ZoomBlurReset *reset;
119         ZoomBlurDefaultSettings *default_settings;
120         ZoomBlurSliderClr *xClr, *yClr, *radiusClr, *stepsClr;
121 };
122
123 class ZoomBlurReset : public BC_GenericButton
124 {
125 public:
126         ZoomBlurReset(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y);
127         ~ZoomBlurReset();
128         int handle_event();
129         ZoomBlurMain *plugin;
130         ZoomBlurWindow *window;
131 };
132
133 class ZoomBlurDefaultSettings : public BC_GenericButton
134 {
135 public:
136         ZoomBlurDefaultSettings(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y, int w);
137         ~ZoomBlurDefaultSettings();
138         int handle_event();
139         ZoomBlurMain *plugin;
140         ZoomBlurWindow *window;
141 };
142
143
144 class ZoomBlurSliderClr : public BC_GenericButton
145 {
146 public:
147         ZoomBlurSliderClr(ZoomBlurMain *plugin, ZoomBlurWindow *window, int x, int y, int w, int clear);
148         ~ZoomBlurSliderClr();
149         int handle_event();
150         ZoomBlurMain *plugin;
151         ZoomBlurWindow *window;
152         int clear;
153 };
154
155
156
157 // Output coords for a layer of blurring
158 // Used for OpenGL only
159 class ZoomBlurLayer
160 {
161 public:
162         ZoomBlurLayer() {};
163         float x1, y1, x2, y2;
164 };
165
166 class ZoomBlurMain : public PluginVClient
167 {
168 public:
169         ZoomBlurMain(PluginServer *server);
170         ~ZoomBlurMain();
171
172         int process_buffer(VFrame *frame,
173                 int64_t start_position,
174                 double frame_rate);
175         int is_realtime();
176         void save_data(KeyFrame *keyframe);
177         void read_data(KeyFrame *keyframe);
178         void update_gui();
179         int handle_opengl();
180
181         PLUGIN_CLASS_MEMBERS(ZoomBlurConfig)
182
183         void delete_tables();
184         VFrame *input, *output, *temp;
185         ZoomBlurEngine *engine;
186         int **scale_y_table;
187         int **scale_x_table;
188         ZoomBlurLayer *layer_table;
189         int table_entries;
190         int need_reconfigure;
191 // The accumulation buffer is needed because 8 bits isn't precise enough
192         unsigned char *accum;
193 };
194
195 class ZoomBlurPackage : public LoadPackage
196 {
197 public:
198         ZoomBlurPackage();
199         int y1, y2;
200 };
201
202 class ZoomBlurUnit : public LoadClient
203 {
204 public:
205         ZoomBlurUnit(ZoomBlurEngine *server, ZoomBlurMain *plugin);
206         void process_package(LoadPackage *package);
207         ZoomBlurEngine *server;
208         ZoomBlurMain *plugin;
209 };
210
211 class ZoomBlurEngine : public LoadServer
212 {
213 public:
214         ZoomBlurEngine(ZoomBlurMain *plugin,
215                 int total_clients,
216                 int total_packages);
217         void init_packages();
218         LoadClient* new_client();
219         LoadPackage* new_package();
220         ZoomBlurMain *plugin;
221 };
222
223
224 #endif