4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "bcdisplayinfo.h"
24 #include "deinterwindow-cv.h"
29 DeInterlaceWindow::DeInterlaceWindow(DeInterlaceMain *client)
30 : PluginClientWindow(client,
37 this->client = client;
38 adaptive=0; dominance_top=0; dominance_bottom=0; threshold=0;
42 DeInterlaceWindow::~DeInterlaceWindow()
46 void DeInterlaceWindow::create_objects()
49 int ys10 = yS(10), ys25 = yS(25);
50 int x = xs10, y = ys10;
51 add_tool(new BC_Title(x, y, _("Select deinterlacing mode")));
53 add_tool(mode = new DeInterlaceMode(client, this, x, y));
54 mode->create_objects();
56 optional_controls_x=x;
57 optional_controls_y=y;
59 char string[BCTEXTLEN];
60 get_status_string(string, 0);
61 add_tool(status = new BC_Title(x, y, string));
64 set_mode(client->config.mode, 1);
67 void DeInterlaceWindow::get_status_string(char *string, int changed_rows)
69 sprintf(string, _("Changed rows: %d\n"), changed_rows);
72 int DeInterlaceWindow::set_mode(int mode, int recursive)
75 client->config.mode = mode;
77 /* Restore position of controls */
78 x=optional_controls_x;
79 y=optional_controls_y;
80 if (adaptive) { delete adaptive; adaptive=0; }
81 if (threshold) { delete threshold; threshold=0; }
82 if (dominance_top) { delete dominance_top; dominance_top=0; }
83 if (dominance_bottom) { delete dominance_bottom; dominance_bottom=0; }
85 /* Display Dominance controls */
88 case DEINTERLACE_KEEP:
89 case DEINTERLACE_BOBWEAVE:
90 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Keep top field")));
92 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Keep bottom field")));
95 case DEINTERLACE_AVG_1F:
96 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Average top fields")));
98 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y,_("Average bottom fields")));
101 case DEINTERLACE_SWAP:
102 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
104 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
107 case DEINTERLACE_TEMPORALSWAP:
108 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
110 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
113 case DEINTERLACE_NONE:
114 case DEINTERLACE_AVG:
119 if (dominance_top&&dominance_bottom) {
120 dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
121 dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
124 /* Display Threshold and adaptive controls */
126 case DEINTERLACE_AVG_1F:
127 add_subwindow(adaptive = new DeInterlaceAdaptive(client, x, y));
129 add_subwindow(threshold = new DeInterlaceThreshold(client, x + xS(150), y));
130 add_subwindow(threshold->title_caption=new BC_Title(x+xS(150), y + yS(50), _("Threshold")));
131 threshold->show_window(0);
132 adaptive->update(client->config.adaptive?BC_Toggle::TOGGLE_CHECKED:0);
134 case DEINTERLACE_BOBWEAVE:
135 add_subwindow(threshold = new DeInterlaceThreshold(client, x + xS(150), y));
136 add_subwindow(threshold->title_caption=new BC_Title(x+xS(150), y + yS(50), _("Bob Threshold")));
137 threshold->show_window(0);
139 case DEINTERLACE_NONE:
140 case DEINTERLACE_KEEP:
141 case DEINTERLACE_AVG:
142 case DEINTERLACE_SWAP:
143 case DEINTERLACE_TEMPORALSWAP:
151 client->send_configure_change();
156 DeInterlaceOption::DeInterlaceOption(DeInterlaceMain *client,
157 DeInterlaceWindow *window,
162 : BC_Radial(x, y, client->config.mode == output, text)
164 this->client = client;
165 this->window = window;
166 this->output = output;
169 DeInterlaceOption::~DeInterlaceOption()
172 int DeInterlaceOption::handle_event()
174 window->set_mode(output, 0);
179 DeInterlaceAdaptive::DeInterlaceAdaptive(DeInterlaceMain *client, int x, int y)
180 : BC_CheckBox(x, y, client->config.adaptive, _("Adaptive"))
182 this->client = client;
184 int DeInterlaceAdaptive::handle_event()
186 client->config.adaptive = get_value();
187 client->send_configure_change();
191 DeInterlaceDominanceTop::DeInterlaceDominanceTop(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
192 : BC_Radial(x, y, client->config.dominance, title)
194 this->client = client;
195 this->window = window;
198 int DeInterlaceDominanceTop::handle_event()
200 client->config.dominance = (get_value()==0);
201 window->dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
202 client->send_configure_change();
207 DeInterlaceDominanceBottom::DeInterlaceDominanceBottom(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, const char * title)
208 : BC_Radial(x, y, client->config.dominance, title)
210 this->client = client;
211 this->window = window;
213 int DeInterlaceDominanceBottom::handle_event()
216 client->config.dominance = (get_value() != 0 );
217 window->dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
218 client->send_configure_change();
223 DeInterlaceThreshold::DeInterlaceThreshold(DeInterlaceMain *client, int x, int y)
224 : BC_IPot(x, y, client->config.threshold, 0, 100)
226 this->client = client;
229 int DeInterlaceThreshold::handle_event()
231 client->config.threshold = get_value();
232 client->send_configure_change();
236 DeInterlaceThreshold::~DeInterlaceThreshold()
238 if (title_caption) delete title_caption;
241 DeInterlaceMode::DeInterlaceMode(DeInterlaceMain*plugin,
242 DeInterlaceWindow *gui,
245 : BC_PopupMenu(x, y, xS(200), to_text(plugin->config.mode), 1)
247 this->plugin = plugin;
250 void DeInterlaceMode::create_objects()
252 add_item(new BC_MenuItem(to_text(DEINTERLACE_NONE)));
253 add_item(new BC_MenuItem(to_text(DEINTERLACE_KEEP)));
254 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG)));
255 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG_1F)));
256 add_item(new BC_MenuItem(to_text(DEINTERLACE_BOBWEAVE)));
257 add_item(new BC_MenuItem(to_text(DEINTERLACE_SWAP)));
258 add_item(new BC_MenuItem(to_text(DEINTERLACE_TEMPORALSWAP)));
261 char* DeInterlaceMode::to_text(int mode)
265 case DEINTERLACE_KEEP:
266 return _("Duplicate one field");
267 case DEINTERLACE_AVG_1F:
268 return _("Average one field");
269 case DEINTERLACE_AVG:
270 return _("Average both fields");
271 case DEINTERLACE_BOBWEAVE:
272 return _("Bob & Weave");
273 case DEINTERLACE_SWAP:
274 return _("Spatial field swap");
275 case DEINTERLACE_TEMPORALSWAP:
276 return _("Temporal field swap");
278 return _("Do Nothing");
281 int DeInterlaceMode::from_text(char *text)
283 if(!strcmp(text, to_text(DEINTERLACE_KEEP)))
284 return DEINTERLACE_KEEP;
285 if(!strcmp(text, to_text(DEINTERLACE_AVG)))
286 return DEINTERLACE_AVG;
287 if(!strcmp(text, to_text(DEINTERLACE_AVG_1F)))
288 return DEINTERLACE_AVG_1F;
289 if(!strcmp(text, to_text(DEINTERLACE_BOBWEAVE)))
290 return DEINTERLACE_BOBWEAVE;
291 if(!strcmp(text, to_text(DEINTERLACE_SWAP)))
292 return DEINTERLACE_SWAP;
293 if(!strcmp(text, to_text(DEINTERLACE_TEMPORALSWAP)))
294 return DEINTERLACE_TEMPORALSWAP;
295 return DEINTERLACE_NONE;
298 int DeInterlaceMode::handle_event()
300 plugin->config.mode = from_text(get_text());
301 gui->set_mode(plugin->config.mode,0);
302 plugin->send_configure_change();