2 #include "colormodels.h"
7 #include "burnwindow.h"
14 #define _(String) gettext(String)
15 #define gettext_noop(String) String
16 #define N_(String) gettext_noop (String)
18 PluginClient* new_plugin(PluginServer *server)
20 return new BurnMain(server);
34 BurnConfig::BurnConfig()
41 BurnMain::BurnMain(PluginServer *server)
42 : PluginVClient(server)
58 // Set result to 0 to indicate a server side close
59 thread->window->set_done(0);
60 thread->completion.lock();
65 if(defaults) delete defaults;
67 if(buffer) delete [] buffer;
68 if(burn_server) delete burn_server;
69 if(effecttv) delete effecttv;
72 char* BurnMain::plugin_title() { return _("BurningTV"); }
73 int BurnMain::is_realtime() { return 1; }
75 NEW_PICON_MACRO(BurnMain)
76 SHOW_GUI_MACRO(BurnMain, BurnThread)
77 SET_STRING_MACRO(BurnMain)
78 RAISE_WINDOW_MACRO(BurnMain)
80 int BurnMain::load_defaults()
85 int BurnMain::save_defaults()
90 void BurnMain::load_configuration()
92 //printf("BurnMain::load_configuration %d\n", source_position);
96 void BurnMain::save_data(KeyFrame *keyframe)
100 void BurnMain::read_data(KeyFrame *keyframe)
108 static void HSItoRGB(double H,
115 double T, Rv, Gv, Bv;
118 Rv = 1 + S * sin(T - 2 * M_PI / 3);
120 Bv = 1 + S * sin(T + 2 * M_PI / 3);
123 *r = (int)CLIP(Rv * T, 0, 255);
124 *g = (int)CLIP(Gv * T, 0, 255);
125 *b = (int)CLIP(Bv * T, 0, 255);
129 void BurnMain::make_palette()
133 for(i = 0; i < MAXCOLOR; i++)
135 HSItoRGB(4.6 - 1.5 * i / MAXCOLOR,
136 (double)i / MAXCOLOR,
137 (double)i / MAXCOLOR,
144 //printf("BurnMain::make_palette %d\n", palette[0][i]);
148 for(i = MAXCOLOR; i < 256; i++)
166 int BurnMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr)
168 this->input_ptr = input_ptr;
169 this->output_ptr = output_ptr;
171 load_configuration();
175 effecttv = new EffectTV(input_ptr->get_w(), input_ptr->get_h());
176 buffer = (unsigned char *)new unsigned char[input_ptr->get_w() * input_ptr->get_h()];
179 effecttv->image_set_threshold_y(config.threshold);
182 burn_server = new BurnServer(this, 1, 1);
187 bzero(buffer, input_ptr->get_w() * input_ptr->get_h());
188 effecttv->image_bgset_y(input_ptr);
190 burn_server->process_packages();
193 // if(total >= config.recycle * project_frame_rate) total = 0;
199 BurnServer::BurnServer(BurnMain *plugin, int total_clients, int total_packages)
200 : LoadServer(total_clients, total_packages)
202 this->plugin = plugin;
206 LoadClient* BurnServer::new_client()
208 return new BurnClient(this);
214 LoadPackage* BurnServer::new_package()
216 return new BurnPackage;
221 void BurnServer::init_packages()
223 for(int i = 0; i < total_packages; i++)
225 BurnPackage *package = (BurnPackage*)packages[i];
226 package->row1 = plugin->input_ptr->get_h() / total_packages * i;
227 package->row2 = package->row1 + plugin->input_ptr->get_h() / total_packages;
228 if(i >= total_packages - 1)
229 package->row2 = plugin->input_ptr->get_h();
240 BurnClient::BurnClient(BurnServer *server)
243 this->plugin = server->plugin;
254 #define BURN(type, components) \
257 for(y = 0; y < height; y++) \
259 for(x = 1; x < width - 1; x++) \
261 for(c = 0; c < components; c++) \
264 output_rows[0][i * components + c] = input_rows[0][i * components + c]; \
266 if(sizeof(type) == 2) \
268 a = (input_rows[0][i * components + c] & 0xffff) >> 8; \
269 b = plugin->palette[c][plugin->buffer[i]] & 0xff; \
272 output_rows[0][i * components + c] = a | (b - (b >> 16)); \
276 a = input_rows[0][i * components + c] & 0xff; \
277 b = plugin->palette[c][plugin->buffer[i]] & 0xff; \
280 output_rows[0][i * components + c] = a | (b - (b >> 8)); \
292 void BurnClient::process_package(LoadPackage *package)
294 BurnPackage *local_package = (BurnPackage*)package;
295 unsigned char **input_rows = plugin->input_ptr->get_rows() + local_package->row1;
296 unsigned char **output_rows = plugin->output_ptr->get_rows() + local_package->row1;
297 int width = plugin->input_ptr->get_w();
298 int height = local_package->row2 - local_package->row1;
300 int pitch = width * plugin->input_ptr->get_bytes_per_pixel();
306 diff = plugin->effecttv->image_bgsubtract_y(input_rows,
307 plugin->input_ptr->get_color_model());
309 for(x = 1; x < width - 1; x++)
312 for(y = 0; y < height - 1; y++)
314 w = diff[y * width + x];
315 plugin->buffer[y * width + x] |= v ^ w;
320 for(x = 1; x < width - 1; x++)
325 for(y = 1; y < height; y++)
327 v = plugin->buffer[i];
329 if(v < plugin->config.decay)
330 plugin->buffer[i - width] = 0;
332 plugin->buffer[i - width + EffectTV::fastrand() % 3 - 1] =
333 v - (EffectTV::fastrand() & plugin->config.decay);
341 switch(plugin->input_ptr->get_color_model())
358 case BC_RGBA16161616:
359 case BC_YUVA16161616:
369 BurnPackage::BurnPackage()