X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fcinelerra%2Fmwindow.C;h=2dbb5b3af5d818128b87a1f29aa1e8e33aaaab12;hb=2f1bbd12877daf745e1d18b62b731f04cece827e;hp=33cee066a515ecfff676d5b8ea90cc600d298f7d;hpb=95683646dce10ad3f6a8c8c9c9225c69f4841ec5;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 33cee066..2dbb5b3a 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -89,6 +89,7 @@ #include "pluginserver.h" #include "pluginset.h" #include "preferences.h" +#include "proxy.h" #include "record.h" #include "recordmonitor.h" #include "recordlabel.h" @@ -297,6 +298,9 @@ MWindow::~MWindow() #endif reset_caches(); dead_plugins->remove_all_objects(); +// must delete theme before destroying plugindb +// theme destructor will be deleted by delete_plugins + delete theme; theme = 0; delete_plugins(); finit_error(); keyframe_threads->remove_all_objects(); @@ -325,7 +329,6 @@ MWindow::~MWindow() delete defaults; defaults = 0; delete assets; assets = 0; delete splash_window; splash_window = 0; -// delete theme; theme = 0; // deleted by delete_plugins if( !edl->Garbage::remove_user() ) edl = 0; delete channeldb_buz; delete channeldb_v4l2jpeg; @@ -733,6 +736,66 @@ void MWindow::add_plugins(ArrayList &plugins) plugins.remove_all(); } +void MWindow::init_plugin_tips(ArrayList &plugins, const char *lang) +{ + const char *cfg_path = File::get_cindat_path(); + char msg_path[BCTEXTLEN]; int txt = 0; + FILE *fp = 0; + if( BC_Resources::language[0] ) { + snprintf(msg_path, sizeof(msg_path), "%s/info/plugins.%s", + cfg_path, lang); + fp = fopen(msg_path, "r"); + } + if( !fp ) { + txt = 1; + snprintf(msg_path, sizeof(msg_path), "%s/info/plugins.txt", + cfg_path); + fp = fopen(msg_path, "r"); + } + if( !fp ) return; + char text[BCTEXTLEN]; + char *tp = text, *ep = tp + sizeof(text)-1; + char title[BCTEXTLEN]; + title[0] = 0; + int no = 0; + for(;;) { + ++no; int done = 1; + char line[BCTEXTLEN], *cp = line; + if( fgets(line,sizeof(line)-1,fp) ) { + if( *cp == '#' ) continue; + done = *cp == ' ' || *cp == '\t' ? 0 : -1; + } + if( done ) { + if( tp > text && *--tp == '\n' ) *tp = 0; + if( title[0] ) { + tp = !txt ? title : _(title); + int idx = plugins.size(); + while( --idx>=0 && strcmp(plugins[idx]->title, tp) ); + if( idx >= 0 ) { + delete [] plugins[idx]->tip; + plugins[idx]->tip = cstrdup(text); + } + title[0] = 0; + } + if( done > 0 ) break; + tp = text; *tp = 0; + char *dp = strchr(cp, ':'); + if( !dp ) { + printf("plugin tips: error on line %d\n", no); + continue; + } + char *bp = title; + while( cp < dp ) *bp++ = *cp++; + *bp = 0; + ++cp; + } + + while( *cp == ' ' || *cp == '\t' ) ++cp; + for( ; tpremove_all_objects(); @@ -962,12 +1025,13 @@ void MWindow::init_theme() fprintf(stderr, _("MWindow::init_theme: prefered theme %s not found.\n"), preferences->theme); - if( !theme_plugin && strcasecmp(preferences->theme, DEFAULT_THEME) ) { + const char *default_theme = _(DEFAULT_THEME); + if( !theme_plugin && strcasecmp(preferences->theme, default_theme) ) { fprintf(stderr, _("MWindow::init_theme: trying default theme %s\n"), - DEFAULT_THEME); + default_theme); for(int i = 0; i < plugindb->total && !theme_plugin; i++) { if( plugindb->get(i)->theme && - !strcasecmp(DEFAULT_THEME, plugindb->get(i)->title) ) + !strcasecmp(default_theme, plugindb->get(i)->title) ) theme_plugin = plugindb->get(i); } } @@ -1431,14 +1495,10 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); if(load_mode != LOADMODE_RESOURCESONLY) { -SET_TRACE RecordLabels *labels = edl->session->label_cells ? new RecordLabels(new_file) : 0; -SET_TRACE asset_to_edl(new_edl, new_asset, labels); -SET_TRACE new_edls.append(new_edl); -SET_TRACE new_asset->Garbage::remove_user(); delete labels; new_asset = 0; @@ -1469,6 +1529,7 @@ SET_TRACE case FILE_NOT_FOUND: sprintf(string, _("Failed to open %s"), new_asset->path); gui->show_message(string, theme->message_error); + gui->update_default_message(); break; // Unknown format @@ -1665,10 +1726,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); edl->session->autos_follow_edits); } - paste_edls(&new_edls, - load_mode, - 0, - -1, + paste_edls(&new_edls, load_mode, 0, -1, edl->session->labels_follow_edits, edl->session->plugins_follow_edits, edl->session->autos_follow_edits, @@ -1743,10 +1801,6 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); show_plugin(plugin); } } - else - { - plugin->show = 0; - } plugin = (Plugin*)plugin->next; } @@ -1760,6 +1814,9 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); ( load_mode == LOADMODE_REPLACE || load_mode == LOADMODE_REPLACE_CONCATENATE ) ) { select_asset(0, 0); + edl->session->proxy_scale = 1; + edl->session->proxy_use_scaler = 0; + edl->session->proxy_auto_scale = 0; edl->local_session->preview_start = 0; edl->local_session->preview_end = edl->tracks->total_playable_length(); edl->local_session->loop_playback = 0; @@ -1770,6 +1827,27 @@ 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 ) ) { + ArrayList orig_idxbls; + for( int i=0; itracks->first; track; track=track->next ) { + if( track->data_type != TRACK_VIDEO ) continue; + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + Indexable *idxbl = (Indexable *)edit->asset; + if( !idxbl ) continue; + if( !idxbl->have_video() ) continue; + if( edit->channel != 0 ) continue; // first layer only + orig_idxbls.append(edit->asset); + } + } + } + render_proxy(orig_idxbls); + } + // need to update undo before project, since mwindow is unlocked & a new load // can begin here. Should really prevent loading until we're done. if(debug) printf("MWindow::load_filenames %d\n", __LINE__); @@ -1814,8 +1892,35 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); return 0; } +void MWindow::render_proxy(ArrayList &new_idxbls) +{ + Asset *format_asset = new Asset; + format_asset->format = FILE_FFMPEG; + format_asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); + ProxyRender proxy_render(this, format_asset); + int new_scale = edl->session->proxy_scale; + int use_scaler = edl->session->proxy_use_scaler; + for( int i=0; ipath) > 0 ? 1 : 0; + int got_it = exists && // if proxy exists, and is newer than orig + fs.get_date(proxy->path) > fs.get_date(orig->path) ? 1 : 0; + if( got_it ) continue; + proxy_render.add_needed(orig, proxy); + } +// render needed proxies + int result = proxy_render.create_needed_proxies(new_scale); + if( !result ) { + add_proxy(use_scaler, + &proxy_render.orig_idxbls, &proxy_render.orig_proxies); + } + format_asset->remove_user(); +} void MWindow::test_plugins(EDL *new_edl, char *path) { @@ -1928,7 +2033,6 @@ void MWindow::create_objects(int want_gui, int want_new, char *config_path) { - FileSystem fs; const int debug = 0; if(debug) PRINT_TRACE @@ -1952,6 +2056,7 @@ void MWindow::create_objects(int want_gui, if(debug) PRINT_TRACE init_ladspa_plugins(this, preferences); if(debug) PRINT_TRACE + init_plugin_tips(*plugindb, cin_lang); if(splash_window) splash_window->operation->update(_("Initializing GUI")); if(debug) PRINT_TRACE @@ -2508,12 +2613,11 @@ SET_TRACE SET_TRACE //printf("MWindow::show_plugin 1\n"); - if(!done) - { - if(!plugin->track) - { - printf("MWindow::show_plugin track not defined.\n"); - } + if( !done && !plugin->track ) { + printf("MWindow::show_plugin track not defined.\n"); + done = 1; + } + if( !done ) { PluginServer *server = scan_plugindb(plugin->title, plugin->track->data_type); @@ -2892,7 +2996,7 @@ void MWindow::update_project(int load_mode) const int debug = 0; if(debug) PRINT_TRACE - restart_brender(); + init_brender(); edl->tracks->update_y_pixels(theme); if(debug) PRINT_TRACE @@ -3254,7 +3358,8 @@ void MWindow::dump_exe(FILE *fp) char mtime[256]; strftime(mtime, sizeof(mtime), "%F %T", tm); fprintf(fp,"mtime: %s\n", mtime); - +#if 0 +// people hit ctl-c waiting for this int fd = open(proc_path,O_RDONLY+O_NONBLOCK); if( fd < 0 ) { fprintf(fp,"open: %m\n"); return; } uint8_t *bfr = 0; @@ -3279,6 +3384,7 @@ void MWindow::dump_exe(FILE *fp) for( int i=0; i<20; ++i ) fprintf(fp, "%02x", digest[i]); if( ret < 0 ) fprintf(fp, " (ret %d)", ret); if( pos < st.st_size ) fprintf(fp, " (pos %jd)", pos); +#endif fprintf(fp, "\n"); } @@ -3557,7 +3663,8 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra int result = file->open_file(preferences, asset, 1, 0); if( !result && delete_tracks > 0 ) undo->update_undo_before(); - if( !result && asset->video_data && asset->get_video_layers() > 0 ) { + int video_layers = asset->get_video_layers(); + if( !result && asset->video_data && vstream < video_layers ) { // try to get asset up to date, may fail file->select_video_stream(asset, vstream); // either way use what was/is there. @@ -3613,7 +3720,7 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra if( !result && asset->audio_data && asset->channels > 0 ) { session->sample_rate = asset->get_sample_rate(); int64_t channel_mask = 0; - int astrm = !asset->video_data ? -1 : + int astrm = !asset->video_data || vstream >= video_layers ? -1 : file->get_audio_for_video(vstream, astream, channel_mask); if( astrm >= 0 ) file->select_audio_stream(asset, astrm); if( astrm < 0 || !channel_mask ) channel_mask = (1<channels)-1;