2 #include "bcdisplayinfo.h"
7 #include "overlayframe.h"
21 REGISTER_PLUGIN(BandSlideMain)
27 BandSlideCount::BandSlideCount(BandSlideMain *plugin,
28 BandSlideWindow *window,
31 : BC_TumbleTextBox(window,
32 (int64_t)plugin->bands,
39 this->plugin = plugin;
40 this->window = window;
43 int BandSlideCount::handle_event()
45 plugin->bands = atol(get_text());
46 plugin->send_configure_change();
50 BandSlideIn::BandSlideIn(BandSlideMain *plugin,
51 BandSlideWindow *window,
56 plugin->direction == 0,
59 this->plugin = plugin;
60 this->window = window;
63 int BandSlideIn::handle_event()
66 plugin->direction = 0;
67 window->out->update(0);
68 plugin->send_configure_change();
72 BandSlideOut::BandSlideOut(BandSlideMain *plugin,
73 BandSlideWindow *window,
78 plugin->direction == 1,
81 this->plugin = plugin;
82 this->window = window;
85 int BandSlideOut::handle_event()
88 plugin->direction = 1;
89 window->in->update(0);
90 plugin->send_configure_change();
101 BandSlideWindow::BandSlideWindow(BandSlideMain *plugin, int x, int y)
102 : BC_Window(plugin->gui_string,
113 this->plugin = plugin;
117 int BandSlideWindow::close_event()
123 void BandSlideWindow::create_objects()
126 add_subwindow(new BC_Title(x, y, _("Bands:")));
128 count = new BandSlideCount(plugin,
132 count->create_objects();
136 add_subwindow(new BC_Title(x, y, _("Direction:")));
138 add_subwindow(in = new BandSlideIn(plugin,
143 add_subwindow(out = new BandSlideOut(plugin,
155 PLUGIN_THREAD_OBJECT(BandSlideMain, BandSlideThread, BandSlideWindow)
162 BandSlideMain::BandSlideMain(PluginServer *server)
163 : PluginVClient(server)
167 PLUGIN_CONSTRUCTOR_MACRO
170 BandSlideMain::~BandSlideMain()
172 PLUGIN_DESTRUCTOR_MACRO
175 char* BandSlideMain::plugin_title() { return N_("BandSlide"); }
176 int BandSlideMain::is_video() { return 1; }
177 int BandSlideMain::is_transition() { return 1; }
178 int BandSlideMain::uses_gui() { return 1; }
180 SHOW_GUI_MACRO(BandSlideMain, BandSlideThread);
181 SET_STRING_MACRO(BandSlideMain)
182 RAISE_WINDOW_MACRO(BandSlideMain)
185 VFrame* BandSlideMain::new_picon()
187 return new VFrame(picon_png);
190 int BandSlideMain::load_defaults()
192 char directory[BCTEXTLEN];
193 // set the default directory
194 sprintf(directory, "%sbandslide.rc", BCASTDIR);
197 defaults = new Defaults(directory);
200 bands = defaults->get("BANDS", bands);
201 direction = defaults->get("DIRECTION", direction);
205 int BandSlideMain::save_defaults()
207 defaults->update("BANDS", bands);
208 defaults->update("DIRECTION", direction);
213 void BandSlideMain::save_data(KeyFrame *keyframe)
216 output.set_shared_string(keyframe->data, MESSAGESIZE);
217 output.tag.set_title("BANDSLIDE");
218 output.tag.set_property("BANDS", bands);
219 output.tag.set_property("DIRECTION", direction);
221 output.terminate_string();
224 void BandSlideMain::read_data(KeyFrame *keyframe)
228 input.set_shared_string(keyframe->data, strlen(keyframe->data));
230 while(!input.read_tag())
232 if(input.tag.title_is("BANDSLIDE"))
234 bands = input.tag.get_property("BANDS", bands);
235 direction = input.tag.get_property("DIRECTION", direction);
240 void BandSlideMain::load_configuration()
242 read_data(get_prev_keyframe(get_source_position()));
247 #define BANDSLIDE(type, components) \
252 PluginClient::get_source_position() / \
253 PluginClient::get_total_len(); \
254 for(int i = 0; i < bands; i++) \
256 for(int j = 0; j < band_h; j++) \
258 int row = i * band_h + j; \
260 if(row >= 0 && row < h) \
262 type *in_row = (type*)incoming->get_rows()[row]; \
263 type *out_row = (type*)outgoing->get_rows()[row]; \
267 for(int k = 0, l = w - x; k < x; k++, l++) \
269 out_row[k * components + 0] = in_row[l * components + 0]; \
270 out_row[k * components + 1] = in_row[l * components + 1]; \
271 out_row[k * components + 2] = in_row[l * components + 2]; \
272 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
277 for(int k = w - x, l = 0; k < w; k++, l++) \
279 out_row[k * components + 0] = in_row[l * components + 0]; \
280 out_row[k * components + 1] = in_row[l * components + 1]; \
281 out_row[k * components + 2] = in_row[l * components + 2]; \
282 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
292 PluginClient::get_source_position() / \
293 PluginClient::get_total_len(); \
294 for(int i = 0; i < bands; i++) \
296 for(int j = 0; j < band_h; j++) \
298 int row = i * band_h + j; \
300 if(row >= 0 && row < h) \
302 type *in_row = (type*)incoming->get_rows()[row]; \
303 type *out_row = (type*)outgoing->get_rows()[row]; \
308 for(k = 0, l = w - x; k < x; k++, l++) \
310 out_row[k * components + 0] = out_row[l * components + 0]; \
311 out_row[k * components + 1] = out_row[l * components + 1]; \
312 out_row[k * components + 2] = out_row[l * components + 2]; \
313 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
317 out_row[k * components + 0] = in_row[k * components + 0]; \
318 out_row[k * components + 1] = in_row[k * components + 1]; \
319 out_row[k * components + 2] = in_row[k * components + 2]; \
320 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
325 for(int k = w - 1, l = x - 1; k >= w - x; k--, l--) \
327 out_row[k * components + 0] = out_row[l * components + 0]; \
328 out_row[k * components + 1] = out_row[l * components + 1]; \
329 out_row[k * components + 2] = out_row[l * components + 2]; \
330 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
332 for(int k = 0; k < w - x; k++) \
334 out_row[k * components + 0] = in_row[k * components + 0]; \
335 out_row[k * components + 1] = in_row[k * components + 1]; \
336 out_row[k * components + 2] = in_row[k * components + 2]; \
337 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
348 int BandSlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
350 load_configuration();
352 int w = incoming->get_w();
353 int h = incoming->get_h();
354 int band_h = ((bands == 0) ? h : (h / bands + 1));
356 switch(incoming->get_color_model())
360 BANDSLIDE(unsigned char, 3)
367 BANDSLIDE(unsigned char, 4)
374 BANDSLIDE(uint16_t, 3)
376 case BC_RGBA16161616:
377 case BC_YUVA16161616:
378 BANDSLIDE(uint16_t, 4)