[Cin] failed experiment at making burn configurable

Andrew Randrianasulu randrianasulu at gmail.com
Sun May 8 04:50:28 CEST 2022


ah, forgot about update_gui()

but it still segfault (



On Sunday, May 8, 2022, Andrew Randrianasulu <randrianasulu at gmail.com>
wrote:

> :(
>
>
>
> ---------- Forwarded message ----------
> From: *Андрей Рандрианасулу* <randrik at mail.ru>
> Date: Sunday, May 8, 2022
> Subject: failed experiment at making burn configurable
> To: randrianasulu <randrianasulu at gmail.com>
>
>
> fail at attempt at using sliders
>
> --
> Андрей  Рандрианасулу
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20220508/d790437d/attachment.htm>
-------------- next part --------------
diff --git a/cinelerra-5.1/plugins/burn/burn.C b/cinelerra-5.1/plugins/burn/burn.C
index cbf9939e..c05492b4 100644
--- a/cinelerra-5.1/plugins/burn/burn.C
+++ b/cinelerra-5.1/plugins/burn/burn.C
@@ -38,22 +38,22 @@ REGISTER_PLUGIN(BurnMain)
 
 
 
-
-
-
-
-
-
-
-
-
-BurnConfig::BurnConfig()
+void BurnConfig::reset()
 {
 	threshold = 50;
 	decay = 15;
 	recycle = 1.0;
 }
 
+BurnConfig::BurnConfig()
+{
+	reset();
+}
+
+BurnConfig::~BurnConfig()
+{
+}
+
 BurnMain::BurnMain(PluginServer *server)
  : PluginVClient(server)
 {
@@ -64,6 +64,27 @@ BurnMain::BurnMain(PluginServer *server)
 	effecttv = 0;
 }
 
+int BurnConfig::equivalent(BurnConfig &that)
+{
+	return threshold == that.threshold &&
+		decay == that.decay;
+}
+
+void BurnConfig::copy_from(BurnConfig &that)
+{
+	threshold = that.threshold;
+	decay = that.decay;
+}
+
+void BurnConfig::interpolate(BurnConfig &prev,
+	BurnConfig &next, int64_t prev_frame, int64_t next_frame, int64_t current_frame)
+
+{
+	copy_from(prev);
+}
+
+
+
 BurnMain::~BurnMain()
 {
 
@@ -80,23 +101,55 @@ int BurnMain::is_realtime() { return 1; }
 NEW_WINDOW_MACRO(BurnMain, BurnWindow)
 
 
-int BurnMain::load_configuration()
+void BurnMain::update_gui()
 {
-	return 0;
-//printf("BurnMain::load_configuration %d\n", source_position);
+    if(thread)
+    {
+	load_configuration();
+	thread->window->lock_window();
+	((BurnWindow *)thread->window)->update();
+	thread->window->unlock_window();
+    }
 }
 
+LOAD_CONFIGURATION_MACRO(BurnMain, BurnConfig)
 
 void BurnMain::save_data(KeyFrame *keyframe)
 {
+	FileXML output;
+	
+	output.set_shared_output(keyframe->xbuf);
+
+	output.tag.set_title("BURNTV");
+	output.tag.set_property("THRESHOLD", config.threshold);
+	output.tag.set_property("DECAY", config.decay);
+	output.append_tag();
+	output.tag.set_title("/BURNTV");
+	output.append_tag();
+	output.append_newline();
+	output.terminate_string();
 }
 
 void BurnMain::read_data(KeyFrame *keyframe)
 {
+	FileXML input;
+	input.set_shared_input(keyframe->xbuf);
+	
+	while(!input.read_tag())
+	{
+		if(input.tag.title_is("BURNTV"))
+		{
+			config.threshold = input.tag.get_property("THRESHOLD",
+				config.threshold);
+			config.decay = input.tag.get_property("DECAY", config.decay);
+		}
+	}
 }
 
 
 
+
+
 #define MAXCOLOR 120
 
 void BurnMain::HSItoRGB(double H,
@@ -439,4 +492,3 @@ BurnPackage::BurnPackage()
 }
 
 
-
diff --git a/cinelerra-5.1/plugins/burn/burn.h b/cinelerra-5.1/plugins/burn/burn.h
index 22fbfc88..597f47e8 100644
--- a/cinelerra-5.1/plugins/burn/burn.h
+++ b/cinelerra-5.1/plugins/burn/burn.h
@@ -37,6 +37,13 @@ class BurnConfig
 {
 public:
 	BurnConfig();
+	~BurnConfig();
+
+	void reset();
+	int equivalent(BurnConfig &that);
+	void copy_from(BurnConfig &that);
+	void interpolate(BurnConfig &prev,
+		BurnConfig &next, int64_t prev_frame, int64_t next_frame, int64_t current_frame);
 	int threshold;
 	int decay;
 	double recycle;  // Seconds to a recycle
@@ -82,12 +89,11 @@ public:
 	int process_realtime(VFrame *input_ptr, VFrame *output_ptr);
 	int is_realtime();
 	PLUGIN_CLASS_MEMBERS(BurnConfig);
+
 	void save_data(KeyFrame *keyframe);
 	void read_data(KeyFrame *keyframe);
 
-
-
-
+	void update_gui();
 
 	void HSItoRGB(double H,
 		double S,
@@ -99,6 +105,7 @@ public:
 	void make_palette(int color_model);
 
 	BurnServer *burn_server;
+	BurnClient *burn_client;
 
 	int palette[3][256];
 	unsigned char *buffer;
@@ -111,12 +118,4 @@ public:
 };
 
 
-
-
-
-
-
-
-
-
 #endif
diff --git a/cinelerra-5.1/plugins/burn/burnwindow.C b/cinelerra-5.1/plugins/burn/burnwindow.C
index 9d6a5d70..9a543cc6 100644
--- a/cinelerra-5.1/plugins/burn/burnwindow.C
+++ b/cinelerra-5.1/plugins/burn/burnwindow.C
@@ -26,12 +26,6 @@
 
 
 
-
-
-
-
-
-
 BurnWindow::BurnWindow(BurnMain *client)
  : PluginClientWindow(client,
 	xS(300),
@@ -47,13 +41,49 @@ BurnWindow::~BurnWindow()
 {
 }
 
+void BurnWindow::update()
+{
+	threshold->update(client->config.threshold);
+	decay->update(client->config.decay);
+}
+
+
+BurnSize::BurnSize(BurnMain *client, int x, int y, int w,
+	 int min, int max, int *output)
+ : BC_ISlider(x, y, 0, 200, 200, min, max, *output)
+{
+	this->plugin = plugin;
+	this->output = output;
+}
+
+int BurnSize::handle_event()
+{
+	int ret = BC_ISlider::handle_event();
+	plugin->send_configure_change();
+	return ret;
+}
+
+
+
 void BurnWindow::create_objects()
 {
+	BC_WindowBase *win;
+	int title_h;
+	
+	int xs10 = xS(10);
 	int x = xS(10), y = yS(10);
-	add_subwindow(new BC_Title(x, y,
-		_("BurningTV from EffectTV\n"
-		"Copyright (C) 2001 FUKUCHI Kentarou")
-	));
+	add_subwindow(win = new BC_Title(x, y, _("Threshold")));
+	title_h = win->get_h() + 8;
+	y += title_h;
+	add_subwindow(threshold = new BurnSize(client, x+xs10, y, yS(10),
+		0, 100, &client->config.threshold));
+	y += threshold->get_h() + 8;
+	add_subwindow(win = new BC_Title(x, y, _("Decay")));
+	y += title_h;
+	add_subwindow(decay = new BurnSize(client, x+xs10, y, yS(10),
+		0, 50, &client->config.decay));
+	
+	
 
 	show_window();
 	flush();
diff --git a/cinelerra-5.1/plugins/burn/burnwindow.h b/cinelerra-5.1/plugins/burn/burnwindow.h
index 636d5405..2f0aca51 100644
--- a/cinelerra-5.1/plugins/burn/burnwindow.h
+++ b/cinelerra-5.1/plugins/burn/burnwindow.h
@@ -22,6 +22,7 @@
 #ifndef BURNWINDOW_H
 #define BURNWINDOW_H
 
+#include "bcslider.h"
 #include "guicast.h"
 
 class BurnThread;
@@ -31,6 +32,18 @@ class BurnWindow;
 #include "mutex.h"
 #include "burn.h"
 
+class BurnSize : public BC_ISlider
+{
+public:
+	BurnSize(BurnMain *plugin, int x, int y,
+		int w, int min, int max, int *output);
+
+	int handle_event();
+	BurnMain *plugin;
+	int *output;
+};
+
+
 
 
 
@@ -41,11 +54,13 @@ public:
 	~BurnWindow();
 
 	void create_objects();
+	void update();
 
 	BurnMain *client;
-};
-
 
+	BurnSize *threshold;
+	BurnSize *decay;
+};
 
 
 


More information about the Cin mailing list