2 #include "bcdisplayinfo.h"
6 #include "overlayframe.h"
15 #define _(String) gettext(String)
16 #define gettext_noop(String) String
17 #define N_(String) gettext_noop (String)
24 REGISTER_PLUGIN(BandWipeMain)
30 BandWipeCount::BandWipeCount(BandWipeMain *plugin,
31 BandWipeWindow *window,
34 : BC_TumbleTextBox(window,
35 (int64_t)plugin->bands,
42 this->plugin = plugin;
43 this->window = window;
46 int BandWipeCount::handle_event()
48 plugin->bands = atol(get_text());
49 plugin->send_configure_change();
54 BandWipeIn::BandWipeIn(BandWipeMain *plugin,
55 BandWipeWindow *window,
60 plugin->direction == 0,
63 this->plugin = plugin;
64 this->window = window;
67 int BandWipeIn::handle_event()
70 plugin->direction = 0;
71 window->out->update(0);
72 plugin->send_configure_change();
76 BandWipeOut::BandWipeOut(BandWipeMain *plugin,
77 BandWipeWindow *window,
82 plugin->direction == 1,
85 this->plugin = plugin;
86 this->window = window;
89 int BandWipeOut::handle_event()
92 plugin->direction = 1;
93 window->in->update(0);
94 plugin->send_configure_change();
104 BandWipeWindow::BandWipeWindow(BandWipeMain *plugin, int x, int y)
105 : BC_Window(plugin->gui_string,
116 this->plugin = plugin;
120 int BandWipeWindow::close_event()
126 void BandWipeWindow::create_objects()
129 add_subwindow(new BC_Title(x, y, _("Bands:")));
131 count = new BandWipeCount(plugin,
135 count->create_objects();
137 // add_subwindow(new BC_Title(x, y, _("Direction:")));
139 // add_subwindow(in = new BandWipeIn(plugin,
145 // add_subwindow(out = new BandWipeOut(plugin,
157 PLUGIN_THREAD_OBJECT(BandWipeMain, BandWipeThread, BandWipeWindow)
164 BandWipeMain::BandWipeMain(PluginServer *server)
165 : PluginVClient(server)
169 PLUGIN_CONSTRUCTOR_MACRO
172 BandWipeMain::~BandWipeMain()
174 PLUGIN_DESTRUCTOR_MACRO
177 char* BandWipeMain::plugin_title() { return _("BandWipe"); }
178 int BandWipeMain::is_video() { return 1; }
179 int BandWipeMain::is_transition() { return 1; }
180 int BandWipeMain::uses_gui() { return 1; }
181 SHOW_GUI_MACRO(BandWipeMain, BandWipeThread);
182 SET_STRING_MACRO(BandWipeMain)
183 RAISE_WINDOW_MACRO(BandWipeMain)
186 VFrame* BandWipeMain::new_picon()
188 return new VFrame(picon_png);
191 int BandWipeMain::load_defaults()
193 char directory[BCTEXTLEN];
194 // set the default directory
195 sprintf(directory, "%sbandwipe.rc", BCASTDIR);
198 defaults = new Defaults(directory);
201 bands = defaults->get("BANDS", bands);
202 direction = defaults->get("DIRECTION", direction);
206 int BandWipeMain::save_defaults()
208 defaults->update("BANDS", bands);
209 defaults->update("DIRECTION", direction);
214 void BandWipeMain::save_data(KeyFrame *keyframe)
217 output.set_shared_string(keyframe->data, MESSAGESIZE);
218 output.tag.set_title("BANDWIPE");
219 output.tag.set_property("BANDS", bands);
220 output.tag.set_property("DIRECTION", direction);
222 output.terminate_string();
225 void BandWipeMain::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("BANDWIPE"))
235 bands = input.tag.get_property("BANDS", bands);
236 direction = input.tag.get_property("DIRECTION", direction);
241 void BandWipeMain::load_configuration()
243 read_data(get_prev_keyframe(get_source_position()));
248 #define BANDWIPE(type, components) \
253 PluginClient::get_source_position() / \
254 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; k < x; k++) \
271 out_row[k * components + 0] = in_row[k * components + 0]; \
272 out_row[k * components + 1] = in_row[k * components + 1]; \
273 out_row[k * components + 2] = in_row[k * components + 2]; \
274 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
279 for(int k = w - x; k < w; k++) \
281 out_row[k * components + 0] = in_row[k * components + 0]; \
282 out_row[k * components + 1] = in_row[k * components + 1]; \
283 out_row[k * components + 2] = in_row[k * components + 2]; \
284 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
294 PluginClient::get_source_position() / \
295 PluginClient::get_total_len(); \
297 for(int i = 0; i < bands; i++) \
299 for(int j = 0; j < band_h; j++) \
301 int row = i * band_h + j; \
303 if(row >= 0 && row < h) \
305 type *in_row = (type*)incoming->get_rows()[row]; \
306 type *out_row = (type*)outgoing->get_rows()[row]; \
310 for(int k = x; k < w; k++) \
312 out_row[k * components + 0] = in_row[k * components + 0]; \
313 out_row[k * components + 1] = in_row[k * components + 1]; \
314 out_row[k * components + 2] = in_row[k * components + 2]; \
315 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
320 for(int k = 0; k < w - x; k++) \
322 out_row[k * components + 0] = in_row[k * components + 0]; \
323 out_row[k * components + 1] = in_row[k * components + 1]; \
324 out_row[k * components + 2] = in_row[k * components + 2]; \
325 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
336 int BandWipeMain::process_realtime(VFrame *incoming, VFrame *outgoing)
338 load_configuration();
340 int w = incoming->get_w();
341 int h = incoming->get_h();
342 int band_h = ((bands == 0) ? h : (h / bands + 1));
344 switch(incoming->get_color_model())
348 BANDWIPE(unsigned char, 3)
352 BANDWIPE(unsigned char, 4)
356 BANDWIPE(uint16_t, 3)
358 case BC_RGBA16161616:
359 case BC_YUVA16161616:
360 BANDWIPE(uint16_t, 4)