From: Good Guy Date: Thu, 30 Dec 2021 01:14:36 +0000 (-0700) Subject: improved Blur plugin X-Git-Tag: 2021-12~1 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=eb23696d9df4cf447d60f3fa0009028602d33c6c;p=goodguy%2Fcinelerra.git improved Blur plugin --- diff --git a/cinelerra-5.1/ffmpeg/video/ffv1.mkv b/cinelerra-5.1/ffmpeg/video/ffv1.mkv index 15f5fde6..67630021 100644 --- a/cinelerra-5.1/ffmpeg/video/ffv1.mkv +++ b/cinelerra-5.1/ffmpeg/video/ffv1.mkv @@ -1,4 +1,6 @@ matroska ffv1 +# For specific version, remove # and change the 3 on next line +# level=3 threads=8 context=1 slices=30 diff --git a/cinelerra-5.1/plugins/blur/blur.C b/cinelerra-5.1/plugins/blur/blur.C index bc404397..896cddbb 100644 --- a/cinelerra-5.1/plugins/blur/blur.C +++ b/cinelerra-5.1/plugins/blur/blur.C @@ -40,16 +40,24 @@ BlurConfig::BlurConfig() { - reset(); + reset(RESET_ALL); } -void BlurConfig::reset() +void BlurConfig::reset(int clear) { - vertical = 1; - horizontal = 1; - radius = 5; - a_key = 0; - a = r = g = b = 1; + switch(clear) { + case RESET_RADIUS : + radius = 5; + break; + case RESET_ALL : + default: + vertical = 1; + horizontal = 1; + radius = 5; + a_key = 0; + a = r = g = b = 1; + break; + } } int BlurConfig::equivalent(BlurConfig &that) @@ -293,7 +301,7 @@ void BlurMain::update_gui() ((BlurWindow*)thread->window)->lock_window("BlurMain::update_gui"); ((BlurWindow*)thread->window)->horizontal->update(config.horizontal); ((BlurWindow*)thread->window)->vertical->update(config.vertical); - ((BlurWindow*)thread->window)->radius->update(config.radius); + ((BlurWindow*)thread->window)->radius_slider->update(config.radius); ((BlurWindow*)thread->window)->radius_text->update((int64_t)config.radius); ((BlurWindow*)thread->window)->a_key->update(config.a_key); ((BlurWindow*)thread->window)->a->update(config.a); diff --git a/cinelerra-5.1/plugins/blur/blur.h b/cinelerra-5.1/plugins/blur/blur.h index b85e2bbe..40184092 100644 --- a/cinelerra-5.1/plugins/blur/blur.h +++ b/cinelerra-5.1/plugins/blur/blur.h @@ -47,7 +47,7 @@ class BlurConfig { public: BlurConfig(); - void reset(); + void reset(int clear); int equivalent(BlurConfig &that); void copy_from(BlurConfig &that); diff --git a/cinelerra-5.1/plugins/blur/blurwindow.C b/cinelerra-5.1/plugins/blur/blurwindow.C index 44ba304e..46854b63 100644 --- a/cinelerra-5.1/plugins/blur/blurwindow.C +++ b/cinelerra-5.1/plugins/blur/blurwindow.C @@ -31,10 +31,10 @@ BlurWindow::BlurWindow(BlurMain *client) : PluginClientWindow(client, - xS(210), - yS(360), - xS(210), - yS(360), + xS(420), + yS(250), + xS(420), + yS(250), 0) { this->client = client; @@ -47,67 +47,97 @@ BlurWindow::~BlurWindow() void BlurWindow::create_objects() { - int xs10 = xS(10); - int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys35 = yS(35), ys40 = yS(40); + int xs10 = xS(10), xs20 = xS(20), xs200 = xS(200); + int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40); + int x2 = xS(80), x3 = xS(180); int x = xs10, y = ys10; - BC_Title *title; + int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22 - add_subwindow(new BC_Title(x, y, _("Blur"))); + BC_TitleBar *title_bar; + BC_Bar *bar; + + add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Radius"))); + y += ys20; + add_subwindow(new BC_Title(x, y, _("Radius:"))); + radius_text = new BlurRadiusText(client, this, (x + x2), y); + radius_text->create_objects(); + add_subwindow(radius_slider = new BlurRadiusSlider(client, this, x3, y, xs200)); + clr_x = x3 + radius_slider->get_w() + x; + add_subwindow(radius_Clr = new BlurRadiusClr(client, this, clr_x, y)); +// December 2021: Disable and Hide 'Alpha determines radius' checkbox for bug(?) +// y += ys30; + add_subwindow(a_key = new BlurAKey(client, x, y)); + y += ys40; + + add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Direction"))); y += ys20; add_subwindow(horizontal = new BlurHorizontal(client, this, x, y)); y += ys30; add_subwindow(vertical = new BlurVertical(client, this, x, y)); - y += ys35; - add_subwindow(title = new BC_Title(x, y, _("Radius:"))); - y += title->get_h() + ys10; - add_subwindow(radius = new BlurRadius(client, this, x, y)); - add_subwindow(radius_text = new BlurRadiusText(client, this, x + radius->get_w() + xs10, y, 100)); - y += radius->get_h() + ys10; - add_subwindow(a_key = new BlurAKey(client, x, y)); - y += ys30; - add_subwindow(a = new BlurA(client, x, y)); - y += ys30; - add_subwindow(r = new BlurR(client, x, y)); - y += ys30; - add_subwindow(g = new BlurG(client, x, y)); - y += ys30; - add_subwindow(b = new BlurB(client, x, y)); y += ys40; + + add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, xs20, xs10, _("Color channel"))); + y += ys20; + int x1 = x; + int toggle_w = (get_w()-2*x) / 4; + add_subwindow(r = new BlurR(client, x1, y)); + x1 += toggle_w; + add_subwindow(g = new BlurG(client, x1, y)); + x1 += toggle_w; + add_subwindow(b = new BlurB(client, x1, y)); + x1 += toggle_w; + add_subwindow(a = new BlurA(client, x1, y)); + y += ys30; + +// Reset section + add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x)); + y += ys10; add_subwindow(reset = new BlurReset(client, this, x, y)); show_window(); + +// December 2021: Disable and Hide 'Alpha determines radius' checkbox for bug(?) + a_key->disable(); + a_key->hide_window(); + flush(); } // for Reset button -void BlurWindow::update() +void BlurWindow::update(int clear) { - horizontal->update(client->config.horizontal); - vertical->update(client->config.vertical); - radius->update(client->config.radius); - radius_text->update((int64_t)client->config.radius); - a_key->update(client->config.a_key); - a->update(client->config.a); - r->update(client->config.r); - g->update(client->config.g); - b->update(client->config.b); + switch(clear) { + case RESET_RADIUS : + radius_slider->update(client->config.radius); + radius_text->update((int64_t)client->config.radius); + break; + case RESET_ALL : + default: + horizontal->update(client->config.horizontal); + vertical->update(client->config.vertical); + radius_slider->update(client->config.radius); + radius_text->update((int64_t)client->config.radius); + a_key->update(client->config.a_key); + a->update(client->config.a); + r->update(client->config.r); + g->update(client->config.g); + b->update(client->config.b); + break; + } } -BlurRadius::BlurRadius(BlurMain *client, BlurWindow *gui, int x, int y) - : BC_IPot(x, - y, - client->config.radius, - 0, - MAXRADIUS) +BlurRadiusSlider::BlurRadiusSlider(BlurMain *client, BlurWindow *gui, int x, int y, int w) + : BC_ISlider(x, y, 0, w, w, 0, MAXRADIUS, client->config.radius, 0, 0, 0) { this->client = client; this->gui = gui; + enable_show_value(0); // Hide caption } -BlurRadius::~BlurRadius() +BlurRadiusSlider::~BlurRadiusSlider() { } -int BlurRadius::handle_event() +int BlurRadiusSlider::handle_event() { client->config.radius = get_value(); gui->radius_text->update((int64_t)client->config.radius); @@ -118,21 +148,24 @@ int BlurRadius::handle_event() -BlurRadiusText::BlurRadiusText(BlurMain *client, BlurWindow *gui, int x, int y, int w) - : BC_TextBox(x, - y, - w, - 1, - client->config.radius) +BlurRadiusText::BlurRadiusText(BlurMain *client, BlurWindow *gui, int x, int y) + : BC_TumbleTextBox(gui, client->config.radius, + 0, MAXRADIUS, x, y, xS(60), 0) { this->client = client; this->gui = gui; + set_increment(1); +} +BlurRadiusText::~BlurRadiusText() +{ } - int BlurRadiusText::handle_event() { client->config.radius = atoi(get_text()); - gui->radius->update((int64_t)client->config.radius); + if(client->config.radius > MAXRADIUS) client->config.radius = MAXRADIUS; + else if(client->config.radius < 0) client->config.radius = 0; + gui->radius_text->update((int64_t)client->config.radius); + gui->radius_slider->update(client->config.radius); client->send_configure_change(); return 1; } @@ -182,7 +215,7 @@ int BlurHorizontal::handle_event() BlurA::BlurA(BlurMain *client, int x, int y) - : BC_CheckBox(x, y, client->config.a, _("Blur alpha")) + : BC_CheckBox(x, y, client->config.a, _("Alpha")) { this->client = client; } @@ -209,7 +242,7 @@ int BlurAKey::handle_event() } BlurR::BlurR(BlurMain *client, int x, int y) - : BC_CheckBox(x, y, client->config.r, _("Blur red")) + : BC_CheckBox(x, y, client->config.r, _("Red")) { this->client = client; } @@ -221,7 +254,7 @@ int BlurR::handle_event() } BlurG::BlurG(BlurMain *client, int x, int y) - : BC_CheckBox(x, y, client->config.g, _("Blur green")) + : BC_CheckBox(x, y, client->config.g, _("Green")) { this->client = client; } @@ -233,7 +266,7 @@ int BlurG::handle_event() } BlurB::BlurB(BlurMain *client, int x, int y) - : BC_CheckBox(x, y, client->config.b, _("Blur blue")) + : BC_CheckBox(x, y, client->config.b, _("Blue")) { this->client = client; } @@ -255,8 +288,26 @@ BlurReset::~BlurReset() } int BlurReset::handle_event() { - client->config.reset(); - window->update(); + client->config.reset(RESET_ALL); + window->update(RESET_ALL); + client->send_configure_change(); + return 1; +} + +BlurRadiusClr::BlurRadiusClr(BlurMain *client, BlurWindow *gui, int x, int y) + : BC_Button(x, y, client->get_theme()->get_image_set("reset_button")) +{ + this->client = client; + this->gui = gui; +} +BlurRadiusClr::~BlurRadiusClr() +{ +} +int BlurRadiusClr::handle_event() +{ + client->config.reset(RESET_RADIUS); + gui->update(RESET_RADIUS); client->send_configure_change(); return 1; } + diff --git a/cinelerra-5.1/plugins/blur/blurwindow.h b/cinelerra-5.1/plugins/blur/blurwindow.h index d5d900cd..e2f9180b 100644 --- a/cinelerra-5.1/plugins/blur/blurwindow.h +++ b/cinelerra-5.1/plugins/blur/blurwindow.h @@ -31,12 +31,16 @@ class BlurWindow; #include "guicast.h" #include "mutex.h" #include "thread.h" +#include "theme.h" +#define RESET_ALL 0 +#define RESET_RADIUS 1 class BlurVertical; class BlurHorizontal; -class BlurRadius; +class BlurRadiusSlider; class BlurRadiusText; +class BlurRadiusClr; class BlurA; class BlurR; class BlurG; @@ -51,13 +55,14 @@ public: ~BlurWindow(); void create_objects(); - void update(); + void update(int clear); BlurMain *client; BlurVertical *vertical; BlurHorizontal *horizontal; - BlurRadius *radius; + BlurRadiusSlider *radius_slider; BlurRadiusText *radius_text; + BlurRadiusClr *radius_Clr; BlurA *a; BlurR *r; BlurG *g; @@ -104,20 +109,21 @@ public: }; -class BlurRadius : public BC_IPot +class BlurRadiusSlider : public BC_ISlider { public: - BlurRadius(BlurMain *client, BlurWindow *gui, int x, int y); - ~BlurRadius(); + BlurRadiusSlider(BlurMain *client, BlurWindow *gui, int x, int y, int w); + ~BlurRadiusSlider(); int handle_event(); BlurMain *client; BlurWindow *gui; }; -class BlurRadiusText : public BC_TextBox +class BlurRadiusText : public BC_TumbleTextBox { public: - BlurRadiusText(BlurMain *client, BlurWindow *gui, int x, int y, int w); + BlurRadiusText(BlurMain *client, BlurWindow *gui, int x, int y); + ~BlurRadiusText(); int handle_event(); BlurMain *client; BlurWindow *gui; @@ -155,5 +161,15 @@ public: BlurWindow *window; }; +class BlurRadiusClr : public BC_Button +{ +public: + BlurRadiusClr(BlurMain *client, BlurWindow *gui, int x, int y); + ~BlurRadiusClr(); + int handle_event(); + BlurMain *client; + BlurWindow *gui; +}; + #endif