From a718f58e6d8061f83bd0c0b10848ac415cd21fcd Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sat, 24 Oct 2020 16:21:55 -0600 Subject: [PATCH] rework proxy for 1:1 and new layout, fix proxy for resized assets, change track gang_master patchbay flag use to allow disabled slaves --- cinelerra-5.1/cinelerra/clippopup.C | 4 +- cinelerra-5.1/cinelerra/edl.C | 19 ++-- cinelerra-5.1/cinelerra/edl.inc | 4 + cinelerra-5.1/cinelerra/edlsession.C | 25 +++-- cinelerra-5.1/cinelerra/edlsession.h | 2 +- cinelerra-5.1/cinelerra/mainmenu.C | 1 - cinelerra-5.1/cinelerra/mainmenu.h | 2 + cinelerra-5.1/cinelerra/mwindow.C | 37 ++++---- cinelerra-5.1/cinelerra/mwindowgui.C | 16 +++- cinelerra-5.1/cinelerra/proxy.C | 137 ++++++++++++++++++--------- cinelerra-5.1/cinelerra/proxy.h | 20 +++- cinelerra-5.1/cinelerra/track.C | 8 +- 12 files changed, 181 insertions(+), 94 deletions(-) diff --git a/cinelerra-5.1/cinelerra/clippopup.C b/cinelerra-5.1/cinelerra/clippopup.C index 65eebb61..d473e195 100644 --- a/cinelerra-5.1/cinelerra/clippopup.C +++ b/cinelerra-5.1/cinelerra/clippopup.C @@ -439,10 +439,10 @@ ClipPopupToMedia::~ClipPopupToMedia() int ClipPopupToMedia::handle_event() { - if( mwindow->edl->session->proxy_scale == 1 ) + if( mwindow->edl->session->proxy_state != PROXY_ACTIVE ) mwindow->clip_to_media(); else - eprintf("Nesting not allowed when proxy scale != 1"); + eprintf("Nesting not allowed when proxy active"); return 1; } diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index 98200322..8597dab3 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -1675,26 +1675,29 @@ void EDL::set_proxy(int new_scale, int new_use_scaler, ArrayList *orig_assets, ArrayList *proxy_assets) { int orig_scale = session->proxy_scale; - session->proxy_scale = new_scale; + int proxy_scale = new_scale; + if( !proxy_scale ) proxy_scale = 1; + session->proxy_scale = proxy_scale; int orig_use_scaler = session->proxy_use_scaler; session->proxy_use_scaler = new_use_scaler; if( orig_use_scaler ) orig_scale = 1; - int scale = new_use_scaler ? new_scale : 1; - int asset_scale = new_scale == 1 && !new_use_scaler ? 0 : scale; + int scale = new_use_scaler ? proxy_scale : 1; + int asset_scale = !new_scale ? 0 : !new_use_scaler ? 1 : scale; // change original assets to proxy assets - int folder_no = new_use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER; + int folder_no = !new_use_scaler && !new_scale ? AW_MEDIA_FOLDER : AW_PROXY_FOLDER; for( int i=0,n=proxy_assets->size(); iget(i); proxy_idxbl->folder_no = folder_no; if( !proxy_idxbl->is_asset ) continue; Asset *proxy_asset = assets->update((Asset *)proxy_idxbl); + proxy_asset->proxy_scale = asset_scale; + if( !new_scale ) continue; // in case geom resized proxy_asset->width = proxy_asset->actual_width * scale; proxy_asset->height = proxy_asset->actual_height * scale; - proxy_asset->proxy_scale = asset_scale; } // rescale to full size asset in read_frame - if( new_use_scaler ) new_scale = 1; - rescale_proxy(orig_scale, new_scale); + if( new_use_scaler ) proxy_scale = 1; + rescale_proxy(orig_scale, proxy_scale); // replace track contents for( Track *track=tracks->first; track; track=track->next ) { @@ -1738,7 +1741,7 @@ void EDL::set_proxy(int new_scale, int new_use_scaler, } } if( has_proxy && !orig_use_scaler ) - clip->rescale_proxy(orig_scale, new_scale); + clip->rescale_proxy(orig_scale, proxy_scale); } } diff --git a/cinelerra-5.1/cinelerra/edl.inc b/cinelerra-5.1/cinelerra/edl.inc index 966eef59..c23ecdb2 100644 --- a/cinelerra-5.1/cinelerra/edl.inc +++ b/cinelerra-5.1/cinelerra/edl.inc @@ -182,4 +182,8 @@ class EDL; #define INSERT_EFFECTS_EXTRA 5 #define INSERT_EFFECTS_MASTER 6 +#define PROXY_INACTIVE 0 +#define PROXY_ACTIVE 1 +#define PROXY_DISABLED 2 + #endif diff --git a/cinelerra-5.1/cinelerra/edlsession.C b/cinelerra-5.1/cinelerra/edlsession.C index 35cd1977..1471834d 100644 --- a/cinelerra-5.1/cinelerra/edlsession.C +++ b/cinelerra-5.1/cinelerra/edlsession.C @@ -101,6 +101,7 @@ EDLSession::EDLSession(EDL *edl) playback_buffer = 4096; playback_cursor_visible = 0; playback_preload = 0; + proxy_state = PROXY_INACTIVE; proxy_scale = 1; proxy_disabled_scale = 1; proxy_use_scaler = 0; @@ -179,6 +180,7 @@ int EDLSession::need_rerender(EDLSession *ptr) (subtitle_number != ptr->subtitle_number) || (interpolate_raw != ptr->interpolate_raw) || (white_balance_raw != ptr->white_balance_raw) || + (proxy_state != ptr->proxy_state) || (proxy_disabled_scale != ptr->proxy_disabled_scale) || (proxy_scale != ptr->proxy_scale) || (proxy_use_scaler != ptr->proxy_use_scaler) || @@ -196,6 +198,7 @@ void EDLSession::equivalent_output(EDLSession *session, double *result) session->white_balance_raw != white_balance_raw || session->decode_subtitles != decode_subtitles || session->subtitle_number != subtitle_number || + session->proxy_state != proxy_state || session->proxy_disabled_scale != proxy_disabled_scale || session->proxy_scale != proxy_scale || session->proxy_use_scaler != proxy_use_scaler ) @@ -570,6 +573,11 @@ int EDLSession::load_video_config(FileXML *file, int append_mode, uint32_t load_ proxy_disabled_scale = file->tag.get_property("PROXY_DISABLED_SCALE", proxy_disabled_scale); proxy_use_scaler = file->tag.get_property("PROXY_USE_SCALER", proxy_use_scaler); proxy_auto_scale = file->tag.get_property("PROXY_AUTO_SCALE", proxy_auto_scale); + proxy_state = file->tag.get_property("PROXY_STATE", -1); + if( proxy_state < 0 ) // convert older edl + proxy_state = proxy_scale != 1 ? PROXY_ACTIVE : + proxy_disabled_scale != 1 ? PROXY_DISABLED : + PROXY_INACTIVE; return 0; } @@ -762,6 +770,7 @@ int EDLSession::save_video_config(FileXML *file) file->tag.set_property("OUTPUTH", output_h); file->tag.set_property("ASPECTW", aspect_w); file->tag.set_property("ASPECTH", aspect_h); + file->tag.set_property("PROXY_STATE", proxy_state); file->tag.set_property("PROXY_SCALE", proxy_scale); file->tag.set_property("PROXY_DISABLED_SCALE", proxy_disabled_scale); file->tag.set_property("PROXY_USE_SCALER", proxy_use_scaler); @@ -908,6 +917,7 @@ int EDLSession::copy(EDLSession *session) vwindow_meter = session->vwindow_meter; vwindow_zoom = session->vwindow_zoom; vwindow_click2play = session->vwindow_click2play; + proxy_state = session->proxy_state; proxy_scale = session->proxy_scale; proxy_disabled_scale = session->proxy_disabled_scale; proxy_use_scaler = session->proxy_use_scaler; @@ -928,13 +938,12 @@ void EDLSession::dump() printf("EDLSession::dump\n"); printf(" audio_tracks=%d audio_channels=%d sample_rate=%jd\n" " video_tracks=%d frame_rate=%f output_w=%d output_h=%d aspect_w=%f aspect_h=%f\n" - " decode subtitles=%d subtitle_number=%d label_cells=%d program_no=%d\n" - " proxy scale=%d\n disabled_scale=%d, use_scaler=%d, auto_scale=%d\n" - " proxy_beep=%f render_beep=%f\n", - audio_tracks, audio_channels, sample_rate, video_tracks, - frame_rate, output_w, output_h, aspect_w, aspect_h, - decode_subtitles, subtitle_number, label_cells, program_no, - proxy_scale, proxy_disabled_scale, proxy_use_scaler, proxy_auto_scale, - proxy_beep, render_beep); + " decode subtitles=%d subtitle_number=%d label_cells=%d program_no=%d render_beep=%f\n" + " proxy_* auto_scale=%d state=%d scale=%d disabled_scale=%d use_scaler=%d beep=%f\n", + audio_tracks, audio_channels, sample_rate, + video_tracks, frame_rate, output_w, output_h, aspect_w, aspect_h, + decode_subtitles, subtitle_number, label_cells, program_no, render_beep, + proxy_auto_scale, proxy_state, proxy_scale, proxy_disabled_scale, + proxy_use_scaler, proxy_beep); } diff --git a/cinelerra-5.1/cinelerra/edlsession.h b/cinelerra-5.1/cinelerra/edlsession.h index b95b8672..f88a1268 100644 --- a/cinelerra-5.1/cinelerra/edlsession.h +++ b/cinelerra-5.1/cinelerra/edlsession.h @@ -164,7 +164,7 @@ public: int program_no; int playback_software_position; // current settings are scaled this much from the original settings - int proxy_scale; + int proxy_scale, proxy_state; // original proxy_scale when proxy_enable disables/enables proxy int proxy_disabled_scale; // upscale geom from proxy to session on read in diff --git a/cinelerra-5.1/cinelerra/mainmenu.C b/cinelerra-5.1/cinelerra/mainmenu.C index 56b18436..b7b9f358 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.C +++ b/cinelerra-5.1/cinelerra/mainmenu.C @@ -223,7 +223,6 @@ void MainMenu::create_objects() settingsmenu->add_item(new SetFormat(mwindow)); settingsmenu->add_item(preferences = new PreferencesMenuitem(mwindow)); - ProxyMenuItem *proxy; settingsmenu->add_item(proxy = new ProxyMenuItem(mwindow)); proxy->create_objects(); ConvertMenuItem *convert; diff --git a/cinelerra-5.1/cinelerra/mainmenu.h b/cinelerra-5.1/cinelerra/mainmenu.h index c9127fa8..983addcb 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.h +++ b/cinelerra-5.1/cinelerra/mainmenu.h @@ -35,6 +35,7 @@ #include "module.inc" #include "new.inc" #include "plugindialog.inc" +#include "proxy.inc" #include "quit.inc" #include "record.inc" #include "render.inc" @@ -176,6 +177,7 @@ public: MixerItems *mixer_items; LoadLayout *load_layout; LoadLayout *save_layout; + ProxyMenuItem *proxy; }; // ========================================= edit diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 4179cc51..f8d4fc4e 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -2302,6 +2302,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); load_mode == LOADMODE_REPLACE_CONCATENATE ) && (ftype != FILE_IS_XML || edl_mode != LOADMODE_EDL_CLIP) ) { select_asset(0, 0); + edl->session->proxy_state = PROXY_INACTIVE; edl->session->proxy_scale = 1; edl->session->proxy_disabled_scale = 1; edl->session->proxy_use_scaler = 0; @@ -2319,8 +2320,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); goto_start(); } - if( ( edl->session->proxy_auto_scale && edl->session->proxy_scale != 1 ) && - ( load_mode != LOADMODE_REPLACE && load_mode != LOADMODE_REPLACE_CONCATENATE ) ) { + if( edl->session->proxy_state != PROXY_INACTIVE && edl->session->proxy_auto_scale && + load_mode != LOADMODE_REPLACE && load_mode != LOADMODE_REPLACE_CONCATENATE ) { ArrayList orig_idxbls; for( int i=0; i &new_idxbls) int MWindow::enable_proxy() { int ret = 0; - if( edl->session->proxy_scale == 1 && - edl->session->proxy_disabled_scale != 1 ) { + if( edl->session->proxy_state == PROXY_DISABLED ) { int new_scale = edl->session->proxy_disabled_scale; int new_use_scaler = edl->session->proxy_use_scaler; Asset *asset = new Asset; @@ -2439,6 +2439,7 @@ int MWindow::enable_proxy() beep(2000., 1.5, gain); } edl->session->proxy_disabled_scale = 1; + edl->session->proxy_state = PROXY_ACTIVE; gui->lock_window("MWindow::to_proxy"); update_project(LOADMODE_REPLACE); gui->unlock_window(); @@ -2448,15 +2449,15 @@ int MWindow::enable_proxy() int MWindow::disable_proxy() { - if( edl->session->proxy_scale != 1 && - edl->session->proxy_disabled_scale == 1 ) { - int old_scale = edl->session->proxy_scale, new_scale = 1; + if( edl->session->proxy_state == PROXY_ACTIVE ) { + int old_scale = edl->session->proxy_scale, new_scale = 0; int new_use_scaler = edl->session->proxy_use_scaler; Asset *asset = new Asset; asset->format = FILE_FFMPEG; asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); to_proxy(asset, new_scale, new_use_scaler); asset->remove_user(); + edl->session->proxy_state = PROXY_DISABLED; edl->session->proxy_disabled_scale = old_scale; gui->lock_window("MWindow::to_proxy"); update_project(LOADMODE_REPLACE); @@ -2473,7 +2474,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) edl->Garbage::add_user(); save_backup(); undo_before(_("proxy"), this); - int asset_scale = new_scale == 1 ? 0 : + int asset_scale = !new_scale ? 0 : !new_use_scaler ? 1 : new_scale; ProxyRender proxy_render(this, asset, asset_scale); @@ -2481,7 +2482,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) // remove all session proxy assets at the at the current proxy_scale int proxy_scale = edl->session->proxy_scale; - if( proxy_scale > 1 ) { + if( edl->session->proxy_state == PROXY_ACTIVE ) { Asset *orig_asset = edl->assets->first; for( ; orig_asset; orig_asset=orig_asset->next ) { char new_path[BCTEXTLEN]; @@ -2520,7 +2521,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) } // convert from the proxy assets to the original assets - edl->set_proxy(1, 0, &proxy_assets, &orig_idxbls); + edl->set_proxy(0, 0, &proxy_assets, &orig_idxbls); // remove the references for( int i=0; iassets->first; for( ; orig; orig=orig->next ) { @@ -2569,7 +2570,10 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) proxy_render.add_needed(orig_nested, proxy); } } + edl->session->proxy_state = PROXY_ACTIVE; } + else + edl->session->proxy_state = PROXY_INACTIVE; int result = 0; // test for existing files @@ -2578,13 +2582,13 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) confirm_paths.remove_all_objects(); } - if( !result ) + if( !result && new_scale ) result = proxy_render.create_needed_proxies(new_scale); - if( !result ) // resize project + if( !result ) { // resize project edl->set_proxy(new_scale, new_use_scaler, &proxy_render.orig_idxbls, &proxy_render.orig_proxies); - + } undo_after(_("proxy"), LOAD_ALL); edl->Garbage::remove_user(); restart_brender(); @@ -3437,8 +3441,9 @@ int MWindow::get_hash_color(Edit *edit) (Indexable*)edit->asset : (Indexable*)edit->nested_edl; if( !idxbl ) return 0; char path[BCTEXTLEN]; - if( !edit->asset || edit->track->data_type != TRACK_VIDEO || - edl->session->proxy_scale == 1 || +// map proxy colors to unproxy colors + if( edl->session->proxy_state != PROXY_ACTIVE || + !edit->asset || edit->track->data_type != TRACK_VIDEO || ProxyRender::from_proxy_path(path, (Asset*)idxbl, edl->session->proxy_scale) ) strcpy(path, idxbl->path); char *cp = strrchr(path, '/'); diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index 5e4dc7bd..a68d4d17 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -56,6 +56,7 @@ #include "pluginpopup.h" #include "pluginset.h" #include "preferences.h" +#include "proxy.h" #include "record.h" #include "recordgui.h" #include "renderengine.h" @@ -578,10 +579,9 @@ void MWindowGUI::update_patchbay() void MWindowGUI::update_proxy_toggle() { - int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0; + int value = mwindow->edl->session->proxy_state == PROXY_ACTIVE ? 0 : 1; proxy_toggle->set_value(value); - if( mwindow->edl->session->proxy_scale == 1 && - mwindow->edl->session->proxy_disabled_scale == 1 ) + if( mwindow->edl->session->proxy_state == PROXY_INACTIVE ) proxy_toggle->hide(); else proxy_toggle->show(); @@ -2414,12 +2414,12 @@ ProxyToggle::ProxyToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y) : BC_Toggle(x, y, ( !mwindow->edl->session->proxy_use_scaler ? mwindow->theme->proxy_p_toggle : mwindow->theme->proxy_s_toggle ), - mwindow->edl->session->proxy_disabled_scale != 1) + mwindow->edl->session->proxy_state == PROXY_DISABLED) { this->mwindow = mwindow; this->mbuttons = mbuttons; scaler_images = mwindow->edl->session->proxy_use_scaler; - set_tooltip(mwindow->edl->session->proxy_disabled_scale==1 ? + set_tooltip(mwindow->edl->session->proxy_state!=PROXY_DISABLED ? _("Disable proxy") : _("Enable proxy")); } @@ -2455,6 +2455,12 @@ int ProxyToggle::handle_event() mwindow->enable_proxy(); mwindow->gui->lock_window("ProxyToggle::handle_event"); set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy")); + ProxyDialog *dialog = mwindow->gui->mainmenu->proxy->dialog; + if( dialog && dialog->gui ) { + dialog->gui->lock_window("ProxyToggle::handle_event"); + dialog->gui->update(); + dialog->gui->unlock_window(); + } return 1; } diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index fff64f37..be78b777 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -48,7 +48,7 @@ #include "vrender.h" #define WIDTH xS(400) -#define HEIGHT yS(330) +#define HEIGHT yS(400) #define MAX_SCALE 16 ProxyMenuItem::ProxyMenuItem(MWindow *mwindow) @@ -92,9 +92,11 @@ ProxyDialog::ProxyDialog(MWindow *mwindow) bzero(size_text, sizeof(char*) * MAX_SIZES); bzero(size_factors, sizeof(int) * MAX_SIZES); - size_text[0] = cstrdup(_("Original size")); - size_factors[0] = 1; - total_sizes = 1; + size_text[0] = cstrdup(_("off")); + size_text[1] = cstrdup(_("1")); + size_factors[0] = 0; + size_factors[1] = 1; + total_sizes = 2; } ProxyDialog::~ProxyDialog() @@ -131,12 +133,12 @@ void ProxyDialog::scale_to_text(char *string, int scale) void ProxyDialog::calculate_sizes() { - for( int i=1; iedl->session->proxy_auto_scale = auto_scale; - mwindow->edl->session->proxy_beep = beep; + mwindow->edl->session->proxy_beep = beeper_volume; asset->save_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0); result = mwindow->to_proxy(asset, new_scale, use_scaler); - if( result >= 0 && beep > 0 && new_scale != 1 ) { + if( result >= 0 && beeper_on && beeper_volume > 0 && new_scale >= 1 ) { if( !result ) { - mwindow->beep(4000., 0.5, beep); + mwindow->beep(4000., 0.5, beeper_volume); usleep(250000); - mwindow->beep(1000., 0.5, beep); + mwindow->beep(1000., 0.5, beeper_volume); usleep(250000); - mwindow->beep(4000., 0.5, beep); + mwindow->beep(4000., 0.5, beeper_volume); } else - mwindow->beep(2000., 2.0, beep); + mwindow->beep(2000., 2.0, beeper_volume); } mwindow->edl->session->proxy_disabled_scale = 1; mwindow->gui->lock_window("ProxyDialog::handle_close_event"); @@ -407,13 +410,17 @@ void ProxyWindow::create_objects() { lock_window("ProxyWindow::create_objects"); int margin = mwindow->theme->widget_border; - int lmargin = margin + xS(10); + int xs10 = xS(10), x1 = xS(50); + int lmargin = margin + xs10; + int x = lmargin, y = margin+yS(10); dialog->use_scaler = mwindow->edl->session->proxy_use_scaler; dialog->orig_scale = mwindow->edl->session->proxy_scale; dialog->auto_scale = mwindow->edl->session->proxy_auto_scale; - dialog->beep = mwindow->edl->session->proxy_beep; - dialog->new_scale = dialog->orig_scale; + dialog->beeper_on = mwindow->edl->session->proxy_beep > 0 ? 1 : 0; + dialog->beeper_volume = mwindow->edl->session->proxy_beep; + dialog->new_scale = mwindow->edl->session->proxy_state != PROXY_INACTIVE ? + dialog->orig_scale : 0; dialog->orig_w = mwindow->edl->session->output_w; dialog->orig_h = mwindow->edl->session->output_h; if( !dialog->use_scaler ) { @@ -421,48 +428,59 @@ void ProxyWindow::create_objects() dialog->orig_h *= dialog->orig_scale; } - int x = lmargin; - int y = margin+yS(10); - add_subwindow(use_scaler = new ProxyUseScaler(this, x, y)); - y += use_scaler->get_h() + margin; + add_subwindow(title_bar1 = new BC_TitleBar(xs10, y, get_w()-xS(30), xS(20), xs10, + _("Scaling options"))); + y += title_bar1->get_h() + 3*margin; BC_Title *text; + x = lmargin; add_subwindow(text = new BC_Title(x, y, _("Scale factor:"))); - x += text->get_w() + margin; - - int popupmenu_w = BC_PopupMenu::calculate_w(get_text_width(MEDIUMFONT, dialog->size_text[0])+xS(15)); + int popupmenu_w = BC_PopupMenu::calculate_w(get_text_width(MEDIUMFONT, dialog->size_text[0])+xS(25)); + x += text->get_w() + 2*margin; add_subwindow(scale_factor = new ProxyMenu(mwindow, this, x, y, popupmenu_w, "")); scale_factor->update_sizes(); - x += scale_factor->get_w() + margin; - + x += popupmenu_w + margin; ProxyTumbler *tumbler; add_subwindow(tumbler = new ProxyTumbler(mwindow, this, x, y)); y += tumbler->get_h() + margin; - x = lmargin; - add_subwindow(text = new BC_Title(x, y, _("New media dimensions: "))); + x = x1; + add_subwindow(text = new BC_Title(x, y, _("Media size: "))); x += text->get_w() + margin; add_subwindow(new_dimensions = new BC_Title(x, y, "")); y += new_dimensions->get_h() + margin; - x = lmargin; + x = x1; add_subwindow(text = new BC_Title(x, y, _("Active Scale: "))); x += text->get_w() + margin; add_subwindow(active_scale = new BC_Title(x, y, "")); + x += xS(64); + add_subwindow(text = new BC_Title(x, y, _("State: "))); + x += text->get_w() + margin; + add_subwindow(active_state = new BC_Title(x, y, "")); y += active_scale->get_h() + margin; - x = lmargin; y += yS(25); + add_subwindow(use_scaler = new ProxyUseScaler(this, x1, y)); + y += use_scaler->get_h() + margin; + add_subwindow(auto_scale = new ProxyAutoScale(this, x1, y)); + y += auto_scale->get_h() + 2*margin; + + x = lmargin; y += yS(15); format_tools = new ProxyFormatTools(mwindow, this, dialog->asset); format_tools->create_objects(x, y, 0, 1, 0, 0, 0, 1, 0, 1, // skip the path 0, 0); + y += margin; + add_subwindow(title_bar2 = new BC_TitleBar(xs10, y, get_w()-xS(30), xS(20), xs10, + _("Beep on Done"))); + y += title_bar2->get_h() + 3*margin; + x = lmargin; - add_subwindow(auto_scale = new ProxyAutoScale(this, x, y)); - y += auto_scale->get_h() + margin; + add_subwindow(text = new BC_Title(x, y, _("Volume:"))); + x += text->get_w() + 2*margin; add_subwindow(beep_on_done = new ProxyBeepOnDone(this, x, y)); x += beep_on_done->get_w() + margin + xS(10); - add_subwindow(new BC_Title(x, y+yS(10), _("Beep on done volume"))); -// y += beep_on_done->get_h() + margin; + add_subwindow(beep_volume = new ProxyBeepVolume(this, x, y)); update(); @@ -488,25 +506,38 @@ void ProxyFormatTools::update_format() void ProxyWindow::update() { char string[BCSTRLEN]; - int new_w = dialog->orig_w / dialog->new_scale; + dialog->scale_to_text(string, dialog->new_scale); + scale_factor->set_text(string); + int new_scale = dialog->new_scale; + if( new_scale < 1 ) new_scale = 1; + int new_w = dialog->orig_w / new_scale; if( new_w & 1 ) ++new_w; - int new_h = dialog->orig_h / dialog->new_scale; + int new_h = dialog->orig_h / new_scale; if( new_h & 1 ) ++new_h; sprintf(string, "%dx%d", new_w, new_h); new_dimensions->update(string); - dialog->scale_to_text(string, dialog->new_scale); - scale_factor->set_text(string); use_scaler->update(); auto_scale->update(); - int scale = mwindow->edl->session->proxy_scale; - if( scale == 1 ) scale = mwindow->edl->session->proxy_disabled_scale; + int scale = mwindow->edl->session->proxy_state == PROXY_ACTIVE ? + mwindow->edl->session->proxy_scale : + mwindow->edl->session->proxy_state == PROXY_DISABLED ? + mwindow->edl->session->proxy_disabled_scale : 1; sprintf(string, scale>1 ? "1/%d" : "%d", scale); active_scale->update(string); + const char *state = ""; + switch( mwindow->edl->session->proxy_state ) { + case PROXY_INACTIVE: state = _("Off"); break; + case PROXY_ACTIVE: state = _("Active"); break; + case PROXY_DISABLED: state = _("Disabled"); break; + } + active_state->update(state); + beep_on_done->update(dialog->beeper_on); + beep_volume->update(dialog->beeper_volume*100.f); } ProxyUseScaler::ProxyUseScaler(ProxyWindow *pwindow, int x, int y) - : BC_CheckBox(x, y, pwindow->dialog->use_scaler, _("Use scaler (FFMPEG only)")) + : BC_CheckBox(x, y, pwindow->dialog->use_scaler, _("Don't resize project (FFMPEG only)")) { this->pwindow = pwindow; } @@ -539,11 +570,11 @@ ProxyAutoScale::ProxyAutoScale(ProxyWindow *pwindow, int x, int y) void ProxyAutoScale::update() { ProxyDialog *dialog = pwindow->dialog; - if( dialog->new_scale == 1 ) dialog->auto_scale = 0; + int can_auto_scale = dialog->new_scale >= 1 ? 1 : 0; + if( !can_auto_scale ) dialog->auto_scale = 0; BC_CheckBox::update(dialog->auto_scale); - int can_auto_proxy = dialog->new_scale != 1 ? 1 : 0; - if( !can_auto_proxy && enabled ) disable(); - if( can_auto_proxy && !enabled ) enable(); + if( !can_auto_scale && enabled ) disable(); + if( can_auto_scale && !enabled ) enable(); } int ProxyAutoScale::handle_event() @@ -554,14 +585,28 @@ int ProxyAutoScale::handle_event() } ProxyBeepOnDone::ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y) - : BC_FPot(x, y, pwindow->dialog->beep*100.f, 0.f, 100.f) + : BC_CheckBox(x, y, pwindow->dialog->beeper_on) { this->pwindow = pwindow; } int ProxyBeepOnDone::handle_event() { - pwindow->dialog->beep = get_value()/100.f; + pwindow->dialog->beeper_on = get_value(); + return 1; +} + +ProxyBeepVolume::ProxyBeepVolume(ProxyWindow *pwindow, int x, int y) + : BC_FSlider(x, y, 0, xS(160), xS(160), 0.f, 100.f, + pwindow->dialog->beeper_volume*100.f, 0) +{ + this->pwindow = pwindow; +} + +int ProxyBeepVolume::handle_event() +{ + pwindow->dialog->beeper_volume = get_value()/100.f; + pwindow->dialog->beeper_on = pwindow->dialog->beeper_volume>0 ? 1 : 0; pwindow->update(); return 1; } diff --git a/cinelerra-5.1/cinelerra/proxy.h b/cinelerra-5.1/cinelerra/proxy.h index b134b910..71b91fa5 100644 --- a/cinelerra-5.1/cinelerra/proxy.h +++ b/cinelerra-5.1/cinelerra/proxy.h @@ -29,7 +29,7 @@ #include "bcdialog.h" #include "cache.inc" #include "file.inc" -#include "formattools.inc" +#include "formattools.h" #include "loadbalance.h" #include "mutex.inc" #include "mwindow.inc" @@ -112,7 +112,8 @@ public: int orig_scale, new_scale; int use_scaler, auto_scale; int orig_w, orig_h; - float beep; + int beeper_on; + float beeper_volume; char *size_text[MAX_SIZES]; int size_factors[MAX_SIZES]; int total_sizes; @@ -138,11 +139,19 @@ public: ProxyWindow *pwindow; }; -class ProxyBeepOnDone : public BC_FPot +class ProxyBeepOnDone : public BC_CheckBox { public: ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y); - void update(); + int handle_event(); + + ProxyWindow *pwindow; +}; + +class ProxyBeepVolume : public BC_FSlider +{ +public: + ProxyBeepVolume(ProxyWindow *pwindow, int x, int y); int handle_event(); ProxyWindow *pwindow; @@ -194,13 +203,16 @@ public: MWindow *mwindow; ProxyDialog *dialog; + BC_TitleBar *title_bar1, *title_bar2; FormatTools *format_tools; BC_Title *new_dimensions; BC_Title *active_scale; + BC_Title *active_state; ProxyMenu *scale_factor; ProxyUseScaler *use_scaler; ProxyAutoScale *auto_scale; ProxyBeepOnDone *beep_on_done; + ProxyBeepVolume *beep_volume; }; class ProxyFarm; diff --git a/cinelerra-5.1/cinelerra/track.C b/cinelerra-5.1/cinelerra/track.C index 03034830..5c07480e 100644 --- a/cinelerra-5.1/cinelerra/track.C +++ b/cinelerra-5.1/cinelerra/track.C @@ -1836,18 +1836,20 @@ int Track::in_gang(Track *track) int Track::is_armed() { - return gang_master()->armed; + return armed && gang_master()->armed; } int Track::is_ganged() { - return gang_master()->ganged; + return ganged && gang_master()->ganged; } int Track::armed_gang(Track *track) { + if( !track->ganged ) return 0; if( edl->local_session->gang_tracks == GANG_NONE ) return ganged; Track *current = gang_master(); + if( !current->ganged ) return 0; for(;;) { if( track == current ) return 1; current = current->next; @@ -1858,7 +1860,7 @@ int Track::armed_gang(Track *track) int Track::plays() { - return gang_master()->play; + return play && gang_master()->play; } int Track::index_in(Mixer *mixer) -- 2.26.2