2 #include "bcdisplayinfo.h"
6 #include "overlayframe.h"
14 #define _(String) gettext(String)
15 #define gettext_noop(String) String
16 #define N_(String) gettext_noop (String)
23 REGISTER_PLUGIN(BandSlideMain)
29 BandSlideCount::BandSlideCount(BandSlideMain *plugin,
30 BandSlideWindow *window,
33 : BC_TumbleTextBox(window,
34 (int64_t)plugin->bands,
41 this->plugin = plugin;
42 this->window = window;
45 int BandSlideCount::handle_event()
47 plugin->bands = atol(get_text());
48 plugin->send_configure_change();
52 BandSlideIn::BandSlideIn(BandSlideMain *plugin,
53 BandSlideWindow *window,
58 plugin->direction == 0,
61 this->plugin = plugin;
62 this->window = window;
65 int BandSlideIn::handle_event()
68 plugin->direction = 0;
69 window->out->update(0);
70 plugin->send_configure_change();
74 BandSlideOut::BandSlideOut(BandSlideMain *plugin,
75 BandSlideWindow *window,
80 plugin->direction == 1,
83 this->plugin = plugin;
84 this->window = window;
87 int BandSlideOut::handle_event()
90 plugin->direction = 1;
91 window->in->update(0);
92 plugin->send_configure_change();
103 BandSlideWindow::BandSlideWindow(BandSlideMain *plugin, int x, int y)
104 : BC_Window(plugin->gui_string,
115 this->plugin = plugin;
119 int BandSlideWindow::close_event()
125 void BandSlideWindow::create_objects()
128 add_subwindow(new BC_Title(x, y, _("Bands:")));
130 count = new BandSlideCount(plugin,
134 count->create_objects();
138 add_subwindow(new BC_Title(x, y, _("Direction:")));
140 add_subwindow(in = new BandSlideIn(plugin,
145 add_subwindow(out = new BandSlideOut(plugin,
157 PLUGIN_THREAD_OBJECT(BandSlideMain, BandSlideThread, BandSlideWindow)
164 BandSlideMain::BandSlideMain(PluginServer *server)
165 : PluginVClient(server)
169 PLUGIN_CONSTRUCTOR_MACRO
172 BandSlideMain::~BandSlideMain()
174 PLUGIN_DESTRUCTOR_MACRO
177 char* BandSlideMain::plugin_title() { return _("BandSlide"); }
178 int BandSlideMain::is_video() { return 1; }
179 int BandSlideMain::is_transition() { return 1; }
180 int BandSlideMain::uses_gui() { return 1; }
181 SHOW_GUI_MACRO(BandSlideMain, BandSlideThread);
182 SET_STRING_MACRO(BandSlideMain)
183 RAISE_WINDOW_MACRO(BandSlideMain)
186 VFrame* BandSlideMain::new_picon()
188 return new VFrame(picon_png);
191 int BandSlideMain::load_defaults()
193 char directory[BCTEXTLEN];
194 // set the default directory
195 sprintf(directory, "%sbandslide.rc", BCASTDIR);
198 defaults = new Defaults(directory);
201 bands = defaults->get("BANDS", bands);
202 direction = defaults->get("DIRECTION", direction);
206 int BandSlideMain::save_defaults()
208 defaults->update("BANDS", bands);
209 defaults->update("DIRECTION", direction);
214 void BandSlideMain::save_data(KeyFrame *keyframe)
217 output.set_shared_string(keyframe->data, MESSAGESIZE);
218 output.tag.set_title("BANDSLIDE");
219 output.tag.set_property("BANDS", bands);
220 output.tag.set_property("DIRECTION", direction);
222 output.terminate_string();
225 void BandSlideMain::read_data(KeyFrame *keyframe)
229 input.set_shared_string(keyframe->data, strlen(keyframe->data));
231 while(!input.read_tag())
233 if(input.tag.title_is("BANDSLIDE"))
235 bands = input.tag.get_property("BANDS", bands);
236 direction = input.tag.get_property("DIRECTION", direction);
241 void BandSlideMain::load_configuration()
243 read_data(get_prev_keyframe(get_source_position()));
248 #define BANDSLIDE(type, components) \
253 PluginClient::get_source_position() / \
254 PluginClient::get_total_len(); \
255 for(int i = 0; i < bands; i++) \
257 for(int j = 0; j < band_h; j++) \
259 int row = i * band_h + j; \
261 if(row >= 0 && row < h) \
263 type *in_row = (type*)incoming->get_rows()[row]; \
264 type *out_row = (type*)outgoing->get_rows()[row]; \
268 for(int k = 0, l = w - x; k < x; k++, l++) \
270 out_row[k * components + 0] = in_row[l * components + 0]; \
271 out_row[k * components + 1] = in_row[l * components + 1]; \
272 out_row[k * components + 2] = in_row[l * components + 2]; \
273 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
278 for(int k = w - x, l = 0; k < w; k++, l++) \
280 out_row[k * components + 0] = in_row[l * components + 0]; \
281 out_row[k * components + 1] = in_row[l * components + 1]; \
282 out_row[k * components + 2] = in_row[l * components + 2]; \
283 if(components == 4) out_row[k * components + 3] = in_row[l * components + 3]; \
293 PluginClient::get_source_position() / \
294 PluginClient::get_total_len(); \
295 for(int i = 0; i < bands; i++) \
297 for(int j = 0; j < band_h; j++) \
299 int row = i * band_h + j; \
301 if(row >= 0 && row < h) \
303 type *in_row = (type*)incoming->get_rows()[row]; \
304 type *out_row = (type*)outgoing->get_rows()[row]; \
309 for(k = 0, l = w - x; k < x; k++, l++) \
311 out_row[k * components + 0] = out_row[l * components + 0]; \
312 out_row[k * components + 1] = out_row[l * components + 1]; \
313 out_row[k * components + 2] = out_row[l * components + 2]; \
314 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
318 out_row[k * components + 0] = in_row[k * components + 0]; \
319 out_row[k * components + 1] = in_row[k * components + 1]; \
320 out_row[k * components + 2] = in_row[k * components + 2]; \
321 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
326 for(int k = w - 1, l = x - 1; k >= w - x; k--, l--) \
328 out_row[k * components + 0] = out_row[l * components + 0]; \
329 out_row[k * components + 1] = out_row[l * components + 1]; \
330 out_row[k * components + 2] = out_row[l * components + 2]; \
331 if(components == 4) out_row[k * components + 3] = out_row[l * components + 3]; \
333 for(int k = 0; k < w - x; k++) \
335 out_row[k * components + 0] = in_row[k * components + 0]; \
336 out_row[k * components + 1] = in_row[k * components + 1]; \
337 out_row[k * components + 2] = in_row[k * components + 2]; \
338 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
349 int BandSlideMain::process_realtime(VFrame *incoming, VFrame *outgoing)
351 load_configuration();
353 int w = incoming->get_w();
354 int h = incoming->get_h();
355 int band_h = ((bands == 0) ? h : (h / bands + 1));
357 switch(incoming->get_color_model())
361 BANDSLIDE(unsigned char, 3)
365 BANDSLIDE(unsigned char, 4)
369 BANDSLIDE(uint16_t, 3)
371 case BC_RGBA16161616:
372 case BC_YUVA16161616:
373 BANDSLIDE(uint16_t, 4)