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 x1 = 10, x2 = 40, x3 = 80, x4 = 175, x5 = 260, y = 10;
50 add_tool(new BC_Title(x1, y, _("Frames to average")));
52 add_tool(total_frames = new SelTempAvgSlider(client, x1, y));
55 add_tool(new BC_Title(x1, y, _("Use Method:")));
58 add_tool(method_none = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_NONE, _("None ")));
61 add_tool(method_seltempavg = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_SELTEMPAVG, _("Selective Temporal Averaging: ")));
64 add_tool(new BC_Title(x3, y, _("Av. Thres.")));
65 add_tool(new BC_Title(x4, y, _("S.D. Thres.")));
66 add_tool(new BC_Title(x5, y, _("Mask")));
69 add_tool(new BC_Title(x2, y, _("R / Y")));
70 add_tool(avg_threshold_RY = new SelTempAvgThreshSlider(client, x3, y, AVG_RY,client->config.avg_threshold_RY));
71 add_tool(std_threshold_RY = new SelTempAvgThreshSlider(client, x4, y, STD_RY,client->config.std_threshold_RY));
72 add_tool(mask_RY = new SelTempAvgMask(client, x5, y, MASK_RY, client->config.mask_RY));
75 add_tool(new BC_Title(x2, y, _("G / U")));
76 add_tool(avg_threshold_GU = new SelTempAvgThreshSlider(client, x3, y, AVG_GU,client->config.avg_threshold_GU));
77 add_tool(std_threshold_GU = new SelTempAvgThreshSlider(client, x4, y, STD_GU,client->config.std_threshold_GU));
78 add_tool(mask_GU = new SelTempAvgMask(client, x5, y, MASK_GU,client->config.mask_GU));
81 add_tool(new BC_Title(x2, y, _("B / V")));
82 add_tool(avg_threshold_BV = new SelTempAvgThreshSlider(client, x3, y, AVG_BV,client->config.avg_threshold_BV));
83 add_tool(std_threshold_BV = new SelTempAvgThreshSlider(client, x4, y, STD_BV,client->config.std_threshold_BV));
84 add_tool(mask_BV = new SelTempAvgMask(client, x5, y, MASK_BV,client->config.mask_BV));
87 add_tool(method_average = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_AVERAGE, _("Average")));
89 add_tool(method_stddev = new SelTempAvgMethodRadial(client, this, x1, y, SelTempAvgConfig::METHOD_STDDEV, _("Standard Deviation")));
92 add_tool(new BC_Title(x1, y, _("First frame in average:")));
94 add_tool(offset_fixed = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_FIXED, _("Fixed offset: ")));
95 add_tool(offset_fixed_value = new SelTempAvgOffsetValue(client, x4, y));
98 add_tool(offset_restartmarker = new SelTempAvgOffsetRadial(client, this, x1, y, SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS, _("Restart marker system:")));
99 add_tool(offset_restartmarker_pos = new BC_TextBox(x4+20, y, 100, 1, ""));
100 offset_restartmarker_pos->disable();
102 add_tool(offset_restartmarker_keyframe = new SelTempAvgStartKeyframe(client, x2 + 10, y));
106 add_tool(new BC_Title(x1, y, _("Other Options:")));
108 add_tool(paranoid = new SelTempAvgParanoid(client, x1, y));
110 add_tool(no_subtract = new SelTempAvgNoSubtract(client, x1, y));
112 add_tool(new BC_Title(x2, y, _("Gain:")));
113 add_tool(gain = new SelTempAvgGainValue(client, x3, y));
123 SelTempAvgThreshSlider::SelTempAvgThreshSlider(SelTempAvgMain *client, int x, int y, int id, float currentval)
124 : BC_TextBox(x,y, 80, 1, currentval)
129 this->client = client;
131 SelTempAvgThreshSlider::~SelTempAvgThreshSlider()
134 int SelTempAvgThreshSlider::handle_event()
136 float val = atof(get_text());
142 client->config.avg_threshold_RY = val;
145 client->config.avg_threshold_GU = val;
148 client->config.avg_threshold_BV = val;
151 client->config.std_threshold_RY = val;
154 client->config.std_threshold_GU = val;
157 client->config.std_threshold_BV = val;
161 client->send_configure_change();
166 SelTempAvgOffsetValue::SelTempAvgOffsetValue(SelTempAvgMain *client, int x, int y)
167 : BC_TextBox(x,y, 80, 1, client->config.offset_fixed_value)
169 this->client = client;
171 SelTempAvgOffsetValue::~SelTempAvgOffsetValue()
174 int SelTempAvgOffsetValue::handle_event()
176 int val = atoi(get_text());
178 client->config.offset_fixed_value = val;
179 client->send_configure_change();
184 SelTempAvgGainValue::SelTempAvgGainValue(SelTempAvgMain *client, int x, int y)
185 : BC_TextBox(x,y, 80, 1, client->config.gain)
187 this->client = client;
189 SelTempAvgGainValue::~SelTempAvgGainValue()
192 int SelTempAvgGainValue::handle_event()
194 float val = atof(get_text());
197 client->config.gain = val;
198 client->send_configure_change();
206 SelTempAvgSlider::SelTempAvgSlider(SelTempAvgMain *client, int x, int y)
207 : BC_ISlider(x, y, 0, 190, 200, 1, MAX_FRAMES, client->config.frames)
209 this->client = client;
211 SelTempAvgSlider::~SelTempAvgSlider()
214 int SelTempAvgSlider::handle_event()
216 int result = get_value();
217 if(result < 1) result = 1;
218 client->config.frames = result;
219 client->send_configure_change();
225 SelTempAvgOffsetRadial::SelTempAvgOffsetRadial(SelTempAvgMain *client, SelTempAvgWindow *gui, int x, int y, int type, char *caption)
226 : BC_Radial(x, y, client->config.offsetmode == type, caption)
228 this->client = client;
232 int SelTempAvgOffsetRadial::handle_event()
234 int result = get_value();
235 client->config.offsetmode = result;
237 gui->offset_fixed->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_FIXED);
238 gui->offset_restartmarker->update(client->config.offsetmode == SelTempAvgConfig::OFFSETMODE_RESTARTMARKERSYS);
240 client->send_configure_change();
246 SelTempAvgMethodRadial::SelTempAvgMethodRadial(SelTempAvgMain *client,
247 SelTempAvgWindow *gui, int x, int y, int type, char *caption)
250 client->config.method == type,
253 this->client = client;
257 int SelTempAvgMethodRadial::handle_event()
259 int result = get_value();
260 client->config.method = result;
262 gui->method_none->update(client->config.method == SelTempAvgConfig::METHOD_NONE);
263 gui->method_seltempavg->update(client->config.method == SelTempAvgConfig::METHOD_SELTEMPAVG);
264 gui->method_average->update(client->config.method == SelTempAvgConfig::METHOD_AVERAGE);
265 gui->method_stddev->update(client->config.method == SelTempAvgConfig::METHOD_STDDEV);
267 client->send_configure_change();
272 SelTempAvgParanoid::SelTempAvgParanoid(SelTempAvgMain *client, int x, int y)
273 : BC_CheckBox(x, y, client->config.paranoid, _("Reprocess frame again"))
275 this->client = client;
277 int SelTempAvgParanoid::handle_event()
279 int result = get_value();
280 client->config.paranoid = result;
281 client->send_configure_change();
286 SelTempAvgNoSubtract::SelTempAvgNoSubtract(SelTempAvgMain *client, int x, int y)
287 : BC_CheckBox(x, y, client->config.nosubtract, _("Disable subtraction"))
289 this->client = client;
291 int SelTempAvgNoSubtract::handle_event()
293 int result = get_value();
294 client->config.nosubtract = result;
295 client->send_configure_change();
299 SelTempAvgMask::SelTempAvgMask(SelTempAvgMain *client, int x, int y, int type, int val)
300 : BC_CheckBox(x, y, val, "")
302 this->client = client;
305 int SelTempAvgMask::handle_event()
307 int result = get_value();
310 client->config.mask_RY = result;
313 client->config.mask_GU = result;
316 client->config.mask_BV = result;
319 client->send_configure_change();
325 SelTempAvgStartKeyframe::SelTempAvgStartKeyframe(SelTempAvgMain *client, int x, int y)
326 : BC_CheckBox(x, y, client->config.nosubtract, _("This Frame is a start of a section"))
328 this->client = client;
330 int SelTempAvgStartKeyframe::handle_event()
332 int result = get_value();
333 client->config.offset_restartmarker_keyframe = result;
334 client->send_configure_change();