1 #include "bcdisplayinfo.h"
5 #include "overlayframe.h"
15 #define _(String) gettext(String)
16 #define gettext_noop(String) String
17 #define N_(String) gettext_noop (String)
19 REGISTER_PLUGIN(SlideMain)
25 SlideLeft::SlideLeft(SlideMain *plugin,
31 plugin->motion_direction == 0,
34 this->plugin = plugin;
35 this->window = window;
38 int SlideLeft::handle_event()
41 plugin->motion_direction = 0;
42 window->right->update(0);
43 plugin->send_configure_change();
47 SlideRight::SlideRight(SlideMain *plugin,
53 plugin->motion_direction == 1,
56 this->plugin = plugin;
57 this->window = window;
60 int SlideRight::handle_event()
63 plugin->motion_direction = 1;
64 window->left->update(0);
65 plugin->send_configure_change();
69 SlideIn::SlideIn(SlideMain *plugin,
75 plugin->direction == 0,
78 this->plugin = plugin;
79 this->window = window;
82 int SlideIn::handle_event()
85 plugin->direction = 0;
86 window->out->update(0);
87 plugin->send_configure_change();
91 SlideOut::SlideOut(SlideMain *plugin,
97 plugin->direction == 1,
100 this->plugin = plugin;
101 this->window = window;
104 int SlideOut::handle_event()
107 plugin->direction = 1;
108 window->in->update(0);
109 plugin->send_configure_change();
120 SlideWindow::SlideWindow(SlideMain *plugin, int x, int y)
121 : BC_Window(plugin->gui_string,
132 this->plugin = plugin;
136 int SlideWindow::close_event()
142 void SlideWindow::create_objects()
145 add_subwindow(new BC_Title(x, y, _("Direction:")));
147 add_subwindow(left = new SlideLeft(plugin,
152 add_subwindow(right = new SlideRight(plugin,
159 add_subwindow(new BC_Title(x, y, _("Direction:")));
161 add_subwindow(in = new SlideIn(plugin,
166 add_subwindow(out = new SlideOut(plugin,
178 PLUGIN_THREAD_OBJECT(SlideMain, SlideThread, SlideWindow)
185 SlideMain::SlideMain(PluginServer *server)
186 : PluginVClient(server)
188 motion_direction = 0;
190 PLUGIN_CONSTRUCTOR_MACRO
193 SlideMain::~SlideMain()
195 PLUGIN_DESTRUCTOR_MACRO
198 char* SlideMain::plugin_title() { return N_("Slide"); }
199 int SlideMain::is_video() { return 1; }
200 int SlideMain::is_transition() { return 1; }
201 int SlideMain::uses_gui() { return 1; }
203 SHOW_GUI_MACRO(SlideMain, SlideThread);
204 SET_STRING_MACRO(SlideMain)
205 RAISE_WINDOW_MACRO(SlideMain)
208 VFrame* SlideMain::new_picon()
210 return new VFrame(picon_png);
213 int SlideMain::load_defaults()
215 char directory[BCTEXTLEN];
216 // set the default directory
217 sprintf(directory, "%sslide.rc", BCASTDIR);
220 defaults = new BC_Hash(directory);
223 motion_direction = defaults->get("MOTION_DIRECTION", motion_direction);
224 direction = defaults->get("DIRECTION", direction);
228 int SlideMain::save_defaults()
230 defaults->update("MOTION_DIRECTION", motion_direction);
231 defaults->update("DIRECTION", direction);
236 void SlideMain::save_data(KeyFrame *keyframe)
239 output.set_shared_string(keyframe->data, MESSAGESIZE);
240 output.tag.set_title("SLIDE");
241 output.tag.set_property("MOTION_DIRECTION", motion_direction);
242 output.tag.set_property("DIRECTION", direction);
244 output.terminate_string();
247 void SlideMain::read_data(KeyFrame *keyframe)
251 input.set_shared_string(keyframe->data, strlen(keyframe->data));
253 while(!input.read_tag())
255 if(input.tag.title_is("SLIDE"))
257 motion_direction = input.tag.get_property("MOTION_DIRECTION", motion_direction);
258 direction = input.tag.get_property("DIRECTION", direction);
263 void SlideMain::load_configuration()
265 read_data(get_prev_keyframe(get_source_position()));
271 #define SLIDE(type, components) \
275 int in_add, out_add, cpy_len; \
276 if(motion_direction == 0) \
279 PluginClient::get_source_position() / \
280 PluginClient::get_total_len(); \
282 in_add = (w - x) * components * sizeof(type); \
283 cpy_len = x * components * sizeof(type); \
288 PluginClient::get_source_position() / \
289 PluginClient::get_total_len(); \
290 out_add = x * components * sizeof(type); \
292 cpy_len = (w - x) * components * sizeof(type); \
295 for(int j = 0; j < h; j++) \
297 memcpy( ((char *)outgoing->get_rows()[j]) + out_add, \
298 ((char *)incoming->get_rows()[j]) + in_add, \
304 if(motion_direction == 0) \
307 PluginClient::get_source_position() / \
308 PluginClient::get_total_len(); \
309 for(int j = 0; j < h; j++) \
311 char *in_row = (char*)incoming->get_rows()[j]; \
312 char *out_row = (char*)outgoing->get_rows()[j]; \
313 memmove(out_row + 0, out_row + ((w - x) * components * sizeof(type)), x * components * sizeof(type)); \
314 memcpy (out_row + x * components * sizeof(type), in_row + x * components * sizeof (type), (w - x) * components * sizeof(type)); \
320 PluginClient::get_source_position() / \
321 PluginClient::get_total_len(); \
322 for(int j = 0; j < h; j++) \
324 char *in_row = (char*)incoming->get_rows()[j]; \
325 char *out_row = (char*)outgoing->get_rows()[j]; \
327 memmove(out_row + (x * components *sizeof(type)), out_row + 0, (w - x) * components * sizeof(type)); \
328 memcpy (out_row + 0, in_row + 0, (x) * components * sizeof(type)); \
338 int SlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
340 load_configuration();
342 int w = incoming->get_w();
343 int h = incoming->get_h();
345 // struct timeval start_time;
346 // gettimeofday(&start_time, 0);
348 switch(incoming->get_color_model())
358 SLIDE(unsigned char, 3)
362 SLIDE(unsigned char, 4)
368 case BC_RGBA16161616:
369 case BC_YUVA16161616:
374 // int64_t dif= get_difference(&start_time);
375 // printf("diff: %lli\n", dif);