2 #include "bcdisplayinfo.h"
7 #include "overlayframe.h"
20 REGISTER_PLUGIN(BandWipeMain)
26 BandWipeCount::BandWipeCount(BandWipeMain *plugin,
27 BandWipeWindow *window,
30 : BC_TumbleTextBox(window,
31 (int64_t)plugin->bands,
38 this->plugin = plugin;
39 this->window = window;
42 int BandWipeCount::handle_event()
44 plugin->bands = atol(get_text());
45 plugin->send_configure_change();
50 BandWipeIn::BandWipeIn(BandWipeMain *plugin,
51 BandWipeWindow *window,
56 plugin->direction == 0,
59 this->plugin = plugin;
60 this->window = window;
63 int BandWipeIn::handle_event()
66 plugin->direction = 0;
67 window->out->update(0);
68 plugin->send_configure_change();
72 BandWipeOut::BandWipeOut(BandWipeMain *plugin,
73 BandWipeWindow *window,
78 plugin->direction == 1,
81 this->plugin = plugin;
82 this->window = window;
85 int BandWipeOut::handle_event()
88 plugin->direction = 1;
89 window->in->update(0);
90 plugin->send_configure_change();
100 BandWipeWindow::BandWipeWindow(BandWipeMain *plugin, int x, int y)
101 : BC_Window(plugin->gui_string,
112 this->plugin = plugin;
116 int BandWipeWindow::close_event()
122 void BandWipeWindow::create_objects()
125 add_subwindow(new BC_Title(x, y, _("Bands:")));
127 count = new BandWipeCount(plugin,
131 count->create_objects();
133 // add_subwindow(new BC_Title(x, y, _("Direction:")));
135 // add_subwindow(in = new BandWipeIn(plugin,
141 // add_subwindow(out = new BandWipeOut(plugin,
153 PLUGIN_THREAD_OBJECT(BandWipeMain, BandWipeThread, BandWipeWindow)
160 BandWipeMain::BandWipeMain(PluginServer *server)
161 : PluginVClient(server)
165 PLUGIN_CONSTRUCTOR_MACRO
168 BandWipeMain::~BandWipeMain()
170 PLUGIN_DESTRUCTOR_MACRO
173 char* BandWipeMain::plugin_title() { return N_("BandWipe"); }
174 int BandWipeMain::is_video() { return 1; }
175 int BandWipeMain::is_transition() { return 1; }
176 int BandWipeMain::uses_gui() { return 1; }
178 SHOW_GUI_MACRO(BandWipeMain, BandWipeThread);
179 SET_STRING_MACRO(BandWipeMain)
180 RAISE_WINDOW_MACRO(BandWipeMain)
183 VFrame* BandWipeMain::new_picon()
185 return new VFrame(picon_png);
188 int BandWipeMain::load_defaults()
190 char directory[BCTEXTLEN];
191 // set the default directory
192 sprintf(directory, "%sbandwipe.rc", BCASTDIR);
195 defaults = new BC_Hash(directory);
198 bands = defaults->get("BANDS", bands);
199 direction = defaults->get("DIRECTION", direction);
203 int BandWipeMain::save_defaults()
205 defaults->update("BANDS", bands);
206 defaults->update("DIRECTION", direction);
211 void BandWipeMain::save_data(KeyFrame *keyframe)
214 output.set_shared_string(keyframe->data, MESSAGESIZE);
215 output.tag.set_title("BANDWIPE");
216 output.tag.set_property("BANDS", bands);
217 output.tag.set_property("DIRECTION", direction);
219 output.terminate_string();
222 void BandWipeMain::read_data(KeyFrame *keyframe)
226 input.set_shared_string(keyframe->data, strlen(keyframe->data));
228 while(!input.read_tag())
230 if(input.tag.title_is("BANDWIPE"))
232 bands = input.tag.get_property("BANDS", bands);
233 direction = input.tag.get_property("DIRECTION", direction);
238 void BandWipeMain::load_configuration()
240 read_data(get_prev_keyframe(get_source_position()));
245 #define BANDWIPE(type, components) \
250 PluginClient::get_source_position() / \
251 PluginClient::get_total_len(); \
253 for(int i = 0; i < bands; i++) \
255 for(int j = 0; j < band_h; j++) \
257 int row = i * band_h + j; \
259 if(row >= 0 && row < h) \
261 type *in_row = (type*)incoming->get_rows()[row]; \
262 type *out_row = (type*)outgoing->get_rows()[row]; \
266 for(int k = 0; k < x; k++) \
268 out_row[k * components + 0] = in_row[k * components + 0]; \
269 out_row[k * components + 1] = in_row[k * components + 1]; \
270 out_row[k * components + 2] = in_row[k * components + 2]; \
271 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
276 for(int k = w - x; k < w; k++) \
278 out_row[k * components + 0] = in_row[k * components + 0]; \
279 out_row[k * components + 1] = in_row[k * components + 1]; \
280 out_row[k * components + 2] = in_row[k * components + 2]; \
281 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
291 PluginClient::get_source_position() / \
292 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]; \
307 for(int k = x; k < w; k++) \
309 out_row[k * components + 0] = in_row[k * components + 0]; \
310 out_row[k * components + 1] = in_row[k * components + 1]; \
311 out_row[k * components + 2] = in_row[k * components + 2]; \
312 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
317 for(int k = 0; k < w - x; k++) \
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]; \
333 int BandWipeMain::process_realtime(VFrame *incoming, VFrame *outgoing)
335 load_configuration();
337 int w = incoming->get_w();
338 int h = incoming->get_h();
339 int band_h = ((bands == 0) ? h : (h / bands + 1));
341 switch(incoming->get_color_model())
345 BANDWIPE(unsigned char, 3)
352 BANDWIPE(unsigned char, 4)
359 BANDWIPE(uint16_t, 3)
361 case BC_RGBA16161616:
362 case BC_YUVA16161616:
363 BANDWIPE(uint16_t, 4)