164eeb62c5be736f2365cf2fdd7c60a61209cec7
[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 ScaleWidth;
29 class ScaleHeight;
30 class ScaleConstrain;
31 class ScaleThread;
32 class ScaleWin;
33
34 #include "bchash.h"
35 #include "guicast.h"
36 #include "mwindow.inc"
37 #include "mutex.h"
38 #include "new.h"
39 #include "scalewin.h"
40 #include "overlayframe.h"
41 #include "pluginvclient.h"
42
43 #define FIXED_SCALE 0
44 #define FIXED_SIZE 1
45
46 class ScaleConfig
47 {
48 public:
49         ScaleConfig();
50
51         void copy_from(ScaleConfig &src);
52         int equivalent(ScaleConfig &src);
53         void interpolate(ScaleConfig &prev,
54                 ScaleConfig &next,
55                 int64_t prev_frame,
56                 int64_t next_frame,
57                 int64_t current_frame);
58
59         int type;
60         float x_factor, y_factor;
61         int width, height;
62         int constrain;
63 };
64
65
66 class ScaleXFactor : public BC_TumbleTextBox
67 {
68 public:
69         ScaleXFactor(ScaleWin *win, ScaleMain *client, int x, int y);
70         ~ScaleXFactor();
71         int handle_event();
72
73         ScaleMain *client;
74         ScaleWin *win;
75         int enabled;
76 };
77
78 class ScaleWidth : public BC_TumbleTextBox
79 {
80 public:
81         ScaleWidth(ScaleWin *win, ScaleMain *client, int x, int y);
82         ~ScaleWidth();
83         int handle_event();
84
85         ScaleMain *client;
86         ScaleWin *win;
87         int enabled;
88 };
89
90 class ScaleYFactor : public BC_TumbleTextBox
91 {
92 public:
93         ScaleYFactor(ScaleWin *win, ScaleMain *client, int x, int y);
94         ~ScaleYFactor();
95         int handle_event();
96
97         ScaleMain *client;
98         ScaleWin *win;
99         int enabled;
100 };
101
102 class ScaleHeight : public BC_TumbleTextBox
103 {
104 public:
105         ScaleHeight(ScaleWin *win, ScaleMain *client, int x, int y);
106         ~ScaleHeight();
107         int handle_event();
108
109         ScaleMain *client;
110         ScaleWin *win;
111         int enabled;
112 };
113
114 class ScaleUseScale : public BC_Radial
115 {
116 public:
117         ScaleUseScale(ScaleWin *win, ScaleMain *client, int x, int y);
118         ~ScaleUseScale();
119         int handle_event();
120
121         ScaleWin *win;
122         ScaleMain *client;
123 };
124
125 class ScaleUseSize : public BC_Radial
126 {
127 public:
128         ScaleUseSize(ScaleWin *win, ScaleMain *client, int x, int y);
129         ~ScaleUseSize();
130         int handle_event();
131
132         ScaleWin *win;
133         ScaleMain *client;
134 };
135
136 class ScaleConstrain : public BC_CheckBox
137 {
138 public:
139         ScaleConstrain(ScaleMain *client, int x, int y);
140         ~ScaleConstrain();
141         int handle_event();
142
143         ScaleMain *client;
144 };
145
146 class ScaleWin : public PluginClientWindow
147 {
148 public:
149         ScaleWin(ScaleMain *client);
150         ~ScaleWin();
151
152         void create_objects();
153
154         ScaleMain *client;
155         ScaleXFactor *x_factor;
156         ScaleYFactor *y_factor;
157         ScaleWidth *width;
158         ScaleHeight *height;
159         FrameSizePulldown *pulldown;
160         ScaleUseScale *use_scale;
161         ScaleUseSize *use_size;
162         ScaleConstrain *constrain;
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
200 #endif