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"
27 #include "overlayframe.h"
36 REGISTER_PLUGIN(WipeMain)
42 WipeLeft::WipeLeft(WipeMain *plugin,
48 plugin->direction == 0,
51 this->plugin = plugin;
52 this->window = window;
55 int WipeLeft::handle_event()
58 plugin->direction = 0;
59 window->right->update(0);
60 plugin->send_configure_change();
64 WipeRight::WipeRight(WipeMain *plugin,
70 plugin->direction == 1,
73 this->plugin = plugin;
74 this->window = window;
77 int WipeRight::handle_event()
80 plugin->direction = 1;
81 window->left->update(0);
82 plugin->send_configure_change();
93 WipeWindow::WipeWindow(WipeMain *plugin)
94 : PluginClientWindow(plugin,
101 this->plugin = plugin;
107 void WipeWindow::create_objects()
110 add_subwindow(new BC_Title(x, y, _("Direction:")));
112 add_subwindow(left = new WipeLeft(plugin,
117 add_subwindow(right = new WipeRight(plugin,
134 WipeMain::WipeMain(PluginServer *server)
135 : PluginVClient(server)
141 WipeMain::~WipeMain()
146 const char* WipeMain::plugin_title() { return N_("Wipe"); }
147 int WipeMain::is_video() { return 1; }
148 int WipeMain::is_transition() { return 1; }
149 int WipeMain::uses_gui() { return 1; }
151 NEW_WINDOW_MACRO(WipeMain, WipeWindow)
154 void WipeMain::save_data(KeyFrame *keyframe)
157 output.set_shared_output(keyframe->xbuf);
158 output.tag.set_title("WIPE");
159 output.tag.set_property("DIRECTION", direction);
161 output.tag.set_title("/WIPE");
163 output.append_newline();
164 output.terminate_string();
167 void WipeMain::read_data(KeyFrame *keyframe)
171 input.set_shared_input(keyframe->xbuf);
173 while(!input.read_tag())
175 if(input.tag.title_is("WIPE"))
177 direction = input.tag.get_property("DIRECTION", direction);
182 int WipeMain::load_configuration()
184 read_data(get_prev_keyframe(get_source_position()));
193 #define WIPE(type, components) \
197 for(int j = 0; j < h; j++) \
199 type *in_row = (type*)incoming->get_rows()[j]; \
200 type *out_row = (type*)outgoing->get_rows()[j]; \
201 int x = incoming->get_w() * \
202 PluginClient::get_source_position() / \
203 PluginClient::get_total_len(); \
205 for(int k = 0; k < x; k++) \
207 out_row[k * components + 0] = in_row[k * components + 0]; \
208 out_row[k * components + 1] = in_row[k * components + 1]; \
209 out_row[k * components + 2] = in_row[k * components + 2]; \
210 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
216 for(int j = 0; j < h; j++) \
218 type *in_row = (type*)incoming->get_rows()[j]; \
219 type *out_row = (type*)outgoing->get_rows()[j]; \
220 int x = incoming->get_w() - incoming->get_w() * \
221 PluginClient::get_source_position() / \
222 PluginClient::get_total_len(); \
224 for(int k = x; k < w; k++) \
226 out_row[k * components + 0] = in_row[k * components + 0]; \
227 out_row[k * components + 1] = in_row[k * components + 1]; \
228 out_row[k * components + 2] = in_row[k * components + 2]; \
229 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
239 int WipeMain::process_realtime(VFrame *incoming, VFrame *outgoing)
241 load_configuration();
243 int w = incoming->get_w();
244 int h = incoming->get_h();
247 switch(incoming->get_color_model())
254 WIPE(unsigned char, 3)
261 WIPE(unsigned char, 4)
267 case BC_RGBA16161616:
268 case BC_YUVA16161616: