1 #include "bcdisplayinfo.h"
6 #include "overlayframe.h"
9 #include "irissquare.h"
16 REGISTER_PLUGIN(IrisSquareMain)
22 IrisSquareIn::IrisSquareIn(IrisSquareMain *plugin,
23 IrisSquareWindow *window,
28 plugin->direction == 0,
31 this->plugin = plugin;
32 this->window = window;
35 int IrisSquareIn::handle_event()
38 plugin->direction = 0;
39 window->out->update(0);
40 plugin->send_configure_change();
44 IrisSquareOut::IrisSquareOut(IrisSquareMain *plugin,
45 IrisSquareWindow *window,
50 plugin->direction == 1,
53 this->plugin = plugin;
54 this->window = window;
57 int IrisSquareOut::handle_event()
60 plugin->direction = 1;
61 window->in->update(0);
62 plugin->send_configure_change();
73 IrisSquareWindow::IrisSquareWindow(IrisSquareMain *plugin, int x, int y)
74 : BC_Window(plugin->gui_string,
85 this->plugin = plugin;
89 int IrisSquareWindow::close_event()
95 void IrisSquareWindow::create_objects()
98 add_subwindow(new BC_Title(x, y, _("Direction:")));
100 add_subwindow(in = new IrisSquareIn(plugin,
105 add_subwindow(out = new IrisSquareOut(plugin,
116 PLUGIN_THREAD_OBJECT(IrisSquareMain, IrisSquareThread, IrisSquareWindow)
123 IrisSquareMain::IrisSquareMain(PluginServer *server)
124 : PluginVClient(server)
127 PLUGIN_CONSTRUCTOR_MACRO
130 IrisSquareMain::~IrisSquareMain()
132 PLUGIN_DESTRUCTOR_MACRO
135 char* IrisSquareMain::plugin_title() { return N_("IrisSquare"); }
136 int IrisSquareMain::is_video() { return 1; }
137 int IrisSquareMain::is_transition() { return 1; }
138 int IrisSquareMain::uses_gui() { return 1; }
140 SHOW_GUI_MACRO(IrisSquareMain, IrisSquareThread);
141 SET_STRING_MACRO(IrisSquareMain)
142 RAISE_WINDOW_MACRO(IrisSquareMain)
145 VFrame* IrisSquareMain::new_picon()
147 return new VFrame(picon_png);
150 int IrisSquareMain::load_defaults()
152 char directory[BCTEXTLEN];
153 // set the default directory
154 sprintf(directory, "%sirissquare.rc", BCASTDIR);
157 defaults = new BC_Hash(directory);
160 direction = defaults->get("DIRECTION", direction);
164 int IrisSquareMain::save_defaults()
166 defaults->update("DIRECTION", direction);
171 void IrisSquareMain::save_data(KeyFrame *keyframe)
174 output.set_shared_string(keyframe->data, MESSAGESIZE);
175 output.tag.set_title("IRISSQUARE");
176 output.tag.set_property("DIRECTION", direction);
178 output.terminate_string();
181 void IrisSquareMain::read_data(KeyFrame *keyframe)
185 input.set_shared_string(keyframe->data, strlen(keyframe->data));
187 while(!input.read_tag())
189 if(input.tag.title_is("IRISSQUARE"))
191 direction = input.tag.get_property("DIRECTION", direction);
196 void IrisSquareMain::load_configuration()
198 read_data(get_prev_keyframe(get_source_position()));
206 #define IRISSQUARE(type, components) \
210 int x1 = w / 2 - w / 2 * \
211 PluginClient::get_source_position() / \
212 PluginClient::get_total_len(); \
213 int x2 = w / 2 + w / 2 * \
214 PluginClient::get_source_position() / \
215 PluginClient::get_total_len(); \
216 int y1 = h / 2 - h / 2 * \
217 PluginClient::get_source_position() / \
218 PluginClient::get_total_len(); \
219 int y2 = h / 2 + h / 2 * \
220 PluginClient::get_source_position() / \
221 PluginClient::get_total_len(); \
222 for(int j = y1; j < y2; j++) \
224 type *in_row = (type*)incoming->get_rows()[j]; \
225 type *out_row = (type*)outgoing->get_rows()[j]; \
227 for(int k = x1; k < x2; k++) \
229 out_row[k * components + 0] = in_row[k * components + 0]; \
230 out_row[k * components + 1] = in_row[k * components + 1]; \
231 out_row[k * components + 2] = in_row[k * components + 2]; \
232 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
239 PluginClient::get_source_position() / \
240 PluginClient::get_total_len(); \
241 int x2 = w - w / 2 * \
242 PluginClient::get_source_position() / \
243 PluginClient::get_total_len(); \
245 PluginClient::get_source_position() / \
246 PluginClient::get_total_len(); \
247 int y2 = h - h / 2 * \
248 PluginClient::get_source_position() / \
249 PluginClient::get_total_len(); \
250 for(int j = 0; j < y1; j++) \
252 type *in_row = (type*)incoming->get_rows()[j]; \
253 type *out_row = (type*)outgoing->get_rows()[j]; \
255 for(int k = 0; k < w; k++) \
257 out_row[k * components + 0] = in_row[k * components + 0]; \
258 out_row[k * components + 1] = in_row[k * components + 1]; \
259 out_row[k * components + 2] = in_row[k * components + 2]; \
260 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
263 for(int j = y1; j < y2; j++) \
265 type *in_row = (type*)incoming->get_rows()[j]; \
266 type *out_row = (type*)outgoing->get_rows()[j]; \
268 for(int k = 0; k < x1; k++) \
270 out_row[k * components + 0] = in_row[k * components + 0]; \
271 out_row[k * components + 1] = in_row[k * components + 1]; \
272 out_row[k * components + 2] = in_row[k * components + 2]; \
273 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
275 for(int k = x2; k < w; k++) \
277 out_row[k * components + 0] = in_row[k * components + 0]; \
278 out_row[k * components + 1] = in_row[k * components + 1]; \
279 out_row[k * components + 2] = in_row[k * components + 2]; \
280 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
283 for(int j = y2; j < h; j++) \
285 type *in_row = (type*)incoming->get_rows()[j]; \
286 type *out_row = (type*)outgoing->get_rows()[j]; \
288 for(int k = 0; k < w; k++) \
290 out_row[k * components + 0] = in_row[k * components + 0]; \
291 out_row[k * components + 1] = in_row[k * components + 1]; \
292 out_row[k * components + 2] = in_row[k * components + 2]; \
293 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
303 int IrisSquareMain::process_realtime(VFrame *incoming, VFrame *outgoing)
305 load_configuration();
307 int w = incoming->get_w();
308 int h = incoming->get_h();
311 switch(incoming->get_color_model())
314 IRISSQUARE(float, 3);
318 IRISSQUARE(unsigned char, 3)
321 IRISSQUARE(float, 4);
325 IRISSQUARE(unsigned char, 4)
329 IRISSQUARE(uint16_t, 3)
331 case BC_RGBA16161616:
332 case BC_YUVA16161616:
333 IRISSQUARE(uint16_t, 4)