From: Good Guy Date: Sun, 11 Mar 2018 18:29:55 +0000 (-0600) Subject: add audio to proxy, and minor bug fixes X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=86bd203ac1fc29d93f63d13e2979468f06bdc3a2;p=goodguy%2Fhistory.git add audio to proxy, and minor bug fixes --- diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index 07cc8eb4..15620af7 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -100,10 +100,11 @@ void AssetPopup::paste_assets() mwindow->gui->lock_window("AssetPopup::paste_assets"); mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets"); - gui->collect_assets(); + int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0; + gui->collect_assets(proxy); mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1), - mwindow->edl->tracks->first, - 0); // do not overwrite + mwindow->edl->tracks->first, 0); // do not overwrite + mwindow->session->clear_drag_proxy(); gui->unlock_window(); mwindow->gui->unlock_window(); @@ -140,7 +141,8 @@ void AssetPopup::match_all() int AssetPopup::update() { format->update(); - gui->collect_assets(); + int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0; + gui->collect_assets(proxy); return 0; } diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index ea21a02c..0ed6b1ce 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -56,6 +56,7 @@ #include "mwindow.h" #include "newfolder.h" #include "preferences.h" +#include "proxy.h" #include "renderengine.h" #include "samples.h" #include "theme.h" @@ -1571,18 +1572,62 @@ void AWindowGUI::sort_folders() update_assets(); } -void AWindowGUI::collect_assets() +EDL *AWindowGUI::collect_proxy(Indexable *indexable) +{ + Asset *proxy_asset = (Asset *)indexable; + char path[BCTEXTLEN]; + int proxy_scale = mwindow->edl->session->proxy_scale; + ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale); + Asset *unproxy_asset = mwindow->edl->assets->get_asset(path); + if( !unproxy_asset || !unproxy_asset->channels ) return 0; +// make a clip from proxy video tracks and unproxy audio tracks + EDL *proxy_edl = new EDL(mwindow->edl); + proxy_edl->create_objects(); + FileSystem fs; fs.extract_name(path, proxy_asset->path); + strcpy(proxy_edl->local_session->clip_title, path); + strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip")); + proxy_edl->session->video_tracks = proxy_asset->layers; + proxy_edl->session->audio_tracks = unproxy_asset->channels; + proxy_edl->create_default_tracks(); + double length = proxy_asset->frame_rate > 0 ? + (double)proxy_asset->video_length / proxy_asset->frame_rate : + 1.0 / mwindow->edl->session->frame_rate; + Track *current = proxy_edl->tracks->first; + for( int vtrack=0; current; current=NEXT ) { + if( current->data_type != TRACK_VIDEO ) continue; + current->insert_asset(proxy_asset, 0, length, 0, vtrack++); + } + length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate; + current = proxy_edl->tracks->first; + for( int atrack=0; current; current=NEXT ) { + if( current->data_type != TRACK_AUDIO ) continue; + current->insert_asset(unproxy_asset, 0, length, 0, atrack++); + } + return proxy_edl; +} + + +void AWindowGUI::collect_assets(int proxy) { - int i = 0; mwindow->session->drag_assets->remove_all(); mwindow->session->drag_clips->remove_all(); - while(1) - { - AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++); - if( !result ) break; - - if( result->indexable ) mwindow->session->drag_assets->append(result->indexable); - if( result->edl ) mwindow->session->drag_clips->append(result->edl); + mwindow->session->clear_drag_proxy(); + int i = 0; AssetPicon *result; + while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) { + Indexable *indexable = result->indexable; EDL *drag_edl; + if( proxy && (drag_edl=collect_proxy(indexable)) ) { + mwindow->session->drag_clips->append(drag_edl); + mwindow->session->drag_proxy->append(drag_edl); + continue; + } + if( indexable ) { + mwindow->session->drag_assets->append(indexable); + continue; + } + if( result->edl ) { + mwindow->session->drag_clips->append(result->edl); + continue; + } } } @@ -1761,7 +1806,6 @@ int AWindowGUI::drag_motion() int AWindowGUI::drag_stop() { if( get_hidden() ) return 0; - return 0; } @@ -2051,7 +2095,7 @@ void AWindowAssets::draw_background() int AWindowAssets::drag_start_event() { int collect_pluginservers = 0; - int collect_assets = 0; + int collect_assets = 0, proxy = 0; if( BC_ListBox::drag_start_event() ) { switch( mwindow->edl->session->awindow_folder ) { @@ -2074,6 +2118,10 @@ int AWindowAssets::drag_start_event() case AW_LABEL_FOLDER: // do nothing! break; + case AW_PROXY_FOLDER: + proxy = 1; + // fall thru + case AW_MEDIA_FOLDER: default: mwindow->session->current_operation = DRAG_ASSET; collect_assets = 1; @@ -2093,7 +2141,7 @@ int AWindowAssets::drag_start_event() } if( collect_assets ) { - gui->collect_assets(); + gui->collect_assets(proxy); } return 1; @@ -2169,6 +2217,8 @@ int AWindowAssets::drag_stop_event() BC_ListBox::drag_stop_event(); // since NO_OPERATION is also defined in listbox, we have to reach for global scope... mwindow->session->current_operation = ::NO_OPERATION; + mwindow->session->clear_drag_proxy(); + return 1; } diff --git a/cinelerra-5.1/cinelerra/awindowgui.h b/cinelerra-5.1/cinelerra/awindowgui.h index 04d83460..4bc25642 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.h +++ b/cinelerra-5.1/cinelerra/awindowgui.h @@ -179,7 +179,8 @@ public: int drag_motion(); int drag_stop(); // Collect items into the drag vectors of MainSession - void collect_assets(); + void collect_assets(int proxy=0); + EDL *collect_proxy(Indexable *indexable); void create_persistent_folder(ArrayList *output, int do_audio, int do_video, diff --git a/cinelerra-5.1/cinelerra/indexable.C b/cinelerra-5.1/cinelerra/indexable.C index a038b330..1fff3eff 100644 --- a/cinelerra-5.1/cinelerra/indexable.C +++ b/cinelerra-5.1/cinelerra/indexable.C @@ -62,7 +62,7 @@ void Indexable::update_path(const char *new_path) void Indexable::update_index(Indexable *src) { if( index_state == src->index_state ) return; - index_state->remove_user(); + if( index_state ) index_state->remove_user(); index_state = src->index_state; index_state->add_user(); } diff --git a/cinelerra-5.1/cinelerra/mainsession.C b/cinelerra-5.1/cinelerra/mainsession.C index f7224b4c..d919c556 100644 --- a/cinelerra-5.1/cinelerra/mainsession.C +++ b/cinelerra-5.1/cinelerra/mainsession.C @@ -49,6 +49,7 @@ MainSession::MainSession(MWindow *mwindow) drag_assets = new ArrayList; drag_auto_gang = new ArrayList; drag_clips = new ArrayList; + drag_proxy = new ArrayList; drag_edits = new ArrayList; drag_edit = 0; clip_number = 1; @@ -113,10 +114,12 @@ MainSession::MainSession(MWindow *mwindow) MainSession::~MainSession() { + clear_drag_proxy(); delete drag_pluginservers; delete drag_assets; delete drag_auto_gang; delete drag_clips; + delete drag_proxy; delete drag_edits; } @@ -141,6 +144,13 @@ void MainSession::boundaries() CLAMP(cwindow_controls, 0, 1); } +void MainSession::clear_drag_proxy() +{ + for( int i=drag_proxy->size(); --i>=0; ) + drag_proxy->get(i)->remove_user(); + drag_proxy->remove_all(); +} + void MainSession::save_x11_host(int play_config, const char *x11_host) { strcpy(!play_config ? a_x11_host : b_x11_host, x11_host); diff --git a/cinelerra-5.1/cinelerra/mainsession.h b/cinelerra-5.1/cinelerra/mainsession.h index ab53708d..cc16c737 100644 --- a/cinelerra-5.1/cinelerra/mainsession.h +++ b/cinelerra-5.1/cinelerra/mainsession.h @@ -49,15 +49,12 @@ public: int load_defaults(BC_Hash *defaults); int save_defaults(BC_Hash *defaults); + void clear_drag_proxy(); void save_x11_host(int play_config, const char *x11_host); int set_default_x11_host(int win_config=-1); void default_window_positions(int window_config=0); void boundaries(); - - - - // For drag and drop events // The entire track where the dropped asset is going to go Track *track_highlighted; @@ -77,6 +74,7 @@ public: Edits *trim_edits; ArrayList *drag_assets; ArrayList *drag_clips; + ArrayList *drag_proxy; Auto *drag_auto; ArrayList *drag_auto_gang; diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index b406c7b2..2366c388 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -2380,6 +2380,18 @@ void MWindow::set_proxy(int use_scaler, int new_scale, int auto_scale, } } } + for( int j=0,m=edl->clips.size(); jclips[j]; + for( Track *track=clip->tracks->first; track; track=track->next ) { + if( track->data_type != TRACK_VIDEO ) continue; + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + if( !edit->asset ) continue; + if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) { + edit->asset = proxy_asset; + } + } + } + } } } diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index 4774ecde..5aff535a 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -83,7 +83,9 @@ ProxyDialog::ProxyDialog(MWindow *mwindow) asset = new Asset; bzero(size_text, sizeof(char*) * MAX_SIZES); bzero(size_factors, sizeof(int) * MAX_SIZES); - total_sizes = 0; + size_text[0] = cstrdup(_("Original size")); + size_factors[0] = 1; + total_sizes = 1; } ProxyDialog::~ProxyDialog() @@ -207,6 +209,8 @@ void ProxyDialog::to_proxy() proxy->width = proxy->actual_width; proxy->height = proxy->actual_height; proxy->remove_user(); + mwindow->edl->assets->remove_pointer(proxy); + proxy->remove_user(); } proxy_assets.remove_all(); for( int i = 0; i < orig_idxbls.size(); i++ ) @@ -291,7 +295,7 @@ void ProxyRender::from_proxy_path(char *new_path, Asset *asset, int scale) char prxy[BCTEXTLEN]; int n = sprintf(prxy, ".proxy%d", scale); strcpy(new_path, asset->path); - char *ptr = strstr(asset->path, prxy); + char *ptr = strstr(new_path, prxy); if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return; // remove proxy, path.proxy#-sfx.ext => path.sfx char *ext = strrchr(ptr, '.'); @@ -454,9 +458,6 @@ void ProxyWindow::create_objects() add_subwindow(text = new BC_Title(x, y, _("Scale factor:"))); x += text->get_w() + margin; - dialog->size_text[0] = cstrdup(_("Original size")); - dialog->size_factors[0] = 1; - dialog->total_sizes = 1; int popupmenu_w = BC_PopupMenu::calculate_w(get_text_width(MEDIUMFONT, dialog->size_text[0])); add_subwindow(scale_factor = new ProxyMenu(mwindow, this, x, y, popupmenu_w, "")); scale_factor->update_sizes(); diff --git a/cinelerra-5.1/cinelerra/proxy.h b/cinelerra-5.1/cinelerra/proxy.h index c2ad5486..8726cb78 100644 --- a/cinelerra-5.1/cinelerra/proxy.h +++ b/cinelerra-5.1/cinelerra/proxy.h @@ -68,7 +68,7 @@ public: ProxyRender(MWindow *mwindow, Asset *format_asset); ~ProxyRender(); void to_proxy_path(char *new_path, Indexable *indexable, int scale); - void from_proxy_path(char *new_path, Asset *asset, int scale); + static void from_proxy_path(char *new_path, Asset *asset, int scale); ArrayList orig_idxbls; // originals which match the proxy assets ArrayList orig_proxies; // proxy assets