no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / perspective / perspective.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 #include <math.h>
23 #include <stdint.h>
24 #include <string.h>
25
26 #include "affine.inc"
27 #include "clip.h"
28 #include "bchash.h"
29 #include "filexml.h"
30 #include "guicast.h"
31 #include "keyframe.h"
32 #include "loadbalance.h"
33 #include "pluginvclient.h"
34 #include "vframe.h"
35
36
37 class PerspectiveConfig;
38 class PerspectiveCanvas;
39 class PerspectiveCoord;
40 class PerspectiveReset;
41 class PerspectiveMode;
42 class PerspectiveDirection;
43 class PerspectiveAffine;
44 class PerspectiveAffineItem;
45 class PerspectiveZoomView;
46 class PerspectiveWindow;
47 class PerspectiveMain;
48
49 class PerspectiveConfig
50 {
51 public:
52         PerspectiveConfig();
53
54         int equivalent(PerspectiveConfig &that);
55         void copy_from(PerspectiveConfig &that);
56         void interpolate(PerspectiveConfig &prev, PerspectiveConfig &next,
57                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
58
59         float x1, y1, x2, y2, x3, y3, x4, y4;
60         float view_x, view_y, view_zoom;
61         int mode, smoothing;
62         int window_w, window_h;
63         int current_point;
64         int forward;
65 };
66
67
68
69 class PerspectiveCanvas : public BC_SubWindow
70 {
71 public:
72         PerspectiveCanvas(PerspectiveWindow *gui,
73                 int x, int y, int w, int h);
74         int button_press_event();
75         int button_release_event();
76         int cursor_motion_event();
77
78         int state;
79         enum { NONE, DRAG, DRAG_FULL, ZOOM, DRAG_VIEW };
80
81         int start_x, start_y;
82         float start_x1, start_y1;
83         float start_x2, start_y2;
84         float start_x3, start_y3;
85         float start_x4, start_y4;
86         PerspectiveWindow *gui;
87 };
88
89 class PerspectiveCoord : public BC_TumbleTextBox
90 {
91 public:
92         PerspectiveCoord(PerspectiveWindow *gui,
93                 int x, int y, float value, int is_x);
94         int handle_event();
95         PerspectiveWindow *gui;
96         int is_x;
97 };
98
99 class PerspectiveReset : public BC_GenericButton
100 {
101 public:
102         PerspectiveReset(PerspectiveWindow *gui, int x, int y);
103         int handle_event();
104         PerspectiveWindow *gui;
105 };
106
107 class PerspectiveMode : public BC_Radial
108 {
109 public:
110         PerspectiveMode(PerspectiveWindow *gui,
111                 int x, int y, int value, char *text);
112         int handle_event();
113         PerspectiveWindow *gui;
114         int value;
115 };
116
117 class PerspectiveDirection : public BC_Radial
118 {
119 public:
120         PerspectiveDirection(PerspectiveWindow *gui,
121                 int x, int y, int value, char *text);
122         int handle_event();
123         PerspectiveWindow *gui;
124         int value;
125 };
126
127 class PerspectiveAffine : public BC_PopupMenu
128 {
129         static const int n_modes = AffineEngine::AF_MODES;
130         const char *affine_modes[n_modes];
131         PerspectiveAffineItem *affine_items[n_modes];
132 public:
133         PerspectiveAffine(PerspectiveWindow *gui, int x, int y);
134         ~PerspectiveAffine();
135
136         void create_objects();
137         void update(int mode, int send=1);
138         void affine_item(int id);
139
140         PerspectiveWindow *gui;
141         int mode;
142 };
143
144 class PerspectiveAffineItem : public BC_MenuItem
145 {
146 public:
147         PerspectiveAffineItem(const char *txt, int id)
148         : BC_MenuItem(txt) { this->id = id; }
149
150         int handle_event();
151         PerspectiveWindow *gui;
152         int id;
153 };
154
155 class PerspectiveZoomView : public BC_FSlider
156 {
157 public:
158         PerspectiveZoomView(PerspectiveWindow *gui,
159                 int x, int y, int w);
160         ~PerspectiveZoomView();
161
162         int handle_event();
163         char *get_caption();
164         void update(float zoom);
165
166         PerspectiveWindow *gui;
167 };
168
169
170 class PerspectiveWindow : public PluginClientWindow
171 {
172 public:
173         PerspectiveWindow(PerspectiveMain *plugin);
174         ~PerspectiveWindow();
175
176         void create_objects();
177         int resize_event(int x, int y);
178         void update_canvas();
179         void update_mode();
180         void update_view_zoom();
181         void reset_view();
182         void update_coord();
183         void calculate_canvas_coords(
184                 int &x1, int &y1, int &x2, int &y2,
185                 int &x3, int &y3, int &x4, int &y4);
186
187         PerspectiveCanvas *canvas;
188         BC_Title *curr_point;
189         PerspectiveCoord *x, *y;
190         PerspectiveReset *reset;
191         PerspectiveZoomView *zoom_view;
192         PerspectiveMode *mode_perspective, *mode_sheer, *mode_stretch;
193         PerspectiveAffine *affine;
194         PerspectiveMain *plugin;
195         PerspectiveDirection *forward, *reverse;
196 };
197
198
199 class PerspectiveMain : public PluginVClient
200 {
201 public:
202         PerspectiveMain(PluginServer *server);
203         ~PerspectiveMain();
204
205         int process_buffer(VFrame *frame,
206                 int64_t start_position,
207                 double frame_rate);
208         int is_realtime();
209         void save_data(KeyFrame *keyframe);
210         void read_data(KeyFrame *keyframe);
211         void update_gui();
212         int handle_opengl();
213
214         PLUGIN_CLASS_MEMBERS(PerspectiveConfig)
215
216         float get_current_x();
217         float get_current_y();
218         void set_current_x(float value);
219         void set_current_y(float value);
220         VFrame *input, *output;
221         VFrame *temp;
222         AffineEngine *engine;
223 };
224
225