Contributed Speed PerCent video plugin
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / speed_pc / speed_pc.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008-2016 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 /*
23  * 2020. Derivative by ReframeRT plugin for a more easy use.
24  * It uses percentage value of the speed referred to originl speed (=100%).
25  * Some old ReframeRT parameters (Stretch and denom) have not been deleted,
26  * for future development, if any.
27  * Stretch and denom variables are set to a constant value:
28  * Stretch= 1; denom= 100.00.
29  * Speed_MIN= 1.00%; Speed_MAX= 1000.00% 
30  */
31
32 #ifndef SPEED_PC_H
33 #define SPEED_PC_H
34
35
36 #include "bcdisplayinfo.h"
37 #include "clip.h"
38 #include "bchash.h"
39 #include "filexml.h"
40 #include "guicast.h"
41 #include "language.h"
42 #include "pluginvclient.h"
43 #include "theme.h"
44 #include "transportque.h"
45
46
47 #define RESET_DEFAULT_SETTINGS 10
48 #define RESET_ALL    0
49 #define RESET_SPEED  1
50
51 class SpeedPcConfig;
52 class SpeedPcText;
53 class SpeedPcSlider;
54 class SpeedPcStretch;
55 class SpeedPcDownsample;
56 class SpeedPcInterpolate;
57 class SpeedPcClr;
58 class SpeedPc;
59 class SpeedPcWindow;
60 class SpeedPcReset;
61
62
63
64 class SpeedPcConfig
65 {
66 public:
67         SpeedPcConfig();
68         void boundaries();
69         int equivalent(SpeedPcConfig &src);
70         void reset(int clear);
71         void copy_from(SpeedPcConfig &src);
72         void interpolate(SpeedPcConfig &prev,
73                 SpeedPcConfig &next,
74                 int64_t prev_frame,
75                 int64_t next_frame,
76                 int64_t current_frame);
77
78         double num;
79         double denom;
80         int stretch;
81         int interp;
82         int optic_flow;
83 };
84
85
86
87 class SpeedPcToggle : public BC_Radial
88 {
89 public:
90         SpeedPcToggle(SpeedPc *plugin,
91                 SpeedPcWindow *gui,
92                 int init_value,
93                 int x,
94                 int y,
95                 int value,
96                 const char *string);
97         int handle_event();
98
99         SpeedPc *plugin;
100         SpeedPcWindow *gui;
101         int value;
102 };
103
104 class SpeedPcText : public BC_TumbleTextBox
105 {
106 public:
107         SpeedPcText(SpeedPc *plugin,
108                 SpeedPcWindow *gui,
109                 int x,
110                 int y);
111         ~SpeedPcText();
112         int handle_event();
113         SpeedPc *plugin;
114         SpeedPcWindow *gui;
115 };
116
117 class SpeedPcSlider : public BC_FSlider
118 {
119 public:
120         SpeedPcSlider(SpeedPc *plugin,
121                 SpeedPcWindow *gui,
122                 int x, int y, int w);
123         ~SpeedPcSlider();
124         int handle_event();
125         SpeedPc *plugin;
126         SpeedPcWindow *gui;
127 };
128
129 class SpeedPcClr : public BC_Button
130 {
131 public:
132         SpeedPcClr(SpeedPc *plugin, SpeedPcWindow *gui,
133                 int x, int y, int clear);
134         ~SpeedPcClr();
135         int handle_event();
136         SpeedPc *plugin;
137         SpeedPcWindow *gui;
138         int clear;
139 };
140
141 class SpeedPcStretch : public BC_Radial
142 {
143 public:
144         SpeedPcStretch(SpeedPc *plugin,
145                 SpeedPcWindow *gui,
146                 int x,
147                 int y);
148         int handle_event();
149         SpeedPc *plugin;
150         SpeedPcWindow *gui;
151 };
152
153 class SpeedPcDownsample : public BC_Radial
154 {
155 public:
156         SpeedPcDownsample(SpeedPc *plugin,
157                 SpeedPcWindow *gui,
158                 int x,
159                 int y);
160         int handle_event();
161         SpeedPc *plugin;
162         SpeedPcWindow *gui;
163 };
164
165 class SpeedPcInterpolate : public BC_CheckBox
166 {
167 public:
168         SpeedPcInterpolate(SpeedPc *plugin,
169                 SpeedPcWindow *gui,
170                 int x,
171                 int y);
172         int handle_event();
173         SpeedPc *plugin;
174         SpeedPcWindow *gui;
175 };
176
177 class SpeedPcReset : public BC_GenericButton
178 {
179 public:
180         SpeedPcReset(SpeedPc *plugin, SpeedPcWindow *gui, int x, int y);
181         ~SpeedPcReset();
182         int handle_event();
183         SpeedPc *plugin;
184         SpeedPcWindow *gui;
185 };
186
187 class SpeedPcWindow : public PluginClientWindow
188 {
189 public:
190         SpeedPcWindow(SpeedPc *plugin);
191         ~SpeedPcWindow();
192         void create_objects();
193         void update(int clear);
194
195         int update_toggles();
196
197         SpeedPc *plugin;
198
199         SpeedPcToggle *toggle25pc;
200         SpeedPcToggle *toggle50pc;
201         SpeedPcToggle *toggle100pc;
202         SpeedPcToggle *toggle200pc;
203         SpeedPcToggle *toggle400pc;
204
205         SpeedPcText *speed_pc_text;
206         SpeedPcSlider *speed_pc_slider;
207         SpeedPcClr *speed_pc_clr;
208         SpeedPcStretch *stretch;
209         SpeedPcDownsample *downsample;
210         SpeedPcInterpolate *interpolate;
211
212         SpeedPcReset *reset;
213 };
214
215
216 class SpeedPc : public PluginVClient
217 {
218 public:
219         SpeedPc(PluginServer *server);
220         ~SpeedPc();
221
222         PLUGIN_CLASS_MEMBERS(SpeedPcConfig)
223
224         void save_data(KeyFrame *keyframe);
225         void read_data(KeyFrame *keyframe);
226         void update_gui();
227         int is_realtime();
228         int is_synthesis();
229         int process_buffer(VFrame *frame,
230                 int64_t start_position,
231                 double frame_rate);
232 };
233
234 #endif