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 _("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->get_data(), MESSAGESIZE);
158 output.tag.set_title("WIPE");
159 output.tag.set_property("DIRECTION", direction);
161 output.terminate_string();
164 void WipeMain::read_data(KeyFrame *keyframe)
168 input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
170 while(!input.read_tag())
172 if(input.tag.title_is("WIPE"))
174 direction = input.tag.get_property("DIRECTION", direction);
179 int WipeMain::load_configuration()
181 read_data(get_prev_keyframe(get_source_position()));
190 #define WIPE(type, components) \
194 for(int j = 0; j < h; j++) \
196 type *in_row = (type*)incoming->get_rows()[j]; \
197 type *out_row = (type*)outgoing->get_rows()[j]; \
198 int x = incoming->get_w() * \
199 PluginClient::get_source_position() / \
200 PluginClient::get_total_len(); \
202 for(int k = 0; k < x; k++) \
204 out_row[k * components + 0] = in_row[k * components + 0]; \
205 out_row[k * components + 1] = in_row[k * components + 1]; \
206 out_row[k * components + 2] = in_row[k * components + 2]; \
207 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
213 for(int j = 0; j < h; j++) \
215 type *in_row = (type*)incoming->get_rows()[j]; \
216 type *out_row = (type*)outgoing->get_rows()[j]; \
217 int x = incoming->get_w() - incoming->get_w() * \
218 PluginClient::get_source_position() / \
219 PluginClient::get_total_len(); \
221 for(int k = x; k < w; k++) \
223 out_row[k * components + 0] = in_row[k * components + 0]; \
224 out_row[k * components + 1] = in_row[k * components + 1]; \
225 out_row[k * components + 2] = in_row[k * components + 2]; \
226 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
236 int WipeMain::process_realtime(VFrame *incoming, VFrame *outgoing)
238 load_configuration();
240 int w = incoming->get_w();
241 int h = incoming->get_h();
244 switch(incoming->get_color_model())
251 WIPE(unsigned char, 3)
258 WIPE(unsigned char, 4)
264 case BC_RGBA16161616:
265 case BC_YUVA16161616: