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 int result = get_value();
237 client->config.offsetmode = result;
239 gui->offset_fixed->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_FIXED);
240 gui->offset_restartmarker->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS);
242 client->send_configure_change();
248 SelTempAvgMethodRadial::SelTempAvgMethodRadial(SelTempAvgMain *client,
249 SelTempAvgWindow *gui, int x, int y, int type, char *caption)
252 client->config.method == type,
255 this->client = client;
259 int SelTempAvgMethodRadial::handle_event()
261 int result = get_value();
262 client->config.method = result;
264 gui->method_none->update(client->config.method == SelTempAvgConfig::METHOD_NONE);
265 gui->method_seltempavg->update(client->config.method == SelTempAvgConfig::METHOD_SELTEMPAVG);
266 gui->method_average->update(client->config.method == SelTempAvgConfig::METHOD_AVERAGE);
267 gui->method_stddev->update(client->config.method == SelTempAvgConfig::METHOD_STDDEV);
269 client->send_configure_change();
274 SelTempAvgParanoid::SelTempAvgParanoid(SelTempAvgMain *client, int x, int y)
275 : BC_CheckBox(x, y, client->config.paranoid, _("Reprocess frame again"))
277 this->client = client;
279 int SelTempAvgParanoid::handle_event()
281 int result = get_value();
282 client->config.paranoid = result;
283 client->send_configure_change();
288 SelTempAvgNoSubtract::SelTempAvgNoSubtract(SelTempAvgMain *client, int x, int y)
289 : BC_CheckBox(x, y, client->config.nosubtract, _("Disable subtraction"))
291 this->client = client;
293 int SelTempAvgNoSubtract::handle_event()
295 int result = get_value();
296 client->config.nosubtract = result;
297 client->send_configure_change();
301 SelTempAvgMask::SelTempAvgMask(SelTempAvgMain *client, int x, int y, int type, int val)
302 : BC_CheckBox(x, y, val, "")
304 this->client = client;
307 int SelTempAvgMask::handle_event()
309 int result = get_value();
312 client->config.mask_RY = result;
315 client->config.mask_GU = result;
318 client->config.mask_BV = result;
321 client->send_configure_change();
327 SelTempAvgStartKeyframe::SelTempAvgStartKeyframe(SelTempAvgMain *client, int x, int y)
328 : BC_CheckBox(x, y, client->config.nosubtract, _("This Frame is a start of a section"))
330 this->client = client;
332 int SelTempAvgStartKeyframe::handle_event()
334 int result = get_value();
335 client->config.offset_restartmarker_keyframe = result;
336 client->send_configure_change();