1 #include "bcdisplayinfo.h"
5 #include "overlayframe.h"
8 #include "irissquare.h"
15 #define _(String) gettext(String)
16 #define gettext_noop(String) String
17 #define N_(String) gettext_noop (String)
20 REGISTER_PLUGIN(IrisSquareMain)
26 IrisSquareIn::IrisSquareIn(IrisSquareMain *plugin,
27 IrisSquareWindow *window,
32 plugin->direction == 0,
35 this->plugin = plugin;
36 this->window = window;
39 int IrisSquareIn::handle_event()
42 plugin->direction = 0;
43 window->out->update(0);
44 plugin->send_configure_change();
48 IrisSquareOut::IrisSquareOut(IrisSquareMain *plugin,
49 IrisSquareWindow *window,
54 plugin->direction == 1,
57 this->plugin = plugin;
58 this->window = window;
61 int IrisSquareOut::handle_event()
64 plugin->direction = 1;
65 window->in->update(0);
66 plugin->send_configure_change();
77 IrisSquareWindow::IrisSquareWindow(IrisSquareMain *plugin, int x, int y)
78 : BC_Window(plugin->gui_string,
89 this->plugin = plugin;
93 int IrisSquareWindow::close_event()
99 void IrisSquareWindow::create_objects()
102 add_subwindow(new BC_Title(x, y, _("Direction:")));
104 add_subwindow(in = new IrisSquareIn(plugin,
109 add_subwindow(out = new IrisSquareOut(plugin,
120 PLUGIN_THREAD_OBJECT(IrisSquareMain, IrisSquareThread, IrisSquareWindow)
127 IrisSquareMain::IrisSquareMain(PluginServer *server)
128 : PluginVClient(server)
131 PLUGIN_CONSTRUCTOR_MACRO
134 IrisSquareMain::~IrisSquareMain()
136 PLUGIN_DESTRUCTOR_MACRO
139 char* IrisSquareMain::plugin_title() { return _("IrisSquare"); }
140 int IrisSquareMain::is_video() { return 1; }
141 int IrisSquareMain::is_transition() { return 1; }
142 int IrisSquareMain::uses_gui() { return 1; }
143 SHOW_GUI_MACRO(IrisSquareMain, IrisSquareThread);
144 SET_STRING_MACRO(IrisSquareMain)
145 RAISE_WINDOW_MACRO(IrisSquareMain)
148 VFrame* IrisSquareMain::new_picon()
150 return new VFrame(picon_png);
153 int IrisSquareMain::load_defaults()
155 char directory[BCTEXTLEN];
156 // set the default directory
157 sprintf(directory, "%sirissquare.rc", BCASTDIR);
160 defaults = new Defaults(directory);
163 direction = defaults->get("DIRECTION", direction);
167 int IrisSquareMain::save_defaults()
169 defaults->update("DIRECTION", direction);
174 void IrisSquareMain::save_data(KeyFrame *keyframe)
177 output.set_shared_string(keyframe->data, MESSAGESIZE);
178 output.tag.set_title("IRISSQUARE");
179 output.tag.set_property("DIRECTION", direction);
181 output.terminate_string();
184 void IrisSquareMain::read_data(KeyFrame *keyframe)
188 input.set_shared_string(keyframe->data, strlen(keyframe->data));
190 while(!input.read_tag())
192 if(input.tag.title_is("IRISSQUARE"))
194 direction = input.tag.get_property("DIRECTION", direction);
199 void IrisSquareMain::load_configuration()
201 read_data(get_prev_keyframe(get_source_position()));
209 #define IRISSQUARE(type, components) \
213 int x1 = w / 2 - w / 2 * \
214 PluginClient::get_source_position() / \
215 PluginClient::get_total_len(); \
216 int x2 = w / 2 + w / 2 * \
217 PluginClient::get_source_position() / \
218 PluginClient::get_total_len(); \
219 int y1 = h / 2 - h / 2 * \
220 PluginClient::get_source_position() / \
221 PluginClient::get_total_len(); \
222 int y2 = h / 2 + h / 2 * \
223 PluginClient::get_source_position() / \
224 PluginClient::get_total_len(); \
225 for(int j = y1; j < y2; j++) \
227 type *in_row = (type*)incoming->get_rows()[j]; \
228 type *out_row = (type*)outgoing->get_rows()[j]; \
230 for(int k = x1; k < x2; k++) \
232 out_row[k * components + 0] = in_row[k * components + 0]; \
233 out_row[k * components + 1] = in_row[k * components + 1]; \
234 out_row[k * components + 2] = in_row[k * components + 2]; \
235 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
242 PluginClient::get_source_position() / \
243 PluginClient::get_total_len(); \
244 int x2 = w - w / 2 * \
245 PluginClient::get_source_position() / \
246 PluginClient::get_total_len(); \
248 PluginClient::get_source_position() / \
249 PluginClient::get_total_len(); \
250 int y2 = h - h / 2 * \
251 PluginClient::get_source_position() / \
252 PluginClient::get_total_len(); \
253 for(int j = 0; j < y1; j++) \
255 type *in_row = (type*)incoming->get_rows()[j]; \
256 type *out_row = (type*)outgoing->get_rows()[j]; \
258 for(int k = 0; k < w; k++) \
260 out_row[k * components + 0] = in_row[k * components + 0]; \
261 out_row[k * components + 1] = in_row[k * components + 1]; \
262 out_row[k * components + 2] = in_row[k * components + 2]; \
263 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
266 for(int j = y1; j < y2; j++) \
268 type *in_row = (type*)incoming->get_rows()[j]; \
269 type *out_row = (type*)outgoing->get_rows()[j]; \
271 for(int k = 0; k < x1; k++) \
273 out_row[k * components + 0] = in_row[k * components + 0]; \
274 out_row[k * components + 1] = in_row[k * components + 1]; \
275 out_row[k * components + 2] = in_row[k * components + 2]; \
276 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
278 for(int k = x2; k < w; k++) \
280 out_row[k * components + 0] = in_row[k * components + 0]; \
281 out_row[k * components + 1] = in_row[k * components + 1]; \
282 out_row[k * components + 2] = in_row[k * components + 2]; \
283 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
286 for(int j = y2; j < h; j++) \
288 type *in_row = (type*)incoming->get_rows()[j]; \
289 type *out_row = (type*)outgoing->get_rows()[j]; \
291 for(int k = 0; k < w; k++) \
293 out_row[k * components + 0] = in_row[k * components + 0]; \
294 out_row[k * components + 1] = in_row[k * components + 1]; \
295 out_row[k * components + 2] = in_row[k * components + 2]; \
296 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
306 int IrisSquareMain::process_realtime(VFrame *incoming, VFrame *outgoing)
308 load_configuration();
310 int w = incoming->get_w();
311 int h = incoming->get_h();
314 switch(incoming->get_color_model())
318 IRISSQUARE(unsigned char, 3)
322 IRISSQUARE(unsigned char, 4)
326 IRISSQUARE(uint16_t, 3)
328 case BC_RGBA16161616:
329 case BC_YUVA16161616:
330 IRISSQUARE(uint16_t, 4)