upgrades to scopewindow, add blurbox, bd.sh sed tab test, tweak clk2play over window...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / scopewindow.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #ifndef SCOPEWINDOW_H
22 #define SCOPEWINDOW_H
23
24
25 #include "guicast.h"
26 #include "loadbalance.h"
27 #include "mwindow.h"
28 #include "pluginclient.h"
29 #include "recordmonitor.inc"
30 #include "scopewindow.inc"
31 #include "theme.inc"
32
33 enum {
34         SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
35         SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
36         SCOPE_VECTORSCOPE,
37 };
38
39 // Number of divisions in histogram.
40 // 65536 + min and max range to speed up the tabulation
41 #define TOTAL_BINS 0x13333
42 #define HIST_SECTIONS 4
43 #define FLOAT_RANGE 1.2
44 // Minimum value in percentage
45 #define HISTOGRAM_MIN -10
46 #define FLOAT_MIN -0.1
47 // Maximum value in percentage
48 #define HISTOGRAM_MAX 110
49 #define FLOAT_MAX 1.1
50
51 #define MIN_SCOPE_W xS(640)
52 #define MIN_SCOPE_H yS(320)
53
54
55 #define WAVEFORM_DIVISIONS 12
56 #define VECTORSCOPE_DIVISIONS 11
57
58 class ScopePackage : public LoadPackage
59 {
60 public:
61         ScopePackage();
62         int row1, row2;
63 };
64
65
66 class ScopeUnit : public LoadClient
67 {
68 public:
69         ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
70         void process_package(LoadPackage *package);
71         int bins[HIST_SECTIONS][TOTAL_BINS];
72         ScopeGUI *gui;
73 };
74
75 class ScopeEngine : public LoadServer
76 {
77 public:
78         ScopeEngine(ScopeGUI *gui, int cpus);
79         virtual ~ScopeEngine();
80         void init_packages();
81         LoadClient* new_client();
82         LoadPackage* new_package();
83         void process();
84         ScopeGUI *gui;
85 };
86
87 class ScopePanel : public BC_SubWindow
88 {
89 public:
90         ScopePanel(ScopeGUI *gui, int x, int y, int w, int h);
91         void create_objects();
92         virtual void update_point(int x, int y);
93         virtual void draw_point();
94         virtual void clear_point();
95         int button_press_event();
96         int cursor_motion_event();
97         int button_release_event();
98         int is_dragging;
99         ScopeGUI *gui;
100 };
101
102 class ScopeWaveform : public ScopePanel
103 {
104 public:
105         ScopeWaveform(ScopeGUI *gui, int x, int y, int w, int h);
106         virtual void update_point(int x, int y);
107         virtual void draw_point();
108         virtual void clear_point();
109         int drag_x;
110         int drag_y;
111 };
112
113
114 class ScopeVectorscope : public ScopePanel
115 {
116 public:
117         ScopeVectorscope(ScopeGUI *gui, int x, int y, int w, int h);
118         virtual void update_point(int x, int y);
119         virtual void draw_point();
120         virtual void clear_point();
121         int drag_radius;
122         float drag_angle;
123 };
124
125 class ScopeHistogram : public ScopePanel
126 {
127 public:
128         ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
129         void clear_point();
130         void update_point(int x, int y);
131         void draw_point();
132         void draw(int flash, int flush);
133         void draw_mode(int mode, int color, int y, int h);
134         int drag_x;
135 };
136
137
138 class ScopeScopesOn : public BC_MenuItem
139 {
140 public:
141         ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
142         int handle_event();
143
144         ScopeMenu *scope_menu;
145         int id;
146 };
147
148 class ScopeMenu : public BC_PopupMenu
149 {
150 public:
151         ScopeMenu(ScopeGUI *gui, int x, int y);
152         void create_objects();
153         void update_toggles();
154
155         ScopeGUI *gui;
156         ScopeScopesOn *hist_on;
157         ScopeScopesOn *hist_rgb_on;
158         ScopeScopesOn *wave_on;
159         ScopeScopesOn *wave_rgb_on;
160         ScopeScopesOn *wave_ply_on;
161         ScopeScopesOn *vect_on;
162 };
163
164 class ScopeWaveSlider : public BC_ISlider
165 {
166 public:
167         ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
168         int handle_event();
169         ScopeGUI *gui;
170 };
171
172 class ScopeVectSlider : public BC_ISlider
173 {
174 public:
175         ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
176         int handle_event();
177         ScopeGUI *gui;
178 };
179
180 class ScopeSmooth : public BC_CheckBox
181 {
182 public:
183         ScopeSmooth(ScopeGUI *gui, int x, int y);
184         int handle_event();
185         ScopeGUI *gui;
186 };
187
188
189 class ScopeGUI : public PluginClientWindow
190 {
191 public:
192         ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
193         ScopeGUI(PluginClient *plugin, int w, int h);
194         virtual ~ScopeGUI();
195
196         void reset();
197         virtual void create_objects();
198         void create_panels();
199         virtual int resize_event(int w, int h);
200         virtual int translation_event();
201         virtual void update_scope() {}
202
203 // Called for user storage when toggles change
204         virtual void toggle_event();
205
206 // update toggles
207         void update_toggles();
208         void calculate_sizes(int w, int h);
209         void allocate_vframes();
210         void draw_overlays(int overlays, int borders, int flush);
211         void process(VFrame *output_frame);
212         void draw(int flash, int flush);
213         void clear_points(int flash);
214
215         Theme *theme;
216         VFrame *output_frame;
217         VFrame *data_frame, *temp_frame;
218         ScopeEngine *engine;
219         BoxBlur *box_blur;
220         VFrame *waveform_vframe;
221         VFrame *vector_vframe;
222         ScopeHistogram *histogram;
223         ScopeWaveform *waveform;
224         ScopeVectorscope *vectorscope;
225         ScopeMenu *scope_menu;
226         ScopeWaveSlider *wave_slider;
227         ScopeVectSlider *vect_slider;
228         ScopeSmooth *smooth;
229         BC_Title *value_text;
230
231         int x, y, w, h;
232         int vector_x, vector_y, vector_w, vector_h;
233         int wave_x, wave_y, wave_w, wave_h;
234         int hist_x, hist_y, hist_w, hist_h;
235
236         int cpus;
237         int use_hist, use_wave, use_vector;
238         int use_hist_parade, use_wave_parade;
239
240         int bins[HIST_SECTIONS][TOTAL_BINS];
241         int frame_w, use_smooth;
242         int use_wave_gain, use_vect_gain;
243 };
244
245
246 class BoxBlurPackage : public LoadPackage
247 {
248 public:
249         BoxBlurPackage();
250         int u1, u2;
251 };
252
253 class BoxBlurUnit : public LoadClient
254 {
255 public:
256         BoxBlurUnit(BoxBlur*server);
257         template<class dst_t, class src_t>
258                 void blurt_package(LoadPackage *package);
259         void process_package(LoadPackage *package);
260 };
261
262 class BoxBlur : public LoadServer
263 {
264 public:
265         BoxBlur(int cpus);
266         virtual ~BoxBlur();
267         void init_packages();
268         LoadClient* new_client();
269         LoadPackage* new_package();
270         void process(VFrame *dst, VFrame *src, int uv,
271                 int radius, int power, int comp);
272         void hblur(VFrame *dst, VFrame *src,
273                 int radius, int power, int comp=-1);
274         void vblur(VFrame *dst, VFrame *src,
275                 int radius, int power, int comp=-1);
276         void blur(VFrame *dst, VFrame *src,
277                 int radius, int power, int comp=-1);
278         const uint8_t *src_data;
279         uint8_t *dst_data;
280         int src_ustep, dst_ustep;
281         int src_vstep, dst_vstep;
282         int radius, power;
283         int ulen, vlen, c0, c1;
284 };
285
286 #endif