From: Good Guy Date: Fri, 29 Sep 2017 01:40:08 +0000 (-0600) Subject: sams latest icons, rework proxy settings X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=2f1bbd12877daf745e1d18b62b731f04cece827e;p=goodguy%2Fhistory.git sams latest icons, rework proxy settings --- diff --git a/cinelerra-5.1/cfg-cv.sh b/cinelerra-5.1/cfg-cv.sh index 3ae46732..153a526b 100755 --- a/cinelerra-5.1/cfg-cv.sh +++ b/cinelerra-5.1/cfg-cv.sh @@ -75,8 +75,8 @@ export MJPEG_CFLAGS="-I$THIRDPARTY/mjpegtools-2.1.0/. \ -I$THIRDPARTY/mjpegtools-2.1.0/lavtools \ -I$THIRDPARTY/mjpegtools-2.1.0/utils" -export LIBX264_CFLAGS="-I$THIRDPARTY/x264-20151229/." -export LIBX264_LIBS="-L$THIRDPARTY/x264-20151229/. -lx264" +export LIBX264_CFLAGS="-I$THIRDPARTY/x264-snapshot-20160220-2245-stable/." +export LIBX264_LIBS="-L$THIRDPARTY/x264-snapshot-20160220-2245-stable/. -lx264" for f in $MJPEG_LIBS $LIBX264_LIBS; do LIBS=`echo "$LIBS" | sed -e "s;[ ]*\<$f\>[ ]*; ;"` diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 90287ac9..8b9a3ff4 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -76,7 +76,8 @@ const char *AWindowGUI::folder_names[] = N_("Labels"), N_("Clips"), N_("Media"), - N_("User") + N_("Proxy"), + N_("User"), }; @@ -582,6 +583,7 @@ SET_TRACE folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1)); folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1)); folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1)); + folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1)); folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1)); create_label_folder(); @@ -970,7 +972,7 @@ void AWindowGUI::update_folder_list() // printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text()); // Delete excess - for( int i = folders.total - 1; i >= 0; i-- ) { + for( int i=folders.total; --i>=0; ) { AssetPicon *picon = (AssetPicon*)folders.values[i]; if( !picon->in_use && !picon->persistent ) { delete picon; @@ -1295,10 +1297,12 @@ void AWindowGUI::filter_displayed_assets() } // Ensure the current folder icon is highlighted - for( int i = 0; i < folders.total; i++ ) - folders.values[i]->set_selected(0); - - folders.values[mwindow->edl->session->awindow_folder]->set_selected(1); + int selected_folder = mwindow->edl->session->awindow_folder; + for( int i = 0; i < folders.total; i++ ) { + AssetPicon *folder_item = (AssetPicon *)folders.values[i]; + int selected = folder_item->foldernum == selected_folder ? 1 : 0; + folder_item->set_selected(selected); + } } @@ -1569,6 +1573,7 @@ int AWindowAssets::button_press_event() gui->cliplist_menu->activate_menu(); break; case AW_MEDIA_FOLDER: + case AW_PROXY_FOLDER: gui->assetlist_menu->update_titles(); gui->assetlist_menu->activate_menu(); break; diff --git a/cinelerra-5.1/cinelerra/edl.inc b/cinelerra-5.1/cinelerra/edl.inc index 83d7b13d..a6ecb427 100644 --- a/cinelerra-5.1/cinelerra/edl.inc +++ b/cinelerra-5.1/cinelerra/edl.inc @@ -62,8 +62,9 @@ class EDL; #define AW_LABEL_FOLDER 4 #define AW_CLIP_FOLDER 5 #define AW_MEDIA_FOLDER 6 -#define AW_USER_FOLDER 7 -#define AWINDOW_FOLDERS 8 +#define AW_PROXY_FOLDER 7 +#define AW_USER_FOLDER 8 +#define AWINDOW_FOLDERS 9 #define AWINDOW_MODES 2 diff --git a/cinelerra-5.1/cinelerra/edlsession.C b/cinelerra-5.1/cinelerra/edlsession.C index 1ad03070..5876b919 100644 --- a/cinelerra-5.1/cinelerra/edlsession.C +++ b/cinelerra-5.1/cinelerra/edlsession.C @@ -87,7 +87,6 @@ EDLSession::EDLSession(EDL *edl) interpolate_raw = 1; white_balance_raw = 1; labels_follow_edits = 1; - mpeg4_deblock = 1; plugins_follow_edits = 1; single_standalone = 1; meter_format = METER_DB; @@ -98,8 +97,9 @@ EDLSession::EDLSession(EDL *edl) playback_buffer = 4096; playback_cursor_visible = 0; playback_preload = 0; - proxy_use_scaler = 0; proxy_scale = 1; + proxy_use_scaler = 0; + proxy_auto_scale = 1; decode_subtitles = 0; subtitle_number = 0; label_cells = 0; @@ -167,9 +167,7 @@ int EDLSession::need_rerender(EDLSession *ptr) (decode_subtitles != ptr->decode_subtitles) || (subtitle_number != ptr->subtitle_number) || (interpolate_raw != ptr->interpolate_raw) || - (white_balance_raw != ptr->white_balance_raw) || - (proxy_use_scaler != ptr->proxy_use_scaler) || - (proxy_scale != ptr->proxy_scale)); + (white_balance_raw != ptr->white_balance_raw)); } void EDLSession::equivalent_output(EDLSession *session, double *result) @@ -181,11 +179,10 @@ void EDLSession::equivalent_output(EDLSession *session, double *result) session->interpolation_type != interpolation_type || session->interpolate_raw != interpolate_raw || session->white_balance_raw != white_balance_raw || - session->mpeg4_deblock != mpeg4_deblock || session->decode_subtitles != decode_subtitles || session->subtitle_number != subtitle_number || - session->proxy_use_scaler != proxy_use_scaler || - session->proxy_scale != proxy_scale ) + session->proxy_scale != proxy_scale || + session->proxy_use_scaler != proxy_use_scaler ) *result = 0; // If it's before the current brender_start, render extra data. @@ -279,7 +276,6 @@ int EDLSession::load_defaults(BC_Hash *defaults) meter_format = defaults->get("METER_FORMAT", METER_DB); min_meter_db = defaults->get("MIN_METER_DB", -85); max_meter_db = defaults->get("MAX_METER_DB", 6); - mpeg4_deblock = defaults->get("MPEG4_DEBLOCK", mpeg4_deblock); output_w = defaults->get("OUTPUTW", output_w); output_h = defaults->get("OUTPUTH", output_h); playback_buffer = defaults->get("PLAYBACK_BUFFER", 4096); @@ -421,7 +417,6 @@ int EDLSession::save_defaults(BC_Hash *defaults) defaults->update("METER_FORMAT", meter_format); defaults->update("MIN_METER_DB", min_meter_db); defaults->update("MAX_METER_DB", max_meter_db); - defaults->update("MPEG4_DEBLOCK", mpeg4_deblock); defaults->update("OUTPUTW", output_w); defaults->update("OUTPUTH", output_h); defaults->update("PLAYBACK_BUFFER", playback_buffer); @@ -553,8 +548,9 @@ int EDLSession::load_video_config(FileXML *file, int append_mode, uint32_t load_ output_h = file->tag.get_property("OUTPUTH", output_h); aspect_w = file->tag.get_property("ASPECTW", aspect_w); aspect_h = file->tag.get_property("ASPECTH", aspect_h); - proxy_use_scaler = file->tag.get_property("PROXY_USE_SCALER", proxy_use_scaler); proxy_scale = file->tag.get_property("PROXY_SCALE", proxy_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); return 0; } @@ -628,7 +624,6 @@ int EDLSession::load_xml(FileXML *file, folderlist_format = file->tag.get_property("FOLDERLIST_FORMAT", folderlist_format); highlighted_track = file->tag.get_property("HIGHLIGHTED_TRACK", 0); labels_follow_edits = file->tag.get_property("LABELS_FOLLOW_EDITS", labels_follow_edits); - mpeg4_deblock = file->tag.get_property("MPEG4_DEBLOCK", mpeg4_deblock); plugins_follow_edits = file->tag.get_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits); single_standalone = file->tag.get_property("SINGLE_STANDALONE", single_standalone); playback_preload = file->tag.get_property("PLAYBACK_PRELOAD", playback_preload); @@ -692,7 +687,6 @@ int EDLSession::save_xml(FileXML *file) file->tag.set_property("FOLDERLIST_FORMAT", folderlist_format); file->tag.set_property("HIGHLIGHTED_TRACK", highlighted_track); file->tag.set_property("LABELS_FOLLOW_EDITS", labels_follow_edits); - file->tag.set_property("MPEG4_DEBLOCK", mpeg4_deblock); file->tag.set_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits); file->tag.set_property("SINGLE_STANDALONE", single_standalone); file->tag.set_property("PLAYBACK_PRELOAD", playback_preload); @@ -744,8 +738,9 @@ 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_USE_SCALER", proxy_use_scaler); file->tag.set_property("PROXY_SCALE", proxy_scale); + file->tag.set_property("PROXY_USE_SCALER", proxy_use_scaler); + file->tag.set_property("PROXY_AUTO_SCALE", proxy_auto_scale); file->append_tag(); file->tag.set_title("/VIDEO"); file->append_tag(); @@ -841,7 +836,6 @@ int EDLSession::copy(EDLSession *session) meter_format = session->meter_format; min_meter_db = session->min_meter_db; max_meter_db = session->max_meter_db; - mpeg4_deblock = session->mpeg4_deblock; output_w = session->output_w; output_h = session->output_h; playback_buffer = session->playback_buffer; @@ -884,8 +878,9 @@ int EDLSession::copy(EDLSession *session) view_follows_playback = session->view_follows_playback; vwindow_meter = session->vwindow_meter; vwindow_zoom = session->vwindow_zoom; - proxy_use_scaler = session->proxy_use_scaler; proxy_scale = session->proxy_scale; + proxy_use_scaler = session->proxy_use_scaler; + proxy_auto_scale = session->proxy_auto_scale; subtitle_number = session->subtitle_number; decode_subtitles = session->decode_subtitles; @@ -901,10 +896,10 @@ void EDLSession::dump() 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_use_scaler=%d, proxy_scale=%d\n", + " proxy_scale=%d\n proxy_use_scaler=%d, proxy_auto_scale=%d\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_use_scaler, proxy_scale); + proxy_scale, proxy_use_scaler, proxy_auto_scale); } diff --git a/cinelerra-5.1/cinelerra/edlsession.h b/cinelerra-5.1/cinelerra/edlsession.h index 28c3c623..d5d610ee 100644 --- a/cinelerra-5.1/cinelerra/edlsession.h +++ b/cinelerra-5.1/cinelerra/edlsession.h @@ -141,7 +141,6 @@ public: int white_balance_raw; // labels follow edits during editing int labels_follow_edits; - int mpeg4_deblock; int plugins_follow_edits; // For main menu plugin attaching, // // attach 1 standalone on the first track and share it with other tracks @@ -160,7 +159,11 @@ public: int program_no; int playback_software_position; // current settings are scaled this much from the original settings - int proxy_use_scaler, proxy_scale; + int proxy_scale; +// upscale geom from proxy to session on read in + int proxy_use_scaler; +// automatically rescale assets when loaded + int proxy_auto_scale; // int playback_strategy; // Play audio in realtime priority int real_time_playback; diff --git a/cinelerra-5.1/cinelerra/mainsession.C b/cinelerra-5.1/cinelerra/mainsession.C index b9c18df6..4ff969fd 100644 --- a/cinelerra-5.1/cinelerra/mainsession.C +++ b/cinelerra-5.1/cinelerra/mainsession.C @@ -385,7 +385,7 @@ int MainSession::load_defaults(BC_Hash *defaults) //printf("MainSession::load_defaults 1\n"); // Other windows - afolders_w = defaults->get("ABINS_W", 140); + afolders_w = defaults->get("ABINS_W", 200); rwindow_x = defaults->get("RWINDOW_X", rwindow_x); rwindow_y = defaults->get("RWINDOW_Y", rwindow_y); rwindow_w = defaults->get("RWINDOW_W", rwindow_w); diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 6a639671..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" @@ -1494,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; @@ -1817,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; @@ -1827,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__); @@ -1871,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) { @@ -1985,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 @@ -2957,8 +3004,6 @@ void MWindow::update_project(int load_mode) if(load_mode == LOADMODE_REPLACE || load_mode == LOADMODE_REPLACE_CONCATENATE) { - edl->session->proxy_scale = 1; - edl->session->proxy_use_scaler = 0; gui->load_panes(); } diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index a97e85ba..2ada7db3 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -492,8 +492,13 @@ public: int modify_edithandles(); int modify_pluginhandles(); void finish_modify_handles(); - void set_proxy(int use_scaler, int new_scale, - ArrayList *orig_assets, ArrayList *proxy_assets); + void set_proxy(int use_scaler, int new_scale, int auto_scale, + ArrayList *orig_assets, + ArrayList *proxy_assets); + void add_proxy(int use_scaler, + ArrayList *orig_assets, + ArrayList *proxy_assets); + void render_proxy(ArrayList &new_idxbls); void dump_plugins(FILE *fp=stdout); void dump_edl(FILE *fp=stdout); diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 85b5f743..9d1a9dfc 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -2274,14 +2274,16 @@ void MWindow::remap_audio(int pattern) } } -void MWindow::set_proxy(int use_scaler, int new_scale, - ArrayList *orig_assets, ArrayList *proxy_assets) +void MWindow::set_proxy(int use_scaler, int new_scale, int auto_scale, + ArrayList *orig_assets, + ArrayList *proxy_assets) { int orig_use_scaler = edl->session->proxy_use_scaler; int orig_scale = edl->session->proxy_scale; // rescale to full size asset in read_frame edl->session->proxy_use_scaler = use_scaler; edl->session->proxy_scale = new_scale; + edl->session->proxy_auto_scale = auto_scale; if( use_scaler ) { for( int i=0; isize(); ++i ) { @@ -2320,8 +2322,39 @@ void MWindow::set_proxy(int use_scaler, int new_scale, } // change original assets to proxy assets - for( int i=0; isize(); i++ ) { + int awindow_folder = use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER; + for( int i=0,n=proxy_assets->size(); iassets->update((Asset *)proxy_assets->get(i)); + proxy_asset->awindow_folder = awindow_folder; +// replace track contents + for( Track *track = edl->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; + } + } + } + } +} + +void MWindow::add_proxy(int use_scaler, + ArrayList *orig_assets, + ArrayList *proxy_assets) +{ + if( use_scaler ) { + for( int i=0,n=proxy_assets->size(); iget(i); + proxy_asset->width = orig_assets->get(i)->get_w(); + proxy_asset->height = orig_assets->get(i)->get_h(); + } + } + +// change original assets to proxy assets + for( int i=0,n=proxy_assets->size(); iassets->update((Asset *)proxy_assets->get(i)); + proxy_asset->awindow_folder = AW_PROXY_FOLDER; // replace track contents for( Track *track = edl->tracks->first; track; track = track->next ) { if( track->data_type != TRACK_VIDEO ) continue; diff --git a/cinelerra-5.1/cinelerra/playbackprefs.h b/cinelerra-5.1/cinelerra/playbackprefs.h index 9b1c3243..167d3bd6 100644 --- a/cinelerra-5.1/cinelerra/playbackprefs.h +++ b/cinelerra-5.1/cinelerra/playbackprefs.h @@ -32,7 +32,6 @@ class PlaybackRealTime; class PlaybackMap51_2; class VideoAsynchronous; class VideoEveryFrame; -class PlaybackDeblock; class PlaybackPreload; class PlaybackInterpolateRaw; class PlaybackWhiteBalanceRaw; @@ -69,7 +68,6 @@ public: PlaybackConfig *playback_config; BC_Title *framerate_title; - PlaybackDeblock *mpeg4_deblock; PlaybackInterpolateRaw *interpolate_raw; PlaybackWhiteBalanceRaw *white_balance_raw; VideoAsynchronous *asynchronous; @@ -157,14 +155,6 @@ public: PlaybackPrefs *playback_prefs; }; -class PlaybackDeblock : public BC_CheckBox -{ -public: - PlaybackDeblock(PreferencesWindow *pwindow, int x, int y); - int handle_event(); - PreferencesWindow *pwindow; -}; - class PlaybackPreload : public BC_TextBox { public: diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index d126cf14..90c02a73 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -21,6 +21,7 @@ #include "assets.h" #include "bcsignals.h" +#include "cache.h" #include "clip.h" #include "confirmsave.h" #include "cstrdup.h" @@ -31,6 +32,7 @@ #include "filesystem.h" #include "formattools.h" #include "language.h" +#include "mainerror.h" #include "mainprogress.h" #include "mainundo.h" #include "mutex.h" @@ -39,10 +41,13 @@ #include "overlayframe.h" #include "preferences.h" #include "proxy.h" +#include "renderengine.h" #include "theme.h" +#include "transportque.h" +#include "vrender.h" #define WIDTH 400 -#define HEIGHT 320 +#define HEIGHT 285 #define MAX_SCALE 16 ProxyMenuItem::ProxyMenuItem(MWindow *mwindow) @@ -54,50 +59,49 @@ ProxyMenuItem::ProxyMenuItem(MWindow *mwindow) void ProxyMenuItem::create_objects() { - thread = new ProxyThread(mwindow); + dialog = new ProxyDialog(mwindow); } int ProxyMenuItem::handle_event() { mwindow->gui->unlock_window(); - thread->start(); + dialog->start(); mwindow->gui->lock_window("ProxyMenuItem::handle_event"); return 1; } -ProxyThread::ProxyThread(MWindow *mwindow) +ProxyDialog::ProxyDialog(MWindow *mwindow) { this->mwindow = mwindow; gui = 0; asset = new Asset; - progress = 0; - counter_lock = new Mutex("ProxyThread::counter_lock"); bzero(size_text, sizeof(char*) * MAX_SIZES); bzero(size_factors, sizeof(int) * MAX_SIZES); total_sizes = 0; } -ProxyThread::~ProxyThread() + +ProxyDialog::~ProxyDialog() { + close_window(); for( int i=0; iremove_user(); } -BC_Window* ProxyThread::new_gui() +BC_Window* ProxyDialog::new_gui() { asset->format = FILE_FFMPEG; asset->load_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0); - mwindow->gui->lock_window("ProxyThread::new_gui"); - int x = mwindow->gui->get_abs_cursor_x(0) - WIDTH / 2; - int y = mwindow->gui->get_abs_cursor_y(0) - HEIGHT / 2; - - gui = new ProxyWindow(mwindow, this, x, y); + mwindow->gui->lock_window("ProxyDialog::new_gui"); + int cx, cy; + mwindow->gui->get_abs_cursor_xy(cx, cy); + gui = new ProxyWindow(mwindow, this, cx - WIDTH/2, cy - HEIGHT/2); gui->create_objects(); mwindow->gui->unlock_window(); return gui; } -void ProxyThread::scale_to_text(char *string, int scale) +void ProxyDialog::scale_to_text(char *string, int scale) { strcpy(string, size_text[0]); for( int i = 0; i < total_sizes; i++ ) { @@ -109,7 +113,7 @@ void ProxyThread::scale_to_text(char *string, int scale) } -void ProxyThread::calculate_sizes() +void ProxyDialog::calculate_sizes() { for( int i=1; isave_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0); @@ -154,38 +158,26 @@ void ProxyThread::handle_close_event(int result) to_proxy(); } -void ProxyThread::to_proxy() +void ProxyDialog::to_proxy() { -// test for new files - ArrayList confirm_paths; - confirm_paths.set_array_delete(); -// all proxy assets + ArrayList orig_idxbls; ArrayList proxy_assets; -// assets which must be created - ArrayList needed_assets; -// original assets - ArrayList orig_assets; -// original assets which match the needed_assets - ArrayList needed_orig_assets; - Asset *proxy_asset = 0; - Asset *orig_asset = 0; + EDL *edl = mwindow->edl; mwindow->edl->Garbage::add_user(); mwindow->save_backup(); mwindow->undo->update_undo_before(_("proxy"), this); - - EDL *&edl = mwindow->edl; - EDLSession *&session = edl->session; - Assets *&assets = edl->assets; + ProxyRender proxy_render(mwindow, asset); // revert project to original size from current size // remove all session proxy assets at the at the current proxy_scale - if( session->proxy_scale > 1 ) { - orig_asset = assets->first; + int proxy_scale = edl->session->proxy_scale; + if( proxy_scale > 1 ) { + Asset *orig_asset = edl->assets->first; for( ; orig_asset; orig_asset=orig_asset->next ) { char new_path[BCTEXTLEN]; - to_proxy_path(new_path, orig_asset, session->proxy_scale); - proxy_asset = assets->get_asset(new_path); + proxy_render.to_proxy_path(new_path, orig_asset, proxy_scale); + Asset *proxy_asset = edl->assets->get_asset(new_path); if( !proxy_asset ) continue; // test if proxy asset was already added to proxy_assets int got_it = 0; @@ -195,203 +187,230 @@ void ProxyThread::to_proxy() // add pointer to existing EDL asset if it exists // EDL won't delete it unless it's the same pointer. proxy_assets.append(proxy_asset); - proxy_asset->Garbage::add_user(); - orig_assets.append(orig_asset); - orig_asset->Garbage::add_user(); + proxy_asset->add_user(); + orig_idxbls.append(orig_asset); + orig_asset->add_user(); } // convert from the proxy assets to the original assets - mwindow->set_proxy(0, 1, &proxy_assets, &orig_assets); + int proxy_auto_scale = edl->session->proxy_auto_scale; + mwindow->set_proxy(0, 1, proxy_auto_scale, &proxy_assets, &orig_idxbls); -// remove the proxy assets - mwindow->remove_assets_from_project(0, 0, &proxy_assets, NULL); +// remove the references for( int i=0; iGarbage::remove_user(); + proxy_assets[i]->remove_user(); proxy_assets.remove_all(); - for( int i = 0; i < orig_assets.size(); i++ ) - orig_assets.get(i)->Garbage::remove_user(); - orig_assets.remove_all(); + for( int i = 0; i < orig_idxbls.size(); i++ ) + orig_idxbls[i]->remove_user(); + orig_idxbls.remove_all(); } + ArrayList confirm_paths; // test for new files + confirm_paths.set_array_delete(); + // convert to new size if not original size if( new_scale != 1 ) { - orig_asset = assets->first; - for( ; orig_asset; orig_asset=orig_asset->next ) { - if( !orig_asset->video_data ) continue; - char new_path[BCTEXTLEN]; - to_proxy_path(new_path, orig_asset, new_scale); -// add to proxy_assets & orig_assets if it isn't already there. - int got_it = 0; - for( int i = 0; !got_it && ipath, new_path); - if( !got_it ) { - proxy_asset = new Asset; -// new compression parameters - proxy_asset->copy_format(asset, 0); - proxy_asset->update_path(new_path); - proxy_asset->audio_data = 0; - proxy_asset->video_data = 1; - proxy_asset->layers = 1; - proxy_asset->width = orig_asset->width / new_scale; - if( proxy_asset->width & 1 ) ++proxy_asset->width; - proxy_asset->actual_width = proxy_asset->width; - proxy_asset->height = orig_asset->height / new_scale; - if( proxy_asset->height & 1 ) ++proxy_asset->height; - proxy_asset->actual_height = proxy_asset->height; - proxy_asset->frame_rate = orig_asset->frame_rate; - proxy_asset->video_length = orig_asset->video_length; - proxy_assets.append(proxy_asset); - orig_asset->add_user(); - orig_assets.append(orig_asset); - } - -// test if proxy file exists. - int exists = 0; - FILE *fd = fopen(new_path, "r"); - if( fd ) { - exists = 1; - fclose(fd); - FileSystem fs; -// got it if proxy file is newer than original. - got_it = fs.get_date(new_path) > fs.get_date(asset->path); - } - else - got_it = 0; - + FileSystem fs; + Asset *orig = mwindow->edl->assets->first; + for( ; orig; orig=orig->next ) { + Asset *proxy = proxy_render.add_original(orig, new_scale); + if( !proxy ) continue; + int exists = fs.get_size(proxy->path) > 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 ) { if( exists ) // prompt user to overwrite - confirm_paths.append(cstrdup(new_path)); - - needed_assets.append(proxy_asset); - proxy_asset->add_user(); - needed_orig_assets.append(orig_asset); - orig_asset->add_user(); -//printf("ProxyThread::handle_close_event %d %s\n", __LINE__, new_path); + confirm_paths.append(cstrdup(proxy->path)); + proxy_render.add_needed(orig, proxy); } } + } + int result = 0; // test for existing files - int result = 0; - if( confirm_paths.size() ) { - result = ConfirmSave::test_files(mwindow, &confirm_paths); - confirm_paths.remove_all_objects(); - } - - if( !result ) { - int canceled = 0; - failed = 0; - -// create proxy assets which don't already exist - if( needed_orig_assets.size() > 0 ) { - int64_t total_len = 0; - for( int i = 0; i < needed_orig_assets.size(); i++ ) - total_len += needed_orig_assets.get(i)->video_length; -// start progress bar. MWindow is locked inside this - progress = mwindow->mainprogress-> - start_progress(_("Creating proxy files..."), total_len); - total_rendered = 0; - - ProxyFarm engine(mwindow, this, - &needed_assets, &needed_orig_assets); - engine.process_packages(); -printf("failed=%d canceled=%d\n", failed, progress->is_cancelled()); - -// stop progress bar - canceled = progress->is_cancelled(); - progress->stop_progress(); - delete progress; progress = 0; - - if( failed && !canceled ) { - int cx, cy; - mwindow->gui->get_abs_cursor_xy(cx, cy, 1); - ErrorBox error_box(PROGRAM_NAME ": Error", cx, cy); - error_box.create_objects(_("Error making proxy.")); - error_box.raise_window(); - error_box.run_window(); - } - } + if( confirm_paths.size() ) { + result = ConfirmSave::test_files(mwindow, &confirm_paths); + confirm_paths.remove_all_objects(); + } -// resize project - if( !failed && !canceled ) { - mwindow->set_proxy(use_scaler, new_scale, &orig_assets, &proxy_assets); - } - } + if( !result ) + result = proxy_render.create_needed_proxies(new_scale); - for( int i = 0; i < proxy_assets.size(); i++ ) - proxy_assets.get(i)->Garbage::remove_user(); - for( int i = 0; i < orig_assets.size(); i++ ) - orig_assets.get(i)->Garbage::remove_user(); - for( int i = 0; i < needed_assets.size(); i++ ) - needed_assets.get(i)->Garbage::remove_user(); - for( int i = 0; i < needed_orig_assets.size(); i++ ) - needed_orig_assets.get(i)->Garbage::remove_user(); - } + if( !result ) // resize project + mwindow->set_proxy(use_scaler, new_scale, auto_scale, + &proxy_render.orig_idxbls, &proxy_render.orig_proxies); mwindow->undo->update_undo_after(_("proxy"), LOAD_ALL); mwindow->edl->Garbage::remove_user(); mwindow->restart_brender(); - mwindow->gui->lock_window("ProxyThread::to_proxy"); + mwindow->gui->lock_window("ProxyDialog::to_proxy"); mwindow->update_project(LOAD_ALL); mwindow->gui->unlock_window(); } -void ProxyThread::to_proxy_path(char *new_path, Asset *asset, int scale) +void ProxyRender::to_proxy_path(char *new_path, Indexable *indexable, int scale) { - strcpy(new_path, asset->path); - char prxy[BCTEXTLEN]; - sprintf(prxy, ".proxy%d", scale); // path is already a proxy - if( strstr(new_path, prxy) ) return; - int len = strlen(new_path); -// insert proxy prxy - char *ptr = strrchr(new_path, '.'); - if( ptr ) { - char *cp = new_path + len; - int n = strlen(prxy); - char *bp = cp + n; - for( *bp=0; cp>ptr; ) *--bp = *--cp; - for( cp= prxy+n; bp>ptr; ) *--bp = *--cp; -//printf("ProxyThread::to_proxy_path %d %s %s\n", __LINE__, new_path), asset->path); + if( strstr(indexable->path, ".proxy") ) return; + strcpy(new_path, indexable->path); + char prxy[BCSTRLEN]; + int n = sprintf(prxy, ".proxy%d", scale); +// insert proxy, path.sfx => path.proxy#-sfx.ext + char *ep = new_path + strlen(new_path); + char *sfx = strrchr(new_path, '.'); + if( sfx ) { + char *bp = ep, *cp = (ep += n); + while( --bp > sfx ) *--cp = *bp; + *--cp = '-'; } - else - strcpy(new_path+len, prxy); + else { + sfx = ep; ep += n; + } + for( char *cp=prxy; --n>=0; ++cp ) *sfx++ = *cp; + const char *ext = format_asset->format == FILE_FFMPEG ? + format_asset->fformat : File::get_tag(format_asset->format); + *ep++ = '.'; + while( *ext ) *ep++ = *ext++; + *ep = 0; +//printf("ProxyRender::to_proxy_path %d %s %s\n", __LINE__, new_path), asset->path); } -void ProxyThread::from_proxy_path(char *new_path, Asset *asset, int scale) +void ProxyRender::from_proxy_path(char *new_path, Asset *asset, int scale) { char prxy[BCTEXTLEN]; - sprintf(prxy, ".proxy%d", scale); + int n = sprintf(prxy, ".proxy%d", scale); strcpy(new_path, asset->path); char *ptr = strstr(asset->path, prxy); - if( !ptr ) return; - int n = strlen(prxy); - for( char *cp=ptr+n; --n>=0; ++ptr,++cp ) *ptr = *cp; + if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return; +// remove proxy, path.proxy#-sfx.ext => path.sfx + char *ext = strrchr(ptr, '.'); + if( !ext ) ext = ptr + strlen(ptr); + char *cp = ptr + n; + for( *cp='.'; cpmwindow = mwindow; + this->format_asset = format_asset; + progress = 0; + counter_lock = new Mutex("ProxyDialog::counter_lock"); + total_rendered = 0; + failed = 0; canceled = 0; +} + +ProxyRender::~ProxyRender() +{ + delete progress; + delete counter_lock; + + for( int i=0,n=orig_idxbls.size(); iremove_user(); + for( int i=0,n=orig_proxies.size(); iremove_user(); + for( int i=0,n=needed_idxbls.size(); iremove_user(); + for( int i=0,n=needed_proxies.size(); iremove_user(); +} + +Asset *ProxyRender::add_original(Indexable *idxbl, int new_scale) +{ + if( !idxbl->have_video() ) return 0; + if( idxbl->get_video_frames() <= 0 ) return 0; +// don't proxy proxies + if( strstr(idxbl->path,".proxy") ) return 0; + char new_path[BCTEXTLEN]; + to_proxy_path(new_path, idxbl, new_scale); +// don't proxy if not readable + if( idxbl->is_asset && access(idxbl->path, R_OK) ) return 0; +// add to orig_idxbls & orig_proxies if it isn't already there. + int got_it = 0; + for( int i = 0; !got_it && ipath, new_path); + if( got_it ) return 0; + +// new proxy asset + Asset *proxy = new Asset; +// new compression parameters + proxy->copy_format(format_asset, 0); + proxy->update_path(new_path); + proxy->audio_data = 0; + proxy->video_data = 1; + proxy->layers = 1; + proxy->width = idxbl->get_w() / new_scale; + if( proxy->width & 1 ) ++proxy->width; + proxy->actual_width = proxy->width; + proxy->height = idxbl->get_h() / new_scale; + if( proxy->height & 1 ) ++proxy->height; + proxy->actual_height = proxy->height; + proxy->frame_rate = idxbl->get_frame_rate(); + proxy->video_length = idxbl->get_video_frames(); + orig_proxies.append(proxy); + orig_idxbls.append(idxbl); + idxbl->add_user(); + return proxy; +} + +void ProxyRender::add_needed(Indexable *idxbl, Asset *proxy) +{ + needed_idxbls.append(idxbl); + idxbl->add_user(); + needed_proxies.append(proxy); + proxy->add_user(); +} + +void ProxyRender::update_progress() { counter_lock->lock(); - total_rendered++; + ++total_rendered; counter_lock->unlock(); progress->update(total_rendered); } -int ProxyThread::is_canceled() +int ProxyRender::is_canceled() { return progress->is_cancelled(); } +int ProxyRender::create_needed_proxies(int new_scale) +{ + if( !needed_proxies.size() ) return 0; + total_rendered = 0; + failed = 0; canceled = 0; +// create proxy assets which don't already exist + int64_t total_len = 0; + for( int i = 0; i < needed_idxbls.size(); i++ ) { + total_len += needed_idxbls[i]->get_video_frames(); + } + +// start progress bar. MWindow is locked inside this + progress = mwindow->mainprogress-> + start_progress(_("Creating proxy files..."), total_len); + + ProxyFarm engine(mwindow, this, &needed_idxbls, &needed_proxies); + engine.process_packages(); +printf("failed=%d canceled=%d\n", failed, progress->is_cancelled()); + +// stop progress bar + canceled = progress->is_cancelled(); + progress->stop_progress(); + delete progress; progress = 0; -ProxyWindow::ProxyWindow(MWindow *mwindow, ProxyThread *thread, int x, int y) + if( failed && !canceled ) { + eprintf("Error making proxy."); + } + + return !failed && !canceled ? 0 : 1; +} + + +ProxyWindow::ProxyWindow(MWindow *mwindow, ProxyDialog *dialog, int x, int y) : BC_Window(_(PROGRAM_NAME ": Proxy settings"), x, y, WIDTH, HEIGHT, -1, -1, 0, 0, 1) { this->mwindow = mwindow; - this->thread = thread; + this->dialog = dialog; format_tools = 0; } @@ -406,27 +425,26 @@ ProxyWindow::~ProxyWindow() void ProxyWindow::create_objects() { lock_window("ProxyWindow::create_objects"); - int margin = mwindow->theme->widget_border; + + 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->new_scale = dialog->orig_scale; + int x = margin; - int y = margin; - thread->use_scaler = mwindow->edl->session->proxy_use_scaler; - thread->orig_scale = mwindow->edl->session->proxy_scale; - thread->new_scale = thread->orig_scale; + int y = margin+10; + add_subwindow(use_scaler = new ProxyUseScaler(this, x, y)); + y += use_scaler->get_h() + margin; BC_Title *text; - add_subwindow(text = new BC_Title(x, y, - _("What size should the project\n" - "be scaled to for editing?"))); - y += text->get_h() * 2 + margin; - add_subwindow(text = new BC_Title(x, y, _("Scale factor:"))); x += text->get_w() + margin; - thread->size_text[0] = cstrdup(_("Original size")); - thread->size_factors[0] = 1; - thread->total_sizes = 1; - int popupmenu_w = BC_PopupMenu::calculate_w(get_text_width(MEDIUMFONT, thread->size_text[0])); + 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(); x += scale_factor->get_w() + margin; @@ -434,24 +452,22 @@ void ProxyWindow::create_objects() ProxyTumbler *tumbler; add_subwindow(tumbler = new ProxyTumbler(mwindow, this, x, y)); y += tumbler->get_h() + margin; - x = margin; - add_subwindow(use_scaler = new ProxyUseScaler(mwindow, this, x, y)); - y += use_scaler->get_h() + margin; - y += 25; x = margin; add_subwindow(text = new BC_Title(x, y, _("New media dimensions: "))); x += text->get_w() + margin; add_subwindow(new_dimensions = new BC_Title(x, y, "")); + y += new_dimensions->get_h() + margin; - x = margin; - y += new_dimensions->get_h() * 2 + margin; - - - format_tools = new ProxyFormatTools(mwindow, this, thread->asset); + x = margin; y += 25; + 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); + x = margin; + add_subwindow(auto_scale = new ProxyAutoScale(this, x, y)); + y += auto_scale->get_h() + margin; + update(); add_subwindow(new BC_OKButton(this)); @@ -478,47 +494,70 @@ void ProxyWindow::update() char string[BCTEXTLEN]; //printf("ProxyWindow::update %d %d %d %d %d\n", // __LINE__, mwindow->edl->session->output_w, mwindow->edl->session->output_h, -// thread->orig_scale, thread->new_scale); - int orig_w = mwindow->edl->session->output_w * thread->orig_scale; - int orig_h = mwindow->edl->session->output_h * thread->orig_scale; - int new_w = orig_w / thread->new_scale; +// dialog->orig_scale, dialog->new_scale); + int orig_w = mwindow->edl->session->output_w * dialog->orig_scale; + int orig_h = mwindow->edl->session->output_h * dialog->orig_scale; + int new_w = orig_w / dialog->new_scale; if( new_w & 1 ) ++new_w; - int new_h = orig_h / thread->new_scale; + int new_h = orig_h / dialog->new_scale; if( new_h & 1 ) ++new_h; sprintf(string, "%dx%d", new_w, new_h); new_dimensions->update(string); - thread->scale_to_text(string, thread->new_scale); + dialog->scale_to_text(string, dialog->new_scale); scale_factor->set_text(string); use_scaler->update(); + auto_scale->update(); } -ProxyUseScaler::ProxyUseScaler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y) - : BC_CheckBox(x, y, pwindow->thread->use_scaler, _("Use scaler (FFMPEG only)")) +ProxyUseScaler::ProxyUseScaler(ProxyWindow *pwindow, int x, int y) + : BC_CheckBox(x, y, pwindow->dialog->use_scaler, _("Use scaler (FFMPEG only)")) { - this->mwindow = mwindow; this->pwindow = pwindow; } void ProxyUseScaler::update() { - ProxyThread *thread = pwindow->thread; - if( thread->asset->format != FILE_FFMPEG ) thread->use_scaler = 0; - BC_CheckBox::update(thread->use_scaler); - int scaler_avail = thread->asset->format == FILE_FFMPEG ? 1 : 0; + ProxyDialog *dialog = pwindow->dialog; + if( dialog->asset->format != FILE_FFMPEG ) dialog->use_scaler = 0; + BC_CheckBox::update(dialog->use_scaler); + int scaler_avail = dialog->asset->format == FILE_FFMPEG ? 1 : 0; if( !scaler_avail && enabled ) disable(); if( scaler_avail && !enabled ) enable(); } int ProxyUseScaler::handle_event() { - pwindow->thread->new_scale = 1; - pwindow->thread->use_scaler = get_value(); + pwindow->dialog->new_scale = 1; + pwindow->dialog->use_scaler = get_value(); pwindow->scale_factor->update_sizes(); pwindow->update(); return 1; } +ProxyAutoScale::ProxyAutoScale(ProxyWindow *pwindow, int x, int y) + : BC_CheckBox(x, y, pwindow->dialog->use_scaler, _("Auto proxy/scale media loads")) +{ + this->pwindow = pwindow; +} + +void ProxyAutoScale::update() +{ + ProxyDialog *dialog = pwindow->dialog; + if( dialog->new_scale == 1 ) 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(); +} + +int ProxyAutoScale::handle_event() +{ + pwindow->dialog->auto_scale = get_value(); + pwindow->update(); + return 1; +} + ProxyMenu::ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow, int x, int y, int w, const char *text) @@ -531,19 +570,19 @@ ProxyMenu::ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow, void ProxyMenu::update_sizes() { while( total_items() > 0 ) del_item(0); - ProxyThread *thread = pwindow->thread; - thread->calculate_sizes(); - for( int i=0; i < thread->total_sizes; i++ ) - add_item(new BC_MenuItem(thread->size_text[i])); + ProxyDialog *dialog = pwindow->dialog; + dialog->calculate_sizes(); + for( int i=0; i < dialog->total_sizes; i++ ) + add_item(new BC_MenuItem(dialog->size_text[i])); } int ProxyMenu::handle_event() { - for( int i = 0; i < pwindow->thread->total_sizes; i++ ) { - if( !strcmp(get_text(), pwindow->thread->size_text[i]) ) { - pwindow->thread->new_scale = pwindow->thread->size_factors[i]; - if( pwindow->thread->new_scale == 1 ) - pwindow->thread->use_scaler = 0; + ProxyDialog *dialog = pwindow->dialog; + for( int i = 0; i < dialog->total_sizes; i++ ) { + if( !strcmp(get_text(), pwindow->dialog->size_text[i]) ) { + dialog->new_scale = pwindow->dialog->size_factors[i]; + if( dialog->new_scale == 1 ) dialog->use_scaler = 0; pwindow->update(); break; } @@ -561,12 +600,12 @@ ProxyTumbler::ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y) int ProxyTumbler::handle_up_event() { - if( pwindow->thread->new_scale > 1 ) { + if( pwindow->dialog->new_scale > 1 ) { int i; - for( i = 0; i < pwindow->thread->total_sizes; i++ ) { - if( pwindow->thread->new_scale == pwindow->thread->size_factors[i] ) { + for( i = 0; i < pwindow->dialog->total_sizes; i++ ) { + if( pwindow->dialog->new_scale == pwindow->dialog->size_factors[i] ) { i--; - pwindow->thread->new_scale = pwindow->thread->size_factors[i]; + pwindow->dialog->new_scale = pwindow->dialog->size_factors[i]; pwindow->update(); return 1; } @@ -579,10 +618,10 @@ int ProxyTumbler::handle_up_event() int ProxyTumbler::handle_down_event() { int i; - for( i = 0; i < pwindow->thread->total_sizes - 1; i++ ) { - if( pwindow->thread->new_scale == pwindow->thread->size_factors[i] ) { + for( i = 0; i < pwindow->dialog->total_sizes - 1; i++ ) { + if( pwindow->dialog->new_scale == pwindow->dialog->size_factors[i] ) { i++; - pwindow->thread->new_scale = pwindow->thread->size_factors[i]; + pwindow->dialog->new_scale = pwindow->dialog->size_factors[i]; pwindow->update(); return 1; } @@ -592,118 +631,146 @@ int ProxyTumbler::handle_down_event() } + ProxyPackage::ProxyPackage() : LoadPackage() { } -ProxyClient::ProxyClient(MWindow *mwindow, ProxyThread *thread, ProxyFarm *server) +ProxyClient::ProxyClient(MWindow *mwindow, + ProxyRender *proxy_render, ProxyFarm *server) : LoadClient(server) { this->mwindow = mwindow; - this->thread = thread; + this->proxy_render = proxy_render; + render_engine = 0; + video_cache = 0; + src_file = 0; +} +ProxyClient::~ProxyClient() +{ + delete render_engine; + delete video_cache; + delete src_file; } void ProxyClient::process_package(LoadPackage *ptr) { - ProxyPackage *package = (ProxyPackage*)ptr; - if( thread->failed ) return; + if( proxy_render->failed ) return; + if( proxy_render->is_canceled() ) return; - File src_file; - File dst_file; EDL *edl = mwindow->edl; Preferences *preferences = mwindow->preferences; - int processors = 1; - - int result; - src_file.set_processors(processors); - src_file.set_preload(edl->session->playback_preload); - src_file.set_subtitle(edl->session->decode_subtitles ? - edl->session->subtitle_number : -1); - src_file.set_interpolate_raw(edl->session->interpolate_raw); - src_file.set_white_balance_raw(edl->session->white_balance_raw); - -//printf("%s %s\n", package->orig_asset->path, package->proxy_asset->path); - - - result = src_file.open_file(preferences, package->orig_asset, 1, 0); + ProxyPackage *package = (ProxyPackage*)ptr; + Indexable *orig = package->orig_idxbl; + Asset *proxy = package->proxy_asset; +//printf("%s %s\n", orig->path, proxy->path); + VRender *vrender = 0; + int processors = 1, result = 0; + + if( orig->is_asset ) { + src_file = new File; + src_file->set_processors(processors); + src_file->set_preload(edl->session->playback_preload); + src_file->set_subtitle(edl->session->decode_subtitles ? + edl->session->subtitle_number : -1); + src_file->set_interpolate_raw(edl->session->interpolate_raw); + src_file->set_white_balance_raw(edl->session->white_balance_raw); + if( src_file->open_file(preferences, (Asset*)orig, 1, 0) != FILE_OK ) + result = 1; + } + else { + TransportCommand command; + command.command = CURRENT_FRAME; + command.get_edl()->copy_all((EDL *)orig); + command.change_type = CHANGE_ALL; + command.realtime = 0; + render_engine = new RenderEngine(0, preferences, 0, 0); + render_engine->set_vcache(video_cache = new CICache(preferences)); + render_engine->arm_command(&command); + if( !(vrender = render_engine->vrender) ) + result = 1; + } if( result ) { // go to the next asset if the reader fails -// thread->failed = 1; +// proxy_render->failed = 1; return; } + File dst_file; dst_file.set_processors(processors); - result = dst_file.open_file(preferences, package->proxy_asset, 0, 1); + result = dst_file.open_file(preferences, proxy, 0, 1); if( result ) { - thread->failed = 1; + proxy_render->failed = 1; return; } dst_file.start_video_thread(1, edl->session->color_model, processors > 1 ? 2 : 1, 0); - VFrame src_frame(0, -1, - package->orig_asset->width, package->orig_asset->height, - edl->session->color_model, -1); + int src_w = orig->get_w(), src_h = orig->get_h(); + VFrame src_frame(src_w,src_h, edl->session->color_model); OverlayFrame scaler(processors); - for( int64_t i = 0; i < package->orig_asset->video_length && - !thread->failed && !thread->is_canceled(); i++ ) { - src_file.set_video_position(i, 0); - result = src_file.read_frame(&src_frame); + for( int64_t i=0, length=orig->get_video_frames(); ifailed && !proxy_render->is_canceled(); ++i ) { + if( orig->is_asset ) { + src_file->set_video_position(i, 0); + result = src_file->read_frame(&src_frame); + } + else + result = vrender->process_buffer(&src_frame, i, 0); //printf("result=%d\n", result); if( result ) { // go to the next asset if the reader fails -// thread->failed = 1; +// proxy_render->failed = 1; break; } // have to write after getting the video buffer or it locks up VFrame ***dst_frames = dst_file.get_video_buffer(); VFrame *dst_frame = dst_frames[0][0]; + int dst_w = dst_frame->get_w(), dst_h = dst_frame->get_h(); scaler.overlay(dst_frame, &src_frame, - 0, 0, src_frame.get_w(), src_frame.get_h(), - 0, 0, dst_frame->get_w(), dst_frame->get_h(), + 0,0, src_w,src_h, 0,0, dst_w,dst_h, 1.0, TRANSFER_REPLACE, NEAREST_NEIGHBOR); result = dst_file.write_video_buffer(1); if( result ) { // only fail if the writer fails - thread->failed = 1; + proxy_render->failed = 1; break; } - else { - thread->update_progress(); - } + proxy_render->update_progress(); } } -ProxyFarm::ProxyFarm(MWindow *mwindow, ProxyThread *thread, - ArrayList *proxy_assets, ArrayList *orig_assets) +ProxyFarm::ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render, + ArrayList *orig_idxbls, + ArrayList *proxy_assets) : LoadServer(MIN(mwindow->preferences->processors, proxy_assets->size()), proxy_assets->size()) { this->mwindow = mwindow; - this->thread = thread; + this->proxy_render = proxy_render; + this->orig_idxbls = orig_idxbls; this->proxy_assets = proxy_assets; - this->orig_assets = orig_assets; } void ProxyFarm::init_packages() { for( int i = 0; i < get_total_packages(); i++ ) { - ProxyPackage *package = (ProxyPackage*)get_package(i); - package->proxy_asset = proxy_assets->get(i); - package->orig_asset = orig_assets->get(i); + ProxyPackage *package = (ProxyPackage*)get_package(i); + package->proxy_asset = proxy_assets->get(i); + package->orig_idxbl = orig_idxbls->get(i); } } LoadClient* ProxyFarm::new_client() { - return new ProxyClient(mwindow, thread, this); + return new ProxyClient(mwindow, proxy_render, this); } LoadPackage* ProxyFarm::new_package() diff --git a/cinelerra-5.1/cinelerra/proxy.h b/cinelerra-5.1/cinelerra/proxy.h index 553ef481..1404593f 100644 --- a/cinelerra-5.1/cinelerra/proxy.h +++ b/cinelerra-5.1/cinelerra/proxy.h @@ -26,12 +26,15 @@ #include "arraylist.h" #include "asset.h" #include "bcdialog.h" +#include "cache.inc" +#include "file.inc" #include "formattools.inc" #include "loadbalance.h" #include "mutex.inc" #include "mwindow.inc" +#include "renderengine.inc" -class ProxyThread; +class ProxyDialog; class ProxyWindow; #define MAX_SIZES 16 @@ -45,7 +48,7 @@ public: void create_objects(); MWindow *mwindow; - ProxyThread *thread; + ProxyDialog *dialog; }; class FromProxyMenuItem : public BC_MenuItem @@ -57,35 +60,59 @@ public: MWindow *mwindow; }; -class ProxyThread : public BC_DialogThread + +class ProxyRender { public: - ProxyThread(MWindow *mwindow); - ~ProxyThread(); - BC_Window* new_gui(); - void handle_close_event(int result); - static void to_proxy_path(char *new_path, Asset *asset, int scale); - static void from_proxy_path(char *new_path, Asset *asset, int scale); - void from_proxy(); - void to_proxy(); + 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); + + ArrayList orig_idxbls; // originals which match the proxy assets + ArrayList orig_proxies; // proxy assets + Asset *add_original(Indexable *idxbl, int new_scale); + ArrayList needed_idxbls; // originals which match the needed_assets + ArrayList needed_proxies; // assets which must be created + void add_needed(Indexable *idxbl, Asset *proxy); + + int create_needed_proxies(int new_scale); // increment the frame count by 1 void update_progress(); // if user canceled progress bar int is_canceled(); + + MWindow *mwindow; + Asset *format_asset; + MainProgressBar *progress; + Mutex *counter_lock; + int total_rendered; + int failed, canceled; +}; + +class ProxyDialog : public BC_DialogThread +{ +public: + ProxyDialog(MWindow *mwindow); + ~ProxyDialog(); + BC_Window* new_gui(); + void handle_close_event(int result); + + void from_proxy(); + void to_proxy(); // calculate possible sizes based on the original size void calculate_sizes(); void scale_to_text(char *string, int scale); MWindow *mwindow; ProxyWindow *gui; - MainProgressBar *progress; - Mutex *counter_lock; Asset *asset; + ProxyRender *proxy_render; + int new_scale; int orig_scale; - int total_rendered; - int failed; int use_scaler; + int auto_scale; char *size_text[MAX_SIZES]; int size_factors[MAX_SIZES]; int total_sizes; @@ -94,11 +121,20 @@ public: class ProxyUseScaler : public BC_CheckBox { public: - ProxyUseScaler(MWindow *mwindow, ProxyWindow *pwindow, - int x, int y); + ProxyUseScaler(ProxyWindow *pwindow, int x, int y); void update(); int handle_event(); - MWindow *mwindow; + + ProxyWindow *pwindow; +}; + +class ProxyAutoScale : public BC_CheckBox +{ +public: + ProxyAutoScale(ProxyWindow *pwindow, int x, int y); + void update(); + int handle_event(); + ProxyWindow *pwindow; }; @@ -139,7 +175,7 @@ public: class ProxyWindow : public BC_Window { public: - ProxyWindow(MWindow *mwindow, ProxyThread *thread, + ProxyWindow(MWindow *mwindow, ProxyDialog *dialog, int x, int y); ~ProxyWindow(); @@ -147,11 +183,12 @@ public: void update(); MWindow *mwindow; - ProxyThread *thread; + ProxyDialog *dialog; FormatTools *format_tools; BC_Title *new_dimensions; ProxyMenu *scale_factor; ProxyUseScaler *use_scaler; + ProxyAutoScale *auto_scale; }; class ProxyFarm; @@ -160,36 +197,39 @@ class ProxyPackage : public LoadPackage { public: ProxyPackage(); - Asset *orig_asset; + Indexable *orig_idxbl; Asset *proxy_asset; }; class ProxyClient : public LoadClient { public: - ProxyClient(MWindow *mwindow, ProxyThread *thread, - ProxyFarm *server); + ProxyClient(MWindow *mwindow, ProxyRender *proxy_render, ProxyFarm *server); + ~ProxyClient(); void process_package(LoadPackage *package); MWindow *mwindow; - ProxyThread *thread; + ProxyRender *proxy_render; + RenderEngine *render_engine; + CICache *video_cache; + File *src_file; }; class ProxyFarm : public LoadServer { public: - ProxyFarm(MWindow *mwindow, ProxyThread *thread, - ArrayList *proxy_assets, ArrayList *orig_assets); + ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render, + ArrayList *orig_idxbls, ArrayList *proxy_assets); void init_packages(); LoadClient* new_client(); LoadPackage* new_package(); MWindow *mwindow; - ProxyThread *thread; + ProxyRender *proxy_render; + ArrayList *orig_idxbls; ArrayList *proxy_assets; - ArrayList *orig_assets; }; #endif diff --git a/cinelerra-5.1/info/plugins.txt b/cinelerra-5.1/info/plugins.txt index 79c54c7c..699f5068 100644 --- a/cinelerra-5.1/info/plugins.txt +++ b/cinelerra-5.1/info/plugins.txt @@ -75,14 +75,18 @@ Downsample: Reduce the sie of an image by throwing out data, Edge: Display only the edges of the video throughout the image. Fields to frames: Reads frames at 2x the framerate, combining 2 input frames into 1 interlaced output frame. -Find Object: Locate a specific object in a scene and replace with +FindObj: Locate a specific object in a scene and replace with another object. This uses OpenCV thirdparty package. 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. 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 in the entire region. +GaborObj: Creates an interesting fractalius-like image effect. + Uses the OpenCV thirdparty package. Gamma: Converts the logarithmic colors to linear colors using gamma and maximum value. Gradient: Overlays a smooth color gradient on top of every @@ -128,6 +132,7 @@ MotionCV: Motion tracking/stabilization from the community version of cinelerra. MotionHV: Motion tracking/stabilization from the original author of cinelerra. +MoveObj: Move and stabilize object using OpenCV 3rd party pkg. Oil Painting: Makes video tracks appear as a painting. Overlay: Combine tracks via an overlayer that puts images on top of a bottom layer. @@ -290,7 +295,8 @@ F_mcdeint: Applies motion compensating deinterlacing. F_mestimate: Generate motion vectors. F_mpdecimate: Remove near-duplicate frames. F_negate: Negates input video. -F_nlmeans: Non-local means denoiser. +F_nlmeans: Non-local means denoiser. An example usage is for the + recovery of VHS tapes which look bad. F_noise: Adds noise to the video. Through the settings you can select the variables of the noise diff --git a/cinelerra-5.1/msg/txt b/cinelerra-5.1/msg/txt index 1599add2..c79bc581 100644 --- a/cinelerra-5.1/msg/txt +++ b/cinelerra-5.1/msg/txt @@ -10,6 +10,11 @@ For usage help, refer to the following: Cinfinity icons selected in Preferences (Creative Common By https://creativecommons.org/licenses/by/3.0/) . +September 2017 New Features of note: + Proxy Editing added to Settings pulldown. + OpenCV optional compile with 4 plugins now available. + New Rumbler "dream-like" plugin added. + Always Show Next Frame seeking option in Preferences. August 2017 New Features of note: Specks, Burst, Spiral transition wipes are new. C41 plugin updated for negative images to photos. @@ -18,9 +23,7 @@ August 2017 New Features of note: July 2017 New Features of note: Cinfinity icons added along with a Preferences choice. Perspective plugin improvements with more versatility. - Info on plugins with a short description added. Copy/Paste within and across instances enhancements. - Ffmpeg seek changes for ffmpeg non-stream type files. June 2017 New Features of note: CriKey does edgedetect, chroma key, and interpolation. Faststart option added for Mp4 and QT ffmpeg format. diff --git a/cinelerra-5.1/picon_cinfinity/ff_nlmeans.png b/cinelerra-5.1/picon_cinfinity/ff_nlmeans.png new file mode 100644 index 00000000..e962f219 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_nlmeans.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_noise.png b/cinelerra-5.1/picon_cinfinity/ff_noise.png new file mode 100644 index 00000000..4e8af319 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_noise.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_owdenoise.png b/cinelerra-5.1/picon_cinfinity/ff_owdenoise.png new file mode 100644 index 00000000..81890ea1 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_owdenoise.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_perms.png b/cinelerra-5.1/picon_cinfinity/ff_perms.png new file mode 100644 index 00000000..4f4ed899 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_perms.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_perspective.png b/cinelerra-5.1/picon_cinfinity/ff_perspective.png new file mode 100644 index 00000000..47cbbbfa Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_perspective.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_phase.png b/cinelerra-5.1/picon_cinfinity/ff_phase.png new file mode 100644 index 00000000..b1804adf Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_phase.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_pp.png b/cinelerra-5.1/picon_cinfinity/ff_pp.png new file mode 100644 index 00000000..c9f0bf6d Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_pp.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_pp7.png b/cinelerra-5.1/picon_cinfinity/ff_pp7.png new file mode 100644 index 00000000..b0a72689 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_pp7.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_prewitt.png b/cinelerra-5.1/picon_cinfinity/ff_prewitt.png new file mode 100644 index 00000000..17af53c2 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_prewitt.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_readeia608.png b/cinelerra-5.1/picon_cinfinity/ff_readeia608.png new file mode 100644 index 00000000..61264c40 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_readeia608.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_readvitc.png b/cinelerra-5.1/picon_cinfinity/ff_readvitc.png new file mode 100644 index 00000000..36d92b3b Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_readvitc.png differ diff --git a/cinelerra-5.1/picon_cinfinity/ff_realtime.png b/cinelerra-5.1/picon_cinfinity/ff_realtime.png new file mode 100644 index 00000000..5e597946 Binary files /dev/null and b/cinelerra-5.1/picon_cinfinity/ff_realtime.png differ diff --git a/cinelerra-5.1/plugins/findobj/findobj.C b/cinelerra-5.1/plugins/findobj/findobj.C index 70fc9b3f..6348eb47 100644 --- a/cinelerra-5.1/plugins/findobj/findobj.C +++ b/cinelerra-5.1/plugins/findobj/findobj.C @@ -145,7 +145,7 @@ FindObjMain::~FindObjMain() delete overlayer; } -const char* FindObjMain::plugin_title() { return _("Find Object"); } +const char* FindObjMain::plugin_title() { return _("FindObj"); } int FindObjMain::is_realtime() { return 1; } int FindObjMain::is_multichannel() { return 1; } diff --git a/cinelerra-5.1/plugins/theme_blond/data/mbutton_bg.png b/cinelerra-5.1/plugins/theme_blond/data/mbutton_bg.png index a168af68..b2683102 100644 Binary files a/cinelerra-5.1/plugins/theme_blond/data/mbutton_bg.png and b/cinelerra-5.1/plugins/theme_blond/data/mbutton_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_blond/data/menubar_bg.png b/cinelerra-5.1/plugins/theme_blond/data/menubar_bg.png index 3a64682f..fede59e4 100644 Binary files a/cinelerra-5.1/plugins/theme_blond/data/menubar_bg.png and b/cinelerra-5.1/plugins/theme_blond/data/menubar_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_blue/data/mbutton_bg.png b/cinelerra-5.1/plugins/theme_blue/data/mbutton_bg.png index 52b1dcdc..2f09b66f 100644 Binary files a/cinelerra-5.1/plugins/theme_blue/data/mbutton_bg.png and b/cinelerra-5.1/plugins/theme_blue/data/mbutton_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_blue/data/menubar_bg.png b/cinelerra-5.1/plugins/theme_blue/data/menubar_bg.png index 0d1502cc..3012732e 100644 Binary files a/cinelerra-5.1/plugins/theme_blue/data/menubar_bg.png and b/cinelerra-5.1/plugins/theme_blue/data/menubar_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_hulk/data/mbutton_bg.png b/cinelerra-5.1/plugins/theme_hulk/data/mbutton_bg.png index a47745a3..44e952b7 100644 Binary files a/cinelerra-5.1/plugins/theme_hulk/data/mbutton_bg.png and b/cinelerra-5.1/plugins/theme_hulk/data/mbutton_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_hulk/data/menubar_bg.png b/cinelerra-5.1/plugins/theme_hulk/data/menubar_bg.png index 701cdd7d..d9e86ca9 100644 Binary files a/cinelerra-5.1/plugins/theme_hulk/data/menubar_bg.png and b/cinelerra-5.1/plugins/theme_hulk/data/menubar_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_pinklady/data/mbutton_bg.png b/cinelerra-5.1/plugins/theme_pinklady/data/mbutton_bg.png index 0753247a..327e709c 100644 Binary files a/cinelerra-5.1/plugins/theme_pinklady/data/mbutton_bg.png and b/cinelerra-5.1/plugins/theme_pinklady/data/mbutton_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_pinklady/data/menubar_bg.png b/cinelerra-5.1/plugins/theme_pinklady/data/menubar_bg.png index 87e77f8a..d4e1d993 100644 Binary files a/cinelerra-5.1/plugins/theme_pinklady/data/menubar_bg.png and b/cinelerra-5.1/plugins/theme_pinklady/data/menubar_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_unflat/data/mbutton_bg.png b/cinelerra-5.1/plugins/theme_unflat/data/mbutton_bg.png index 1bb09a2e..122caa2f 100644 Binary files a/cinelerra-5.1/plugins/theme_unflat/data/mbutton_bg.png and b/cinelerra-5.1/plugins/theme_unflat/data/mbutton_bg.png differ diff --git a/cinelerra-5.1/plugins/theme_unflat/data/menubar_bg.png b/cinelerra-5.1/plugins/theme_unflat/data/menubar_bg.png index 3767d380..41ee3cee 100644 Binary files a/cinelerra-5.1/plugins/theme_unflat/data/menubar_bg.png and b/cinelerra-5.1/plugins/theme_unflat/data/menubar_bg.png differ