4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
24 #include "seltempavgwindow.h"
28 #define MAX_FRAMES 1024
31 SelTempAvgWindow::SelTempAvgWindow(SelTempAvgMain *client)
32 : PluginClientWindow(client,
39 this->client = client;
42 SelTempAvgWindow::~SelTempAvgWindow()
46 void SelTempAvgWindow::create_objects()
48 int xs10 = xS(10), xs20 = xS(20), xs40 = xS(40), xs80 = xS(80), xs175=xS(175), xs260=xS(260);
49 int ys10 = yS(10), ys20 = yS(20), ys25 = yS(25), ys30 = yS(30), ys35 = yS(35);
50 int x1 = xs10, x2 = xs40, x3 = xs80, x4 = xs175, x5 = xs260, y = ys10;
52 add_tool(new BC_Title(x1, y, _("Frames to average")));
54 add_tool(total_frames = new SelTempAvgSlider(client, x1, y));
57 add_tool(new BC_Title(x1, y, _("Use Method:")));
60 add_tool(method_none = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_NONE, _("None ")));
63 add_tool(method_seltempavg = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_SELTEMPAVG, _("Selective Temporal Averaging: ")));
66 add_tool(new BC_Title(x3, y, _("Av. Thres.")));
67 add_tool(new BC_Title(x4, y, _("S.D. Thres.")));
68 add_tool(new BC_Title(x5, y, _("Mask")));
71 add_tool(new BC_Title(x2, y, _("R / Y")));
72 add_tool(avg_threshold_RY = new SelTempAvgThreshSlider(client, x3, y, AVG_RY,client->config.avg_threshold_RY));
73 add_tool(std_threshold_RY = new SelTempAvgThreshSlider(client, x4, y, STD_RY,client->config.std_threshold_RY));
74 add_tool(mask_RY = new SelTempAvgMask(client, x5, y, MASK_RY, client->config.mask_RY));
77 add_tool(new BC_Title(x2, y, _("G / U")));
78 add_tool(avg_threshold_GU = new SelTempAvgThreshSlider(client, x3, y, AVG_GU,client->config.avg_threshold_GU));
79 add_tool(std_threshold_GU = new SelTempAvgThreshSlider(client, x4, y, STD_GU,client->config.std_threshold_GU));
80 add_tool(mask_GU = new SelTempAvgMask(client, x5, y, MASK_GU,client->config.mask_GU));
83 add_tool(new BC_Title(x2, y, _("B / V")));
84 add_tool(avg_threshold_BV = new SelTempAvgThreshSlider(client, x3, y, AVG_BV,client->config.avg_threshold_BV));
85 add_tool(std_threshold_BV = new SelTempAvgThreshSlider(client, x4, y, STD_BV,client->config.std_threshold_BV));
86 add_tool(mask_BV = new SelTempAvgMask(client, x5, y, MASK_BV,client->config.mask_BV));
89 add_tool(method_average = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_AVERAGE, _("Average")));
91 add_tool(method_stddev = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_STDDEV, _("Standard Deviation")));
94 add_tool(new BC_Title(x1, y, _("First frame in average:")));
96 add_tool(offset_fixed = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_FIXED, _("Fixed offset: ")));
97 add_tool(offset_fixed_value = new SelTempAvgOffsetValue(client, x4, y));
100 add_tool(offset_restartmarker = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS, _("Restart marker system:")));
101 add_tool(offset_restartmarker_pos = new BC_TextBox(x4+xs20, y, 100, 1, ""));
102 offset_restartmarker_pos->disable();
104 add_tool(offset_restartmarker_keyframe = new SelTempAvgStartKeyframe(client, x2 + xs10, y));
108 add_tool(new BC_Title(x1, y, _("Other Options:")));
110 add_tool(paranoid = new SelTempAvgParanoid(client, x1, y));
112 add_tool(no_subtract = new SelTempAvgNoSubtract(client, x1, y));
114 add_tool(new BC_Title(x2, y, _("Gain:")));
115 add_tool(gain = new SelTempAvgGainValue(client, x3, y));
125 SelTempAvgThreshSlider::SelTempAvgThreshSlider(SelTempAvgMain *client, int x, int y, int id, float currentval)
126 : BC_TextBox(x,y, xS(80), 1, currentval)
131 this->client = client;
133 SelTempAvgThreshSlider::~SelTempAvgThreshSlider()
136 int SelTempAvgThreshSlider::handle_event()
138 float val = atof(get_text());
144 client->config.avg_threshold_RY = val;
147 client->config.avg_threshold_GU = val;
150 client->config.avg_threshold_BV = val;
153 client->config.std_threshold_RY = val;
156 client->config.std_threshold_GU = val;
159 client->config.std_threshold_BV = val;
163 client->send_configure_change();
168 SelTempAvgOffsetValue::SelTempAvgOffsetValue(SelTempAvgMain *client, int x, int y)
169 : BC_TextBox(x,y, xS(80), 1, client->config.offset_fixed_value)
171 this->client = client;
173 SelTempAvgOffsetValue::~SelTempAvgOffsetValue()
176 int SelTempAvgOffsetValue::handle_event()
178 int val = atoi(get_text());
180 client->config.offset_fixed_value = val;
181 client->send_configure_change();
186 SelTempAvgGainValue::SelTempAvgGainValue(SelTempAvgMain *client, int x, int y)
187 : BC_TextBox(x,y, xS(80), 1, client->config.gain)
189 this->client = client;
191 SelTempAvgGainValue::~SelTempAvgGainValue()
194 int SelTempAvgGainValue::handle_event()
196 float val = atof(get_text());
199 client->config.gain = val;
200 client->send_configure_change();
208 SelTempAvgSlider::SelTempAvgSlider(SelTempAvgMain *client, int x, int y)
209 : BC_ISlider(x, y, 0, xS(280), yS(200), 1, MAX_FRAMES, client->config.frames)
211 this->client = client;
213 SelTempAvgSlider::~SelTempAvgSlider()
216 int SelTempAvgSlider::handle_event()
218 int result = get_value();
219 if(result < 1) result = 1;
220 client->config.frames = result;
221 client->send_configure_change();
227 SelTempAvgOffsetRadial::SelTempAvgOffsetRadial(SelTempAvgMain *client, SelTempAvgWindow *gui, int x, int y, int type, char *caption)
228 : BC_Radial(x, y, client->config.offsetmode == type, caption)
230 this->client = client;
234 int SelTempAvgOffsetRadial::handle_event()
236 client->config.offsetmode = type;
238 gui->offset_fixed->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_FIXED);
239 gui->offset_restartmarker->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS);
241 client->send_configure_change();
247 SelTempAvgMethodRadial::SelTempAvgMethodRadial(SelTempAvgMain *client,
248 SelTempAvgWindow *gui, int x, int y, int type, char *caption)
251 client->config.method == type,
254 this->client = client;
258 int SelTempAvgMethodRadial::handle_event()
261 client->config.method = result;
263 gui->method_none->update(client->config.method == SelTempAvgConfig::METHOD_NONE);
264 gui->method_seltempavg->update(client->config.method == SelTempAvgConfig::METHOD_SELTEMPAVG);
265 gui->method_average->update(client->config.method == SelTempAvgConfig::METHOD_AVERAGE);
266 gui->method_stddev->update(client->config.method == SelTempAvgConfig::METHOD_STDDEV);
268 client->send_configure_change();
273 SelTempAvgParanoid::SelTempAvgParanoid(SelTempAvgMain *client, int x, int y)
274 : BC_CheckBox(x, y, client->config.paranoid, _("Reprocess frame again"))
276 this->client = client;
278 int SelTempAvgParanoid::handle_event()
280 int result = get_value();
281 client->config.paranoid = result;
282 client->send_configure_change();
287 SelTempAvgNoSubtract::SelTempAvgNoSubtract(SelTempAvgMain *client, int x, int y)
288 : BC_CheckBox(x, y, client->config.nosubtract, _("Disable subtraction"))
290 this->client = client;
292 int SelTempAvgNoSubtract::handle_event()
294 int result = get_value();
295 client->config.nosubtract = result;
296 client->send_configure_change();
300 SelTempAvgMask::SelTempAvgMask(SelTempAvgMain *client, int x, int y, int type, int val)
301 : BC_CheckBox(x, y, val, "")
303 this->client = client;
306 int SelTempAvgMask::handle_event()
308 int result = get_value();
311 client->config.mask_RY = result;
314 client->config.mask_GU = result;
317 client->config.mask_BV = result;
320 client->send_configure_change();
326 SelTempAvgStartKeyframe::SelTempAvgStartKeyframe(SelTempAvgMain *client, int x, int y)
327 : BC_CheckBox(x, y, client->config.nosubtract, _("This Frame is a start of a section"))
329 this->client = client;
331 int SelTempAvgStartKeyframe::handle_event()
333 int result = get_value();
334 client->config.offset_restartmarker_keyframe = result;
335 client->send_configure_change();