3 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
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.
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.
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
26 #include "loadbalance.h"
28 #include "pluginclient.h"
29 #include "recordmonitor.inc"
30 #include "scopewindow.inc"
34 SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
35 SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
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
51 #define MIN_SCOPE_W xS(640)
52 #define MIN_SCOPE_H yS(320)
55 #define WAVEFORM_DIVISIONS 12
56 #define VECTORSCOPE_DIVISIONS 11
58 class ScopePackage : public LoadPackage
66 class ScopeUnit : public LoadClient
69 ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
70 void process_package(LoadPackage *package);
71 int bins[HIST_SECTIONS][TOTAL_BINS];
75 class ScopeEngine : public LoadServer
78 ScopeEngine(ScopeGUI *gui, int cpus);
79 virtual ~ScopeEngine();
81 LoadClient* new_client();
82 LoadPackage* new_package();
87 class ScopePanel : public BC_SubWindow
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();
102 class ScopeWaveform : public ScopePanel
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();
114 class ScopeVectorscope : public ScopePanel
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();
125 class ScopeHistogram : public ScopePanel
128 ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
130 void update_point(int x, int y);
132 void draw(int flash, int flush);
133 void draw_mode(int mode, int color, int y, int h);
138 class ScopeScopesOn : public BC_MenuItem
141 ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
144 ScopeMenu *scope_menu;
148 class ScopeMenu : public BC_PopupMenu
151 ScopeMenu(ScopeGUI *gui, int x, int y);
152 void create_objects();
153 void update_toggles();
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;
164 class ScopeWaveSlider : public BC_ISlider
167 ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
172 class ScopeVectSlider : public BC_ISlider
175 ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
180 class ScopeSmooth : public BC_CheckBox
183 ScopeSmooth(ScopeGUI *gui, int x, int y);
189 class ScopeGUI : public PluginClientWindow
192 ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
193 ScopeGUI(PluginClient *plugin, int w, int h);
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() {}
203 // Called for user storage when toggles change
204 virtual void toggle_event();
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);
216 VFrame *output_frame;
217 VFrame *data_frame, *temp_frame;
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;
229 BC_Title *value_text;
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;
237 int use_hist, use_wave, use_vector;
238 int use_hist_parade, use_wave_parade;
240 int bins[HIST_SECTIONS][TOTAL_BINS];
241 int frame_w, use_smooth;
242 int use_wave_gain, use_vect_gain;
246 class BoxBlurPackage : public LoadPackage
253 class BoxBlurUnit : public LoadClient
256 BoxBlurUnit(BoxBlur*server);
257 template<class dst_t, class src_t>
258 void blurt_package(LoadPackage *package);
259 void process_package(LoadPackage *package);
262 class BoxBlur : public LoadServer
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;
280 int src_ustep, dst_ustep;
281 int src_vstep, dst_vstep;
283 int ulen, vlen, c0, c1;