00001 #include "bcdisplayinfo.h"
00002 #include "bchash.h"
00003 #include "edl.inc"
00004 #include "filexml.h"
00005 #include "overlayframe.h"
00006 #include "picon_png.h"
00007 #include "vframe.h"
00008 #include "slide.h"
00009
00010
00011 #include <stdint.h>
00012 #include <string.h>
00013
00014 #include <libintl.h>
00015 #define _(String) gettext(String)
00016 #define gettext_noop(String) String
00017 #define N_(String) gettext_noop (String)
00018
00019 REGISTER_PLUGIN(SlideMain)
00020
00021
00022
00023
00024
00025 SlideLeft::SlideLeft(SlideMain *plugin,
00026 SlideWindow *window,
00027 int x,
00028 int y)
00029 : BC_Radial(x,
00030 y,
00031 plugin->motion_direction == 0,
00032 _("Left"))
00033 {
00034 this->plugin = plugin;
00035 this->window = window;
00036 }
00037
00038 int SlideLeft::handle_event()
00039 {
00040 update(1);
00041 plugin->motion_direction = 0;
00042 window->right->update(0);
00043 plugin->send_configure_change();
00044 return 0;
00045 }
00046
00047 SlideRight::SlideRight(SlideMain *plugin,
00048 SlideWindow *window,
00049 int x,
00050 int y)
00051 : BC_Radial(x,
00052 y,
00053 plugin->motion_direction == 1,
00054 _("Right"))
00055 {
00056 this->plugin = plugin;
00057 this->window = window;
00058 }
00059
00060 int SlideRight::handle_event()
00061 {
00062 update(1);
00063 plugin->motion_direction = 1;
00064 window->left->update(0);
00065 plugin->send_configure_change();
00066 return 0;
00067 }
00068
00069 SlideIn::SlideIn(SlideMain *plugin,
00070 SlideWindow *window,
00071 int x,
00072 int y)
00073 : BC_Radial(x,
00074 y,
00075 plugin->direction == 0,
00076 _("In"))
00077 {
00078 this->plugin = plugin;
00079 this->window = window;
00080 }
00081
00082 int SlideIn::handle_event()
00083 {
00084 update(1);
00085 plugin->direction = 0;
00086 window->out->update(0);
00087 plugin->send_configure_change();
00088 return 0;
00089 }
00090
00091 SlideOut::SlideOut(SlideMain *plugin,
00092 SlideWindow *window,
00093 int x,
00094 int y)
00095 : BC_Radial(x,
00096 y,
00097 plugin->direction == 1,
00098 _("Out"))
00099 {
00100 this->plugin = plugin;
00101 this->window = window;
00102 }
00103
00104 int SlideOut::handle_event()
00105 {
00106 update(1);
00107 plugin->direction = 1;
00108 window->in->update(0);
00109 plugin->send_configure_change();
00110 return 0;
00111 }
00112
00113
00114
00115
00116
00117
00118
00119
00120 SlideWindow::SlideWindow(SlideMain *plugin, int x, int y)
00121 : BC_Window(plugin->gui_string,
00122 x,
00123 y,
00124 320,
00125 100,
00126 320,
00127 100,
00128 0,
00129 0,
00130 1)
00131 {
00132 this->plugin = plugin;
00133 }
00134
00135
00136 int SlideWindow::close_event()
00137 {
00138 set_done(1);
00139 return 1;
00140 }
00141
00142 void SlideWindow::create_objects()
00143 {
00144 int x = 10, y = 10;
00145 add_subwindow(new BC_Title(x, y, _("Direction:")));
00146 x += 100;
00147 add_subwindow(left = new SlideLeft(plugin,
00148 this,
00149 x,
00150 y));
00151 x += 100;
00152 add_subwindow(right = new SlideRight(plugin,
00153 this,
00154 x,
00155 y));
00156
00157 y += 30;
00158 x = 10;
00159 add_subwindow(new BC_Title(x, y, _("Direction:")));
00160 x += 100;
00161 add_subwindow(in = new SlideIn(plugin,
00162 this,
00163 x,
00164 y));
00165 x += 100;
00166 add_subwindow(out = new SlideOut(plugin,
00167 this,
00168 x,
00169 y));
00170
00171 show_window();
00172 flush();
00173 }
00174
00175
00176
00177
00178 PLUGIN_THREAD_OBJECT(SlideMain, SlideThread, SlideWindow)
00179
00180
00181
00182
00183
00184
00185 SlideMain::SlideMain(PluginServer *server)
00186 : PluginVClient(server)
00187 {
00188 motion_direction = 0;
00189 direction = 0;
00190 PLUGIN_CONSTRUCTOR_MACRO
00191 }
00192
00193 SlideMain::~SlideMain()
00194 {
00195 PLUGIN_DESTRUCTOR_MACRO
00196 }
00197
00198 char* SlideMain::plugin_title() { return N_("Slide"); }
00199 int SlideMain::is_video() { return 1; }
00200 int SlideMain::is_transition() { return 1; }
00201 int SlideMain::uses_gui() { return 1; }
00202
00203 SHOW_GUI_MACRO(SlideMain, SlideThread);
00204 SET_STRING_MACRO(SlideMain)
00205 RAISE_WINDOW_MACRO(SlideMain)
00206
00207
00208 VFrame* SlideMain::new_picon()
00209 {
00210 return new VFrame(picon_png);
00211 }
00212
00213 int SlideMain::load_defaults()
00214 {
00215 char directory[BCTEXTLEN];
00216
00217 sprintf(directory, "%sslide.rc", BCASTDIR);
00218
00219
00220 defaults = new BC_Hash(directory);
00221 defaults->load();
00222
00223 motion_direction = defaults->get("MOTION_DIRECTION", motion_direction);
00224 direction = defaults->get("DIRECTION", direction);
00225 return 0;
00226 }
00227
00228 int SlideMain::save_defaults()
00229 {
00230 defaults->update("MOTION_DIRECTION", motion_direction);
00231 defaults->update("DIRECTION", direction);
00232 defaults->save();
00233 return 0;
00234 }
00235
00236 void SlideMain::save_data(KeyFrame *keyframe)
00237 {
00238 FileXML output;
00239 output.set_shared_string(keyframe->data, MESSAGESIZE);
00240 output.tag.set_title("SLIDE");
00241 output.tag.set_property("MOTION_DIRECTION", motion_direction);
00242 output.tag.set_property("DIRECTION", direction);
00243 output.append_tag();
00244 output.tag.set_title("/SLIDE");
00245 output.append_tag();
00246 output.terminate_string();
00247 }
00248
00249 void SlideMain::read_data(KeyFrame *keyframe)
00250 {
00251 FileXML input;
00252
00253 input.set_shared_string(keyframe->data, strlen(keyframe->data));
00254
00255 while(!input.read_tag())
00256 {
00257 if(input.tag.title_is("SLIDE"))
00258 {
00259 motion_direction = input.tag.get_property("MOTION_DIRECTION", motion_direction);
00260 direction = input.tag.get_property("DIRECTION", direction);
00261 }
00262 }
00263 }
00264
00265 void SlideMain::load_configuration()
00266 {
00267 read_data(get_prev_keyframe(get_source_position()));
00268 }
00269
00270
00271
00272
00273 #define SLIDE(type, components) \
00274 { \
00275 if(direction == 0) \
00276 { \
00277 int in_add, out_add, cpy_len; \
00278 if(motion_direction == 0) \
00279 { \
00280 int x = w * \
00281 PluginClient::get_source_position() / \
00282 PluginClient::get_total_len(); \
00283 out_add = 0; \
00284 in_add = (w - x) * components * sizeof(type); \
00285 cpy_len = x * components * sizeof(type); \
00286 } \
00287 else \
00288 { \
00289 int x = w - w * \
00290 PluginClient::get_source_position() / \
00291 PluginClient::get_total_len(); \
00292 out_add = x * components * sizeof(type); \
00293 in_add = 0; \
00294 cpy_len = (w - x) * components * sizeof(type); \
00295 } \
00296 \
00297 for(int j = 0; j < h; j++) \
00298 { \
00299 memcpy( ((char *)outgoing->get_rows()[j]) + out_add, \
00300 ((char *)incoming->get_rows()[j]) + in_add, \
00301 cpy_len); \
00302 } \
00303 } \
00304 else \
00305 { \
00306 if(motion_direction == 0) \
00307 { \
00308 int x = w - w * \
00309 PluginClient::get_source_position() / \
00310 PluginClient::get_total_len(); \
00311 for(int j = 0; j < h; j++) \
00312 { \
00313 char *in_row = (char*)incoming->get_rows()[j]; \
00314 char *out_row = (char*)outgoing->get_rows()[j]; \
00315 memmove(out_row + 0, out_row + ((w - x) * components * sizeof(type)), x * components * sizeof(type)); \
00316 memcpy (out_row + x * components * sizeof(type), in_row + x * components * sizeof (type), (w - x) * components * sizeof(type)); \
00317 } \
00318 } \
00319 else \
00320 { \
00321 int x = w * \
00322 PluginClient::get_source_position() / \
00323 PluginClient::get_total_len(); \
00324 for(int j = 0; j < h; j++) \
00325 { \
00326 char *in_row = (char*)incoming->get_rows()[j]; \
00327 char *out_row = (char*)outgoing->get_rows()[j]; \
00328 \
00329 memmove(out_row + (x * components *sizeof(type)), out_row + 0, (w - x) * components * sizeof(type)); \
00330 memcpy (out_row + 0, in_row + 0, (x) * components * sizeof(type)); \
00331 } \
00332 } \
00333 } \
00334 }
00335
00336
00337
00338
00339
00340 int SlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
00341 {
00342 load_configuration();
00343
00344 int w = incoming->get_w();
00345 int h = incoming->get_h();
00346
00347
00348
00349
00350 switch(incoming->get_color_model())
00351 {
00352 case BC_RGB_FLOAT:
00353 SLIDE(float, 3)
00354 break;
00355 case BC_RGBA_FLOAT:
00356 SLIDE(float, 4)
00357 break;
00358 case BC_RGB888:
00359 case BC_YUV888:
00360 SLIDE(unsigned char, 3)
00361 break;
00362 case BC_RGBA8888:
00363 case BC_YUVA8888:
00364 SLIDE(unsigned char, 4)
00365 break;
00366 case BC_RGB161616:
00367 case BC_YUV161616:
00368 SLIDE(uint16_t, 3)
00369 break;
00370 case BC_RGBA16161616:
00371 case BC_YUVA16161616:
00372 SLIDE(uint16_t, 4)
00373 break;
00374 }
00375
00376
00377
00378
00379 return 0;
00380 }