00001 #include "bcdisplayinfo.h"
00002 #include "bchash.h"
00003 #include "edl.inc"
00004 #include "filexml.h"
00005 #include "language.h"
00006 #include "overlayframe.h"
00007 #include "picon_png.h"
00008 #include "vframe.h"
00009 #include "irissquare.h"
00010
00011
00012 #include <stdint.h>
00013 #include <string.h>
00014
00015
00016 REGISTER_PLUGIN(IrisSquareMain)
00017
00018
00019
00020
00021
00022 IrisSquareIn::IrisSquareIn(IrisSquareMain *plugin,
00023 IrisSquareWindow *window,
00024 int x,
00025 int y)
00026 : BC_Radial(x,
00027 y,
00028 plugin->direction == 0,
00029 _("In"))
00030 {
00031 this->plugin = plugin;
00032 this->window = window;
00033 }
00034
00035 int IrisSquareIn::handle_event()
00036 {
00037 update(1);
00038 plugin->direction = 0;
00039 window->out->update(0);
00040 plugin->send_configure_change();
00041 return 0;
00042 }
00043
00044 IrisSquareOut::IrisSquareOut(IrisSquareMain *plugin,
00045 IrisSquareWindow *window,
00046 int x,
00047 int y)
00048 : BC_Radial(x,
00049 y,
00050 plugin->direction == 1,
00051 _("Out"))
00052 {
00053 this->plugin = plugin;
00054 this->window = window;
00055 }
00056
00057 int IrisSquareOut::handle_event()
00058 {
00059 update(1);
00060 plugin->direction = 1;
00061 window->in->update(0);
00062 plugin->send_configure_change();
00063 return 0;
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073 IrisSquareWindow::IrisSquareWindow(IrisSquareMain *plugin, int x, int y)
00074 : BC_Window(plugin->gui_string,
00075 x,
00076 y,
00077 320,
00078 50,
00079 320,
00080 50,
00081 0,
00082 0,
00083 1)
00084 {
00085 this->plugin = plugin;
00086 }
00087
00088
00089 int IrisSquareWindow::close_event()
00090 {
00091 set_done(1);
00092 return 1;
00093 }
00094
00095 void IrisSquareWindow::create_objects()
00096 {
00097 int x = 10, y = 10;
00098 add_subwindow(new BC_Title(x, y, _("Direction:")));
00099 x += 100;
00100 add_subwindow(in = new IrisSquareIn(plugin,
00101 this,
00102 x,
00103 y));
00104 x += 100;
00105 add_subwindow(out = new IrisSquareOut(plugin,
00106 this,
00107 x,
00108 y));
00109 show_window();
00110 flush();
00111 }
00112
00113
00114
00115
00116 PLUGIN_THREAD_OBJECT(IrisSquareMain, IrisSquareThread, IrisSquareWindow)
00117
00118
00119
00120
00121
00122
00123 IrisSquareMain::IrisSquareMain(PluginServer *server)
00124 : PluginVClient(server)
00125 {
00126 direction = 0;
00127 PLUGIN_CONSTRUCTOR_MACRO
00128 }
00129
00130 IrisSquareMain::~IrisSquareMain()
00131 {
00132 PLUGIN_DESTRUCTOR_MACRO
00133 }
00134
00135 char* IrisSquareMain::plugin_title() { return N_("IrisSquare"); }
00136 int IrisSquareMain::is_video() { return 1; }
00137 int IrisSquareMain::is_transition() { return 1; }
00138 int IrisSquareMain::uses_gui() { return 1; }
00139
00140 SHOW_GUI_MACRO(IrisSquareMain, IrisSquareThread);
00141 SET_STRING_MACRO(IrisSquareMain)
00142 RAISE_WINDOW_MACRO(IrisSquareMain)
00143
00144
00145 VFrame* IrisSquareMain::new_picon()
00146 {
00147 return new VFrame(picon_png);
00148 }
00149
00150 int IrisSquareMain::load_defaults()
00151 {
00152 char directory[BCTEXTLEN];
00153
00154 sprintf(directory, "%sirissquare.rc", BCASTDIR);
00155
00156
00157 defaults = new BC_Hash(directory);
00158 defaults->load();
00159
00160 direction = defaults->get("DIRECTION", direction);
00161 return 0;
00162 }
00163
00164 int IrisSquareMain::save_defaults()
00165 {
00166 defaults->update("DIRECTION", direction);
00167 defaults->save();
00168 return 0;
00169 }
00170
00171 void IrisSquareMain::save_data(KeyFrame *keyframe)
00172 {
00173 FileXML output;
00174 output.set_shared_string(keyframe->data, MESSAGESIZE);
00175 output.tag.set_title("IRISSQUARE");
00176 output.tag.set_property("DIRECTION", direction);
00177 output.append_tag();
00178 output.tag.set_title("/IRISSQUARE");
00179 output.append_tag();
00180 output.terminate_string();
00181 }
00182
00183 void IrisSquareMain::read_data(KeyFrame *keyframe)
00184 {
00185 FileXML input;
00186
00187 input.set_shared_string(keyframe->data, strlen(keyframe->data));
00188
00189 while(!input.read_tag())
00190 {
00191 if(input.tag.title_is("IRISSQUARE"))
00192 {
00193 direction = input.tag.get_property("DIRECTION", direction);
00194 }
00195 }
00196 }
00197
00198 void IrisSquareMain::load_configuration()
00199 {
00200 read_data(get_prev_keyframe(get_source_position()));
00201 }
00202
00203
00204
00205
00206
00207
00208 #define IRISSQUARE(type, components) \
00209 { \
00210 if(direction == 0) \
00211 { \
00212 int x1 = w / 2 - w / 2 * \
00213 PluginClient::get_source_position() / \
00214 PluginClient::get_total_len(); \
00215 int x2 = w / 2 + w / 2 * \
00216 PluginClient::get_source_position() / \
00217 PluginClient::get_total_len(); \
00218 int y1 = h / 2 - h / 2 * \
00219 PluginClient::get_source_position() / \
00220 PluginClient::get_total_len(); \
00221 int y2 = h / 2 + h / 2 * \
00222 PluginClient::get_source_position() / \
00223 PluginClient::get_total_len(); \
00224 for(int j = y1; j < y2; j++) \
00225 { \
00226 type *in_row = (type*)incoming->get_rows()[j]; \
00227 type *out_row = (type*)outgoing->get_rows()[j]; \
00228 \
00229 for(int k = x1; k < x2; k++) \
00230 { \
00231 out_row[k * components + 0] = in_row[k * components + 0]; \
00232 out_row[k * components + 1] = in_row[k * components + 1]; \
00233 out_row[k * components + 2] = in_row[k * components + 2]; \
00234 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
00235 } \
00236 } \
00237 } \
00238 else \
00239 { \
00240 int x1 = w / 2 * \
00241 PluginClient::get_source_position() / \
00242 PluginClient::get_total_len(); \
00243 int x2 = w - w / 2 * \
00244 PluginClient::get_source_position() / \
00245 PluginClient::get_total_len(); \
00246 int y1 = h / 2 * \
00247 PluginClient::get_source_position() / \
00248 PluginClient::get_total_len(); \
00249 int y2 = h - h / 2 * \
00250 PluginClient::get_source_position() / \
00251 PluginClient::get_total_len(); \
00252 for(int j = 0; j < y1; j++) \
00253 { \
00254 type *in_row = (type*)incoming->get_rows()[j]; \
00255 type *out_row = (type*)outgoing->get_rows()[j]; \
00256 \
00257 for(int k = 0; k < w; k++) \
00258 { \
00259 out_row[k * components + 0] = in_row[k * components + 0]; \
00260 out_row[k * components + 1] = in_row[k * components + 1]; \
00261 out_row[k * components + 2] = in_row[k * components + 2]; \
00262 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
00263 } \
00264 } \
00265 for(int j = y1; j < y2; j++) \
00266 { \
00267 type *in_row = (type*)incoming->get_rows()[j]; \
00268 type *out_row = (type*)outgoing->get_rows()[j]; \
00269 \
00270 for(int k = 0; k < x1; k++) \
00271 { \
00272 out_row[k * components + 0] = in_row[k * components + 0]; \
00273 out_row[k * components + 1] = in_row[k * components + 1]; \
00274 out_row[k * components + 2] = in_row[k * components + 2]; \
00275 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
00276 } \
00277 for(int k = x2; k < w; k++) \
00278 { \
00279 out_row[k * components + 0] = in_row[k * components + 0]; \
00280 out_row[k * components + 1] = in_row[k * components + 1]; \
00281 out_row[k * components + 2] = in_row[k * components + 2]; \
00282 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
00283 } \
00284 } \
00285 for(int j = y2; j < h; j++) \
00286 { \
00287 type *in_row = (type*)incoming->get_rows()[j]; \
00288 type *out_row = (type*)outgoing->get_rows()[j]; \
00289 \
00290 for(int k = 0; k < w; k++) \
00291 { \
00292 out_row[k * components + 0] = in_row[k * components + 0]; \
00293 out_row[k * components + 1] = in_row[k * components + 1]; \
00294 out_row[k * components + 2] = in_row[k * components + 2]; \
00295 if(components == 4) out_row[k * components + 3] = in_row[k * components + 3]; \
00296 } \
00297 } \
00298 } \
00299 }
00300
00301
00302
00303
00304
00305 int IrisSquareMain::process_realtime(VFrame *incoming, VFrame *outgoing)
00306 {
00307 load_configuration();
00308
00309 int w = incoming->get_w();
00310 int h = incoming->get_h();
00311
00312
00313 switch(incoming->get_color_model())
00314 {
00315 case BC_RGB_FLOAT:
00316 IRISSQUARE(float, 3);
00317 break;
00318 case BC_RGB888:
00319 case BC_YUV888:
00320 IRISSQUARE(unsigned char, 3)
00321 break;
00322 case BC_RGBA_FLOAT:
00323 IRISSQUARE(float, 4);
00324 break;
00325 case BC_RGBA8888:
00326 case BC_YUVA8888:
00327 IRISSQUARE(unsigned char, 4)
00328 break;
00329 case BC_RGB161616:
00330 case BC_YUV161616:
00331 IRISSQUARE(uint16_t, 3)
00332 break;
00333 case BC_RGBA16161616:
00334 case BC_YUVA16161616:
00335 IRISSQUARE(uint16_t, 4)
00336 break;
00337 }
00338 return 0;
00339 }