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
23 #include "bcdisplayinfo.h"
28 #include "overlayframe.h"
40 REGISTER_PLUGIN(BandWipeMain)
46 BandWipeCount::BandWipeCount(BandWipeMain *plugin,
47 BandWipeWindow *window,
50 : BC_TumbleTextBox(window,
51 (int64_t)plugin->bands,
58 this->plugin = plugin;
59 this->window = window;
62 int BandWipeCount::handle_event()
64 plugin->bands = atol(get_text());
65 plugin->send_configure_change();
70 BandWipeIn::BandWipeIn(BandWipeMain *plugin,
71 BandWipeWindow *window,
76 plugin->direction == 0,
79 this->plugin = plugin;
80 this->window = window;
83 int BandWipeIn::handle_event()
86 plugin->direction = 0;
87 window->out->update(0);
88 plugin->send_configure_change();
92 BandWipeOut::BandWipeOut(BandWipeMain *plugin,
93 BandWipeWindow *window,
98 plugin->direction == 1,
101 this->plugin = plugin;
102 this->window = window;
105 int BandWipeOut::handle_event()
108 plugin->direction = 1;
109 window->in->update(0);
110 plugin->send_configure_change();
120 BandWipeWindow::BandWipeWindow(BandWipeMain *plugin)
121 : PluginClientWindow(plugin,
128 this->plugin = plugin;
132 void BandWipeWindow::create_objects()
135 add_subwindow(new BC_Title(x, y, _("Bands:")));
137 count = new BandWipeCount(plugin,
141 count->create_objects();
143 // add_subwindow(new BC_Title(x, y, _("Direction:")));
145 // add_subwindow(in = new BandWipeIn(plugin,
151 // add_subwindow(out = new BandWipeOut(plugin,
168 BandWipeMain::BandWipeMain(PluginServer *server)
169 : PluginVClient(server)
176 BandWipeMain::~BandWipeMain()
181 const char* BandWipeMain::plugin_title() { return N_("BandWipe"); }
182 int BandWipeMain::is_transition() { return 1; }
183 int BandWipeMain::uses_gui() { return 1; }
185 NEW_WINDOW_MACRO(BandWipeMain, BandWipeWindow);
188 void BandWipeMain::save_data(KeyFrame *keyframe)
191 output.set_shared_output(keyframe->xbuf);
192 output.tag.set_title("BANDWIPE");
193 output.tag.set_property("BANDS", bands);
194 output.tag.set_property("DIRECTION", direction);
196 output.tag.set_title("/BANDWIPE");
198 output.append_newline();
199 output.terminate_string();
202 void BandWipeMain::read_data(KeyFrame *keyframe)
206 input.set_shared_input(keyframe->xbuf);
208 while(!input.read_tag())
210 if(input.tag.title_is("BANDWIPE"))
212 bands = input.tag.get_property("BANDS", bands);
213 direction = input.tag.get_property("DIRECTION", direction);
218 int BandWipeMain::load_configuration()
220 read_data(get_prev_keyframe(get_source_position()));
226 #define BANDWIPE(type, components) \
231 PluginClient::get_source_position() / \
232 PluginClient::get_total_len(); \
234 for(int i = 0; i < bands; i++) \
236 for(int j = 0; j < band_h; j++) \
238 int row = i * band_h + j; \
240 if(row >= 0 && row < h) \
242 type *in_row = (type*)incoming->get_rows()[row]; \
243 type *out_row = (type*)outgoing->get_rows()[row]; \
247 for(int k = 0; k < x; k++) \
249 out_row[k * components + 0] = in_row[k * components + 0]; \
250 out_row[k * components + 1] = in_row[k * components + 1]; \
251 out_row[k * components + 2] = in_row[k * components + 2]; \
252 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
257 for(int k = w - x; k < w; k++) \
259 out_row[k * components + 0] = in_row[k * components + 0]; \
260 out_row[k * components + 1] = in_row[k * components + 1]; \
261 out_row[k * components + 2] = in_row[k * components + 2]; \
262 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
272 PluginClient::get_source_position() / \
273 PluginClient::get_total_len(); \
275 for(int i = 0; i < bands; i++) \
277 for(int j = 0; j < band_h; j++) \
279 int row = i * band_h + j; \
281 if(row >= 0 && row < h) \
283 type *in_row = (type*)incoming->get_rows()[row]; \
284 type *out_row = (type*)outgoing->get_rows()[row]; \
288 for(int k = x; k < w; k++) \
290 out_row[k * components + 0] = in_row[k * components + 0]; \
291 out_row[k * components + 1] = in_row[k * components + 1]; \
292 out_row[k * components + 2] = in_row[k * components + 2]; \
293 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
298 for(int k = 0; k < w - x; k++) \
300 out_row[k * components + 0] = in_row[k * components + 0]; \
301 out_row[k * components + 1] = in_row[k * components + 1]; \
302 out_row[k * components + 2] = in_row[k * components + 2]; \
303 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
314 int BandWipeMain::process_realtime(VFrame *incoming, VFrame *outgoing)
316 load_configuration();
318 int w = incoming->get_w();
319 int h = incoming->get_h();
320 int band_h = ((bands == 0) ? h : (h / bands + 1));
322 switch(incoming->get_color_model())
326 BANDWIPE(unsigned char, 3)
333 BANDWIPE(unsigned char, 4)
340 BANDWIPE(uint16_t, 3)
342 case BC_RGBA16161616:
343 case BC_YUVA16161616:
344 BANDWIPE(uint16_t, 4)