4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcdisplayinfo.h"
27 #include "overlayframe.h"
29 #include "irissquare.h"
36 REGISTER_PLUGIN(IrisSquareMain)
42 IrisSquareIn::IrisSquareIn(IrisSquareMain *plugin,
43 IrisSquareWindow *window,
48 plugin->direction == 0,
51 this->plugin = plugin;
52 this->window = window;
55 int IrisSquareIn::handle_event()
58 plugin->direction = 0;
59 window->out->update(0);
60 plugin->send_configure_change();
64 IrisSquareOut::IrisSquareOut(IrisSquareMain *plugin,
65 IrisSquareWindow *window,
70 plugin->direction == 1,
73 this->plugin = plugin;
74 this->window = window;
77 int IrisSquareOut::handle_event()
80 plugin->direction = 1;
81 window->in->update(0);
82 plugin->send_configure_change();
93 IrisSquareWindow::IrisSquareWindow(IrisSquareMain *plugin)
94 : PluginClientWindow(plugin,
101 this->plugin = plugin;
105 void IrisSquareWindow::create_objects()
107 int xs10 = xS(10), xs100 = xS(100);
109 int x = xs10, y = ys10;
110 add_subwindow(new BC_Title(x, y, _("Direction:")));
112 add_subwindow(in = new IrisSquareIn(plugin,
117 add_subwindow(out = new IrisSquareOut(plugin,
134 IrisSquareMain::IrisSquareMain(PluginServer *server)
135 : PluginVClient(server)
141 IrisSquareMain::~IrisSquareMain()
146 const char* IrisSquareMain::plugin_title() { return N_("IrisSquare"); }
147 int IrisSquareMain::is_video() { return 1; }
148 int IrisSquareMain::is_transition() { return 1; }
149 int IrisSquareMain::uses_gui() { return 1; }
151 NEW_WINDOW_MACRO(IrisSquareMain, IrisSquareWindow)
154 void IrisSquareMain::save_data(KeyFrame *keyframe)
157 output.set_shared_output(keyframe->xbuf);
158 output.tag.set_title("IRISSQUARE");
159 output.tag.set_property("DIRECTION", direction);
161 output.tag.set_title("/IRISSQUARE");
163 output.append_newline();
164 output.terminate_string();
167 void IrisSquareMain::read_data(KeyFrame *keyframe)
171 input.set_shared_input(keyframe->xbuf);
173 while(!input.read_tag())
175 if(input.tag.title_is("IRISSQUARE"))
177 direction = input.tag.get_property("DIRECTION", direction);
182 int IrisSquareMain::load_configuration()
184 read_data(get_prev_keyframe(get_source_position()));
193 #define IRISSQUARE(type, components) \
197 int x1 = w / 2 - w / 2 * \
198 PluginClient::get_source_position() / \
199 PluginClient::get_total_len(); \
200 int x2 = w / 2 + w / 2 * \
201 PluginClient::get_source_position() / \
202 PluginClient::get_total_len(); \
203 int y1 = h / 2 - h / 2 * \
204 PluginClient::get_source_position() / \
205 PluginClient::get_total_len(); \
206 int y2 = h / 2 + h / 2 * \
207 PluginClient::get_source_position() / \
208 PluginClient::get_total_len(); \
209 for(int j = y1; j < y2; j++) \
211 type *in_row = (type*)incoming->get_rows()[j]; \
212 type *out_row = (type*)outgoing->get_rows()[j]; \
214 for(int k = x1; k < x2; k++) \
216 out_row[k * components + 0] = in_row[k * components + 0]; \
217 out_row[k * components + 1] = in_row[k * components + 1]; \
218 out_row[k * components + 2] = in_row[k * components + 2]; \
219 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
226 PluginClient::get_source_position() / \
227 PluginClient::get_total_len(); \
228 int x2 = w - w / 2 * \
229 PluginClient::get_source_position() / \
230 PluginClient::get_total_len(); \
232 PluginClient::get_source_position() / \
233 PluginClient::get_total_len(); \
234 int y2 = h - h / 2 * \
235 PluginClient::get_source_position() / \
236 PluginClient::get_total_len(); \
237 for(int j = 0; j < y1; j++) \
239 type *in_row = (type*)incoming->get_rows()[j]; \
240 type *out_row = (type*)outgoing->get_rows()[j]; \
242 for(int k = 0; k < w; k++) \
244 out_row[k * components + 0] = in_row[k * components + 0]; \
245 out_row[k * components + 1] = in_row[k * components + 1]; \
246 out_row[k * components + 2] = in_row[k * components + 2]; \
247 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
250 for(int j = y1; j < y2; 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 < x1; 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]; \
262 for(int k = x2; k < w; k++) \
264 out_row[k * components + 0] = in_row[k * components + 0]; \
265 out_row[k * components + 1] = in_row[k * components + 1]; \
266 out_row[k * components + 2] = in_row[k * components + 2]; \
267 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
270 for(int j = y2; j < h; j++) \
272 type *in_row = (type*)incoming->get_rows()[j]; \
273 type *out_row = (type*)outgoing->get_rows()[j]; \
275 for(int k = 0; 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]; \
290 int IrisSquareMain::process_realtime(VFrame *incoming, VFrame *outgoing)
292 load_configuration();
294 int w = incoming->get_w();
295 int h = incoming->get_h();
298 switch(incoming->get_color_model())
301 IRISSQUARE(float, 3);
305 IRISSQUARE(unsigned char, 3)
308 IRISSQUARE(float, 4);
312 IRISSQUARE(unsigned char, 4)
316 IRISSQUARE(uint16_t, 3)
318 case BC_RGBA16161616:
319 case BC_YUVA16161616:
320 IRISSQUARE(uint16_t, 4)