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 BC_Hash(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.tag.set_title("/BANDSLIDE");
223 output.terminate_string();
226 void BandSlideMain::read_data(KeyFrame *keyframe)
230 input.set_shared_string(keyframe->data, strlen(keyframe->data));
232 while(!input.read_tag())
234 if(input.tag.title_is("BANDSLIDE"))
236 bands = input.tag.get_property("BANDS", bands);
237 direction = input.tag.get_property("DIRECTION", direction);
242 void BandSlideMain::load_configuration()
244 read_data(get_prev_keyframe(get_source_position()));
249 #define BANDSLIDE(type, components) \
254 PluginClient::get_source_position() / \
255 PluginClient::get_total_len(); \
256 for(int i = 0; i < bands; i++) \
258 for(int j = 0; j < band_h; j++) \
260 int row = i * band_h + j; \
262 if(row >= 0 && row < h) \
264 type *in_row = (type*)incoming->get_rows()[row]; \
265 type *out_row = (type*)outgoing->get_rows()[row]; \
269 for(int k = 0, l = w - x; k < x; k++, l++) \
271 out_row[k * components + 0] = in_row[l * components + 0]; \
272 out_row[k * components + 1] = in_row[l * components + 1]; \
273 out_row[k * components + 2] = in_row[l * components + 2]; \
274 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
279 for(int k = w - x, l = 0; k < w; k++, l++) \
281 out_row[k * components + 0] = in_row[l * components + 0]; \
282 out_row[k * components + 1] = in_row[l * components + 1]; \
283 out_row[k * components + 2] = in_row[l * components + 2]; \
284 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
294 PluginClient::get_source_position() / \
295 PluginClient::get_total_len(); \
296 for(int i = 0; i < bands; i++) \
298 for(int j = 0; j < band_h; j++) \
300 int row = i * band_h + j; \
302 if(row >= 0 && row < h) \
304 type *in_row = (type*)incoming->get_rows()[row]; \
305 type *out_row = (type*)outgoing->get_rows()[row]; \
310 for(k = 0, l = w - x; k < x; k++, l++) \
312 out_row[k * components + 0] = out_row[l * components + 0]; \
313 out_row[k * components + 1] = out_row[l * components + 1]; \
314 out_row[k * components + 2] = out_row[l * components + 2]; \
315 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
319 out_row[k * components + 0] = in_row[k * components + 0]; \
320 out_row[k * components + 1] = in_row[k * components + 1]; \
321 out_row[k * components + 2] = in_row[k * components + 2]; \
322 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
327 for(int k = w - 1, l = x - 1; k >= w - x; k--, l--) \
329 out_row[k * components + 0] = out_row[l * components + 0]; \
330 out_row[k * components + 1] = out_row[l * components + 1]; \
331 out_row[k * components + 2] = out_row[l * components + 2]; \
332 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
334 for(int k = 0; k < w - x; k++) \
336 out_row[k * components + 0] = in_row[k * components + 0]; \
337 out_row[k * components + 1] = in_row[k * components + 1]; \
338 out_row[k * components + 2] = in_row[k * components + 2]; \
339 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
350 int BandSlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
352 load_configuration();
354 int w = incoming->get_w();
355 int h = incoming->get_h();
356 int band_h = ((bands == 0) ? h : (h / bands + 1));
358 switch(incoming->get_color_model())
362 BANDSLIDE(unsigned char, 3)
369 BANDSLIDE(unsigned char, 4)
376 BANDSLIDE(uint16_t, 3)
378 case BC_RGBA16161616:
379 case BC_YUVA16161616:
380 BANDSLIDE(uint16_t, 4)