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"
37 REGISTER_PLUGIN(SlideMain)
43 SlideLeft::SlideLeft(SlideMain *plugin,
49 plugin->motion_direction == 0,
52 this->plugin = plugin;
53 this->window = window;
56 int SlideLeft::handle_event()
59 plugin->motion_direction = 0;
60 window->right->update(0);
61 plugin->send_configure_change();
65 SlideRight::SlideRight(SlideMain *plugin,
71 plugin->motion_direction == 1,
74 this->plugin = plugin;
75 this->window = window;
78 int SlideRight::handle_event()
81 plugin->motion_direction = 1;
82 window->left->update(0);
83 plugin->send_configure_change();
87 SlideIn::SlideIn(SlideMain *plugin,
93 plugin->direction == 0,
96 this->plugin = plugin;
97 this->window = window;
100 int SlideIn::handle_event()
103 plugin->direction = 0;
104 window->out->update(0);
105 plugin->send_configure_change();
109 SlideOut::SlideOut(SlideMain *plugin,
115 plugin->direction == 1,
118 this->plugin = plugin;
119 this->window = window;
122 int SlideOut::handle_event()
125 plugin->direction = 1;
126 window->in->update(0);
127 plugin->send_configure_change();
138 SlideWindow::SlideWindow(SlideMain *plugin)
139 : PluginClientWindow(plugin,
146 this->plugin = plugin;
154 void SlideWindow::create_objects()
157 add_subwindow(new BC_Title(x, y, _("Direction:")));
159 add_subwindow(left = new SlideLeft(plugin,
164 add_subwindow(right = new SlideRight(plugin,
171 add_subwindow(new BC_Title(x, y, _("Direction:")));
173 add_subwindow(in = new SlideIn(plugin,
178 add_subwindow(out = new SlideOut(plugin,
197 SlideMain::SlideMain(PluginServer *server)
198 : PluginVClient(server)
200 motion_direction = 0;
205 SlideMain::~SlideMain()
210 const char* SlideMain::plugin_title() { return _("Slide"); }
211 int SlideMain::is_video() { return 1; }
212 int SlideMain::is_transition() { return 1; }
213 int SlideMain::uses_gui() { return 1; }
215 NEW_WINDOW_MACRO(SlideMain, SlideWindow)
218 void SlideMain::save_data(KeyFrame *keyframe)
221 output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
222 output.tag.set_title("SLIDE");
223 output.tag.set_property("MOTION_DIRECTION", motion_direction);
224 output.tag.set_property("DIRECTION", direction);
226 output.tag.set_title("/SLIDE");
228 output.append_newline();
229 output.terminate_string();
232 void SlideMain::read_data(KeyFrame *keyframe)
236 input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
238 while(!input.read_tag())
240 if(input.tag.title_is("SLIDE"))
242 motion_direction = input.tag.get_property("MOTION_DIRECTION", motion_direction);
243 direction = input.tag.get_property("DIRECTION", direction);
248 int SlideMain::load_configuration()
250 read_data(get_prev_keyframe(get_source_position()));
257 #define SLIDE(type, components) \
261 int in_add, out_add, cpy_len; \
262 if(motion_direction == 0) \
265 PluginClient::get_source_position() / \
266 PluginClient::get_total_len(); \
268 in_add = (w - x) * components * sizeof(type); \
269 cpy_len = x * components * sizeof(type); \
274 PluginClient::get_source_position() / \
275 PluginClient::get_total_len(); \
276 out_add = x * components * sizeof(type); \
278 cpy_len = (w - x) * components * sizeof(type); \
281 for(int j = 0; j < h; j++) \
283 memcpy( ((char *)outgoing->get_rows()[j]) + out_add, \
284 ((char *)incoming->get_rows()[j]) + in_add, \
290 if(motion_direction == 0) \
293 PluginClient::get_source_position() / \
294 PluginClient::get_total_len(); \
295 for(int j = 0; j < h; j++) \
297 char *in_row = (char*)incoming->get_rows()[j]; \
298 char *out_row = (char*)outgoing->get_rows()[j]; \
299 memmove(out_row + 0, out_row + ((w - x) * components * sizeof(type)), x * components * sizeof(type)); \
300 memcpy (out_row + x * components * sizeof(type), in_row + x * components * sizeof (type), (w - x) * components * sizeof(type)); \
306 PluginClient::get_source_position() / \
307 PluginClient::get_total_len(); \
308 for(int j = 0; j < h; j++) \
310 char *in_row = (char*)incoming->get_rows()[j]; \
311 char *out_row = (char*)outgoing->get_rows()[j]; \
313 memmove(out_row + (x * components *sizeof(type)), out_row + 0, (w - x) * components * sizeof(type)); \
314 memcpy (out_row + 0, in_row + 0, (x) * components * sizeof(type)); \
324 int SlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
326 load_configuration();
328 int w = incoming->get_w();
329 int h = incoming->get_h();
331 // struct timeval start_time;
332 // gettimeofday(&start_time, 0);
334 switch(incoming->get_color_model())
344 SLIDE(unsigned char, 3)
348 SLIDE(unsigned char, 4)
354 case BC_RGBA16161616:
355 case BC_YUVA16161616:
360 // int64_t dif= get_difference(&start_time);
361 // printf("diff: %lli\n", dif);