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()
108 add_subwindow(new BC_Title(x, y, _("Direction:")));
110 add_subwindow(in = new IrisSquareIn(plugin,
115 add_subwindow(out = new IrisSquareOut(plugin,
132 IrisSquareMain::IrisSquareMain(PluginServer *server)
133 : PluginVClient(server)
139 IrisSquareMain::~IrisSquareMain()
144 const char* IrisSquareMain::plugin_title() { return N_("IrisSquare"); }
145 int IrisSquareMain::is_video() { return 1; }
146 int IrisSquareMain::is_transition() { return 1; }
147 int IrisSquareMain::uses_gui() { return 1; }
149 NEW_WINDOW_MACRO(IrisSquareMain, IrisSquareWindow)
152 void IrisSquareMain::save_data(KeyFrame *keyframe)
155 output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
156 output.tag.set_title("IRISSQUARE");
157 output.tag.set_property("DIRECTION", direction);
159 output.tag.set_title("/IRISSQUARE");
161 output.append_newline();
162 output.terminate_string();
165 void IrisSquareMain::read_data(KeyFrame *keyframe)
169 input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
171 while(!input.read_tag())
173 if(input.tag.title_is("IRISSQUARE"))
175 direction = input.tag.get_property("DIRECTION", direction);
180 int IrisSquareMain::load_configuration()
182 read_data(get_prev_keyframe(get_source_position()));
191 #define IRISSQUARE(type, components) \
195 int x1 = w / 2 - w / 2 * \
196 PluginClient::get_source_position() / \
197 PluginClient::get_total_len(); \
198 int x2 = w / 2 + w / 2 * \
199 PluginClient::get_source_position() / \
200 PluginClient::get_total_len(); \
201 int y1 = h / 2 - h / 2 * \
202 PluginClient::get_source_position() / \
203 PluginClient::get_total_len(); \
204 int y2 = h / 2 + h / 2 * \
205 PluginClient::get_source_position() / \
206 PluginClient::get_total_len(); \
207 for(int j = y1; j < y2; j++) \
209 type *in_row = (type*)incoming->get_rows()[j]; \
210 type *out_row = (type*)outgoing->get_rows()[j]; \
212 for(int k = x1; k < x2; k++) \
214 out_row[k * components + 0] = in_row[k * components + 0]; \
215 out_row[k * components + 1] = in_row[k * components + 1]; \
216 out_row[k * components + 2] = in_row[k * components + 2]; \
217 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
224 PluginClient::get_source_position() / \
225 PluginClient::get_total_len(); \
226 int x2 = w - w / 2 * \
227 PluginClient::get_source_position() / \
228 PluginClient::get_total_len(); \
230 PluginClient::get_source_position() / \
231 PluginClient::get_total_len(); \
232 int y2 = h - h / 2 * \
233 PluginClient::get_source_position() / \
234 PluginClient::get_total_len(); \
235 for(int j = 0; j < y1; j++) \
237 type *in_row = (type*)incoming->get_rows()[j]; \
238 type *out_row = (type*)outgoing->get_rows()[j]; \
240 for(int k = 0; k < w; k++) \
242 out_row[k * components + 0] = in_row[k * components + 0]; \
243 out_row[k * components + 1] = in_row[k * components + 1]; \
244 out_row[k * components + 2] = in_row[k * components + 2]; \
245 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
248 for(int j = y1; j < y2; j++) \
250 type *in_row = (type*)incoming->get_rows()[j]; \
251 type *out_row = (type*)outgoing->get_rows()[j]; \
253 for(int k = 0; k < x1; k++) \
255 out_row[k * components + 0] = in_row[k * components + 0]; \
256 out_row[k * components + 1] = in_row[k * components + 1]; \
257 out_row[k * components + 2] = in_row[k * components + 2]; \
258 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
260 for(int k = x2; k < w; k++) \
262 out_row[k * components + 0] = in_row[k * components + 0]; \
263 out_row[k * components + 1] = in_row[k * components + 1]; \
264 out_row[k * components + 2] = in_row[k * components + 2]; \
265 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
268 for(int j = y2; j < h; j++) \
270 type *in_row = (type*)incoming->get_rows()[j]; \
271 type *out_row = (type*)outgoing->get_rows()[j]; \
273 for(int k = 0; k < w; k++) \
275 out_row[k * components + 0] = in_row[k * components + 0]; \
276 out_row[k * components + 1] = in_row[k * components + 1]; \
277 out_row[k * components + 2] = in_row[k * components + 2]; \
278 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
288 int IrisSquareMain::process_realtime(VFrame *incoming, VFrame *outgoing)
290 load_configuration();
292 int w = incoming->get_w();
293 int h = incoming->get_h();
296 switch(incoming->get_color_model())
299 IRISSQUARE(float, 3);
303 IRISSQUARE(unsigned char, 3)
306 IRISSQUARE(float, 4);
310 IRISSQUARE(unsigned char, 4)
314 IRISSQUARE(uint16_t, 3)
316 case BC_RGBA16161616:
317 case BC_YUVA16161616:
318 IRISSQUARE(uint16_t, 4)