From 5c3e5d5e76c29b49708b4e42d194402150b508ab Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sun, 1 Oct 2017 14:07:51 -0600 Subject: [PATCH] proxy cpus usage, unlock win before render_proxy, snap tweaks --- cinelerra-5.1/cinelerra/awindowgui.C | 147 ++++---------------------- cinelerra-5.1/cinelerra/edl.inc | 3 +- cinelerra-5.1/cinelerra/mwindow.C | 2 + cinelerra-5.1/cinelerra/mwindowmove.C | 14 +++ cinelerra-5.1/cinelerra/proxy.C | 4 +- cinelerra-5.1/cinelerra/tracksedit.C | 5 +- 6 files changed, 47 insertions(+), 128 deletions(-) diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 8b9a3ff4..dcc9aed3 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -77,7 +77,6 @@ const char *AWindowGUI::folder_names[] = N_("Clips"), N_("Media"), N_("Proxy"), - N_("User"), }; @@ -228,6 +227,7 @@ void AssetPicon::reset() label = 0; indexable = 0; edl = 0; + foldernum = AW_NO_FOLDER; icon = 0; icon_vframe = 0; vicon = 0; @@ -241,27 +241,22 @@ void AssetPicon::create_objects() FileSystem fs; char name[BCTEXTLEN]; int pixmap_w, pixmap_h; - const int debug = 0; pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale; - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); if( indexable ) { fs.extract_name(name, indexable->path); set_text(name); } if( indexable && indexable->is_asset ) { - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); Asset *asset = (Asset*)indexable; if( asset->video_data ) { if( mwindow->preferences->use_thumbnails ) { gui->unlock_window(); - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1); - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); if( file ) { int height = asset->height > 0 ? asset->height : 1; @@ -288,27 +283,26 @@ void AssetPicon::create_objects() mwindow->gui->show_message(string); mwindow->gui->unlock_window(); } file->read_frame(gui->temp_picon); - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); mwindow->video_cache->check_in(asset); gui->lock_window("AssetPicon::create_objects 1"); icon = new BC_Pixmap(gui, pixmap_w, pixmap_h); icon->draw_vframe(gui->temp_picon, 0, 0, pixmap_w, pixmap_h, 0, 0); -//printf("%d %d\n", gui->temp_picon->get_w(), gui->temp_picon->get_h()); icon_vframe = new VFrame(0, -1, pixmap_w, pixmap_h, BC_RGB888, -1); icon_vframe->transfer_from(gui->temp_picon); + if( asset->awindow_folder == AW_MEDIA_FOLDER ) { // vicon images - double framerate = asset->get_frame_rate(); - if( !framerate ) framerate = VICON_RATE; - int64_t frames = asset->get_video_frames(); - double secs = frames / framerate; - if( secs > 5 ) secs = 5; - int64_t length = secs * gui->vicon_thread->refresh_rate; - vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length); - gui->vicon_thread->add_vicon(vicon); - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); + double framerate = asset->get_frame_rate(); + if( !framerate ) framerate = VICON_RATE; + int64_t frames = asset->get_video_frames(); + double secs = frames / framerate; + if( secs > 5 ) secs = 5; + int64_t length = secs * gui->vicon_thread->refresh_rate; + vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length); + gui->vicon_thread->add_vicon(vicon); + } } else { @@ -327,9 +321,7 @@ void AssetPicon::create_objects() icon = gui->audio_icon; icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND]; } -//printf("AssetPicon::create_objects 2\n"); - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); } else if( indexable && !indexable->is_asset ) { @@ -338,7 +330,6 @@ void AssetPicon::create_objects() } else if( edl ) { -//printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title); set_text(strcpy(name, edl->local_session->clip_title)); icon = gui->clip_icon; icon_vframe = mwindow->theme->get_image("clip_icon"); @@ -403,26 +394,14 @@ void AssetPicon::create_objects() } set_icon(icon); set_icon_vframe(icon_vframe); - - if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__); } - - - - - AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow) : BC_Window(_(PROGRAM_NAME ": Resources"), mwindow->session->awindow_x, mwindow->session->awindow_y, mwindow->session->awindow_w, mwindow->session->awindow_h, 100, 100, 1, 1, 1) { -// printf("AWindowGUI::AWindowGUI %d %d %d %d\n", -// mwindow->session->awindow_x, -// mwindow->session->awindow_y, -// mwindow->session->awindow_w, -// mwindow->session->awindow_h); this->mwindow = mwindow; this->awindow = awindow; file_icon = 0; @@ -550,12 +529,9 @@ VFrame *AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, void AWindowGUI::create_objects() { lock_window("AWindowGUI::create_objects"); -SET_TRACE -//printf("AWindowGUI::create_objects 1\n"); asset_titles[0] = _("Title"); asset_titles[1] = _("Comments"); -SET_TRACE set_icon(mwindow->theme->get_image("awindow_icon")); file_res = resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN); @@ -574,8 +550,6 @@ SET_TRACE ff_aud_res = plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png); ff_vid_res = plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png); -SET_TRACE - // Mandatory folders folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1)); folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1)); @@ -587,12 +561,10 @@ SET_TRACE folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1)); create_label_folder(); -SET_TRACE mwindow->theme->get_awindow_sizes(this); load_defaults(mwindow->defaults); -SET_TRACE add_subwindow(asset_list = new AWindowAssets(mwindow, this, mwindow->theme->alist_x, @@ -603,7 +575,6 @@ SET_TRACE vicon_thread = new VIconThread(asset_list); vicon_thread->start(); -SET_TRACE add_subwindow(divider = new AWindowDivider(mwindow, this, mwindow->theme->adivider_x, @@ -611,10 +582,8 @@ SET_TRACE mwindow->theme->adivider_w, mwindow->theme->adivider_h)); -SET_TRACE divider->set_cursor(HSEPARATE_CURSOR, 0, 0); -SET_TRACE int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y; int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h; VFrame **images = mwindow->theme->get_image_set("playpatch_data"); @@ -623,17 +592,13 @@ SET_TRACE add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility"))); add_tools->create_objects(); fy += add_tools->get_h(); fh -= add_tools->get_h(); -SET_TRACE add_subwindow(folder_list = new AWindowFolders(mwindow, this, fx, fy, fw, fh)); -SET_TRACE update_effects(); -SET_TRACE //int x = mwindow->theme->abuttons_x; //int y = mwindow->theme->abuttons_y; -SET_TRACE newfolder_thread = new NewFolderThread(mwindow, this); @@ -652,12 +617,9 @@ SET_TRACE cliplist_menu->create_objects(); add_subwindow(labellist_menu = new LabelListMenu(mwindow, this)); labellist_menu->create_objects(); -SET_TRACE add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this)); folderlist_menu->create_objects(); -SET_TRACE -//printf("AWindowGUI::create_objects 2\n"); create_custom_xatoms(); unlock_window(); @@ -927,26 +889,18 @@ void AWindowGUI::async_update_assets() } - - - - - void AWindowGUI::update_folder_list() { stop_vicon_drawing(); -//printf("AWindowGUI::update_folder_list 1\n"); for( int i = 0; i < folders.total; i++ ) { AssetPicon *picon = (AssetPicon*)folders.values[i]; picon->in_use--; } -//printf("AWindowGUI::update_folder_list 1\n"); // Search assets for folders for( int i = 0; i < mwindow->edl->folders.total; i++ ) { const char *folder = mwindow->edl->folders.values[i]; int exists = 0; -//printf("AWindowGUI::update_folder_list 1.1\n"); for( int j = 0; j < folders.total; j++ ) { AssetPicon *picon = (AssetPicon*)folders.values[j]; @@ -959,19 +913,15 @@ void AWindowGUI::update_folder_list() if( !exists ) { int aw_folder = folder_number(folder); - AssetPicon *picon = aw_folder >= 0 ? - new AssetPicon(mwindow, this, aw_folder, 0) : - new AssetPicon(mwindow, this, folder, AW_USER_FOLDER); - picon->create_objects(); - folders.append(picon); + if( aw_folder >= 0 ) { + AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1); + picon->create_objects(); + folders.append(picon); + } } -//printf("AWindowGUI::update_folder_list 1.3\n"); } -//printf("AWindowGUI::update_folder_list 1\n"); -//for( int i = 0; i < folders.total; i++ ) -// printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text()); -// Delete excess +// Delete unused non-persistent folders for( int i=folders.total; --i>=0; ) { AssetPicon *picon = (AssetPicon*)folders.values[i]; if( !picon->in_use && !picon->persistent ) { @@ -979,9 +929,7 @@ void AWindowGUI::update_folder_list() folders.remove_number(i); } } -//for( int i = 0; i < folders.total; i++ ) -// printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text()); -//printf("AWindowGUI::update_folder_list 2\n"); + start_vicon_drawing(); } @@ -1017,19 +965,11 @@ void AWindowGUI::create_label_folder() void AWindowGUI::update_asset_list() { -//printf("AWindowGUI::update_asset_list 1\n"); for( int i = 0; i < assets.total; i++ ) { AssetPicon *picon = (AssetPicon*)assets.values[i]; picon->in_use--; } - - - - -//printf("AWindowGUI::update_asset_list 2\n"); - - // Synchronize EDL clips for( int i = 0; i < mwindow->edl->clips.total; i++ ) { int exists = 0; @@ -1049,20 +989,12 @@ void AWindowGUI::update_asset_list() // Create new listitem if( !exists ) { AssetPicon *picon = new AssetPicon(mwindow, - this, - mwindow->edl->clips.values[i]); + this, mwindow->edl->clips.values[i]); picon->create_objects(); assets.append(picon); } } - - - - -//printf("AWindowGUI::update_asset_list %d\n", __LINE__); - - // Synchronize EDL assets for( Asset *current = mwindow->edl->assets->first; current; @@ -1083,11 +1015,9 @@ void AWindowGUI::update_asset_list() // Create new listitem if( !exists ) { -//printf("AWindowGUI::update_asset_list %d\n", __LINE__); - AssetPicon *picon = new AssetPicon(mwindow, this, current); -//printf("AWindowGUI::update_asset_list %d\n", __LINE__); + AssetPicon *picon = new AssetPicon(mwindow, + this, current); picon->create_objects(); -//printf("AWindowGUI::update_asset_list %d\n", __LINE__); assets.append(picon); } } @@ -1096,9 +1026,6 @@ void AWindowGUI::update_asset_list() mwindow->gui->default_message(); mwindow->gui->unlock_window(); -//printf("AWindowGUI::update_asset_list %d\n", __LINE__); - - // Synchronize nested EDLs for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) { int exists = 0; @@ -1119,36 +1046,23 @@ void AWindowGUI::update_asset_list() // Create new listitem if( !exists ) { AssetPicon *picon = new AssetPicon(mwindow, - this, - indexable); + this, indexable); picon->create_objects(); assets.append(picon); } } - - - - - - - - -//printf("AWindowGUI::update_asset_list %d\n", __LINE__); for( int i = assets.size() - 1; i >= 0; i-- ) { AssetPicon *picon = (AssetPicon*)assets.get(i); -//printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use); if( !picon->in_use ) { delete picon; assets.remove_number(i); } } -//printf("AWindowGUI::update_asset_list 7 %d\n", assets.total); } void AWindowGUI::update_picon(Indexable *indexable) { -//printf("AWindowGUI::update_asset_list 1\n"); VIcon *vicon = 0; for( int i = 0; i < assets.total; i++ ) { AssetPicon *picon = (AssetPicon*)assets.values[i]; @@ -1172,7 +1086,6 @@ void AWindowGUI::update_picon(Indexable *indexable) void AWindowGUI::sort_assets() { -//printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder); switch( mwindow->edl->session->awindow_folder ) { case AW_AEFFECT_FOLDER: sort_picons(&aeffects); @@ -1219,10 +1132,8 @@ void AWindowGUI::copy_picons(ArrayList *dst, dst[1].remove_all_objects(); // Create new pointers -//if( folder ) printf("AWindowGUI::copy_picons 1 %s\n", folder); for( int i = 0; i < src->total; i++ ) { AssetPicon *picon = (AssetPicon*)src->values[i]; -//printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder); if( folder < 0 || (picon->indexable && picon->indexable->awindow_folder == folder) || (picon->edl && picon->edl->local_session->awindow_folder == folder) ) { @@ -1237,14 +1148,12 @@ void AWindowGUI::copy_picons(ArrayList *dst, dst[1].append(item2 = new BC_ListBoxItem("")); item1->set_autoplace_text(1); item2->set_autoplace_text(1); -//printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text()); } } } void AWindowGUI::sort_picons(ArrayList *src) { -//printf("AWindowGUI::sort_picons 1\n") int done = 0; while(!done) { @@ -1308,16 +1217,12 @@ void AWindowGUI::filter_displayed_assets() void AWindowGUI::update_assets() { -//printf("AWindowGUI::update_assets 1\n"); update_folder_list(); -//printf("AWindowGUI::update_assets 2\n"); update_asset_list(); labellist.remove_all_objects(); create_label_folder(); -//printf("AWindowGUI::update_assets 3\n"); filter_displayed_assets(); -//printf("AWindowGUI::update_assets 4\n"); if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) { folder_list->update_format(mwindow->edl->session->folderlist_format, 0); } @@ -1325,7 +1230,6 @@ void AWindowGUI::update_assets() int folder_yposition = folder_list->get_yposition(); folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1); -//printf("AWindowGUI::update_assets 5\n"); if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) { asset_list->update_format(mwindow->edl->session->assetlist_format, 0); } @@ -1339,10 +1243,8 @@ void AWindowGUI::update_assets() mwindow->edl->session->asset_columns, ASSET_COLUMNS, asset_xposition, asset_yposition, -1, 0); asset_list->center_selection(); -//printf("AWindowGUI::update_assets 7\n"); flush(); -//printf("AWindowGUI::update_assets 8\n"); return; } @@ -1489,8 +1391,7 @@ int AWindowFolders::selection_changed() gui->folderlist_menu->activate_menu(); } - mwindow->edl->session->awindow_folder = picon->foldernum; -//printf("AWindowFolders::selection_changed 1\n"); + mwindow->edl->session->awindow_folder = picon->foldernum; gui->asset_list->draw_background(); gui->async_update_assets(); @@ -1587,7 +1488,6 @@ int AWindowAssets::button_press_event() int AWindowAssets::handle_event() { -//printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0)); AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0); if( !asset_picon ) return 0; switch( mwindow->edl->session->awindow_folder ) { @@ -1599,7 +1499,6 @@ int AWindowAssets::handle_event() VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ? mwindow->vwindows.get(DEFAULT_VWINDOW) : 0; if( !vwindow || !vwindow->is_running() ) return 1; -//printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0)); vwindow->gui->lock_window("AWindowAssets::handle_event"); if( asset_picon->indexable ) diff --git a/cinelerra-5.1/cinelerra/edl.inc b/cinelerra-5.1/cinelerra/edl.inc index a6ecb427..0b6f218a 100644 --- a/cinelerra-5.1/cinelerra/edl.inc +++ b/cinelerra-5.1/cinelerra/edl.inc @@ -63,8 +63,7 @@ class EDL; #define AW_CLIP_FOLDER 5 #define AW_MEDIA_FOLDER 6 #define AW_PROXY_FOLDER 7 -#define AW_USER_FOLDER 8 -#define AWINDOW_FOLDERS 9 +#define AWINDOW_FOLDERS 8 #define AWINDOW_MODES 2 diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 2dbb5b3a..633af24a 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -1845,7 +1845,9 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); } } } + gui->unlock_window(); // to update progress bar render_proxy(orig_idxbls); + gui->lock_window("MWindow::load_filenames"); } // need to update undo before project, since mwindow is unlocked & a new load diff --git a/cinelerra-5.1/cinelerra/mwindowmove.C b/cinelerra-5.1/cinelerra/mwindowmove.C index cffc71df..08a623f8 100644 --- a/cinelerra-5.1/cinelerra/mwindowmove.C +++ b/cinelerra-5.1/cinelerra/mwindowmove.C @@ -695,6 +695,12 @@ int MWindow::next_edit_handle(int shift_down) double position = edl->local_session->get_selectionend(1); Units::fix_double(&position); double new_position = INFINITY; + + double max_rate = edl->get_frame_rate(); + int sample_rate = edl->get_sample_rate(); + if( sample_rate > max_rate ) max_rate = sample_rate; + double min_movement = max_rate > 0 ? 1. / max_rate : 1e-6; + // Test for edit handles after cursor position for (Track *track = edl->tracks->first; track; track = track->next) { @@ -704,6 +710,7 @@ int MWindow::next_edit_handle(int shift_down) { double edit_end = track->from_units(edit->startproject + edit->length); Units::fix_double(&edit_end); + if( fabs(edit_end-position) < min_movement ) continue; if (edit_end > position && edit_end < new_position) new_position = edit_end; } @@ -761,6 +768,12 @@ int MWindow::prev_edit_handle(int shift_down) double position = edl->local_session->get_selectionstart(1); double new_position = -1; Units::fix_double(&position); + + double max_rate = edl->get_frame_rate(); + int sample_rate = edl->get_sample_rate(); + if( sample_rate > max_rate ) max_rate = sample_rate; + double min_movement = max_rate > 0 ? 1. / max_rate : 1e-6; + // Test for edit handles before cursor position for (Track *track = edl->tracks->first; track; track = track->next) { @@ -770,6 +783,7 @@ int MWindow::prev_edit_handle(int shift_down) { double edit_end = track->from_units(edit->startproject); Units::fix_double(&edit_end); + if( fabs(edit_end-position) < min_movement ) continue; if (edit_end < position && edit_end > new_position) new_position = edit_end; } diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index 3378c6ed..d8ef2420 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -338,6 +338,7 @@ Asset *ProxyRender::add_original(Indexable *idxbl, int new_scale) proxy = new Asset(new_path); // new compression parameters proxy->copy_format(format_asset, 0); + proxy->awindow_folder = AW_PROXY_FOLDER; proxy->audio_data = 0; proxy->video_data = 1; proxy->layers = 1; @@ -673,7 +674,8 @@ void ProxyClient::process_package(LoadPackage *ptr) Asset *proxy = package->proxy_asset; //printf("%s %s\n", orig->path, proxy->path); VRender *vrender = 0; - int processors = 1, result = 0; + int jobs = proxy_render->needed_proxies.size(); + int processors = preferences->project_smp / jobs + 1, result = 0; if( orig->is_asset ) { src_file = new File; diff --git a/cinelerra-5.1/cinelerra/tracksedit.C b/cinelerra-5.1/cinelerra/tracksedit.C index 18ca87d1..971a005f 100644 --- a/cinelerra-5.1/cinelerra/tracksedit.C +++ b/cinelerra-5.1/cinelerra/tracksedit.C @@ -623,6 +623,9 @@ void Tracks::move_edits(ArrayList *edits, { // This works like this: CUT edit, INSERT edit at final position, keyframes also follow // FIXME: there should be a GUI way to tell whenever user also wants to move autos or not +// this is all screwed up +// inserts defaults/bogus everywhere +#if 0 // Copy keyframes FileXML temp; AutoConf temp_autoconf; @@ -655,7 +658,7 @@ void Tracks::move_edits(ArrayList *edits, dest_track->automation->paste(position_a, source_length, 1.0, &temp, 0, 1, &temp_autoconf); - +#endif // Insert new edit Edit *dest_edit = dest_track->edits->shift(position_i, source_length); -- 2.26.2