From: Good Guy Date: Mon, 16 Dec 2019 22:27:30 +0000 (-0700) Subject: port 7.2 mods: align_edits foreground plugin refresh_frame tweak, rework soundlevel... X-Git-Tag: 2019-12~8 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=04293346a5ef49683cfa6ca3a98ef6cbfcdf7732;p=goodguy%2Fcinelerra.git port 7.2 mods: align_edits foreground plugin refresh_frame tweak, rework soundlevel, colorpicker=gadget, add alpha plugin, apply file textbox bug fix, add set_net_icon, clear_frame=black_frame for alpha colormodels --- diff --git a/cinelerra-5.1/cinelerra/adeviceprefs.C b/cinelerra-5.1/cinelerra/adeviceprefs.C index 4d93df69..60c91269 100644 --- a/cinelerra-5.1/cinelerra/adeviceprefs.C +++ b/cinelerra-5.1/cinelerra/adeviceprefs.C @@ -62,6 +62,9 @@ void ADevicePrefs::reset() follow_audio_config = 0; firewire_path = 0; firewire_syt = 0; + channel_title = 0; + firewire_port = 0; + firewire_channel = 0; syt_title = 0; path_title = 0; @@ -86,6 +89,9 @@ void ADevicePrefs::reset() cine_bits = 0; cine_path = 0; + server_title = 0; + port_title = 0; + esound_port = 0; } int ADevicePrefs::initialize(int creation) @@ -162,7 +168,7 @@ int ADevicePrefs::delete_objects() delete_alsa_objs(); break; case AUDIO_ESOUND: - delete_esound_objs(); + delete_esound_objs(); break; case AUDIO_1394: case AUDIO_DV1394: diff --git a/cinelerra-5.1/cinelerra/colorpicker.C b/cinelerra-5.1/cinelerra/colorpicker.C index ad559a79..78f1f957 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.C +++ b/cinelerra-5.1/cinelerra/colorpicker.C @@ -23,6 +23,7 @@ #include "bccapture.h" #include "bccolors.h" #include "bcdisplayinfo.h" +#include "cstrdup.h" #include "colorpicker.h" #include "condition.h" #include "keys.h" @@ -40,32 +41,28 @@ ColorPicker::ColorPicker(int do_alpha, const char *title) : BC_DialogThread() { - this->title = title; this->do_alpha = do_alpha; - this->ok_cancel = 0; - this->output = this->orig_color = BLACK; - this->alpha = this->orig_alpha = 255; + this->title = cstrdup(title); } ColorPicker::~ColorPicker() { close_window(); + delete [] title; } -void ColorPicker::start_window(int output, int alpha, int ok_cancel) +void ColorPicker::start_window(int color, int alpha, int ok_cancel) { if( running() ) { - ColorWindow *gui = (ColorWindow *)get_gui(); - if( gui ) { - gui->lock_window("ColorPicker::start_window"); - gui->raise_window(1); - gui->unlock_window(); + ColorWindow *window = (ColorWindow *)get_gui(); + if( window ) { + window->lock_window("ColorPicker::start_window"); + window->raise_window(1); + window->unlock_window(); } return; } - this->orig_color = output; - this->orig_alpha = alpha; - this->output = output; + this->color = color; this->alpha = alpha; this->ok_cancel = ok_cancel; start(); @@ -79,7 +76,8 @@ BC_Window* ColorPicker::new_gui() BC_DisplayInfo display_info; int x = display_info.get_abs_cursor_x() + xS(25); int y = display_info.get_abs_cursor_y() - yS(100); - int w = xS(540), h = yS(330); + int w = ColorWindow::calculate_w(); + int h = ColorWindow::calculate_h(); if( ok_cancel ) h += bmax(BC_OKButton::calculate_h(),BC_CancelButton::calculate_h()); int root_w = display_info.get_root_w(), root_h = display_info.get_root_h(); @@ -87,37 +85,65 @@ BC_Window* ColorPicker::new_gui() if( y+h > root_h ) y = root_h - h; if( x < 0 ) x = 0; if( y < 0 ) y = 0; - ColorWindow *gui = new ColorWindow(this, x, y, w, h, window_title); - gui->create_objects(); - return gui; + ColorWindow *window = new ColorWindow(this, x, y, w, h, window_title); + window->start_selection(color, !do_alpha ? -1 : alpha, ok_cancel); + return window; } -void ColorPicker::update_gui(int output, int alpha) +void ColorPicker::update_gui(int color, int alpha) { - ColorWindow *gui = (ColorWindow *)get_gui(); - if( !gui ) return; - gui->lock_window("ColorPicker::update_gui"); - this->output = output; - this->alpha = alpha; - gui->change_values(); - gui->update_display(); - gui->unlock_window(); + ColorWindow *window = (ColorWindow *)get_gui(); + if( !window ) return; + window->update_gui(color, alpha); } -int ColorPicker::handle_new_color(int output, int alpha) +int ColorPicker::handle_new_color(int color, int alpha) { printf("ColorPicker::handle_new_color undefined.\n"); return 1; } - ColorWindow::ColorWindow(ColorPicker *thread, int x, int y, int w, int h, const char *title) - : BC_Window(title, x, y, w, h, w, h, 0, 0, 1) + : BC_Window(title, x, y, w, h, w, h, 0, 0, 1), + ColorGUI(this) { this->thread = thread; +} + +ColorWindow::~ColorWindow() +{ +} + +void ColorWindow::update_gui(int color, int alpha) +{ + lock_window("ColorWindow::update_gui"); + this->color = color; + this->alpha = alpha; + change_values(); + update_display(); + unlock_window(); +} +int ColorWindow::handle_new_color(int color, int alpha) +{ + lock_window("ColorWindow::handle_new_color"); + thread->handle_new_color(color, alpha); + unlock_window(); + return 1; +} + + +ColorGUI::ColorGUI(BC_WindowBase *window) +{ + this->window = window; + this->title = 0; + this->do_alpha = 0; + this->ok_cancel = 0; + this->color = this->orig_color = BLACK; + this->alpha = this->orig_alpha = 255; + wheel = 0; wheel_value = 0; - output = 0; + color = 0; hue = 0; sat = 0; val = 0; red = 0; grn = 0; blu = 0; @@ -131,7 +157,7 @@ ColorWindow::ColorWindow(ColorPicker *thread, int x, int y, int w, int h, const button_grabbed = 0; } -ColorWindow::~ColorWindow() +ColorGUI::~ColorGUI() { delete hsv_h; delete hsv_s; delete hsv_v; delete rgb_r; delete rgb_g; delete rgb_b; @@ -139,19 +165,35 @@ ColorWindow::~ColorWindow() delete aph_a; if( button_grabbed ) { - ungrab_buttons(); - ungrab_cursor(); + window->ungrab_buttons(); + window->ungrab_cursor(); } update_history(rgb888()); save_history(); } -void ColorWindow::create_objects() +void ColorGUI::add_tool(BC_WindowBase *sub_wdw) +{ + window->add_tool(sub_wdw); +} + +void ColorGUI::start_selection(int color, int alpha, int ok_cancel) +{ + this->orig_color = color; + this->orig_alpha = alpha; + this->color = color; + this->alpha = alpha; + this->do_alpha = alpha < 0 ? 0 : 1; + this->ok_cancel = ok_cancel; + create_objects(); +} + +void ColorGUI::create_objects() { int xs5 = xS(5), xs10 = xS(10), xs15 = xS(15); int ys10 = yS(10), ys15 = yS(15), ys25 = yS(25), ys40 = yS(40); int x0 = xs10, y0 = ys10; - lock_window("ColorWindow::create_objects"); + window->lock_window("ColorGUI::create_objects"); change_values(); int x = x0, y = y0; @@ -161,13 +203,13 @@ void ColorWindow::create_objects() x += xS(180); add_tool(wheel_value = new PaletteWheelValue(this, x, y)); wheel_value->create_objects(); x = x0; - y += yS(180); add_tool(output = new PaletteOutput(this, x, y)); - output->create_objects(); - y += output->get_h() + yS(20); + y += yS(180); add_tool(poutput = new PaletteOutput(this, x, y)); + poutput->create_objects(); + y += poutput->get_h() + yS(20); load_history(); int x1 = x; add_tool(hex_btn = new PaletteHexButton(this, x1, y)); - char hex[BCSTRLEN]; sprintf(hex,"%06x",thread->output); + char hex[BCSTRLEN]; sprintf(hex,"%06x",color); x1 += hex_btn->get_w() + xs5; add_tool(hex_box = new PaletteHex(this, x1, y, hex)); x1 += hex_box->get_w() + xs15; @@ -185,7 +227,7 @@ void ColorWindow::create_objects() add_tool(new BC_Title(x, y+=ys40, C_("Y:"), SMALLFONT)); add_tool(new BC_Title(x, y+=ys25, C_("U:"), SMALLFONT)); add_tool(new BC_Title(x, y+=ys25, D_("colorpicker_Cr#V:"), SMALLFONT)); - if( thread->do_alpha ) + if( do_alpha ) add_tool(new BC_Title(x, y+=ys40, C_("A:"), SMALLFONT)); x += xS(24); add_tool(hue = new PaletteHue(this, x, y= y0)); @@ -197,8 +239,8 @@ void ColorWindow::create_objects() add_tool(lum = new PaletteLum(this, x, y+=ys40)); add_tool(c_r = new PaletteCr (this, x, y+=ys25)); add_tool(c_b = new PaletteCb (this, x, y+=ys25)); - if( thread->do_alpha ) - add_tool(alpha = new PaletteAlpha(this, x, y+=ys40)); + if( do_alpha ) + add_tool(palpha = new PaletteAlpha(this, x, y+=ys40)); x += hue->get_w() + xs10; hsv_h = new PaletteHSV(this, x,y= y0, hsv.h, 0, 360); @@ -219,58 +261,58 @@ void ColorWindow::create_objects() yuv_u->create_objects(); yuv_u->set_tooltip(_("Blue Luminance Difference")); yuv_v = new PaletteYUV(this, x,y+=ys25, yuv.v, 0, 1); yuv_v->create_objects(); yuv_v->set_tooltip(_("Red Luminance Difference")); - if( thread->do_alpha ) { + if( do_alpha ) { aph_a = new PaletteAPH(this, x,y+=ys40, aph, 0, 1); aph_a->create_objects(); aph_a->set_tooltip(_("Alpha")); } - if( thread->ok_cancel ) { - add_tool(new BC_OKButton(this)); - add_tool(new BC_CancelButton(this)); + if( ok_cancel ) { + add_tool(new BC_OKButton(window)); + add_tool(new BC_CancelButton(window)); } - thread->create_objects(this); + create_objects(this); update_display(); update_history(); - show_window(1); - unlock_window(); + window->show_window(1); + window->unlock_window(); } -void ColorWindow::change_values() +void ColorGUI::change_values() { - float r = ((thread->output>>16) & 0xff) / 255.; - float g = ((thread->output>>8) & 0xff) / 255.; - float b = ((thread->output>>0) & 0xff) / 255.; + float r = ((color>>16) & 0xff) / 255.; + float g = ((color>>8) & 0xff) / 255.; + float b = ((color>>0) & 0xff) / 255.; rgb.r = r; rgb.g = g; rgb.b = b; - aph = (float)thread->alpha / 255; + aph = (float)alpha / 255; update_rgb(rgb.r, rgb.g, rgb.b); } -int ColorWindow::close_event() +int ColorGUI::close_gui() { - set_done(thread->ok_cancel ? 1 : 0); + window->set_done(ok_cancel ? 1 : 0); return 1; } -void ColorWindow::update_rgb() +void ColorGUI::update_rgb() { update_rgb(rgb.r, rgb.g, rgb.b); update_display(); } -void ColorWindow::update_hsv() +void ColorGUI::update_hsv() { update_hsv(hsv.h, hsv.s, hsv.v); update_display(); } -void ColorWindow::update_yuv() +void ColorGUI::update_yuv() { update_yuv(yuv.y, yuv.u, yuv.v); update_display(); } -void ColorWindow::update_display() +void ColorGUI::update_display() { wheel->draw(wheel->oldhue, wheel->oldsaturation); wheel->oldhue = hsv.h; @@ -279,8 +321,8 @@ void ColorWindow::update_display() wheel->flash(); wheel_value->draw(hsv.h, hsv.s, hsv.v); wheel_value->flash(); - output->draw(); - output->flash(); + poutput->draw(); + poutput->flash(); hue->update((int)hsv.h); sat->update(hsv.s); @@ -305,24 +347,24 @@ void ColorWindow::update_display() yuv_v->update(yuv.v); hex_box->update(); - if( thread->do_alpha ) { - alpha->update(aph); + if( do_alpha ) { + palpha->update(aph); aph_a->update(aph); } } -int ColorWindow::handle_event() +int ColorGUI::handle_gui() { - unlock_window(); - thread->handle_new_color(rgb888(), alpha8()); - lock_window("ColorWindow::handle_event"); + window->unlock_window(); + handle_new_color(rgb888(), alpha8()); + window->lock_window("ColorGUI::handle_event"); return 1; } -void ColorWindow::get_screen_sample() +void ColorGUI::get_screen_sample() { int cx, cy; - get_abs_cursor(cx, cy); + window->get_abs_cursor(cx, cy); BC_Capture capture_bitmap(1, 1, 0); VFrame vframe(1,1,BC_RGB888); capture_bitmap.capture_frame(&vframe, cx,cy); @@ -331,16 +373,16 @@ void ColorWindow::get_screen_sample() update_rgb(); } -int ColorWindow::cursor_motion_event() +int ColorGUI::cursor_motion_gui() { - if( button_grabbed && get_button_down() ) { + if( button_grabbed && window->get_button_down() ) { get_screen_sample(); return 1; } return 0; } -int ColorWindow::button_press_event() +int ColorGUI::button_press_gui() { if( button_grabbed ) { get_screen_sample(); @@ -349,24 +391,24 @@ int ColorWindow::button_press_event() return 0; } -int ColorWindow::button_release_event() +int ColorGUI::button_release_gui() { if( button_grabbed ) { - ungrab_buttons(); - ungrab_cursor(); + window->ungrab_buttons(); + window->ungrab_cursor(); grab_btn->enable(); button_grabbed = 0; update_history(); - return handle_event(); + return handle_gui(); } return 1; } -void ColorWindow::update_rgb_hex(const char *hex) +void ColorGUI::update_rgb_hex(const char *hex) { unsigned color; if( sscanf(hex,"%x",&color) == 1 ) { - if( thread->do_alpha ) { + if( do_alpha ) { aph = ((color>>24) & 0xff) / 255.; aph_a->update(aph); } @@ -376,15 +418,27 @@ void ColorWindow::update_rgb_hex(const char *hex) rgb.r = r; rgb.g = g; rgb.b = b; update_rgb(); update_history(); - handle_event(); + handle_gui(); } } +void ColorGUI::update_gui(int color, int alpha) +{ + printf("ColorGUI::update_gui undefined.\n"); +} -PaletteWheel::PaletteWheel(ColorWindow *window, int x, int y) +int ColorGUI::handle_new_color(int color, int alpha) +{ + printf("ColorGUI::handle_new_color undefined.\n"); + return 1; +} + + + +PaletteWheel::PaletteWheel(ColorGUI *gui, int x, int y) : BC_SubWindow(x, y, xS(170), yS(170)) { - this->window = window; + this->gui = gui; oldhue = 0; oldsaturation = 0; button_down = 0; @@ -411,15 +465,15 @@ int PaletteWheel::cursor_motion_event() int x1, y1, distance; if( button_down && is_event_win() ) { float h = get_angle(get_w()/2, get_h()/2, get_cursor_x(), get_cursor_y()); - bclamp(h, 0, 359.999); window->hsv.h = h; + bclamp(h, 0, 359.999); gui->hsv.h = h; x1 = get_w() / 2 - get_cursor_x(); y1 = get_h() / 2 - get_cursor_y(); distance = (int)sqrt(x1 * x1 + y1 * y1); float s = (float)distance / (get_w() / 2); - bclamp(s, 0, 1); window->hsv.s = s; - window->hsv.v = 1; - window->update_hsv(); - window->handle_event(); + bclamp(s, 0, 1); gui->hsv.s = s; + gui->hsv.v = 1; + gui->update_hsv(); + gui->handle_gui(); return 1; } return 0; @@ -500,8 +554,8 @@ void PaletteWheel::create_objects() 0, 0, get_w(), get_h(), 0, 0, get_w(), get_h(), 0); - oldhue = window->hsv.h; - oldsaturation = window->hsv.s; + oldhue = gui->hsv.h; + oldsaturation = gui->hsv.s; draw(oldhue, oldsaturation); flash(); } @@ -566,10 +620,10 @@ int PaletteWheel::get_angle(float x1, float y1, float x2, float y2) return (int)result; } -PaletteWheelValue::PaletteWheelValue(ColorWindow *window, int x, int y) +PaletteWheelValue::PaletteWheelValue(ColorGUI *gui, int x, int y) : BC_SubWindow(x, y, xS(40), yS(170), BLACK) { - this->window = window; + this->gui = gui; button_down = 0; } PaletteWheelValue::~PaletteWheelValue() @@ -580,7 +634,7 @@ PaletteWheelValue::~PaletteWheelValue() void PaletteWheelValue::create_objects() { frame = new VFrame(get_w(), get_h(), BC_RGB888); - draw(window->hsv.h, window->hsv.s, window->hsv.v); + draw(gui->hsv.h, gui->hsv.s, gui->hsv.v); flash(); } @@ -603,9 +657,9 @@ int PaletteWheelValue::cursor_motion_event() if( button_down && is_event_win() ) { //printf("PaletteWheelValue::cursor_motion 1\n"); float v = 1.0 - (float)(get_cursor_y() - 2) / (get_h() - 4); - bclamp(v, 0, 1); window->hsv.v = v; - window->update_hsv(); - window->handle_event(); + bclamp(v, 0, 1); gui->hsv.v = v; + gui->update_hsv(); + gui->handle_gui(); return 1; } return 0; @@ -650,10 +704,10 @@ int PaletteWheelValue::draw(float hue, float saturation, float value) return 0; } -PaletteOutput::PaletteOutput(ColorWindow *window, int x, int y) +PaletteOutput::PaletteOutput(ColorGUI *gui, int x, int y) : BC_SubWindow(x, y, xS(180), yS(30), BLACK) { - this->window = window; + this->gui = gui; } PaletteOutput::~PaletteOutput() { @@ -673,16 +727,16 @@ int PaletteOutput::handle_event() int PaletteOutput::draw() { - set_color(window->rgb888()); + set_color(gui->rgb888()); draw_box(2, 2, get_w() - 4, get_h() - 4); draw_3d_border(0, 0, get_w(), get_h(), 1); return 0; } -PaletteHue::PaletteHue(ColorWindow *window, int x, int y) - : BC_ISlider(x, y, 0, xS(150), xS(200), 0, 359, (int)(window->hsv.h), 0) +PaletteHue::PaletteHue(ColorGUI *gui, int x, int y) + : BC_ISlider(x, y, 0, xS(150), xS(200), 0, 359, (int)(gui->hsv.h), 0) { - this->window = window; + this->gui = gui; } PaletteHue::~PaletteHue() { @@ -690,16 +744,16 @@ PaletteHue::~PaletteHue() int PaletteHue::handle_event() { - window->hsv.h = get_value(); - window->update_hsv(); - window->handle_event(); + gui->hsv.h = get_value(); + gui->update_hsv(); + gui->handle_gui(); return 1; } -PaletteSat::PaletteSat(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, window->hsv.s, 0) +PaletteSat::PaletteSat(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, gui->hsv.s, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteSat::~PaletteSat() @@ -708,17 +762,17 @@ PaletteSat::~PaletteSat() int PaletteSat::handle_event() { - window->hsv.s = get_value(); - window->update_hsv(); - window->handle_event(); + gui->hsv.s = get_value(); + gui->update_hsv(); + gui->handle_gui(); return 1; } -PaletteVal::PaletteVal(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, window->hsv.v, 0) +PaletteVal::PaletteVal(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, gui->hsv.v, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteVal::~PaletteVal() @@ -727,17 +781,17 @@ PaletteVal::~PaletteVal() int PaletteVal::handle_event() { - window->hsv.v = get_value(); - window->update_hsv(); - window->handle_event(); + gui->hsv.v = get_value(); + gui->update_hsv(); + gui->handle_gui(); return 1; } -PaletteRed::PaletteRed(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->rgb.r, 0) +PaletteRed::PaletteRed(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, gui->rgb.r, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteRed::~PaletteRed() @@ -746,16 +800,16 @@ PaletteRed::~PaletteRed() int PaletteRed::handle_event() { - window->rgb.r = get_value(); - window->update_rgb(); - window->handle_event(); + gui->rgb.r = get_value(); + gui->update_rgb(); + gui->handle_gui(); return 1; } -PaletteGrn::PaletteGrn(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->rgb.g, 0) +PaletteGrn::PaletteGrn(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, gui->rgb.g, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteGrn::~PaletteGrn() @@ -764,16 +818,16 @@ PaletteGrn::~PaletteGrn() int PaletteGrn::handle_event() { - window->rgb.g = get_value(); - window->update_rgb(); - window->handle_event(); + gui->rgb.g = get_value(); + gui->update_rgb(); + gui->handle_gui(); return 1; } -PaletteBlu::PaletteBlu(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->rgb.b, 0) +PaletteBlu::PaletteBlu(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, gui->rgb.b, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteBlu::~PaletteBlu() @@ -782,16 +836,16 @@ PaletteBlu::~PaletteBlu() int PaletteBlu::handle_event() { - window->rgb.b = get_value(); - window->update_rgb(); - window->handle_event(); + gui->rgb.b = get_value(); + gui->update_rgb(); + gui->handle_gui(); return 1; } -PaletteAlpha::PaletteAlpha(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->aph, 0) +PaletteAlpha::PaletteAlpha(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, gui->aph, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteAlpha::~PaletteAlpha() @@ -800,17 +854,17 @@ PaletteAlpha::~PaletteAlpha() int PaletteAlpha::handle_event() { - window->aph = get_value(); - window->aph_a->update(window->aph); - window->hex_box->update(); - window->handle_event(); + gui->aph = get_value(); + gui->aph_a->update(gui->aph); + gui->hex_box->update(); + gui->handle_gui(); return 1; } -PaletteLum::PaletteLum(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->yuv.y, 0) +PaletteLum::PaletteLum(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, gui->yuv.y, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteLum::~PaletteLum() @@ -819,16 +873,16 @@ PaletteLum::~PaletteLum() int PaletteLum::handle_event() { - window->yuv.y = get_value(); - window->update_yuv(); - window->handle_event(); + gui->yuv.y = get_value(); + gui->update_yuv(); + gui->handle_gui(); return 1; } -PaletteCr::PaletteCr(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->yuv.u, 0) +PaletteCr::PaletteCr(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, gui->yuv.u, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteCr::~PaletteCr() @@ -837,16 +891,16 @@ PaletteCr::~PaletteCr() int PaletteCr::handle_event() { - window->yuv.u = get_value(); - window->update_yuv(); - window->handle_event(); + gui->yuv.u = get_value(); + gui->update_yuv(); + gui->handle_gui(); return 1; } -PaletteCb::PaletteCb(ColorWindow *window, int x, int y) - : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, window->yuv.v, 0) +PaletteCb::PaletteCb(ColorGUI *gui, int x, int y) + : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1, gui->yuv.v, 0) { - this->window = window; + this->gui = gui; set_precision(0.01); } PaletteCb::~PaletteCb() @@ -855,13 +909,13 @@ PaletteCb::~PaletteCb() int PaletteCb::handle_event() { - window->yuv.v = get_value(); - window->update_yuv(); - window->handle_event(); + gui->yuv.v = get_value(); + gui->update_yuv(); + gui->handle_gui(); return 1; } -void ColorWindow::update_rgb(float r, float g, float b) +void ColorGUI::update_rgb(float r, float g, float b) { { float y, u, v; YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v); @@ -876,7 +930,7 @@ void ColorWindow::update_rgb(float r, float g, float b) bclamp(v, 0, 1); hsv.v = v; } } -void ColorWindow::update_yuv(float y, float u, float v) +void ColorGUI::update_yuv(float y, float u, float v) { u -= 0.5; v -= 0.5; { float r, g, b; @@ -891,7 +945,7 @@ void ColorWindow::update_yuv(float y, float u, float v) bclamp(v, 0, 1); hsv.v = v; } } -void ColorWindow::update_hsv(float h, float s, float v) +void ColorGUI::update_hsv(float h, float s, float v) { { float r, g, b; HSV::hsv_to_rgb(r,g,b, h,s,v); @@ -906,7 +960,7 @@ void ColorWindow::update_hsv(float h, float s, float v) bclamp(v, 0, 1); yuv.v = v; } } -void ColorWindow::load_history() +void ColorGUI::load_history() { char history_path[BCTEXTLEN]; MWindow::create_defaults_path(history_path,PALETTE_DATA); @@ -936,7 +990,7 @@ void ColorWindow::load_history() v1 = 0.5f * (v1+.5f); } } -void ColorWindow::save_history() +void ColorGUI::save_history() { char history_path[BCTEXTLEN]; MWindow::create_defaults_path(history_path,PALETTE_DATA); @@ -948,7 +1002,7 @@ void ColorWindow::save_history() fclose(fp); } } -void ColorWindow::update_history(int color) +void ColorGUI::update_history(int color) { int out = palette_history[0]; palette_history[0] = color; @@ -958,29 +1012,29 @@ void ColorWindow::update_history(int color) palette_history[i] = in; } } -void ColorWindow::update_history() +void ColorGUI::update_history() { update_history(rgb888()); history->update(0); } -int ColorWindow::rgb888() +int ColorGUI::rgb888() { int r = 255*rgb.r + 0.5, g = 255*rgb.g + 0.5, b = 255*rgb.b + 0.5; bclamp(r, 0, 255); bclamp(g, 0, 255); bclamp(b, 0, 255); return (r<<16) | (g<<8) | (b<<0); } -int ColorWindow::alpha8() +int ColorGUI::alpha8() { int a = 255*aph + 0.5; bclamp(a, 0, 255); return a; } -PaletteNum::PaletteNum(ColorWindow *window, int x, int y, +PaletteNum::PaletteNum(ColorGUI *gui, int x, int y, float &output, float min, float max) - : BC_TumbleTextBox(window, output, min, max, x, y, xS(64)) + : BC_TumbleTextBox(gui->window, output, min, max, x, y, xS(64)) { - this->window = window; + this->gui = gui; this->output = &output; set_increment(0.01); set_precision(2); @@ -994,39 +1048,39 @@ PaletteNum::~PaletteNum() int PaletteHSV::handle_event() { update_output(); - window->update_hsv(); - window->handle_event(); + gui->update_hsv(); + gui->handle_gui(); return 1; } int PaletteRGB::handle_event() { update_output(); - window->update_rgb(); - window->handle_event(); + gui->update_rgb(); + gui->handle_gui(); return 1; } int PaletteYUV::handle_event() { update_output(); - window->update_yuv(); - window->handle_event(); + gui->update_yuv(); + gui->handle_gui(); return 1; } int PaletteAPH::handle_event() { update_output(); - window->update_display(); - window->handle_event(); + gui->update_display(); + gui->handle_gui(); return 1; } -PaletteHexButton::PaletteHexButton(ColorWindow *window, int x, int y) +PaletteHexButton::PaletteHexButton(ColorGUI *gui, int x, int y) : BC_GenericButton(x, y, xS(50), "#") { - this->window = window; + this->gui = gui; set_tooltip(_("hex rgb color")); } PaletteHexButton::~PaletteHexButton() @@ -1034,15 +1088,15 @@ PaletteHexButton::~PaletteHexButton() } int PaletteHexButton::handle_event() { - const char *hex = window->hex_box->get_text(); - window->update_rgb_hex(hex); + const char *hex = gui->hex_box->get_text(); + gui->update_rgb_hex(hex); return 1; } -PaletteHex::PaletteHex(ColorWindow *window, int x, int y, const char *hex) +PaletteHex::PaletteHex(ColorGUI *gui, int x, int y, const char *hex) : BC_TextBox(x, y, xS(100), 1, hex) { - this->window = window; + this->gui = gui; } PaletteHex::~PaletteHex() { @@ -1050,9 +1104,9 @@ PaletteHex::~PaletteHex() void PaletteHex::update() { char hex[BCSTRLEN], *cp = hex; - if( window->thread->do_alpha ) - cp += sprintf(cp,"%02x", window->alpha8()); - sprintf(cp,"%06x",window->rgb888()); + if( gui->do_alpha ) + cp += sprintf(cp,"%02x", gui->alpha8()); + sprintf(cp,"%06x",gui->rgb888()); BC_TextBox::update(hex); } @@ -1060,7 +1114,7 @@ int PaletteHex::keypress_event() { if( get_keypress() != RETURN ) return BC_TextBox::keypress_event(); - window->update_rgb_hex(get_text()); + gui->update_rgb_hex(get_text()); return 1; } @@ -1068,10 +1122,10 @@ int PaletteHex::keypress_event() #include "grabpick_hi_png.h" #include "grabpick_dn_png.h" -PaletteGrabButton::PaletteGrabButton(ColorWindow *window, int x, int y) +PaletteGrabButton::PaletteGrabButton(ColorGUI *gui, int x, int y) : BC_Button(x, y, vframes) { - this->window = window; + this->gui = gui; vframes[0] = new VFramePng(grabpick_up_png); vframes[1] = new VFramePng(grabpick_hi_png); vframes[2] = new VFramePng(grabpick_dn_png); @@ -1084,18 +1138,18 @@ PaletteGrabButton::~PaletteGrabButton() } int PaletteGrabButton::handle_event() { - if( window->grab_buttons() ) { - grab_cursor(); - window->button_grabbed = 1; - button_press_event(); // redraw face HI + if( gui->window->grab_buttons() ) { + gui->window->grab_cursor(); + gui->button_grabbed = 1; + gui->button_press_gui(); // redraw face HI } return 1; } -PaletteHistory::PaletteHistory(ColorWindow *window, int x, int y) +PaletteHistory::PaletteHistory(ColorGUI *gui, int x, int y) : BC_SubWindow(x,y, xS(200), yS(24)) { - this->window = window; + this->gui = gui; button_down = 0; set_tooltip(_("color history")); } @@ -1106,7 +1160,7 @@ void PaletteHistory::update(int flush) { int x1 = 0, x2 = 0; for( int i=0; ipalette_history[i]; + int rgb = gui->palette_history[i]; x2 = (++i * get_w())/PALLETTE_HISTORY_SIZE; draw_3d_box(x1,0,x2-x1,get_h(),WHITE,BLACK,rgb,LTBLUE,DKBLUE); } @@ -1125,9 +1179,9 @@ int PaletteHistory::button_release_event() if( !button_down || !is_event_win() ) return 0; cursor_motion_event(); if( button_down > 0 ) { - window->handle_event(); - window->update_display(); - window->update_history(); + gui->handle_gui(); + gui->update_display(); + gui->update_history(); } button_down = 0; return 1; @@ -1138,13 +1192,13 @@ int PaletteHistory::cursor_motion_event() hide_tooltip(); int pick = (PALLETTE_HISTORY_SIZE * get_cursor_x()) / get_w(); bclamp(pick, 0, PALLETTE_HISTORY_SIZE-1); - int color = window->palette_history[pick]; + int color = gui->palette_history[pick]; float r = ((color>>16) & 0xff) / 255.; float g = ((color>>8) & 0xff) / 255.; float b = ((color>>0) & 0xff) / 255.; - if( window->rgb.r != r || window->rgb.g != g || window->rgb.b != b ) { - window->rgb.r = r; window->rgb.g = g; window->rgb.b = b; - window->update_rgb(); + if( gui->rgb.r != r || gui->rgb.g != g || gui->rgb.b != b ) { + gui->rgb.r = r; gui->rgb.g = g; gui->rgb.b = b; + gui->update_rgb(); } return 1; } diff --git a/cinelerra-5.1/cinelerra/colorpicker.h b/cinelerra-5.1/cinelerra/colorpicker.h index 1fffa252..85fa706b 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.h +++ b/cinelerra-5.1/cinelerra/colorpicker.h @@ -35,6 +35,8 @@ #include "vframe.inc" #define PALLETTE_HISTORY_SIZE 16 +#define COLOR_PICKER_W xS(540) +#define COLOR_PICKER_H yS(330) class ColorPicker : public BC_DialogThread @@ -42,37 +44,44 @@ class ColorPicker : public BC_DialogThread public: ColorPicker(int do_alpha = 0, const char *title = 0); ~ColorPicker(); - - void start_window(int output, int alpha, int ok_cancel=0); - virtual int handle_new_color(int output, int alpha); - void update_gui(int output, int alpha); + void start_window(int color, int alpha, int ok_cancel=0); + virtual void update_gui(int color, int alpha); + virtual int handle_new_color(int color, int alpha); BC_Window* new_gui(); - virtual void create_objects(ColorWindow *gui) {} - int orig_color, orig_alpha; - int output, alpha; - int do_alpha, ok_cancel; + int color, alpha; + int ok_cancel, do_alpha; const char *title; }; -class ColorWindow : public BC_Window +class ColorGUI { public: - ColorWindow(ColorPicker *thread, int x, int y, int w, int h, const char *title); - ~ColorWindow(); + ColorGUI(BC_WindowBase *window); + ~ColorGUI(); + void add_tool(BC_WindowBase *sub_wdw); + void start_selection(int color, int alpha, int ok_cancel); void create_objects(); void change_values(); - int close_event(); + int close_gui(); void update_display(); void update_rgb(); void update_hsv(); void update_yuv(); - int handle_event(); + int handle_gui(); void get_screen_sample(); - int cursor_motion_event(); - int button_press_event(); - int button_release_event(); + int cursor_motion_gui(); + int button_press_gui(); + int button_release_gui(); + + virtual void update_gui(int color, int alpha); + virtual int handle_new_color(int color, int alpha); + virtual void create_objects(ColorGUI *gui) {} + + static int calculate_w() { return COLOR_PICKER_W; } + static int calculate_h() { return COLOR_PICKER_H; } + struct { float r, g, b; } rgb; struct { float y, u, v; } yuv; @@ -85,10 +94,10 @@ public: int rgb888(); int alpha8(); - ColorPicker *thread; + BC_WindowBase *window; PaletteWheel *wheel; PaletteWheelValue *wheel_value; - PaletteOutput *output; + PaletteOutput *poutput; PaletteHue *hue; PaletteSat *sat; PaletteVal *val; @@ -98,7 +107,7 @@ public: PaletteLum *lum; PaletteCr *c_r; PaletteCb *c_b; - PaletteAlpha *alpha; + PaletteAlpha *palpha; PaletteHSV *hsv_h, *hsv_s, *hsv_v; PaletteRGB *rgb_r, *rgb_g, *rgb_b; @@ -113,6 +122,11 @@ public: VFrame *value_bitmap; int button_grabbed; + int orig_color, orig_alpha; + int color, alpha; + int do_alpha, ok_cancel; + const char *title; + int palette_history[PALLETTE_HISTORY_SIZE]; void load_history(); void save_history(); @@ -120,11 +134,28 @@ public: void update_history(); }; +class ColorWindow : public BC_Window, public ColorGUI +{ +public: + ColorWindow(ColorPicker *thread, int x, int y, int w, int h, const char *title); + ~ColorWindow(); + + void update_gui(int color, int alpha); + int handle_new_color(int color, int alpha); + + int close_event() { return close_gui(); } + int cursor_motion_event() { return cursor_motion_gui(); } + int button_press_event() { return button_press_gui(); } + int button_release_event() { return button_release_gui(); } + + ColorPicker *thread; +}; + class PaletteWheel : public BC_SubWindow { public: - PaletteWheel(ColorWindow *window, int x, int y); + PaletteWheel(ColorGUI *gui, int x, int y); ~PaletteWheel(); int button_press_event(); int cursor_motion_event(); @@ -134,7 +165,7 @@ public: int draw(float hue, float saturation); int get_angle(float x1, float y1, float x2, float y2); float torads(float angle); - ColorWindow *window; + ColorGUI *gui; float oldhue; float oldsaturation; int button_down; @@ -143,14 +174,14 @@ public: class PaletteWheelValue : public BC_SubWindow { public: - PaletteWheelValue(ColorWindow *window, int x, int y); + PaletteWheelValue(ColorGUI *gui, int x, int y); ~PaletteWheelValue(); void create_objects(); int button_press_event(); int cursor_motion_event(); int button_release_event(); int draw(float hue, float saturation, float value); - ColorWindow *window; + ColorGUI *gui; int button_down; // Gradient VFrame *frame; @@ -159,111 +190,111 @@ public: class PaletteOutput : public BC_SubWindow { public: - PaletteOutput(ColorWindow *window, int x, int y); + PaletteOutput(ColorGUI *gui, int x, int y); ~PaletteOutput(); void create_objects(); int handle_event(); int draw(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteHue : public BC_ISlider { public: - PaletteHue(ColorWindow *window, int x, int y); + PaletteHue(ColorGUI *gui, int x, int y); ~PaletteHue(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteSat : public BC_FSlider { public: - PaletteSat(ColorWindow *window, int x, int y); + PaletteSat(ColorGUI *gui, int x, int y); ~PaletteSat(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteVal : public BC_FSlider { public: - PaletteVal(ColorWindow *window, int x, int y); + PaletteVal(ColorGUI *gui, int x, int y); ~PaletteVal(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteRed : public BC_FSlider { public: - PaletteRed(ColorWindow *window, int x, int y); + PaletteRed(ColorGUI *gui, int x, int y); ~PaletteRed(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteGrn : public BC_FSlider { public: - PaletteGrn(ColorWindow *window, int x, int y); + PaletteGrn(ColorGUI *gui, int x, int y); ~PaletteGrn(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteBlu : public BC_FSlider { public: - PaletteBlu(ColorWindow *window, int x, int y); + PaletteBlu(ColorGUI *gui, int x, int y); ~PaletteBlu(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteAlpha : public BC_FSlider { public: - PaletteAlpha(ColorWindow *window, int x, int y); + PaletteAlpha(ColorGUI *gui, int x, int y); ~PaletteAlpha(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteLum : public BC_FSlider { public: - PaletteLum(ColorWindow *window, int x, int y); + PaletteLum(ColorGUI *gui, int x, int y); ~PaletteLum(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteCr : public BC_FSlider { public: - PaletteCr(ColorWindow *window, int x, int y); + PaletteCr(ColorGUI *gui, int x, int y); ~PaletteCr(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteCb : public BC_FSlider { public: - PaletteCb(ColorWindow *window, int x, int y); + PaletteCb(ColorGUI *gui, int x, int y); ~PaletteCb(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteNum : public BC_TumbleTextBox { public: - ColorWindow *window; + ColorGUI *gui; float *output; - PaletteNum(ColorWindow *window, int x, int y, + PaletteNum(ColorGUI *gui, int x, int y, float &output, float min, float max); ~PaletteNum(); void update_output() { *output = atof(get_text()); } @@ -273,73 +304,73 @@ public: class PaletteRGB : public PaletteNum { public: - PaletteRGB(ColorWindow *window, int x, int y, + PaletteRGB(ColorGUI *gui, int x, int y, float &output, float min, float max) - : PaletteNum(window, x, y, output, min, max) {} + : PaletteNum(gui, x, y, output, min, max) {} int handle_event(); }; class PaletteYUV : public PaletteNum { public: - PaletteYUV(ColorWindow *window, int x, int y, + PaletteYUV(ColorGUI *gui, int x, int y, float &output, float min, float max) - : PaletteNum(window, x, y, output, min, max) {} + : PaletteNum(gui, x, y, output, min, max) {} int handle_event(); }; class PaletteHSV : public PaletteNum { public: - PaletteHSV(ColorWindow *window, int x, int y, + PaletteHSV(ColorGUI *gui, int x, int y, float &output, float min, float max) - : PaletteNum(window, x, y, output, min, max) {} + : PaletteNum(gui, x, y, output, min, max) {} int handle_event(); }; class PaletteAPH : public PaletteNum { public: - PaletteAPH(ColorWindow *window, int x, int y, + PaletteAPH(ColorGUI *gui, int x, int y, float &output, float min, float max) - : PaletteNum(window, x, y, output, min, max) {} + : PaletteNum(gui, x, y, output, min, max) {} int handle_event(); }; class PaletteHexButton : public BC_GenericButton { public: - PaletteHexButton(ColorWindow *window, int x, int y); + PaletteHexButton(ColorGUI *gui, int x, int y); ~PaletteHexButton(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteHex : public BC_TextBox { public: - PaletteHex(ColorWindow *window, int x, int y, const char *hex); + PaletteHex(ColorGUI *gui, int x, int y, const char *hex); ~PaletteHex(); int keypress_event(); void update(); - ColorWindow *window; + ColorGUI *gui; }; class PaletteGrabButton : public BC_Button { public: - PaletteGrabButton(ColorWindow *window, int x, int y); + PaletteGrabButton(ColorGUI *gui, int x, int y); ~PaletteGrabButton(); int handle_event(); - ColorWindow *window; + ColorGUI *gui; VFrame *vframes[3]; }; class PaletteHistory : public BC_SubWindow { public: - PaletteHistory(ColorWindow *window, int x, int y); + PaletteHistory(ColorGUI *gui, int x, int y); ~PaletteHistory(); void update(int flush=1); int button_press_event(); @@ -348,7 +379,7 @@ public: int cursor_leave_event(); int repeat_event(int64_t duration); - ColorWindow *window; + ColorGUI *gui; int button_down; }; diff --git a/cinelerra-5.1/cinelerra/colorpicker.inc b/cinelerra-5.1/cinelerra/colorpicker.inc index 15b8fc2e..ea985712 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.inc +++ b/cinelerra-5.1/cinelerra/colorpicker.inc @@ -24,6 +24,7 @@ class ColorPicker; class ColorWindow; +class ColorGUI; class PaletteWheel; class PaletteWheelValue; class PaletteOutput; diff --git a/cinelerra-5.1/cinelerra/playabletracks.C b/cinelerra-5.1/cinelerra/playabletracks.C index 6285f350..cf98666b 100644 --- a/cinelerra-5.1/cinelerra/playabletracks.C +++ b/cinelerra-5.1/cinelerra/playabletracks.C @@ -34,35 +34,16 @@ #include "transportque.h" -PlayableTracks::PlayableTracks(EDL *edl, - int64_t current_position, - int direction, - int data_type, - int use_nudge) +PlayableTracks::PlayableTracks(EDL *edl, int64_t current_position, + int direction, int data_type, int use_nudge) : ArrayList() { this->data_type = data_type; - for(Track *current_track = edl->tracks->first; - current_track; - current_track = current_track->next) - { - if(is_playable(current_track, current_position, direction, use_nudge)) - { -// printf("PlayableTracks::PlayableTracks %d this=%p current_track=%p total=%d current_position=%jd\n", -// __LINE__, -// this, -// current_track, -// total, -// current_position); - append(current_track); - } + for( Track *track=edl->tracks->first; track; track=track->next ) { + if( is_playable(track, current_position, direction, use_nudge) ) + append(track); } -// printf("PlayableTracks::PlayableTracks %d data_type=%d total=%d current_position=%jd\n", -// __LINE__, -// data_type, -// total, -// current_position); } PlayableTracks::~PlayableTracks() @@ -70,10 +51,8 @@ PlayableTracks::~PlayableTracks() } -int PlayableTracks::is_playable(Track *current_track, - int64_t position, - int direction, - int use_nudge) +int PlayableTracks::is_playable(Track *current_track, int64_t position, + int direction, int use_nudge) { int result = 1; if(use_nudge) position += current_track->nudge; diff --git a/cinelerra-5.1/cinelerra/plugin.C b/cinelerra-5.1/cinelerra/plugin.C index d28087b8..09d003b3 100644 --- a/cinelerra-5.1/cinelerra/plugin.C +++ b/cinelerra-5.1/cinelerra/plugin.C @@ -217,56 +217,50 @@ void Plugin::equivalent_output(Edit *edit, int64_t *result) keyframes->equivalent_output(plugin->keyframes, startproject, result); } - - -int Plugin::is_synthesis(int64_t position, - int direction) +const char* Plugin::type_to_text(int type) { - switch(plugin_type) - { - case PLUGIN_STANDALONE: - { - if(!track) - { - printf("Plugin::is_synthesis track not defined\n"); - return 0; - } - + switch( type ) { + case PLUGIN_STANDALONE: return _("standalone"); + case PLUGIN_SHAREDPLUGIN: return _("shared plugin"); + case PLUGIN_SHAREDMODULE: return _("shared module"); + } + return _("none"); +} - PluginServer *plugin_server = MWindow::scan_plugindb(title, - track->data_type); -//printf("Plugin::is_synthesis %d %p %d\n", __LINE__, plugin_server, plugin_server->get_synthesis()); -//plugin_server->dump(); - return plugin_server->get_synthesis(); - break; +int Plugin::is_synthesis(int64_t position, int direction, int depth) +{ + if( depth > 255 ) { + printf("Plugin::is_synthesis %d: depth range limit, type=%s, title=%s\n", + __LINE__, type_to_text(plugin_type), title); + return 0; + } + switch( plugin_type ) { + case PLUGIN_STANDALONE: { + if( !track ) { + printf("Plugin::is_synthesis track not defined\n"); + return 0; } + PluginServer *plugin_server = MWindow::scan_plugindb(title, track->data_type); + return plugin_server->get_synthesis(); } // Dereference real plugin and descend another level - case PLUGIN_SHAREDPLUGIN: - { - int real_module_number = shared_location.module; - int real_plugin_number = shared_location.plugin; - Track *track = edl->tracks->number(real_module_number); + case PLUGIN_SHAREDPLUGIN: { + int real_module_number = shared_location.module; + int real_plugin_number = shared_location.plugin; + Track *track = edl->tracks->number(real_module_number); // Get shared plugin from master track - Plugin *plugin = track->get_current_plugin(position, - real_plugin_number, - direction, - 0, - 0); - - if(plugin) - return plugin->is_synthesis(position, direction); - break; - } + Plugin *plugin = track->get_current_plugin(position, + real_plugin_number, direction, 0, 0); + + if(plugin) + return plugin->is_synthesis(position, direction, depth+1); + break; } // Dereference the real track and descend - case PLUGIN_SHAREDMODULE: - { - int real_module_number = shared_location.module; - Track *track = edl->tracks->number(real_module_number); - return track->is_synthesis(position, direction); - break; - } + case PLUGIN_SHAREDMODULE: { + int real_module_number = shared_location.module; + Track *track = edl->tracks->number(real_module_number); + return track->is_synthesis(position, direction, depth+1); } } return 0; } diff --git a/cinelerra-5.1/cinelerra/plugin.h b/cinelerra-5.1/cinelerra/plugin.h index 2a5e696c..92eff4f0 100644 --- a/cinelerra-5.1/cinelerra/plugin.h +++ b/cinelerra-5.1/cinelerra/plugin.h @@ -66,10 +66,10 @@ public: // title. void equivalent_output(Edit *edit, int64_t *result); + const char* type_to_text(int type); // Called by playable tracks to test for playable server. // Descends the plugin tree without creating a virtual console. - int is_synthesis(int64_t position, - int direction); + int is_synthesis(int64_t position, int direction, int depth); virtual int operator==(Plugin& that); virtual int operator==(Edit& that); diff --git a/cinelerra-5.1/cinelerra/track.C b/cinelerra-5.1/cinelerra/track.C index 9fdc531a..91bf401a 100644 --- a/cinelerra-5.1/cinelerra/track.C +++ b/cinelerra-5.1/cinelerra/track.C @@ -166,31 +166,17 @@ void Track::equivalent_output(Track *track, double *result) } -int Track::is_synthesis(int64_t position, - int direction) +int Track::is_synthesis(int64_t position, int direction, int depth) { - int is_synthesis = 0; - for(int i = 0; i < plugin_set.total; i++) - { - Plugin *plugin = get_current_plugin(position, - i, - direction, - 0, - 0); - if(plugin) - { + int result = 0; + for( int i = 0; !result && iplugin_type == PLUGIN_SHAREDMODULE) - is_synthesis = 1; - else - is_synthesis = plugin->is_synthesis(position, - direction); - -//printf("Track::is_synthesis %d %d\n", __LINE__, is_synthesis); - if(is_synthesis) break; - } + result = plugin->plugin_type == PLUGIN_SHAREDMODULE ? 1 : + plugin->is_synthesis(position, direction, depth); } - return is_synthesis; + return result; } void Track::copy_from(Track *track) @@ -953,56 +939,37 @@ int Track::copy_automation(double selectionstart, return 0; } -int Track::paste_automation(double selectionstart, - double total_length, - double frame_rate, - int64_t sample_rate, - FileXML *file, - int default_only, - int active_only) +int Track::paste_automation(double selectionstart, double total_length, + double frame_rate, int64_t sample_rate, + FileXML *file, int default_only, int active_only) { // Only used for pasting automation alone. - int64_t start; - int64_t length; - int result; - double scale; - int current_pluginset; - - if(data_type == TRACK_AUDIO) - scale = edl->session->sample_rate / sample_rate; - else - scale = edl->session->frame_rate / frame_rate; + double scale = data_type == TRACK_AUDIO ? + edl->session->sample_rate / sample_rate : + edl->session->frame_rate / frame_rate ; total_length *= scale; - start = to_units(selectionstart, 0); - length = to_units(total_length, 1); - result = 0; - current_pluginset = 0; + int64_t start = to_units(selectionstart, 0); + int64_t length = to_units(total_length, 1); + int result = 0; + int current_pluginset = 0; //printf("Track::paste_automation 1\n"); - while(!result) - { - result = file->read_tag(); - - if(!result) - { - if(file->tag.title_is("/TRACK")) - result = 1; - else - if(automation->paste(start, length, scale, file, - default_only, active_only, 0)) {} - else if(file->tag.title_is("PLUGINSET")) { - if(current_pluginset < plugin_set.total) { - plugin_set.values[current_pluginset]-> - paste_keyframes(start, length, file, + while( !(result = file->read_tag()) ) { + if( file->tag.title_is("/TRACK") ) break; + if( automation->paste(start, length, scale, file, + default_only, active_only, 0) ) + continue; + if( file->tag.title_is("PLUGINSET") ) { + if( current_pluginset < plugin_set.total ) { + plugin_set.values[current_pluginset]-> + paste_keyframes(start, length, file, default_only, active_only); - current_pluginset++; - } + ++current_pluginset; } } } - return 0; } @@ -1688,64 +1655,63 @@ void Track::reverse_edits(double start, double end, int first_track) } } -void Track::align_edits(double start, - double end, - ArrayList *times) +void Track::align_edits(double start, double end, Track *master_track) { int64_t start_units = to_units(start, 0); int64_t end_units = to_units(end, 0); -// If 1st track with data, times is empty & we need to collect the edit times. - if(!times->size()) - { - for(Edit *current = edits->first; current; current = NEXT) - { - if(current->startproject >= start_units && - current->startproject + current->length <= end_units) - { - times->append(from_units(current->startproject)); - } - } - } - else // All other tracks get silence or cut to align the edits on the times. - { - int current_time = 0; - for(Edit *current = edits->first; - current && current_time < times->size(); ) - { - if(current->startproject >= start_units && - current->startproject + current->length <= end_units) - { - int64_t desired_startunits = to_units(times->get(current_time), 0); - int64_t current_startunits = current->startproject; + Edit *master = master_track->edits->first; + for(Edit *current = edits->first; current && master; ) { + if( current->startproject >= start_units && + current->startproject + current->length <= end_units ) { +// edit is in highlighted region + int64_t master_length_units = to_units(master_track->from_units(master->length), 0); +// starting time of master edit + int64_t master_start_units = to_units(master_track->from_units(master->startproject), 0); +// starting time of current edit + int64_t current_startunits = current->startproject; + +// the following occur if multiple aligns are performed +// master edit is not silence but current edit is silence + if( !master->silence() && current->silence() ) { +// try again with next edit current = NEXT; + continue; + } + if( master->silence() && !current->silence() ) { +// master edit is silence but current edit is not silence + master = master->next; + continue; + } + if( current->length < master_length_units / 2 ) { +// current edit is a glitch edit between 2 required edits + current = NEXT; + continue; + } - - if(current_startunits < desired_startunits) - { + current = NEXT; +// current edit starts before master edit + if( current_startunits < master_start_units ) { //printf("Track::align_edits %d\n", __LINE__); - edits->paste_silence(current_startunits, - desired_startunits); - shift_keyframes(current_startunits, - desired_startunits - current_startunits); - } - else - if(current_startunits > desired_startunits) - { - edits->clear(desired_startunits, - current_startunits); - if(edl->session->autos_follow_edits) - shift_keyframes(desired_startunits, - current_startunits - desired_startunits); - } - - current_time++; + edits->paste_silence(current_startunits, master_start_units); + shift_keyframes(current_startunits, + master_start_units - current_startunits); } - else - { - current = NEXT; + else if( current_startunits > master_start_units ) { +// current edit starts after master edit + edits->clear(master_start_units, + current_startunits); + if(edl->session->autos_follow_edits) + shift_keyframes(master_start_units, + current_startunits - master_start_units); } + + master = master->next; + } + else { + current = NEXT; + master = master->next; } } diff --git a/cinelerra-5.1/cinelerra/track.h b/cinelerra-5.1/cinelerra/track.h index ada29f21..c2c43302 100644 --- a/cinelerra-5.1/cinelerra/track.h +++ b/cinelerra-5.1/cinelerra/track.h @@ -112,7 +112,7 @@ public: double edl_length); void shuffle_edits(double start, double end, int first_track); void reverse_edits(double start, double end, int first_track); - void align_edits(double start, double end, ArrayList *times); + void align_edits(double start, double end, Track *master_track); // Optimize editing void optimize(); int is_muted(int64_t position, int direction); // Test muting status @@ -146,7 +146,7 @@ public: // Called by playable tracks to test for playable server. // Descends the plugin tree without creating a virtual console. // Used by PlayableTracks::is_playable. - int is_synthesis(int64_t position, int direction); + int is_synthesis(int64_t position, int direction, int depth=0); // Used by PlayableTracks::is_playable // Returns 1 if the track is in the output boundaries. diff --git a/cinelerra-5.1/cinelerra/tracksedit.C b/cinelerra-5.1/cinelerra/tracksedit.C index 34a6c00a..7f46fcb2 100644 --- a/cinelerra-5.1/cinelerra/tracksedit.C +++ b/cinelerra-5.1/cinelerra/tracksedit.C @@ -182,19 +182,17 @@ void Tracks::reverse_edits(double start, double end) } } } + void Tracks::align_edits(double start, double end) { // This doesn't affect automation or effects - ArrayList times; - - for(Track *current_track = first; - current_track; - current_track = current_track->next) - { - if(current_track->record) - { - current_track->align_edits(start, end, ×); - } + Track *master_track = 0; + for( Track *track=first; track; track=track->next ) { + if( !track->record ) continue; + if( !master_track ) + master_track = track; + else + track->align_edits(start, end, master_track); } } diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index 9c29ec99..1fb4ca21 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -824,14 +824,14 @@ void VWindowCanvas::close_source() void VWindowCanvas::draw_refresh(int flush) { - EDL *edl = gui->vwindow->get_edl(); - if( !get_canvas()->get_video_on() ) { int cw = get_canvas()->get_w(), ch = get_canvas()->get_h(); get_canvas()->clear_box(0, 0, cw, ch); - int ow = edl ? get_output_w(edl) : 0; - int oh = edl ? get_output_h(edl) : 0; - if( ow > 0 && oh > 0 && refresh_frame ) { + } + EDL *edl = gui->vwindow->get_edl(); + if( refresh_frame && edl ) { + int ow = get_output_w(edl), oh = get_output_h(edl); + if( ow > 0 && oh > 0 ) { float in_x1, in_y1, in_x2, in_y2; float out_x1, out_y1, out_x2, out_y2; get_transfers(edl, @@ -851,6 +851,8 @@ void VWindowCanvas::draw_refresh(int flush) (int)(in_x2 - in_x1), (int)(in_y2 - in_y1), 0); } + } + if( !get_canvas()->get_video_on() ) { draw_overlays(); get_canvas()->flash(flush); } diff --git a/cinelerra-5.1/guicast/bcfilebox.C b/cinelerra-5.1/guicast/bcfilebox.C index 54e6bbf5..9b3b6c89 100644 --- a/cinelerra-5.1/guicast/bcfilebox.C +++ b/cinelerra-5.1/guicast/bcfilebox.C @@ -90,14 +90,8 @@ int BC_FileBoxListBox::selection_changed() filebox->column_of_type(FILEBOX_NAME), 0); if(item) { - char path[BCTEXTLEN]; - strcpy(path, item->get_text()); - filebox->textbox->update(path); - filebox->fs->extract_dir(filebox->directory, path); - filebox->fs->extract_name(filebox->filename, path); - filebox->fs->complete_path(path); - strcpy(filebox->current_path, path); - strcpy(filebox->submitted_path, path); + filebox->textbox->update(item->get_text()); + filebox->update_paths(item->get_text()); } return 1; } @@ -172,11 +166,11 @@ BC_FileBoxTextBox::~BC_FileBoxTextBox() int BC_FileBoxTextBox::handle_event() { - int result = 0; - if(get_keypress() != RETURN) - { + int key = get_keypress(), result = 1; + if( !key || key == RETURN ) // not a text update + filebox->update_paths(filebox->textbox->get_text()); + else result = calculate_suggestions(&filebox->list_column[0]); - } return result; } @@ -1017,6 +1011,17 @@ int BC_FileBox::update_filter(const char *filter) } +void BC_FileBox::update_paths(const char *text) +{ + char path[BCTEXTLEN]; + strncpy(path, text, sizeof(path)-1); + fs->extract_dir(directory, path); + fs->extract_name(filename, path); + fs->complete_path(path); + strcpy(current_path, path); + strcpy(submitted_path, path); +} + void BC_FileBox::move_column(int src, int dst) { if(src != dst) diff --git a/cinelerra-5.1/guicast/bcfilebox.h b/cinelerra-5.1/guicast/bcfilebox.h index 28d2deb2..a0f0b2ee 100644 --- a/cinelerra-5.1/guicast/bcfilebox.h +++ b/cinelerra-5.1/guicast/bcfilebox.h @@ -268,6 +268,7 @@ public: void create_history(); void update_history(); + void update_paths(const char *text); int refresh(int reset=0, int select_all=0); // The OK and Use This button submits a path. diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index e9047f29..f94ee165 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -4294,6 +4294,26 @@ void BC_WindowBase::set_title(const char *text, int utf8) flush(); } +// must be RGBA8888 +void BC_WindowBase::set_net_icon(VFrame *data) +{ + int width = data->get_w(), height = data->get_h(); + int size = 2 + width * height; + unsigned long *icon_data = new unsigned long[size]; + unsigned long *lp = icon_data; + *lp++ = width; *lp++ = height; + uint8_t **rows = data->get_rows(); + for( int y=0; ydisplay, top_level->win, NetWMIcon, + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)icon_data, size); + delete [] icon_data; +} + const char *BC_WindowBase::get_title() { return title; @@ -4315,27 +4335,28 @@ int BC_WindowBase::set_icon(VFrame *data) icon_pixmap = new BC_Pixmap(top_level, data, PIXMAP_ALPHA, 1); if(icon_window) delete icon_window; - icon_window = new BC_Popup(this, - (int)BC_INFINITY, - (int)BC_INFINITY, - icon_pixmap->get_w(), - icon_pixmap->get_h(), - -1, - 1, // All windows are hidden initially + icon_window = new BC_Popup(this, 0, 0, + icon_pixmap->get_w(), icon_pixmap->get_h(), + -1, 1, // All windows are hidden initially icon_pixmap); - XWMHints wm_hints; - wm_hints.flags = WindowGroupHint | IconPixmapHint | IconMaskHint | IconWindowHint; + XWMHints wm_hints; memset(&wm_hints, 0, sizeof(wm_hints)); + wm_hints.flags = IconPixmapHint; // | IconMaskHint | IconWindowHint; wm_hints.icon_pixmap = icon_pixmap->get_pixmap(); wm_hints.icon_mask = icon_pixmap->get_alpha(); wm_hints.icon_window = icon_window->win; - wm_hints.window_group = XGroupLeader; + if( XGroupLeader ) { + wm_hints.flags |= WindowGroupHint; + wm_hints.window_group = XGroupLeader; + } // for(int i = 0; i < 1000; i++) // printf("02x ", icon_pixmap->get_alpha()->get_row_pointers()[0][i]); // printf("\n"); XSetWMHints(top_level->display, top_level->win, &wm_hints); + + set_net_icon(data); XSync(top_level->display, 0); return 0; } diff --git a/cinelerra-5.1/guicast/bcwindowbase.h b/cinelerra-5.1/guicast/bcwindowbase.h index 6acffd1d..a38437bd 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.h +++ b/cinelerra-5.1/guicast/bcwindowbase.h @@ -527,6 +527,7 @@ public: int show_tooltip(int w=-1, int h=-1) { return show_tooltip(0, -1, -1, w, h); } int hide_tooltip(); int set_icon(VFrame *data); + void set_net_icon(VFrame *data); int load_defaults(BC_Hash *defaults); int save_defaults(BC_Hash *defaults); diff --git a/cinelerra-5.1/info/plugins.txt b/cinelerra-5.1/info/plugins.txt index c56601c8..5012a25f 100644 --- a/cinelerra-5.1/info/plugins.txt +++ b/cinelerra-5.1/info/plugins.txt @@ -13,6 +13,8 @@ combines them to 1920x540 interlaced image. AgingTV: Use to achieve an "old" movie or TV show effect by adding moving lines and snow. +Alpha: Vary the alpha value from 0-completely transparent + to 1-no transparency at all. Auto Scale: Automatically scale to a specified size. Blue Banana: Used for color transformation or remapping as well as chroma-key filtering. See Manual for usage: @@ -86,6 +88,7 @@ Flip: Flip a portion of a video track from left to right, up to down or vice versa. FlowObj: Retards image motion as shown with optical flow. Uses the OpenCV thirdparty package. +Foreground: Provide a colored foreground of your choice. Frames to fields: Extracts 2 interlaced fields stored in alternating lines & outputs them as full frames. Freeze Frame: Lowest numbered frame in highlighted area will play diff --git a/cinelerra-5.1/plugin_defs b/cinelerra-5.1/plugin_defs index 86fa7fce..d7313206 100644 --- a/cinelerra-5.1/plugin_defs +++ b/cinelerra-5.1/plugin_defs @@ -23,6 +23,7 @@ video := \ 1080to540 \ 720to480 \ aging \ + alpha \ bandslide \ bandwipe \ bluebanana \ @@ -52,6 +53,7 @@ video := \ fieldframe \ flash \ flip \ + foreground \ framefield \ freezeframe \ gamma \ diff --git a/cinelerra-5.1/plugins/Makefile b/cinelerra-5.1/plugins/Makefile index 1f464d23..22bc7dd6 100644 --- a/cinelerra-5.1/plugins/Makefile +++ b/cinelerra-5.1/plugins/Makefile @@ -26,6 +26,7 @@ DIRS = $(OPENCV_OBJS) \ 1080to540 \ 720to480 \ aging \ + alpha \ scaleratio \ audioscope \ bandslide \ @@ -69,6 +70,7 @@ DIRS = $(OPENCV_OBJS) \ flanger \ flash \ flip \ + foreground \ framefield \ freeverb \ freezeframe \ diff --git a/cinelerra-5.1/plugins/alpha/Makefile b/cinelerra-5.1/plugins/alpha/Makefile new file mode 100644 index 00000000..096e281c --- /dev/null +++ b/cinelerra-5.1/plugins/alpha/Makefile @@ -0,0 +1,9 @@ +include ../../plugin_defs + +OBJS = $(OBJDIR)/alpha.o + +PLUGIN = alpha + +include ../../plugin_config + +$(OBJDIR)/alpha.o: alpha.C diff --git a/cinelerra-5.1/plugins/alpha/alpha.C b/cinelerra-5.1/plugins/alpha/alpha.C new file mode 100644 index 00000000..87f141e9 --- /dev/null +++ b/cinelerra-5.1/plugins/alpha/alpha.C @@ -0,0 +1,229 @@ + +/* + * CINELERRA + * Copyright (C) 2008-2019 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include + +#include "alpha.h" +#include "filexml.h" +#include "keyframe.h" +#include "language.h" +#include "vframe.h" + +REGISTER_PLUGIN(AlphaMain) + + +AlphaConfig::AlphaConfig() +{ + a = 1.; +} + +int AlphaConfig::equivalent(AlphaConfig &that) +{ + return a == that.a; +} + +void AlphaConfig::copy_from(AlphaConfig &that) +{ + a = that.a; +} + +void AlphaConfig::interpolate(AlphaConfig &prev, AlphaConfig &next, + long prev_frame, long next_frame, long current_frame) +{ + double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame); + double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame); + + a = (prev.a * prev_scale + next.a * next_scale); +} + + +AlphaSlider::AlphaSlider(AlphaWindow *window, AlphaMain *plugin, + int x, int y, int w) + : BC_FSlider(x, y, 0, w, w, 0.f, 1.f, plugin->config.a) +{ + this->window = window; + this->plugin = plugin; + set_precision(0.001); +} +AlphaSlider::~AlphaSlider() +{ +} + +int AlphaSlider::handle_event() +{ + plugin->config.a = get_value(); + plugin->send_configure_change(); + return 1; +} + +#define ALPHA_W xS(400) +#define ALPHA_H yS(60) + +AlphaWindow::AlphaWindow(AlphaMain *plugin) + : PluginClientWindow(plugin, ALPHA_W, ALPHA_H, ALPHA_W, ALPHA_H, 0) +{ + this->plugin = plugin; +} + +AlphaWindow::~AlphaWindow() +{ +} + +void AlphaWindow::create_objects() +{ + int x = xS(10), y = yS(10); + BC_Title *title; + add_subwindow(title = new BC_Title(x, y, _("Alpha:"))); + y += title->get_h() + yS(5); + add_subwindow(alpha_slider = new AlphaSlider(this, plugin, x, y, xS(380))); + show_window(); +} + +void AlphaWindow::update() +{ + float alpha = plugin->config.a; + alpha_slider->update(alpha); +} + + +AlphaMain::AlphaMain(PluginServer *server) + : PluginVClient(server) +{ +} + +AlphaMain::~AlphaMain() +{ +} + +const char* AlphaMain::plugin_title() { return N_("Alpha"); } +int AlphaMain::is_realtime() { return 1; } + +NEW_WINDOW_MACRO(AlphaMain, AlphaWindow) + +LOAD_CONFIGURATION_MACRO(AlphaMain, AlphaConfig) + +int AlphaMain::is_synthesis() +{ + return 1; +} + + +int AlphaMain::process_buffer(VFrame *frame, + int64_t start_position, + double frame_rate) +{ + load_configuration(); + + int color_model = frame->get_color_model(); + int need_alpha = BC_CModels::has_alpha(color_model); + if( need_alpha ) { + read_frame(frame, 0, start_position, + frame_rate, get_use_opengl()); + } + int w = frame->get_w(); + int h = frame->get_h(); + + +#define MAIN_LOOP(type, components, is_yuv, max) do { \ + if( components == 4 ) { \ + for( int y=0; yget_rows()[y]; \ + for( int x=0; xget_rows()[y]; \ + for( int x=0; xget_rows()[y]; \ + for( int x=0; xget_color_model() ) { + case BC_RGB888: MAIN_LOOP(uint8_t, 3, 0, 0xff); break; + case BC_RGB_FLOAT: MAIN_LOOP(float, 3, 0, 1.0 ); break; + case BC_YUV888: MAIN_LOOP(uint8_t, 3, 1, 0xff); break; + case BC_RGBA8888: MAIN_LOOP(uint8_t, 4, 0, 0xff); break; + case BC_RGBA_FLOAT: MAIN_LOOP(float, 4, 0, 1.0 ); break; + case BC_YUVA8888: MAIN_LOOP(uint8_t, 4, 1, 0xff); break; + } + + return 0; +} + + +void AlphaMain::update_gui() +{ + if( !thread ) return; + AlphaWindow *window = (AlphaWindow*)thread->window; + if( !window ) return; + if( !load_configuration() ) return; + window->lock_window("AlphaMain::update_gui"); + window->update(); + window->unlock_window(); +} + + +void AlphaMain::save_data(KeyFrame *keyframe) +{ + FileXML output; + output.set_shared_output(keyframe->xbuf); + output.tag.set_title("ALPHA"); + output.tag.set_property("A", config.a); + output.append_tag(); + output.terminate_string(); +} + +void AlphaMain::read_data(KeyFrame *keyframe) +{ + FileXML input; + input.set_shared_input(keyframe->xbuf); + + int result = 0; + while( !(result = input.read_tag()) ) { + if( input.tag.title_is("ALPHA") ) { + config.a = input.tag.get_property("A", config.a); + } + } +} + diff --git a/cinelerra-5.1/plugins/alpha/alpha.h b/cinelerra-5.1/plugins/alpha/alpha.h new file mode 100644 index 00000000..6f146ad8 --- /dev/null +++ b/cinelerra-5.1/plugins/alpha/alpha.h @@ -0,0 +1,89 @@ + +/* + * CINELERRA + * Copyright (C) 2008-2019 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ALPHA_H__ +#define __ALPHA_H__ + +class AlphaConfig; +class AlphaColors; +class AlphaWindow; +class AlphaMain; + +#include "bccolors.h" +#include "filexml.inc" +#include "guicast.h" +#include "pluginvclient.h" +#include "vframe.inc" + +class AlphaConfig +{ +public: + AlphaConfig(); + + int equivalent(AlphaConfig &that); + void copy_from(AlphaConfig &that); + void interpolate(AlphaConfig &prev, AlphaConfig &next, + long prev_frame, long next_frame, long current_frame); + + float a; +}; + +class AlphaSlider : public BC_FSlider +{ +public: + AlphaSlider(AlphaWindow *window, AlphaMain *plugin, int x, int y, int w); + ~AlphaSlider(); + int handle_event(); + + AlphaWindow *window; + AlphaMain *plugin; +}; + + +class AlphaWindow : public PluginClientWindow +{ +public: + AlphaWindow(AlphaMain *plugin); + ~AlphaWindow(); + + void create_objects(); + void update(); + + AlphaMain *plugin; + AlphaSlider *alpha_slider; +}; + +class AlphaMain : public PluginVClient +{ +public: + AlphaMain(PluginServer *server); + ~AlphaMain(); + + int process_buffer(VFrame *frame, int64_t start_position, double frame_rate); + int is_realtime(); + void save_data(KeyFrame *keyframe); + void read_data(KeyFrame *keyframe); + void update_gui(); + int is_synthesis(); + + PLUGIN_CLASS_MEMBERS(AlphaConfig) +}; + +#endif diff --git a/cinelerra-5.1/plugins/crikey/crikey.C b/cinelerra-5.1/plugins/crikey/crikey.C index 2cfa5dc4..d5a6cd13 100644 --- a/cinelerra-5.1/plugins/crikey/crikey.C +++ b/cinelerra-5.1/plugins/crikey/crikey.C @@ -607,7 +607,7 @@ int CriKey::process_buffer(VFrame *frame, int64_t start_position, double frame_r if( !pt->e ) continue; if( set_target(engine->color, pt->x, pt->y) ) continue; engine->threshold = pt->t; - edg->clear_frame(); + edg->black_frame(); engine->process_packages(); fill_edge(edg, w, h); FillRegion fill_region(edg, msk); diff --git a/cinelerra-5.1/plugins/foreground/Makefile b/cinelerra-5.1/plugins/foreground/Makefile new file mode 100644 index 00000000..00bc3630 --- /dev/null +++ b/cinelerra-5.1/plugins/foreground/Makefile @@ -0,0 +1,9 @@ +include ../../plugin_defs + +OBJS = $(OBJDIR)/foreground.o + +PLUGIN = foreground + +include ../../plugin_config + +$(OBJDIR)/foreground.o: foreground.C diff --git a/cinelerra-5.1/plugins/foreground/foreground.C b/cinelerra-5.1/plugins/foreground/foreground.C new file mode 100644 index 00000000..bced1f7d --- /dev/null +++ b/cinelerra-5.1/plugins/foreground/foreground.C @@ -0,0 +1,276 @@ + +/* + * CINELERRA + * Copyright (C) 2008-2019 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include + +#include "foreground.h" +#include "filexml.h" +#include "keyframe.h" +#include "language.h" +#include "vframe.h" + + +REGISTER_PLUGIN(ForegroundMain) + + +ForegroundConfig::ForegroundConfig() +{ + r = 0xff; + g = 0xff; + b = 0xff; + a = 0xff; +} + +int ForegroundConfig::equivalent(ForegroundConfig &that) +{ + return (r == that.r && g == that.g && b == that.b && + a == that.a); +} + +void ForegroundConfig::copy_from(ForegroundConfig &that) +{ + r = that.r; + g = that.g; + b = that.b; + a = that.a; +} + +void ForegroundConfig::interpolate(ForegroundConfig &prev, ForegroundConfig &next, + long prev_frame, long next_frame, long current_frame) +{ + double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame); + double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame); + + + r = (int)(prev.r * prev_scale + next.r * next_scale); + g = (int)(prev.g * prev_scale + next.g * next_scale); + b = (int)(prev.b * prev_scale + next.b * next_scale); + a = (int)(prev.a * prev_scale + next.a * next_scale); +} + +int ForegroundConfig::get_color() +{ + int result = (r << 16) | (g << 8) | (b); + return result; +} + + +ForegroundColors::ForegroundColors(ForegroundWindow *window, ForegroundMain *plugin) + : ColorGUI(window) +{ + this->window = window; + this->plugin = plugin; +} +ForegroundColors::~ForegroundColors() +{ +} + +int ForegroundColors::handle_new_color(int output, int alpha) +{ + plugin->config.r = (output>>16) & 0xff; + plugin->config.g = (output>>8) & 0xff; + plugin->config.b = (output) & 0xff; + plugin->config.a = alpha; + plugin->send_configure_change(); + return 1; +} +void ForegroundColors::update_gui(int output, int alpha) +{ +} + +ForegroundWindow::ForegroundWindow(ForegroundMain *plugin) + : PluginClientWindow(plugin, + ColorWindow::calculate_w(), ColorWindow::calculate_h() + BC_OKButton::calculate_h(), + ColorWindow::calculate_w(), ColorWindow::calculate_h() + BC_OKButton::calculate_h(), + 0) +{ + this->plugin = plugin; + colors = new ForegroundColors(this, plugin); +} + +ForegroundWindow::~ForegroundWindow() +{ + delete colors; +} + +void ForegroundWindow::create_objects() +{ + colors = new ForegroundColors(this, plugin); + int color = plugin->config.get_color(); + int alpha = plugin->config.a; + colors->start_selection(color, alpha, 1); + colors->create_objects(); + show_window(); +} + +void ForegroundWindow::update() +{ + int color = plugin->config.get_color(); + int alpha = plugin->config.a; + colors->update_gui(color, alpha); +} + + +ForegroundMain::ForegroundMain(PluginServer *server) + : PluginVClient(server) +{ +} + +ForegroundMain::~ForegroundMain() +{ +} + +const char* ForegroundMain::plugin_title() { return N_("Foreground"); } +int ForegroundMain::is_realtime() { return 1; } + +NEW_WINDOW_MACRO(ForegroundMain, ForegroundWindow) + +LOAD_CONFIGURATION_MACRO(ForegroundMain, ForegroundConfig) + +int ForegroundMain::is_synthesis() +{ + return 1; +} + + +int ForegroundMain::process_buffer(VFrame *frame, + int64_t start_position, + double frame_rate) +{ + load_configuration(); + + int need_alpha = config.a != 0xff; + if( need_alpha ) { + read_frame(frame, 0, start_position, + frame_rate, get_use_opengl()); + } + + int w = frame->get_w(); + int h = frame->get_h(); + + +#define MAIN_LOOP(type, temp, components, is_yuv) \ +{ \ + temp c1, c2, c3, a; \ + temp transparency, max; \ + if( is_yuv ) { \ + yuv.rgb_to_yuv_8(config.r, config.g, config.b, \ + c1, c2, c3); \ + a = config.a; \ + transparency = 0xff - a; \ + max = 0xff; \ +/* multiply alpha */ \ + if( components == 3 ) { \ + c1 = a * c1 / 0xff; \ + c2 = (a * c2 + 0x80 * transparency) / 0xff; \ + c3 = (a * c3 + 0x80 * transparency) / 0xff; \ + } \ + } \ + else { \ + c1 = config.r; c2 = config.g; c3 = config.b; a = config.a; \ + transparency = 0xff - a; \ + max = 0xff; \ + if( sizeof(type) == 4 ) { \ + c1 /= 0xff; c2 /= 0xff; c3 /= 0xff; a /= 0xff; \ + transparency /= 0xff; \ + max = 1.0; \ + } \ +/* multiply alpha */ \ + if(components == 3) { \ + c1 = a * c1 / max; \ + c2 = a * c2 / max; \ + c3 = a * c3 / max; \ + } \ + } \ + \ + for( int i=0; iget_rows()[i]; \ + for( int j=0; jget_color_model() ) { + case BC_RGB888: MAIN_LOOP(uint8_t, int, 3, 0) break; + case BC_RGB_FLOAT: MAIN_LOOP(float, float, 3, 0) break; + case BC_YUV888: MAIN_LOOP(uint8_t, int, 3, 1) break; + case BC_RGBA8888: MAIN_LOOP(uint8_t, int, 4, 0) break; + case BC_RGBA_FLOAT: MAIN_LOOP(float, float, 4, 0) break; + case BC_YUVA8888: MAIN_LOOP(uint8_t, int, 4, 1) break; + } + + return 0; +} + + +void ForegroundMain::update_gui() +{ + if( !thread ) return; + ForegroundWindow *window = (ForegroundWindow*)thread->window; + if( !window ) return; + if( !load_configuration() ) return; + window->lock_window("ForegroundMain::update_gui"); + window->update(); + window->unlock_window(); +} + + +void ForegroundMain::save_data(KeyFrame *keyframe) +{ + FileXML output; + output.set_shared_output(keyframe->xbuf); + output.tag.set_title("FOREGROUND"); + output.tag.set_property("R", config.r); + output.tag.set_property("G", config.g); + output.tag.set_property("B", config.b); + output.tag.set_property("A", config.a); + output.append_tag(); + output.terminate_string(); +} + +void ForegroundMain::read_data(KeyFrame *keyframe) +{ + FileXML input; + input.set_shared_input(keyframe->xbuf); + + int result = 0; + while( !(result = input.read_tag()) ) { + if( input.tag.title_is("FOREGROUND") ) { + config.r = input.tag.get_property("R", config.r); + config.g = input.tag.get_property("G", config.g); + config.b = input.tag.get_property("B", config.b); + config.a = input.tag.get_property("A", config.a); + } + } +} + diff --git a/cinelerra-5.1/plugins/foreground/foreground.h b/cinelerra-5.1/plugins/foreground/foreground.h new file mode 100644 index 00000000..8036cb8b --- /dev/null +++ b/cinelerra-5.1/plugins/foreground/foreground.h @@ -0,0 +1,98 @@ + +/* + * CINELERRA + * Copyright (C) 2008-2019 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef FOREGROUND_H +#define FOREGROUND_H + +class ForegroundConfig; +class ForegroundColors; +class ForegroundWindow; +class ForegroundMain; + +#include "bccolors.h" +#include "colorpicker.h" +#include "filexml.inc" +#include "guicast.h" +#include "pluginvclient.h" +#include "vframe.inc" + +class ForegroundConfig +{ +public: + ForegroundConfig(); + + int equivalent(ForegroundConfig &that); + void copy_from(ForegroundConfig &that); + void interpolate(ForegroundConfig &prev, ForegroundConfig &next, + long prev_frame, long next_frame, long current_frame); +// Int to hex triplet conversion + int get_color(); + + int r, g, b, a; +}; + +class ForegroundColors : public ColorGUI +{ +public: + ForegroundColors(ForegroundWindow *window, + ForegroundMain *plugin); + virtual ~ForegroundColors(); + + int handle_new_color(int color, int alpha); + void update_gui(int color, int alpha); + + ForegroundWindow *window; + ForegroundMain *plugin; +}; + + +class ForegroundWindow : public PluginClientWindow +{ +public: + ForegroundWindow(ForegroundMain *plugin); + ~ForegroundWindow(); + + void create_objects(); + void update(); + + ForegroundMain *plugin; + ForegroundColors *colors; +}; + +class ForegroundMain : public PluginVClient +{ +public: + ForegroundMain(PluginServer *server); + ~ForegroundMain(); + + int process_buffer(VFrame *frame, + int64_t start_position, + double frame_rate); + int is_realtime(); + void save_data(KeyFrame *keyframe); + void read_data(KeyFrame *keyframe); + void update_gui(); + int is_synthesis(); + + PLUGIN_CLASS_MEMBERS(ForegroundConfig) + YUV yuv; +}; + +#endif diff --git a/cinelerra-5.1/plugins/level/leveleffect.C b/cinelerra-5.1/plugins/level/leveleffect.C index a81b357b..45b47f1f 100644 --- a/cinelerra-5.1/plugins/level/leveleffect.C +++ b/cinelerra-5.1/plugins/level/leveleffect.C @@ -27,6 +27,7 @@ #include "language.h" #include "leveleffect.h" #include "samples.h" +#include "transportque.inc" #include "units.h" #include "vframe.h" @@ -35,25 +36,9 @@ #include #include - - - - - - - - - REGISTER_PLUGIN(SoundLevelEffect) - - - - - - - SoundLevelConfig::SoundLevelConfig() { duration = 1.0; @@ -69,29 +54,13 @@ int SoundLevelConfig::equivalent(SoundLevelConfig &that) return EQUIV(duration, that.duration); } -void SoundLevelConfig::interpolate(SoundLevelConfig &prev, - SoundLevelConfig &next, - int64_t prev_frame, - int64_t next_frame, - int64_t current_frame) +void SoundLevelConfig::interpolate(SoundLevelConfig &prev, SoundLevelConfig &next, + int64_t prev_frame, int64_t next_frame, int64_t current_frame) { duration = prev.duration; } - - - - - - - - - - - - - SoundLevelDuration::SoundLevelDuration(SoundLevelEffect *plugin, int x, int y) : BC_FSlider(x, y, 0, xS(180), yS(180), 0.0, 10.0, plugin->config.duration) { @@ -107,14 +76,8 @@ int SoundLevelDuration::handle_event() } - SoundLevelWindow::SoundLevelWindow(SoundLevelEffect *plugin) - : PluginClientWindow(plugin, - xS(350), - yS(120), - xS(350), - yS(120), - 0) + : PluginClientWindow(plugin, xS(350), yS(120), xS(350), yS(120), 0) { this->plugin = plugin; } @@ -142,33 +105,6 @@ void SoundLevelWindow::create_objects() } - - - - - - - - - - - - - - - - - - - - - - - - - - - SoundLevelEffect::SoundLevelEffect(PluginServer *server) : PluginAClient(server) { @@ -205,16 +141,9 @@ void SoundLevelEffect::read_data(KeyFrame *keyframe) input.set_shared_input(keyframe->xbuf); int result = 0; - while(!result) - { - result = input.read_tag(); - - if(!result) - { - if(input.tag.title_is("SOUNDLEVEL")) - { - config.duration = input.tag.get_property("DURATION", config.duration); - } + while( !(result = input.read_tag()) ) { + if( input.tag.title_is("SOUNDLEVEL") ) { + config.duration = input.tag.get_property("DURATION", config.duration); } } } @@ -236,57 +165,78 @@ void SoundLevelEffect::save_data(KeyFrame *keyframe) void SoundLevelEffect::update_gui() { -//printf("SoundLevelEffect::update_gui 1\n"); - if(thread) - { - load_configuration(); - thread->window->lock_window(); - ((SoundLevelWindow*)thread->window)->duration->update(config.duration); - thread->window->unlock_window(); + if( !thread ) return; + SoundLevelWindow *window = (SoundLevelWindow*)thread->window; + if( !window ) return; + int reconfigure = load_configuration(); + int pending = pending_gui_frame(); + if( !reconfigure && !pending ) return; + window->lock_window(); + if( reconfigure ) { + window->duration->update(config.duration); } -//printf("SoundLevelEffect::update_gui 2\n"); + if( pending ) { + double pos = get_tracking_position(); + double dir = get_tracking_direction() == PLAY_REVERSE ? -1 : 1; + SoundLevelClientFrame *frame = + (SoundLevelClientFrame *)get_gui_frame(pos, dir); + char string[BCSTRLEN]; + sprintf(string, "%.2f", DB::todb(frame->max)); + window->soundlevel_max->update(string); + sprintf(string, "%.2f", DB::todb(frame->rms)); + window->soundlevel_rms->update(string); + } + window->unlock_window(); } int SoundLevelEffect::process_realtime(int64_t size, Samples *input_ptr, Samples *output_ptr) { load_configuration(); + int sample_rate = get_project_samplerate(); + int fragment = config.duration * sample_rate; + int64_t position = get_source_position(); accum_size += size; double *input_samples = input_ptr->get_data(); - for(int i = 0; i < size; i++) - { + for( int i=0; i max_accum) max_accum = value; rms_accum += value * value; - } - - if(accum_size > config.duration * PluginAClient::project_sample_rate) - { -//printf("SoundLevelEffect::process_realtime 1 %f %d\n", rms_accum, accum_size); - rms_accum = sqrt(rms_accum / accum_size); - double arg[2]; - arg[0] = max_accum; - arg[1] = rms_accum; - send_render_gui(arg, 2); - rms_accum = 0; - max_accum = 0; - accum_size = 0; + if( ++accum_size >= fragment ) { + rms_accum = sqrt(rms_accum / accum_size); + SoundLevelClientFrame *level_frame = new SoundLevelClientFrame(); + level_frame->max = max_accum; + level_frame->rms = rms_accum; + level_frame->position = (double)(position+i)/get_project_samplerate(); + add_gui_frame(level_frame); + rms_accum = 0; + max_accum = 0; + accum_size = 0; + } } return 0; } void SoundLevelEffect::render_gui(void *data, int size) { - if(thread) - { - thread->window->lock_window(); - char string[BCTEXTLEN]; - double *arg = (double*)data; - sprintf(string, "%.2f", DB::todb(arg[0])); - ((SoundLevelWindow*)thread->window)->soundlevel_max->update(string); - sprintf(string, "%.2f", DB::todb(arg[1])); - ((SoundLevelWindow*)thread->window)->soundlevel_rms->update(string); - thread->window->flush(); - thread->window->unlock_window(); - } + if( !thread ) return; + SoundLevelWindow *window = (SoundLevelWindow*)thread->window; + if( !window ) return; + window->lock_window(); + char string[BCTEXTLEN]; + double *arg = (double*)data; + sprintf(string, "%.2f", DB::todb(arg[0])); + window->soundlevel_max->update(string); + sprintf(string, "%.2f", DB::todb(arg[1])); + window->soundlevel_rms->update(string); + window->flush(); + window->unlock_window(); +} + +void SoundLevelEffect::render_stop() +{ + rms_accum = 0; + max_accum = 0; + accum_size = 0; } + diff --git a/cinelerra-5.1/plugins/level/leveleffect.h b/cinelerra-5.1/plugins/level/leveleffect.h index 1d13df55..32fded0b 100644 --- a/cinelerra-5.1/plugins/level/leveleffect.h +++ b/cinelerra-5.1/plugins/level/leveleffect.h @@ -30,8 +30,11 @@ class SoundLevelEffect; class SoundLevelWindow; - - +class SoundLevelClientFrame : public PluginClientFrame +{ +public: + double max, rms; +}; class SoundLevelConfig { @@ -39,11 +42,8 @@ public: SoundLevelConfig(); void copy_from(SoundLevelConfig &that); int equivalent(SoundLevelConfig &that); - void interpolate(SoundLevelConfig &prev, - SoundLevelConfig &next, - int64_t prev_frame, - int64_t next_frame, - int64_t current_frame); + void interpolate(SoundLevelConfig &prev, SoundLevelConfig &next, + int64_t prev_frame, int64_t next_frame, int64_t current_frame); float duration; }; @@ -68,14 +68,6 @@ public: SoundLevelEffect *plugin; }; - - - - - - - - class SoundLevelEffect : public PluginAClient { public: @@ -89,6 +81,7 @@ public: void reset(); void update_gui(); void render_gui(void *data, int size); + void render_stop(); @@ -99,14 +92,4 @@ public: int accum_size; }; - - - - - - - - - - #endif diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C index d9489cb3..88d65015 100644 --- a/cinelerra-5.1/plugins/titler/titler.C +++ b/cinelerra-5.1/plugins/titler/titler.C @@ -362,14 +362,14 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n", glyph->right = 0; glyph->bottom = 0; glyph->freetype_index = 0; glyph->data = new VFrame(glyph->width, glyph->height, BC_A8, glyph->pitch); - glyph->data->clear_frame(); + glyph->data->black_frame(); glyph->data_stroke = 0; // create outline glyph if( plugin->config.stroke_width >= SMALL && (plugin->config.style & BC_FONT_OUTLINE) ) { glyph->data_stroke = new VFrame(glyph->width, glyph->height, BC_A8, glyph->pitch); - glyph->data_stroke->clear_frame(); + glyph->data_stroke->black_frame(); } } // char found and no outline desired @@ -399,7 +399,7 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n", //glyph->width, glyph->height, glyph->pitch, glyph->left, glyph->top, glyph->advance_x, glyph->freetype_index); glyph->data = new VFrame(glyph->width, glyph->height, BC_A8, glyph->pitch); - glyph->data->clear_frame(); + glyph->data->black_frame(); bm.buffer = glyph->data->get_data(); ft_Outline_Translate(&((FT_OutlineGlyph) glyph_image)->outline, - bbox.xMin, - bbox.yMin); @@ -500,9 +500,9 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n", //printf("GlyphUnit::process_package 1\n"); glyph->data = new VFrame(glyph->width, glyph->height, BC_A8, glyph->pitch); - glyph->data->clear_frame(); + glyph->data->black_frame(); glyph->data_stroke = new VFrame(glyph->width, glyph->height, BC_A8, glyph->pitch); - glyph->data_stroke->clear_frame(); + glyph->data_stroke->black_frame(); // for debugging memset( glyph->data_stroke->get_data(), 60, glyph->pitch * glyph->height); bm.buffer=glyph->data->get_data(); ft_Outline_Get_Bitmap( freetype_library,