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()
156 int xs10 = xS(10), xs100 = xS(100);
157 int ys10 = yS(10), ys30 = yS(30);
158 int x = xs10, y = ys10;
159 add_subwindow(new BC_Title(x, y, _("Direction:")));
161 add_subwindow(left = new SlideLeft(plugin,
166 add_subwindow(right = new SlideRight(plugin,
173 add_subwindow(new BC_Title(x, y, _("Direction:")));
175 add_subwindow(in = new SlideIn(plugin,
180 add_subwindow(out = new SlideOut(plugin,
199 SlideMain::SlideMain(PluginServer *server)
200 : PluginVClient(server)
202 motion_direction = 0;
207 SlideMain::~SlideMain()
212 const char* SlideMain::plugin_title() { return N_("Slide"); }
213 int SlideMain::is_video() { return 1; }
214 int SlideMain::is_transition() { return 1; }
215 int SlideMain::uses_gui() { return 1; }
217 NEW_WINDOW_MACRO(SlideMain, SlideWindow)
220 void SlideMain::save_data(KeyFrame *keyframe)
223 output.set_shared_output(keyframe->xbuf);
224 output.tag.set_title("SLIDE");
225 output.tag.set_property("MOTION_DIRECTION", motion_direction);
226 output.tag.set_property("DIRECTION", direction);
228 output.tag.set_title("/SLIDE");
230 output.append_newline();
231 output.terminate_string();
234 void SlideMain::read_data(KeyFrame *keyframe)
238 input.set_shared_input(keyframe->xbuf);
240 while(!input.read_tag())
242 if(input.tag.title_is("SLIDE"))
244 motion_direction = input.tag.get_property("MOTION_DIRECTION", motion_direction);
245 direction = input.tag.get_property("DIRECTION", direction);
250 int SlideMain::load_configuration()
252 read_data(get_prev_keyframe(get_source_position()));
259 #define SLIDE(type, components) \
263 int in_add, out_add, cpy_len; \
264 if(motion_direction == 0) \
267 PluginClient::get_source_position() / \
268 PluginClient::get_total_len(); \
270 in_add = (w - x) * components * sizeof(type); \
271 cpy_len = x * components * sizeof(type); \
276 PluginClient::get_source_position() / \
277 PluginClient::get_total_len(); \
278 out_add = x * components * sizeof(type); \
280 cpy_len = (w - x) * components * sizeof(type); \
283 for(int j = 0; j < h; j++) \
285 memcpy( ((char *)outgoing->get_rows()[j]) + out_add, \
286 ((char *)incoming->get_rows()[j]) + in_add, \
292 if(motion_direction == 0) \
295 PluginClient::get_source_position() / \
296 PluginClient::get_total_len(); \
297 for(int j = 0; j < h; j++) \
299 char *in_row = (char*)incoming->get_rows()[j]; \
300 char *out_row = (char*)outgoing->get_rows()[j]; \
301 memmove(out_row + 0, out_row + ((w - x) * components * sizeof(type)), x * components * sizeof(type)); \
302 memcpy (out_row + x * components * sizeof(type), in_row + x * components * sizeof (type), (w - x) * components * sizeof(type)); \
308 PluginClient::get_source_position() / \
309 PluginClient::get_total_len(); \
310 for(int j = 0; j < h; j++) \
312 char *in_row = (char*)incoming->get_rows()[j]; \
313 char *out_row = (char*)outgoing->get_rows()[j]; \
315 memmove(out_row + (x * components *sizeof(type)), out_row + 0, (w - x) * components * sizeof(type)); \
316 memcpy (out_row + 0, in_row + 0, (x) * components * sizeof(type)); \
326 int SlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
328 load_configuration();
330 int w = incoming->get_w();
331 int h = incoming->get_h();
333 // struct timeval start_time;
334 // gettimeofday(&start_time, 0);
336 switch(incoming->get_color_model())
346 SLIDE(unsigned char, 3)
350 SLIDE(unsigned char, 4)
356 case BC_RGBA16161616:
357 case BC_YUVA16161616:
362 // int64_t dif= get_difference(&start_time);
363 // printf("diff: %lli\n", dif);