no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / scale / scale.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 SCALE_H
23 #define SCALE_H
24
25 // the simplest plugin possible
26
27 class ScaleMain;
28 class ScaleConstrain;
29 class ScaleThread;
30 class ScaleWin;
31
32 class ScaleUseScale;
33 class ScaleUseSize;
34
35 class ScaleXFactorText;
36 class ScaleXFactorSlider;
37 class ScaleYFactorText;
38 class ScaleYFactorSlider;
39 class ScaleWidthText;
40 class ScaleWidthSlider;
41 class ScaleHeightText;
42 class ScaleHeightSlider;
43
44 class ScaleClr;
45 class ScaleReset;
46
47 #define RESET_DEFAULT_SETTINGS 10
48 #define RESET_ALL    0
49 #define RESET_X_FACTOR 1
50 #define RESET_Y_FACTOR 2
51 #define RESET_WIDTH  3
52 #define RESET_HEIGHT 4
53
54 #define MIN_FACTOR  0.00
55 #define MAX_FACTOR 10.00
56 #define MAX_WIDTH 16384
57 #define MAX_HEIGHT 9216
58
59
60 #include "bchash.h"
61 #include "guicast.h"
62 #include "mwindow.inc"
63 #include "mutex.h"
64 #include "new.h"
65 #include "scalewin.h"
66 #include "overlayframe.h"
67 #include "pluginvclient.h"
68
69 #define FIXED_SCALE 0
70 #define FIXED_SIZE 1
71
72 class ScaleConfig
73 {
74 public:
75         ScaleConfig();
76         void reset(int clear);
77         void copy_from(ScaleConfig &src);
78         int equivalent(ScaleConfig &src);
79         void interpolate(ScaleConfig &prev,
80                 ScaleConfig &next,
81                 int64_t prev_frame,
82                 int64_t next_frame,
83                 int64_t current_frame);
84
85         int type;
86         float x_factor, y_factor;
87         int width, height;
88         int constrain;
89 };
90
91
92
93
94
95 class ScaleUseScale : public BC_Radial
96 {
97 public:
98         ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y);
99         ~ScaleUseScale();
100         int handle_event();
101
102         ScaleWin *win;
103         ScaleMain *client;
104 };
105
106 class ScaleUseSize : public BC_Radial
107 {
108 public:
109         ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y);
110         ~ScaleUseSize();
111         int handle_event();
112
113         ScaleWin *win;
114         ScaleMain *client;
115 };
116
117 class ScaleConstrain : public BC_CheckBox
118 {
119 public:
120         ScaleConstrain(ScaleWin *win, ScaleMain *client, int x, int y);
121         ~ScaleConstrain();
122         int handle_event();
123
124         ScaleWin *win;
125         ScaleMain *client;
126 };
127
128 class ScaleWin : public PluginClientWindow
129 {
130 public:
131         ScaleWin(ScaleMain *client);
132         ~ScaleWin();
133
134         void create_objects();
135         void update(int clear);
136
137         void update_scale_size_enable();
138
139         ScaleMain *client;
140
141         FrameSizePulldown *pulldown;
142         ScaleUseScale *use_scale;
143         ScaleUseSize *use_size;
144         ScaleConstrain *constrain;
145
146         ScaleXFactorText *x_factor_text;
147         ScaleXFactorSlider *x_factor_slider;
148         ScaleClr *x_factor_clr;
149
150         ScaleYFactorText *y_factor_text;
151         ScaleYFactorSlider *y_factor_slider;
152         ScaleClr *y_factor_clr;
153
154         ScaleWidthText *width_text;
155         ScaleWidthSlider *width_slider;
156         ScaleClr *width_clr;
157
158         ScaleHeightText *height_text;
159         ScaleHeightSlider *height_slider;
160         ScaleClr *height_clr;
161
162         ScaleReset *reset;
163 };
164
165
166
167 class ScaleMain : public PluginVClient
168 {
169 public:
170         ScaleMain(PluginServer *server);
171         ~ScaleMain();
172
173 // required for all realtime plugins
174         PLUGIN_CLASS_MEMBERS(ScaleConfig)
175         int process_buffer(VFrame *frame,
176                 int64_t start_position,
177                 double frame_rate);
178         void calculate_transfer(VFrame *frame,
179                 float &in_x1,
180                 float &in_x2,
181                 float &in_y1,
182                 float &in_y2,
183                 float &out_x1,
184                 float &out_x2,
185                 float &out_y1,
186                 float &out_y2);
187         int handle_opengl();
188         int is_realtime();
189         void update_gui();
190         void save_data(KeyFrame *keyframe);
191         void read_data(KeyFrame *keyframe);
192         void set_type(int type);
193
194
195         PluginServer *server;
196         OverlayFrame *overlayer;   // To scale images
197 };
198
199 class ScaleXFactorText : public BC_TumbleTextBox
200 {
201 public:
202         ScaleXFactorText(ScaleWin *win, ScaleMain *client,
203                 int x,
204                 int y);
205         ~ScaleXFactorText();
206         int handle_event();
207         ScaleWin *win;
208         ScaleMain *client;
209         int enabled;
210 };
211
212 class ScaleXFactorSlider : public BC_FSlider
213 {
214 public:
215         ScaleXFactorSlider(ScaleWin *win, ScaleMain *client,
216                 int x, int y, int w);
217         ~ScaleXFactorSlider();
218         int handle_event();
219         ScaleWin *win;
220         ScaleMain *client;
221 };
222
223 class ScaleYFactorText : public BC_TumbleTextBox
224 {
225 public:
226         ScaleYFactorText(ScaleWin *win, ScaleMain *client,
227                 int x,
228                 int y);
229         ~ScaleYFactorText();
230         int handle_event();
231         ScaleWin *win;
232         ScaleMain *client;
233         int enabled;
234 };
235
236 class ScaleYFactorSlider : public BC_FSlider
237 {
238 public:
239         ScaleYFactorSlider(ScaleWin *win, ScaleMain *client,
240                 int x, int y, int w);
241         ~ScaleYFactorSlider();
242         int handle_event();
243         ScaleWin *win;
244         ScaleMain *client;
245 };
246
247 class ScaleWidthText : public BC_TumbleTextBox
248 {
249 public:
250         ScaleWidthText(ScaleWin *win, ScaleMain *client,
251                 int x,
252                 int y);
253         ~ScaleWidthText();
254         int handle_event();
255         ScaleWin *win;
256         ScaleMain *client;
257         int enabled;
258 };
259
260 class ScaleWidthSlider : public BC_ISlider
261 {
262 public:
263         ScaleWidthSlider(ScaleWin *win, ScaleMain *client,
264                 int x, int y, int w);
265         ~ScaleWidthSlider();
266         int handle_event();
267         ScaleWin *win;
268         ScaleMain *client;
269 };
270
271 class ScaleHeightText : public BC_TumbleTextBox
272 {
273 public:
274         ScaleHeightText(ScaleWin *win, ScaleMain *client,
275                 int x,
276                 int y);
277         ~ScaleHeightText();
278         int handle_event();
279         ScaleWin *win;
280         ScaleMain *client;
281         int enabled;
282 };
283
284 class ScaleHeightSlider : public BC_ISlider
285 {
286 public:
287         ScaleHeightSlider(ScaleWin *win, ScaleMain *client,
288                 int x, int y, int w);
289         ~ScaleHeightSlider();
290         int handle_event();
291         ScaleWin *win;
292         ScaleMain *client;
293 };
294
295
296 class ScaleClr : public BC_Button
297 {
298 public:
299         ScaleClr(ScaleWin *win, ScaleMain *client,
300                 int x, int y, int clear);
301         ~ScaleClr();
302         int handle_event();
303         ScaleWin *win;
304         ScaleMain *client;
305         int clear;
306 };
307
308 class ScaleReset : public BC_GenericButton
309 {
310 public:
311         ScaleReset(ScaleWin *win, ScaleMain *client, int x, int y);
312         ~ScaleReset();
313         int handle_event();
314         ScaleWin *win;
315         ScaleMain *client;
316 };
317
318 #endif