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.terminate_string();
162 void IrisSquareMain::read_data(KeyFrame *keyframe)
166 input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
168 while(!input.read_tag())
170 if(input.tag.title_is("IRISSQUARE"))
172 direction = input.tag.get_property("DIRECTION", direction);
177 int IrisSquareMain::load_configuration()
179 read_data(get_prev_keyframe(get_source_position()));
188 #define IRISSQUARE(type, components) \
192 int x1 = w / 2 - w / 2 * \
193 PluginClient::get_source_position() / \
194 PluginClient::get_total_len(); \
195 int x2 = w / 2 + w / 2 * \
196 PluginClient::get_source_position() / \
197 PluginClient::get_total_len(); \
198 int y1 = h / 2 - h / 2 * \
199 PluginClient::get_source_position() / \
200 PluginClient::get_total_len(); \
201 int y2 = h / 2 + h / 2 * \
202 PluginClient::get_source_position() / \
203 PluginClient::get_total_len(); \
204 for(int j = y1; j < y2; j++) \
206 type *in_row = (type*)incoming->get_rows()[j]; \
207 type *out_row = (type*)outgoing->get_rows()[j]; \
209 for(int k = x1; k < x2; k++) \
211 out_row[k * components + 0] = in_row[k * components + 0]; \
212 out_row[k * components + 1] = in_row[k * components + 1]; \
213 out_row[k * components + 2] = in_row[k * components + 2]; \
214 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
221 PluginClient::get_source_position() / \
222 PluginClient::get_total_len(); \
223 int x2 = w - w / 2 * \
224 PluginClient::get_source_position() / \
225 PluginClient::get_total_len(); \
227 PluginClient::get_source_position() / \
228 PluginClient::get_total_len(); \
229 int y2 = h - h / 2 * \
230 PluginClient::get_source_position() / \
231 PluginClient::get_total_len(); \
232 for(int j = 0; j < y1; j++) \
234 type *in_row = (type*)incoming->get_rows()[j]; \
235 type *out_row = (type*)outgoing->get_rows()[j]; \
237 for(int k = 0; k < w; k++) \
239 out_row[k * components + 0] = in_row[k * components + 0]; \
240 out_row[k * components + 1] = in_row[k * components + 1]; \
241 out_row[k * components + 2] = in_row[k * components + 2]; \
242 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
245 for(int j = y1; j < y2; j++) \
247 type *in_row = (type*)incoming->get_rows()[j]; \
248 type *out_row = (type*)outgoing->get_rows()[j]; \
250 for(int k = 0; k < x1; k++) \
252 out_row[k * components + 0] = in_row[k * components + 0]; \
253 out_row[k * components + 1] = in_row[k * components + 1]; \
254 out_row[k * components + 2] = in_row[k * components + 2]; \
255 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
257 for(int k = x2; k < w; k++) \
259 out_row[k * components + 0] = in_row[k * components + 0]; \
260 out_row[k * components + 1] = in_row[k * components + 1]; \
261 out_row[k * components + 2] = in_row[k * components + 2]; \
262 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
265 for(int j = y2; j < h; j++) \
267 type *in_row = (type*)incoming->get_rows()[j]; \
268 type *out_row = (type*)outgoing->get_rows()[j]; \
270 for(int k = 0; k < w; k++) \
272 out_row[k * components + 0] = in_row[k * components + 0]; \
273 out_row[k * components + 1] = in_row[k * components + 1]; \
274 out_row[k * components + 2] = in_row[k * components + 2]; \
275 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
285 int IrisSquareMain::process_realtime(VFrame *incoming, VFrame *outgoing)
287 load_configuration();
289 int w = incoming->get_w();
290 int h = incoming->get_h();
293 switch(incoming->get_color_model())
296 IRISSQUARE(float, 3);
300 IRISSQUARE(unsigned char, 3)
303 IRISSQUARE(float, 4);
307 IRISSQUARE(unsigned char, 4)
311 IRISSQUARE(uint16_t, 3)
313 case BC_RGBA16161616:
314 case BC_YUVA16161616:
315 IRISSQUARE(uint16_t, 4)