From: Good Guy Date: Thu, 22 Feb 2018 21:56:45 +0000 (-0700) Subject: nested clips, big rework and cleanup, sams new icons, leaks and tweaks X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=commitdiff_plain;h=4a90ef3ae46465c0634f81916b79e279e4bd9961;hp=f87479bd556ea7db4afdd02297fc00977412b873 nested clips, big rework and cleanup, sams new icons, leaks and tweaks --- diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile index 22bbdb23..755e4298 100644 --- a/cinelerra-5.1/cinelerra/Makefile +++ b/cinelerra-5.1/cinelerra/Makefile @@ -60,6 +60,7 @@ OBJS = \ $(OBJDIR)/channelpicker.o \ $(OBJDIR)/chantables.o \ $(OBJDIR)/clipedit.o \ + $(OBJDIR)/clipedls.o \ $(OBJDIR)/clippopup.o \ $(OBJDIR)/colorpicker.o \ $(OBJDIR)/commercials.o \ @@ -193,7 +194,6 @@ OBJS = \ $(OBJDIR)/mwindowgui.o \ $(OBJDIR)/mwindowmove.o \ $(OBJDIR)/mwindow.o \ - $(OBJDIR)/nestededls.o \ $(OBJDIR)/newfolder.o \ $(OBJDIR)/new.o \ $(OBJDIR)/overlaydirect.o \ diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 68886913..fc087f56 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -32,6 +32,7 @@ #include "cache.h" #include "cstrdup.h" #include "clip.h" +#include "clipedls.h" #include "clippopup.h" #include "cursors.h" #include "cwindowgui.h" @@ -52,7 +53,6 @@ #include "mainsession.h" #include "mwindowgui.h" #include "mwindow.h" -#include "nestededls.h" #include "newfolder.h" #include "preferences.h" #include "samples.h" @@ -1280,16 +1280,16 @@ void AWindowGUI::update_asset_list() } // Synchronize EDL clips - for( int i = 0; i < mwindow->edl->clips.total; i++ ) { + for( int i=0; iedl->clips.size(); ++i ) { int exists = 0; // Look for clip in existing listitems for( int j = 0; j < assets.total && !exists; j++ ) { AssetPicon *picon = (AssetPicon*)assets.values[j]; - if( picon->id == mwindow->edl->clips.values[i]->id ) { - picon->edl = mwindow->edl->clips.values[i]; - picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title); + if( picon->id == mwindow->edl->clips[i]->id ) { + picon->edl = mwindow->edl->clips[i]; + picon->set_text(mwindow->edl->clips[i]->local_session->clip_title); exists = 1; picon->in_use = 1; } @@ -1298,16 +1298,14 @@ 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[i]); picon->create_objects(); assets.append(picon); } } // Synchronize EDL assets - for( Asset *current = mwindow->edl->assets->first; - current; - current = NEXT ) { + for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) { int exists = 0; // Look for asset in existing listitems @@ -1316,9 +1314,8 @@ void AWindowGUI::update_asset_list() if( picon->id == current->id ) { picon->indexable = current; - exists = 1; picon->in_use = 1; - break; + exists = 1; } } @@ -1336,26 +1333,25 @@ void AWindowGUI::update_asset_list() mwindow->gui->unlock_window(); // Synchronize nested EDLs - for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) { + for( int i=0; iedl->nested_edls.size(); ++i ) { int exists = 0; - Indexable *indexable = mwindow->edl->nested_edls->get(i); + EDL *nested_edl = mwindow->edl->nested_edls[i]; // Look for asset in existing listitems - for( int j = 0; j < assets.total && !exists; j++ ) { + for( int j=0; jid == indexable->id ) { - picon->indexable = indexable; - exists = 1; + if( picon->id == nested_edl->id ) { + picon->indexable = nested_edl; picon->in_use = 1; - break; + exists = 1; } } // Create new listitem if( !exists ) { AssetPicon *picon = new AssetPicon(mwindow, - this, indexable); + this, (Indexable*)nested_edl); picon->create_objects(); assets.append(picon); } diff --git a/cinelerra-5.1/cinelerra/batchrender.C b/cinelerra-5.1/cinelerra/batchrender.C index 8a1bc56f..9e45b3ec 100644 --- a/cinelerra-5.1/cinelerra/batchrender.C +++ b/cinelerra-5.1/cinelerra/batchrender.C @@ -357,7 +357,7 @@ void BatchRenderThread::update_selected_edl() FileXML xml_file; char *path = get_current_edl(); EDL *edl = mwindow->edl; - edl->save_xml(&xml_file, path, 0, 0); + edl->save_xml(&xml_file, path); xml_file.terminate_string(); if( xml_file.write_to_file(path) ) { char msg[BCTEXTLEN]; diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C index 48c27f99..c7cbfbc5 100644 --- a/cinelerra-5.1/cinelerra/bdcreate.C +++ b/cinelerra-5.1/cinelerra/bdcreate.C @@ -266,7 +266,7 @@ int CreateBD_Thread::create_bd_jobs(ArrayList *jobs, const char char xml_filename[BCTEXTLEN]; sprintf(xml_filename, "%s/bd.xml", asset_dir); FileXML xml_file; - edl->save_xml(&xml_file, xml_filename, 0, 0); + edl->save_xml(&xml_file, xml_filename); xml_file.terminate_string(); if( xml_file.write_to_file(xml_filename) ) { char msg[BCTEXTLEN]; diff --git a/cinelerra-5.1/cinelerra/cache.C b/cinelerra-5.1/cinelerra/cache.C index 7fed3e68..de8563a9 100644 --- a/cinelerra-5.1/cinelerra/cache.C +++ b/cinelerra-5.1/cinelerra/cache.C @@ -43,6 +43,7 @@ CICache::CICache(Preferences *preferences) edl = 0; check_out_lock = new Condition(0, "CICache::check_out_lock", 0); total_lock = new Mutex("CICache::total_lock"); + check_outs = 0; } CICache::~CICache() @@ -106,6 +107,8 @@ SET_TRACE current->age = EDL::next_id(); current->checked_out = tid; } + else if( current->checked_out == tid ) + ++check_outs; else current = 0; } @@ -122,13 +125,17 @@ SET_TRACE int CICache::check_in(Asset *asset) { total_lock->lock("CICache::check_in"); - CICacheItem *current = first; - while(current && strcmp(current->asset->path, asset->path) != 0) - current = NEXT; - if(current && current->checked_out) { - current->checked_out = 0; - current->Garbage::remove_user(); + if( !check_outs ) { + CICacheItem *current = first; + while(current && strcmp(current->asset->path, asset->path) != 0) + current = NEXT; + if(current && current->checked_out) { + current->checked_out = 0; + current->Garbage::remove_user(); + } } + else + --check_outs; total_lock->unlock(); // Release for blocking check_out operations diff --git a/cinelerra-5.1/cinelerra/cache.h b/cinelerra-5.1/cinelerra/cache.h index 876637f2..fde997a5 100644 --- a/cinelerra-5.1/cinelerra/cache.h +++ b/cinelerra-5.1/cinelerra/cache.h @@ -114,6 +114,8 @@ private: int lock_all(); int unlock_all(); + int check_outs; + // to prevent one from checking the same asset out before it's checked in // yet without blocking the asset trying to get checked in // use a seperate mutex for checkouts and checkins diff --git a/cinelerra-5.1/cinelerra/clipedit.C b/cinelerra-5.1/cinelerra/clipedit.C index 74d2ff8e..a3f633aa 100644 --- a/cinelerra-5.1/cinelerra/clipedit.C +++ b/cinelerra-5.1/cinelerra/clipedit.C @@ -58,9 +58,9 @@ void ClipEdit::handle_close_event(int result) { if( !result ) { int name_ok = 1; - for( int i = 0; name_ok && i < mwindow->edl->clips.total; ++i ) { + for( int i=0; name_ok && iedl->clips.size(); ++i ) { if( !strcasecmp(clip->local_session->clip_title, - mwindow->edl->clips.values[i]->local_session->clip_title) && + mwindow->edl->clips[i]->local_session->clip_title) && (create_it || strcasecmp(clip->local_session->clip_title, original->local_session->clip_title)) ) name_ok = 0; @@ -90,11 +90,8 @@ void ClipEdit::handle_close_event(int result) mwindow->session->clip_number--; } - - -// For creating new clips, the original was copied in add_clip. -// For editing old clips, the original was transferred to another variable. - if( !create_it ) clip->remove_user(); +// always a copy from new_gui + clip->remove_user(); original = 0; clip = 0; create_it = 0; @@ -105,12 +102,9 @@ void ClipEdit::handle_close_event(int result) BC_Window* ClipEdit::new_gui() { original = clip; - - if( !create_it ) { - this->clip = new EDL(mwindow->edl); - clip->create_objects(); - clip->copy_all(original); - } + this->clip = new EDL(mwindow->edl); + clip->create_objects(); + clip->copy_all(original); window = new ClipEditWindow(mwindow, this); window->create_objects(); diff --git a/cinelerra-5.1/cinelerra/clipedls.C b/cinelerra-5.1/cinelerra/clipedls.C new file mode 100644 index 00000000..65dd58e2 --- /dev/null +++ b/cinelerra-5.1/cinelerra/clipedls.C @@ -0,0 +1,93 @@ +#include "bcsignals.h" +#include "clipedls.h" +#include "edl.h" +#include "filexml.h" +#include "indexstate.h" + + +ClipEDLs::ClipEDLs() +{ +} + +ClipEDLs::~ClipEDLs() +{ + clear(); +} + +void ClipEDLs::clear() +{ + for( int i=0; iremove_user(); + remove_all(); +} + +void ClipEDLs::add_clip(EDL *edl) +{ + append(edl); + edl->add_user(); +} + +void ClipEDLs::remove_clip(EDL *clip) +{ + int n = size(); + remove(clip); + n -= size(); + while( --n >= 0 ) clip->remove_user(); +} + + +EDL* ClipEDLs::get_copy(EDL *src) +{ + if( !src ) return 0; + for( int i=0; ipath, src->path) ) return dst; + } + + EDL *dst = new EDL; + dst->create_objects(); + dst->copy_all(src); + append(dst); + return dst; +} + +EDL* ClipEDLs::load(char *path) +{ + for( int i=0; ipath, path) ) return dst; + } + + EDL *dst = new EDL; + dst->create_objects(); + + FileXML xml_file; + xml_file.read_from_file(path); + dst->load_xml(&xml_file, LOAD_ALL); + +// Override path EDL was saved to with the path it was loaded from. + dst->set_path(path); + append(dst); + return dst; +} + +void ClipEDLs::copy_nested(ClipEDLs &nested) +{ + clear(); + for( int i=0; icreate_objects(); + new_edl->copy_all(nested[i]); + append(new_edl); + } +} + +void ClipEDLs::update_index(EDL *clip_edl) +{ + for( int i=0; ipath, clip_edl->path) ) { + current->update_index(clip_edl); + } + } +} + diff --git a/cinelerra-5.1/cinelerra/clipedls.h b/cinelerra-5.1/cinelerra/clipedls.h new file mode 100644 index 00000000..8d4a4f8d --- /dev/null +++ b/cinelerra-5.1/cinelerra/clipedls.h @@ -0,0 +1,26 @@ +#ifndef NESTEDEDLS_H +#define NESTEDEDLS_H + + +#include "arraylist.h" +#include "edl.inc" + +class ClipEDLs : public ArrayList +{ +public: + ClipEDLs(); + ~ClipEDLs(); + + void add_clip(EDL *clip); + void remove_clip(EDL *clip); +// Return copy of the src EDL which belongs to the current object. + EDL* get_copy(EDL *src); + void copy_nested(ClipEDLs &nested); + EDL* load(char *path); + void clear(); + void update_index(EDL *clip); +}; + +#endif + + diff --git a/cinelerra-5.1/cinelerra/clipedls.inc b/cinelerra-5.1/cinelerra/clipedls.inc new file mode 100644 index 00000000..8febdcd4 --- /dev/null +++ b/cinelerra-5.1/cinelerra/clipedls.inc @@ -0,0 +1,9 @@ +#ifndef __CLIPEDLS_INC__ +#define __CLIPEDLS_INC__ + +class ClipEDLs; + +#endif + + + diff --git a/cinelerra-5.1/cinelerra/clippopup.C b/cinelerra-5.1/cinelerra/clippopup.C index 07ae7252..db11a158 100644 --- a/cinelerra-5.1/cinelerra/clippopup.C +++ b/cinelerra-5.1/cinelerra/clippopup.C @@ -26,16 +26,21 @@ #include "awindowgui.h" #include "bcsignals.h" #include "clipedit.h" +#include "clipedls.h" #include "cwindow.h" #include "cwindowgui.h" +#include "edit.h" +#include "edits.h" #include "edl.h" #include "filexml.h" #include "language.h" #include "localsession.h" #include "mainerror.h" +#include "mainindexes.h" #include "mainsession.h" #include "mwindow.h" #include "mwindowgui.h" +#include "track.h" #include "tracks.h" #include "vwindow.h" #include "vwindowgui.h" @@ -63,6 +68,8 @@ void ClipPopup::create_objects() add_item(view = new ClipPopupView(mwindow, this)); add_item(view_window = new ClipPopupViewWindow(mwindow, this)); add_item(new ClipPopupCopy(mwindow, this)); + add_item(new ClipPopupNest(mwindow, this)); + add_item(new ClipPopupUnNest(mwindow, this)); add_item(new ClipPopupPaste(mwindow, this)); add_item(menu_item = new BC_MenuItem(_("Match..."))); menu_item->add_submenu(submenu = new BC_SubMenu()); @@ -249,7 +256,7 @@ int ClipPopupCopy::handle_event() FileXML file; EDL *edl = mwindow->session->drag_clips->values[0]; double start = 0, end = edl->tracks->total_length(); - edl->copy(start, end, 1, 0, 0, &file, "", 1); + edl->copy(start, end, 1, &file, "", 1); const char *file_string = file.string(); long file_length = strlen(file_string); gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION); @@ -406,3 +413,104 @@ void ClipListMenu::update() format->update(); } + +ClipPopupNest::ClipPopupNest(MWindow *mwindow, ClipPopup *popup) + : BC_MenuItem(_("Nest")) +{ + this->mwindow = mwindow; + this->popup = popup; +} +ClipPopupNest::~ClipPopupNest() +{ +} + +int ClipPopupNest::handle_event() +{ + MWindowGUI *gui = mwindow->gui; + gui->lock_window("ClipPopupNest::handle_event 1"); + if( mwindow->session->drag_clips->total > 0 ) { + EDL *edl = mwindow->edl; + EDL *clip = mwindow->session->drag_clips->values[0]; + EDL *clip_edl = new EDL; // no parent for nested clip + clip_edl->create_objects(); + clip_edl->copy_all(clip); + EDL *new_clip = new EDL(edl); + new_clip->create_objects(); + new_clip->awindow_folder = AW_CLIP_FOLDER; + snprintf(new_clip->local_session->clip_title, + sizeof(new_clip->local_session->clip_title), + _("Nested: %s"), clip->local_session->clip_title); + strcpy(new_clip->local_session->clip_notes, + clip->local_session->clip_notes); + time_t dt; time(&dt); + struct tm dtm; localtime_r(&dt, &dtm); + char path[BCSTRLEN]; + sprintf(path, _("Nested_%02d%02d%02d-%02d%02d%02d"), + dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, + dtm.tm_hour, dtm.tm_min, dtm.tm_sec); + clip_edl->set_path(path); + new_clip->set_path(path); + new_clip->to_nested(clip_edl); + int idx = edl->clips.number_of(clip); + if( idx >= 0 ) { + edl->clips[idx] = new_clip; + clip->remove_user(); + } + else + edl->clips.append(new_clip); + mwindow->mainindexes->add_next_asset(0, clip_edl); + mwindow->mainindexes->start_build(); + clip_edl->remove_user(); + popup->gui->async_update_assets(); + } + gui->unlock_window(); + return 1; +} + + +ClipPopupUnNest::ClipPopupUnNest(MWindow *mwindow, ClipPopup *popup) + : BC_MenuItem(_("UnNest")) +{ + this->mwindow = mwindow; + this->popup = popup; +} +ClipPopupUnNest::~ClipPopupUnNest() +{ +} + +int ClipPopupUnNest::handle_event() +{ + EDL *nested_edl = 0; + MWindowGUI *gui = mwindow->gui; + gui->lock_window("ClipPopupUnNest::handle_event 1"); + if( mwindow->session->drag_clips->total > 0 ) { + EDL *clip = mwindow->session->drag_clips->values[0]; + Track *track = clip->tracks->first; + Edit *edit = track ? track->edits->first : 0; + nested_edl = edit && !edit->next && !edit->asset ? edit->nested_edl : 0; + while( nested_edl && (track=track->next)!=0 ) { + Edit *edit = track->edits->first; + if( !edit || edit->next || edit->nested_edl != nested_edl ) + nested_edl = 0; + } + if( nested_edl ) { + EDL *edl = mwindow->edl; + EDL *new_clip = new EDL(edl); + new_clip->create_objects(); + new_clip->copy_all(nested_edl); + new_clip->awindow_folder = AW_CLIP_FOLDER; + int idx = edl->clips.number_of(clip); + if( idx >= 0 ) { + edl->clips[idx] = new_clip; + clip->remove_user(); + } + else + edl->clips.append(new_clip); + edl->clips.add_clip(new_clip); + popup->gui->async_update_assets(); + } + } + gui->unlock_window(); + return 1; +} + diff --git a/cinelerra-5.1/cinelerra/clippopup.h b/cinelerra-5.1/cinelerra/clippopup.h index c641ce0f..dba9eab4 100644 --- a/cinelerra-5.1/cinelerra/clippopup.h +++ b/cinelerra-5.1/cinelerra/clippopup.h @@ -208,4 +208,28 @@ public: AWindowGUI *gui; }; +class ClipPopupNest : public BC_MenuItem +{ +public: + ClipPopupNest(MWindow *mwindow, ClipPopup *popup); + ~ClipPopupNest(); + + int handle_event(); + + MWindow *mwindow; + ClipPopup *popup; +}; + +class ClipPopupUnNest : public BC_MenuItem +{ +public: + ClipPopupUnNest(MWindow *mwindow, ClipPopup *popup); + ~ClipPopupUnNest(); + + int handle_event(); + + MWindow *mwindow; + ClipPopup *popup; +}; + #endif diff --git a/cinelerra-5.1/cinelerra/dvdcreate.C b/cinelerra-5.1/cinelerra/dvdcreate.C index 89072ef0..1014baf5 100644 --- a/cinelerra-5.1/cinelerra/dvdcreate.C +++ b/cinelerra-5.1/cinelerra/dvdcreate.C @@ -275,7 +275,7 @@ int CreateDVD_Thread::create_dvd_jobs(ArrayList *jobs, const ch char xml_filename[BCTEXTLEN]; sprintf(xml_filename, "%s/dvd.xml", asset_dir); FileXML xml_file; - edl->save_xml(&xml_file, xml_filename, 0, 0); + edl->save_xml(&xml_file, xml_filename); xml_file.terminate_string(); if( xml_file.write_to_file(xml_filename) ) { char msg[BCTEXTLEN]; diff --git a/cinelerra-5.1/cinelerra/edit.C b/cinelerra-5.1/cinelerra/edit.C index 9eb0d9d8..ce2612ac 100644 --- a/cinelerra-5.1/cinelerra/edit.C +++ b/cinelerra-5.1/cinelerra/edit.C @@ -32,7 +32,6 @@ #include "localsession.h" #include "plugin.h" #include "mainsession.h" -#include "nestededls.h" #include "strack.h" #include "trackcanvas.h" #include "tracks.h" @@ -242,7 +241,7 @@ int Edit::silence() void Edit::copy_from(Edit *edit) { - this->nested_edl = edl->nested_edls->get_copy(edit->nested_edl); + this->nested_edl = edl->nested_edls.get_copy(edit->nested_edl); this->asset = edl->assets->update(edit->asset); this->startsource = edit->startsource; this->startproject = edit->startproject; diff --git a/cinelerra-5.1/cinelerra/editpanel.C b/cinelerra-5.1/cinelerra/editpanel.C index a5d8df9b..8da34dba 100644 --- a/cinelerra-5.1/cinelerra/editpanel.C +++ b/cinelerra-5.1/cinelerra/editpanel.C @@ -940,7 +940,7 @@ EditCut::EditCut(MWindow *mwindow, EditPanel *panel, int x, int y) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("Cut ( x )")); + set_tooltip(_("Split | Cut ( x )")); } EditCut::~EditCut() { diff --git a/cinelerra-5.1/cinelerra/edits.C b/cinelerra-5.1/cinelerra/edits.C index 9024af90..d4886476 100644 --- a/cinelerra-5.1/cinelerra/edits.C +++ b/cinelerra-5.1/cinelerra/edits.C @@ -26,6 +26,7 @@ #include "bcsignals.h" #include "cache.h" #include "clip.h" +#include "clipedls.h" #include "edit.h" #include "edits.h" #include "edl.h" @@ -34,7 +35,6 @@ #include "filexml.h" #include "filesystem.h" #include "localsession.h" -#include "nestededls.h" #include "plugin.h" #include "strategies.inc" #include "track.h" @@ -111,11 +111,8 @@ printf("Edits::operator= 1\n"); } -void Edits::insert_asset(Asset *asset, - EDL *nested_edl, - int64_t length, - int64_t position, - int track_number) +void Edits::insert_asset(Asset *asset, EDL *nested_edl, + int64_t length, int64_t position, int track_number) { Edit *new_edit = insert_new_edit(position); @@ -172,7 +169,7 @@ void Edits::insert_edits(Edits *source_edits, { EDL *dest_nested_edl = 0; if(source_edit->nested_edl) - dest_nested_edl = edl->nested_edls->get_copy(source_edit->nested_edl); + dest_nested_edl = edl->nested_edls.get_copy(source_edit->nested_edl); // Update Assets Asset *dest_asset = 0; @@ -462,11 +459,10 @@ int Edits::load_edit(FileXML *file, int64_t &startproject, int track_offset) file->tag.get_property("SRC", path); //printf("Edits::load_edit %d path=%s\n", __LINE__, path); if(path[0] != 0) { - current->nested_edl = edl->nested_edls->get(path); + current->nested_edl = edl->nested_edls.load(path); } // printf("Edits::load_edit %d nested_edl->path=%s\n", -// __LINE__, -// current->nested_edl->path); +// __LINE__, current->nested_edl->path); } else if(file->tag.title_is("FILE")) { char filename[BCTEXTLEN]; diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index 7298baa3..13c03263 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -27,8 +27,10 @@ #include "awindowgui.inc" #include "bcsignals.h" #include "clip.h" +#include "cstrdup.h" #include "bccmodels.h" #include "bchash.h" +#include "clipedls.h" #include "edits.h" #include "edl.h" #include "edlsession.h" @@ -40,7 +42,6 @@ #include "localsession.h" #include "maskautos.h" #include "mutex.h" -#include "nestededls.h" #include "panauto.h" #include "panautos.h" #include "playbackconfig.h" @@ -60,10 +61,6 @@ -Mutex* EDL::id_lock = 0; - - - EDL::EDL(EDL *parent_edl) : Indexable(0) { @@ -71,15 +68,7 @@ EDL::EDL(EDL *parent_edl) tracks = 0; labels = 0; local_session = 0; -// vwindow_edl = 0; -// vwindow_edl_shared = 0; - folders.set_array_delete(); - -// persistent for now -// new_folder(CLIP_FOLDER); -// new_folder(MEDIA_FOLDER); - id = next_id(); path[0] = 0; } @@ -88,60 +77,25 @@ EDL::EDL(EDL *parent_edl) EDL::~EDL() { - if(tracks) - { - delete tracks; - } - if(labels) - { - delete labels; - } - - if(local_session) - { - delete local_session; - } - - + delete tracks; + delete labels; + delete local_session; remove_vwindow_edls(); - -// if(vwindow_edl && !vwindow_edl_shared) -// vwindow_edl->Garbage::remove_user(); - - if(!parent_edl) - { + if( !parent_edl ) { delete assets; delete session; } - - folders.remove_all_objects(); - for(int i = 0; i < clips.size(); i++) - clips.get(i)->Garbage::remove_user(); - clips.remove_all(); - delete nested_edls; } - void EDL::create_objects() { tracks = new Tracks(this); - if(!parent_edl) - { - assets = new Assets(this); - session = new EDLSession(this); - } - else - { - assets = parent_edl->assets; - session = parent_edl->session; - } - + assets = !parent_edl ? new Assets(this) : parent_edl->assets; + session = !parent_edl ? new EDLSession(this) : parent_edl->session; local_session = new LocalSession(this); labels = new Labels(this, "LABELS"); - nested_edls = new NestedEDLs; -// last_playback_position = 0; } EDL& EDL::operator=(EDL &edl) @@ -153,7 +107,7 @@ printf("EDL::operator= 1\n"); int EDL::load_defaults(BC_Hash *defaults) { - if(!parent_edl) + if( !parent_edl ) session->load_defaults(defaults); local_session->load_defaults(defaults); @@ -162,7 +116,7 @@ int EDL::load_defaults(BC_Hash *defaults) int EDL::save_defaults(BC_Hash *defaults) { - if(!parent_edl) + if( !parent_edl ) session->save_defaults(defaults); local_session->save_defaults(defaults); @@ -178,29 +132,23 @@ void EDL::boundaries() int EDL::create_default_tracks() { - for(int i = 0; i < session->video_tracks; i++) - { + for( int i=0; ivideo_tracks; ++i ) { tracks->add_video_track(0, 0); } - for(int i = 0; i < session->audio_tracks; i++) - { + for( int i=0; iaudio_tracks; ++i ) { tracks->add_audio_track(0, 0); } return 0; } -int EDL::load_xml(FileXML *file, - uint32_t load_flags) +int EDL::load_xml(FileXML *file, uint32_t load_flags) { int result = 0; -// Track numbering offset for replacing undo data. - int track_offset = 0; // Clear objects folders.remove_all_objects(); - if((load_flags & LOAD_ALL) == LOAD_ALL) - { + if( (load_flags & LOAD_ALL) == LOAD_ALL ) { remove_vwindow_edls(); } @@ -213,181 +161,172 @@ int EDL::load_xml(FileXML *file, // The parent_edl test is required to make EDL loading work because // when loading an EDL the EDL tag is already read by the parent. - if(!parent_edl) - { - do{ + if( !parent_edl ) { + do { result = file->read_tag(); - }while(!result && + } while(!result && !file->tag.title_is("XML") && !file->tag.title_is("EDL")); } + return result ? result : read_xml(file, load_flags); +} + +int EDL::read_xml(FileXML *file, uint32_t load_flags) +{ + int result = 0; +// Track numbering offset for replacing undo data. + int track_offset = 0; - if(!result) - { // Get path for backups -// path[0] = 0; - file->tag.get_property("path", path); + file->tag.get_property("path", path); // Erase everything - if((load_flags & LOAD_ALL) == LOAD_ALL || - (load_flags & LOAD_EDITS) == LOAD_EDITS) - { - while(tracks->last) delete tracks->last; - } + if( (load_flags & LOAD_ALL) == LOAD_ALL || + (load_flags & LOAD_EDITS) == LOAD_EDITS ) { + while(tracks->last) delete tracks->last; + } - if((load_flags & LOAD_ALL) == LOAD_ALL) - { - for(int i = 0; i < clips.size(); i++) - clips.get(i)->Garbage::remove_user(); - clips.remove_all(); - mixers.remove_all_objects(); - } + if( (load_flags & LOAD_ALL) == LOAD_ALL ) { + clips.clear(); + mixers.remove_all_objects(); + } - if(load_flags & LOAD_TIMEBAR) - { - while(labels->last) delete labels->last; - local_session->unset_inpoint(); - local_session->unset_outpoint(); - } + if( load_flags & LOAD_TIMEBAR ) { + while(labels->last) delete labels->last; + local_session->unset_inpoint(); + local_session->unset_outpoint(); + } // This was originally in LocalSession::load_xml - if(load_flags & LOAD_SESSION) - { - local_session->clipboard_length = 0; - } + if( load_flags & LOAD_SESSION ) { + local_session->clipboard_length = 0; + } - do{ - result = file->read_tag(); + do { + result = file->read_tag(); - if(!result) - { - if(file->tag.title_is("/XML") || - file->tag.title_is("/EDL") || - file->tag.title_is("/CLIP_EDL") || - file->tag.title_is("/VWINDOW_EDL")) - { - result = 1; - } - else - if(file->tag.title_is("CLIPBOARD")) - { - local_session->clipboard_length = - file->tag.get_property("LENGTH", (double)0); - } - else - if(file->tag.title_is("VIDEO")) - { - if((load_flags & LOAD_VCONFIG) && - (load_flags & LOAD_SESSION)) - session->load_video_config(file, 0, load_flags); - else - result = file->skip_tag(); - } - else - if(file->tag.title_is("AUDIO")) - { - if((load_flags & LOAD_ACONFIG) && - (load_flags & LOAD_SESSION)) - session->load_audio_config(file, 0, load_flags); - else - result = file->skip_tag(); - } - else - if(file->tag.title_is("FOLDER")) - { - char folder[BCTEXTLEN]; - strcpy(folder, file->read_text()); - new_folder(folder); - } + if( !result ) { + if( file->tag.title_is("/XML") || + file->tag.title_is("/EDL") || + file->tag.title_is("/CLIP_EDL") || + file->tag.title_is("/NESTED_EDL") || + file->tag.title_is("/VWINDOW_EDL") ) { + result = 1; + } + else + if( file->tag.title_is("CLIPBOARD") ) { + local_session->clipboard_length = + file->tag.get_property("LENGTH", (double)0); + } + else + if( file->tag.title_is("VIDEO") ) { + if( (load_flags & LOAD_VCONFIG) && + (load_flags & LOAD_SESSION) ) + session->load_video_config(file, 0, load_flags); else - if(file->tag.title_is("MIXERS")) - { - if((load_flags & LOAD_SESSION)) - mixers.load(file); - else - result = file->skip_tag(); - } + result = file->skip_tag(); + } + else + if( file->tag.title_is("AUDIO") ) { + if( (load_flags & LOAD_ACONFIG) && + (load_flags & LOAD_SESSION) ) + session->load_audio_config(file, 0, load_flags); else - if(file->tag.title_is("ASSETS")) - { - if(load_flags & LOAD_ASSETS) - assets->load(file, load_flags); - else - result = file->skip_tag(); - } + result = file->skip_tag(); + } + else + if( file->tag.title_is("FOLDER") ) { + char folder[BCTEXTLEN]; + strcpy(folder, file->read_text()); + new_folder(folder); + } + else + if( file->tag.title_is("MIXERS") ) { + if( (load_flags & LOAD_SESSION) ) + mixers.load(file); else - if(file->tag.title_is(labels->xml_tag)) - { - if(load_flags & LOAD_TIMEBAR) - labels->load(file, load_flags); - else - result = file->skip_tag(); - } + result = file->skip_tag(); + } + else + if( file->tag.title_is("ASSETS") ) { + if( load_flags & LOAD_ASSETS ) + assets->load(file, load_flags); else - if(file->tag.title_is("LOCALSESSION")) - { - if((load_flags & LOAD_SESSION) || - (load_flags & LOAD_TIMEBAR)) - local_session->load_xml(file, load_flags); - else - result = file->skip_tag(); - } + result = file->skip_tag(); + } + else + if( file->tag.title_is(labels->xml_tag) ) { + if( load_flags & LOAD_TIMEBAR ) + labels->load(file, load_flags); else - if(file->tag.title_is("SESSION")) - { - if((load_flags & LOAD_SESSION) && - !parent_edl) - session->load_xml(file, 0, load_flags); - else - result = file->skip_tag(); - } + result = file->skip_tag(); + } + else + if( file->tag.title_is("LOCALSESSION") ) { + if( (load_flags & LOAD_SESSION) || + (load_flags & LOAD_TIMEBAR) ) + local_session->load_xml(file, load_flags); else - if(file->tag.title_is("TRACK")) - { - tracks->load(file, track_offset, load_flags); - } + result = file->skip_tag(); + } + else + if( file->tag.title_is("SESSION") ) { + if( (load_flags & LOAD_SESSION) && + !parent_edl ) + session->load_xml(file, 0, load_flags); else + result = file->skip_tag(); + } + else + if( file->tag.title_is("TRACK") ) { + tracks->load(file, track_offset, load_flags); + } + else // Sub EDL. // Causes clip creation to fail because that involves an opening EDL tag. - if(file->tag.title_is("CLIP_EDL") && !parent_edl) - { - EDL *new_edl = new EDL(this); - new_edl->create_objects(); - new_edl->load_xml(file, LOAD_ALL); - - if((load_flags & LOAD_ALL) == LOAD_ALL) - clips.append(new_edl); - else - new_edl->Garbage::remove_user(); - } - else - if(file->tag.title_is("VWINDOW_EDL") && !parent_edl) - { - EDL *new_edl = new EDL(this); - new_edl->create_objects(); - new_edl->load_xml(file, LOAD_ALL); + if( file->tag.title_is("CLIP_EDL") && !parent_edl ) { + EDL *new_edl = new EDL(this); + new_edl->create_objects(); + new_edl->read_xml(file, LOAD_ALL); + if( (load_flags & LOAD_ALL) == LOAD_ALL ) + clips.add_clip(new_edl); + new_edl->remove_user(); + } + else + if( file->tag.title_is("NESTED_EDL") ) { + EDL *nested_edl = new EDL; + nested_edl->create_objects(); + nested_edl->read_xml(file, LOAD_ALL); + if( (load_flags & LOAD_ALL) == LOAD_ALL ) + nested_edls.add_clip(nested_edl); + nested_edl->remove_user(); + } + else + if( file->tag.title_is("VWINDOW_EDL") && !parent_edl ) { + EDL *new_edl = new EDL(this); + new_edl->create_objects(); + new_edl->read_xml(file, LOAD_ALL); - if((load_flags & LOAD_ALL) == LOAD_ALL) - { -// if(vwindow_edl && !vwindow_edl_shared) -// vwindow_edl->Garbage::remove_user(); + if( (load_flags & LOAD_ALL) == LOAD_ALL ) { +// if( vwindow_edl && !vwindow_edl_shared ) +// vwindow_edl->remove_user(); // vwindow_edl_shared = 0; // vwindow_edl = new_edl; - append_vwindow_edl(new_edl, 0); + append_vwindow_edl(new_edl, 0); - } - else + } + else // Discard if not replacing EDL - { - new_edl->Garbage::remove_user(); - new_edl = 0; - } + { + new_edl->remove_user(); + new_edl = 0; } } - }while(!result); - } + } + } while(!result); + boundaries(); //dump(); @@ -398,30 +337,20 @@ int EDL::load_xml(FileXML *file, // It is a "" if complete names should be used. // Called recursively by copy for clips, thus the string can't be terminated. // The string is not terminated in this call. -int EDL::save_xml(FileXML *file, - const char *output_path, - int is_clip, - int is_vwindow) -{ - copy(0, - tracks->total_length(), - 1, - is_clip, - is_vwindow, - file, - output_path, - 0); +int EDL::save_xml(FileXML *file, const char *output_path) +{ + copy(0, tracks->total_length(), 1, file, output_path, 0); return 0; } int EDL::copy_all(EDL *edl) { - if(this == edl) return 0; + if( this == edl ) return 0; update_index(edl); - nested_edls->clear(); copy_session(edl); copy_assets(edl); copy_clips(edl); + copy_nested(edl); copy_mixers(edl); tracks->copy_from(edl->tracks); labels->copy_from(edl->labels); @@ -430,73 +359,65 @@ int EDL::copy_all(EDL *edl) void EDL::copy_clips(EDL *edl) { - if(this == edl) return; + if( this == edl ) return; remove_vwindow_edls(); -// if(vwindow_edl && !vwindow_edl_shared) -// vwindow_edl->Garbage::remove_user(); +// if( vwindow_edl && !vwindow_edl_shared ) +// vwindow_edl->remove_user(); // vwindow_edl = 0; // vwindow_edl_shared = 0; - for(int i = 0; i < edl->total_vwindow_edls(); i++) - { + for( int i=0; itotal_vwindow_edls(); ++i ) { EDL *new_edl = new EDL(this); new_edl->create_objects(); new_edl->copy_all(edl->get_vwindow_edl(i)); append_vwindow_edl(new_edl, 0); } - for(int i = 0; i < clips.size(); i++) - clips.get(i)->Garbage::remove_user(); - clips.remove_all(); - for(int i = 0; i < edl->clips.total; i++) - { - add_clip(edl->clips.values[i]); - } + clips.clear(); + for( int i=0; iclips.size(); ++i ) add_clip(edl->clips[i]); +} + +void EDL::copy_nested(EDL *edl) +{ + if( this == edl ) return; + nested_edls.copy_nested(edl->nested_edls); } void EDL::copy_assets(EDL *edl) { - if(this == edl) return; + if( this == edl ) return; - if(!parent_edl) - { + if( !parent_edl ) { assets->copy_from(edl->assets); } } void EDL::copy_mixers(EDL *edl) { - if(this == edl) return; + if( this == edl ) return; mixers.copy_from(edl->mixers); } void EDL::copy_session(EDL *edl, int session_only) { - if(this == edl) return; + if( this == edl ) return; - if(!session_only) - { + if( !session_only ) { strcpy(this->path, edl->path); //printf("EDL::copy_session %p %s\n", this, this->path); folders.remove_all_objects(); - for(int i = 0; i < edl->folders.total; i++) - { - char *new_folder; - folders.append(new_folder = new char[strlen(edl->folders.values[i]) + 1]); - strcpy(new_folder, edl->folders.values[i]); - } + for( int i=0; ifolders.size(); ++i ) + folders.append(cstrdup(edl->folders[i])); } - if(!parent_edl) - { + if( !parent_edl ) { session->copy(edl->session); } - if(!session_only) - { + if( !session_only ) { local_session->copy_from(edl->local_session); } } @@ -515,37 +436,22 @@ int EDL::copy_assets(double start, file->append_newline(); // Copy everything for a save - if(all) - { - for(Asset *asset = assets->first; - asset; - asset = asset->next) - { + if( all ) { + for( Asset *asset=assets->first; asset; asset=asset->next ) { asset_list.append(asset); } } - else + else { // Copy just the ones being used. - { - for(current = tracks->first; - current; - current = NEXT) - { - if(current->record) - { - current->copy_assets(start, - end, - &asset_list); - } + for( current = tracks->first; current; current = NEXT ) { + if( !current->record ) continue; + current->copy_assets(start, end, &asset_list); } } // Paths relativised here - for(int i = 0; i < asset_list.total; i++) - { - asset_list.values[i]->write(file, - 0, - output_path); + for( int i=0; iwrite(file, 0, output_path); } file->tag.set_title("/ASSETS"); @@ -555,39 +461,49 @@ int EDL::copy_assets(double start, return 0; } -int EDL::copy(double start, - double end, - int all, - int is_clip, - int is_vwindow, - FileXML *file, - const char *output_path, - int rewind_it) + +int EDL::copy(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it) { -//printf("EDL::copy 1\n"); -// begin file - if(is_clip) - file->tag.set_title("CLIP_EDL"); - else - if(is_vwindow) - file->tag.set_title("VWINDOW_EDL"); - else - { - file->tag.set_title("EDL"); - file->tag.set_property("VERSION", CINELERRA_VERSION); + file->tag.set_title("EDL"); + file->tag.set_property("VERSION", CINELERRA_VERSION); // Save path for restoration of the project title from a backup. - if(this->path[0]) - { - file->tag.set_property("PATH", path); - } - } + if( this->path[0] ) file->tag.set_property("PATH", path); + return copy(start, end, all, + "/EDL", file, output_path, rewind_it); +} +int EDL::copy_clip(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it) +{ + file->tag.set_title("CLIP_EDL"); + return copy(start, end, all, + "/CLIP_EDL", file, output_path, rewind_it); +} +int EDL::copy_nested_edl(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it) +{ + file->tag.set_title("NESTED_EDL"); + if( this->path[0] ) file->tag.set_property("PATH", path); + return copy(start, end, all, + "/NESTED_EDL", file, output_path, rewind_it); +} +int EDL::copy_vwindow_edl(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it) +{ + file->tag.set_title("VWINDOW_EDL"); + return copy(start, end, all, + "/VWINDOW_EDL", file, output_path, rewind_it); +} + +int EDL::copy(double start, double end, int all, + const char *closer, FileXML *file, + const char *output_path, int rewind_it) +{ file->append_tag(); file->append_newline(); - // Set clipboard samples only if copying to clipboard - if(!all) - { + if( !all ) { file->tag.set_title("CLIPBOARD"); file->tag.set_property("LENGTH", end - start); file->append_tag(); @@ -613,38 +529,32 @@ int EDL::copy(double start, session->save_audio_config(file); // Folders - for(int i = 0; i < folders.total; i++) - { + for( int i=0; itag.set_title("FOLDER"); file->append_tag(); - file->append_text(folders.values[i]); + file->append_text(folders[i]); file->tag.set_title("/FOLDER"); file->append_tag(); file->append_newline(); } -// Media -// Don't replicate all assets for every clip. -// The assets for the clips are probably in the main EDL. - if( !is_clip ) - copy_assets(start, end, file, all, output_path); + copy_assets(start, end, file, all, output_path); + + for( int i=0; icopy_nested_edl(0, tracks->total_length(), 1, + file, output_path, 0); + // Clips // Don't want this if using clipboard - if(all) - { - for(int i = 0; i < total_vwindow_edls(); i++) - { - get_vwindow_edl(i)->save_xml(file, - output_path, - 0, - 1); - } + if( all ) { + for( int i=0; icopy_vwindow_edl(0, tracks->total_length(), 1, + file, output_path, 0); + + for( int i=0; icopy_clip(0, tracks->total_length(), 1, + file, output_path, 0); - for(int i = 0; i < clips.total; i++) - clips.values[i]->save_xml(file, - output_path, - 1, - 0); mixers.save(file); } @@ -652,35 +562,38 @@ int EDL::copy(double start, file->append_newline(); } - -//printf("EDL::copy 1\n"); - labels->copy(start, end, file); -//printf("EDL::copy 1\n"); tracks->copy(start, end, all, file, output_path); -//printf("EDL::copy 2\n"); // terminate file - if( is_clip ) - file->tag.set_title("/CLIP_EDL"); - else if( is_vwindow ) - file->tag.set_title("/VWINDOW_EDL"); - else - file->tag.set_title("/EDL"); + file->tag.set_title(closer); file->append_tag(); file->append_newline(); - // For editing operations we want to rewind it for immediate pasting. // For clips and saving to disk leave it alone. - if(rewind_it) - { + if( rewind_it ) { file->terminate_string(); file->rewind(); } return 0; } +int EDL::to_nested(EDL *nested_edl) +{ +// Keep frame rate, sample rate, and output size unchanged. +// These parameters would revert the project if VWindow displayed an asset +// of different size than the project. + +// Nest all video & audio outputs + session->video_tracks = 1; + session->audio_tracks = nested_edl->session->audio_channels; + create_default_tracks(); + insert_asset(0, nested_edl, 0, 0, 0); + return 0; +} + + void EDL::retrack() { int min_w = session->output_w, min_h = session->output_h; @@ -695,7 +608,7 @@ void EDL::retrack() if( h < edit_h ) h = edit_h; } if( track->track_w == w && track->track_h == h ) continue; - ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])-> + ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])-> translate_masks( (w - track->track_w) / 2, (h - track->track_h) / 2); track->track_w = w; track->track_h = h; } @@ -703,16 +616,12 @@ void EDL::retrack() void EDL::rechannel() { - for(Track *current = tracks->first; current; current = NEXT) - { - if(current->data_type == TRACK_AUDIO) - { + for( Track *current=tracks->first; current; current=NEXT ) { + if( current->data_type == TRACK_AUDIO ) { PanAutos *autos = (PanAutos*)current->automation->autos[AUTOMATION_PAN]; ((PanAuto*)autos->default_auto)->rechannel(); - for(PanAuto *keyframe = (PanAuto*)autos->first; - keyframe; - keyframe = (PanAuto*)keyframe->next) - { + for( PanAuto *keyframe = (PanAuto*)autos->first; + keyframe; keyframe = (PanAuto*)keyframe->next ) { keyframe->rechannel(); } } @@ -721,10 +630,8 @@ void EDL::rechannel() void EDL::resample(double old_rate, double new_rate, int data_type) { - for(Track *current = tracks->first; current; current = NEXT) - { - if(current->data_type == data_type) - { + for( Track *current=tracks->first; current; current=NEXT ) { + if( current->data_type == data_type ) { current->resample(old_rate, new_rate); } } @@ -734,11 +641,9 @@ void EDL::resample(double old_rate, double new_rate, int data_type) void EDL::synchronize_params(EDL *edl) { local_session->synchronize_params(edl->local_session); - for(Track *this_track = tracks->first, *that_track = edl->tracks->first; - this_track && that_track; - this_track = this_track->next, - that_track = that_track->next) - { + for( Track *this_track=tracks->first, *that_track=edl->tracks->first; + this_track && that_track; + this_track=this_track->next, that_track=that_track->next ) { this_track->synchronize_params(that_track); } } @@ -749,8 +654,7 @@ int EDL::trim_selection(double start, int edit_plugins, int edit_autos) { - if(start != end) - { + if( start != end ) { // clear the data clear(0, start, @@ -769,16 +673,9 @@ int EDL::trim_selection(double start, int EDL::equivalent(double position1, double position2) { - double threshold = (double).5 / session->frame_rate; - if(session->cursor_on_frames) - threshold = (double).5 / session->frame_rate; - else - threshold = (double)1 / session->sample_rate; - - if(fabs(position2 - position1) < threshold) - return 1; - else - return 0; + double threshold = session->cursor_on_frames ? + 0.5 / session->frame_rate : 1.0 / session->sample_rate; + return fabs(position2 - position1) < threshold ? 1 : 0; } double EDL::equivalent_output(EDL *edl) @@ -797,30 +694,26 @@ void EDL::set_path(const char *path) void EDL::set_inpoint(double position) { - if(equivalent(local_session->get_inpoint(), position) && - local_session->get_inpoint() >= 0) - { + if( equivalent(local_session->get_inpoint(), position) && + local_session->get_inpoint() >= 0 ) { local_session->unset_inpoint(); } - else - { + else { local_session->set_inpoint(align_to_frame(position, 0)); - if(local_session->get_outpoint() <= local_session->get_inpoint()) + if( local_session->get_outpoint() <= local_session->get_inpoint() ) local_session->unset_outpoint(); } } void EDL::set_outpoint(double position) { - if(equivalent(local_session->get_outpoint(), position) && - local_session->get_outpoint() >= 0) - { + if( equivalent(local_session->get_outpoint(), position) && + local_session->get_outpoint() >= 0 ) { local_session->unset_outpoint(); } - else - { + else { local_session->set_outpoint(align_to_frame(position, 0)); - if(local_session->get_inpoint() >= local_session->get_outpoint()) + if( local_session->get_inpoint() >= local_session->get_outpoint() ) local_session->unset_inpoint(); } } @@ -839,8 +732,7 @@ int EDL::blade(double position) int EDL::clear(double start, double end, int clear_labels, int clear_plugins, int edit_autos) { - if(start == end) - { + if( start == end ) { double distance = 0; tracks->clear_handle(start, end, @@ -848,17 +740,16 @@ int EDL::clear(double start, double end, clear_labels, clear_plugins, edit_autos); - if(clear_labels && distance > 0) + if( clear_labels && distance > 0 ) labels->paste_silence(start, start + distance); } - else - { + else { tracks->clear(start, end, clear_plugins, edit_autos); - if(clear_labels) + if( clear_labels ) labels->clear(start, end, 1); @@ -918,7 +809,7 @@ void EDL::paste_silence(double start, int edit_plugins, int edit_autos) { - if(edit_labels) + if( edit_labels ) labels->paste_silence(start, end); tracks->paste_silence(start, end, @@ -929,60 +820,43 @@ void EDL::paste_silence(double start, void EDL::remove_from_project(ArrayList *clips) { - for(int i = 0; i < clips->size(); i++) - { - for(int j = 0; j < this->clips.size(); j++) - { - if(this->clips.get(j) == clips->values[i]) - { - EDL *clip = this->clips.get(j); - this->clips.remove(clip); - clip->Garbage::remove_user(); - } - } + for( int i=0; isize(); ++i ) { + this->clips.remove_clip(clips->get(i)); } } void EDL::remove_from_project(ArrayList *assets) { // Remove from clips - if(!parent_edl) - for(int j = 0; j < clips.total; j++) - { - clips.values[j]->remove_from_project(assets); + if( !parent_edl ) + for( int j=0; jremove_from_project(assets); } // Remove from VWindow EDLs - for(int i = 0; i < total_vwindow_edls(); i++) + for( int i=0; iremove_from_project(assets); - for(int i = 0; i < assets->size(); i++) - { + for( int i=0; isize(); ++i ) { // Remove from tracks - for(Track *track = tracks->first; track; track = track->next) - { + for( Track *track=tracks->first; track; track=track->next ) { track->remove_asset(assets->get(i)); } // Remove from assets - if(!parent_edl && assets->get(i)->is_asset) - { + if( !parent_edl && assets->get(i)->is_asset ) { this->assets->remove_asset((Asset*)assets->get(i)); } else - if(!parent_edl && !assets->get(i)->is_asset) - { - this->nested_edls->remove_edl((EDL*)assets->get(i)); + if( !parent_edl && !assets->get(i)->is_asset ) { + this->nested_edls.remove_clip((EDL*)assets->get(i)); } } } void EDL::update_assets(EDL *src) { - for(Asset *current = src->assets->first; - current; - current = NEXT) - { + for( Asset *current=src->assets->first; current; current=NEXT ) { assets->update(current); } } @@ -990,10 +864,7 @@ void EDL::update_assets(EDL *src) int EDL::get_tracks_height(Theme *theme) { int total_pixels = 0; - for(Track *current = tracks->first; - current; - current = NEXT) - { + for( Track *current=tracks->first; current; current=NEXT ) { total_pixels += current->vertical_span(theme); } return total_pixels; @@ -1002,12 +873,9 @@ int EDL::get_tracks_height(Theme *theme) int64_t EDL::get_tracks_width() { int64_t total_pixels = 0; - for(Track *current = tracks->first; - current; - current = NEXT) - { + for( Track *current=tracks->first; current; current=NEXT ) { int64_t pixels = current->horizontal_span(); - if(pixels > total_pixels) total_pixels = pixels; + if( pixels > total_pixels ) total_pixels = pixels; } //printf("EDL::get_tracks_width %d\n", total_pixels); return total_pixels; @@ -1015,24 +883,24 @@ int64_t EDL::get_tracks_width() // int EDL::calculate_output_w(int single_channel) // { -// if(single_channel) return session->output_w; +// if( single_channel ) return session->output_w; // // int widest = 0; -// for(int i = 0; i < session->video_channels; i++) +// for( int i=0; ivideo_channels; ++i ) // { -// if(session->vchannel_x[i] + session->output_w > widest) widest = session->vchannel_x[i] + session->output_w; +// if( session->vchannel_x[i] + session->output_w > widest ) widest = session->vchannel_x[i] + session->output_w; // } // return widest; // } // // int EDL::calculate_output_h(int single_channel) // { -// if(single_channel) return session->output_h; +// if( single_channel ) return session->output_h; // // int tallest = 0; -// for(int i = 0; i < session->video_channels; i++) +// for( int i=0; ivideo_channels; ++i ) // { -// if(session->vchannel_y[i] + session->output_h > tallest) tallest = session->vchannel_y[i] + session->output_h; +// if( session->vchannel_y[i] + session->output_h > tallest ) tallest = session->vchannel_y[i] + session->output_h; // } // return tallest; // } @@ -1040,7 +908,7 @@ int64_t EDL::get_tracks_width() // Get the total output size scaled to aspect ratio void EDL::calculate_conformed_dimensions(int single_channel, float &w, float &h) { - if((float)session->output_w / session->output_h > get_aspect_ratio()) + if( (float)session->output_w / session->output_h > get_aspect_ratio() ) h = (w = session->output_w) / get_aspect_ratio(); else w = (h = session->output_h) * get_aspect_ratio(); @@ -1053,7 +921,7 @@ float EDL::get_aspect_ratio() int EDL::dump(FILE *fp) { - if(parent_edl) + if( parent_edl ) fprintf(fp,"CLIP\n"); else fprintf(fp,"EDL\n"); @@ -1064,15 +932,13 @@ int EDL::dump(FILE *fp) local_session->get_selectionend(1), local_session->loop_start, local_session->loop_end); - for(int i = 0; i < TOTAL_PANES; i++) - { + for( int i=0; iview_start[i], local_session->track_start[i]); } - if(!parent_edl) - { + if( !parent_edl ) { fprintf(fp,"audio_channels: %d audio_tracks: %d sample_rate: %jd\n", session->audio_channels, session->audio_tracks, @@ -1081,9 +947,9 @@ int EDL::dump(FILE *fp) " video_tracks: %d\n" " frame_rate: %.2f\n" " frames_per_foot: %.2f\n" - " output_w: %d\n" - " output_h: %d\n" - " aspect_w: %f\n" + " output_w: %d\n" + " output_h: %d\n" + " aspect_w: %f\n" " aspect_h: %f\n" " color_model: %d\n", session->video_channels, @@ -1091,26 +957,27 @@ int EDL::dump(FILE *fp) session->frame_rate, session->frames_per_foot, session->output_w, - session->output_h, - session->aspect_w, - session->aspect_h, + session->output_h, + session->aspect_w, + session->aspect_h, session->color_model); - fprintf(fp," CLIPS\n"); - fprintf(fp," total: %d\n", clips.total); - - for(int i = 0; i < clips.total; i++) - { + fprintf(fp," CLIPS"); + fprintf(fp," total: %d\n", clips.size()); + for( int i=0; idump(fp); + clips[i]->dump(fp); fprintf(fp,"\n\n"); } + fprintf(fp," NESTED_EDLS"); + fprintf(fp," total: %d\n", nested_edls.size()); + for( int i=0; ipath); - fprintf(fp," VWINDOW EDLS\n"); + fprintf(fp," VWINDOW EDLS"); fprintf(fp," total: %d\n", total_vwindow_edls()); - for(int i = 0; i < total_vwindow_edls(); i++) - { + for( int i=0; ilocal_session->clip_title); } @@ -1145,8 +1012,8 @@ void EDL::insert_asset(Asset *asset, Asset *new_asset = 0; EDL *new_nested_edl = 0; - if(asset) new_asset = assets->update(asset); - if(nested_edl) new_nested_edl = nested_edls->get_copy(nested_edl); + if( asset ) new_asset = assets->update(asset); + if( nested_edl ) new_nested_edl = nested_edls.get_copy(nested_edl); // Paste video int vtrack = 0; @@ -1158,18 +1025,15 @@ void EDL::insert_asset(Asset *asset, int layers = 0; int channels = 0; - if(new_nested_edl) - { + if( new_nested_edl ) { length = new_nested_edl->tracks->total_length(); layers = 1; channels = new_nested_edl->session->audio_channels; } - if(new_asset) - { + if( new_asset ) { // Insert 1 frame for undefined length - if(new_asset->video_length < 0) - { + if( new_asset->video_length < 0 ) { length = session->si_useduration ? session->si_duration : 1.0 / session->frame_rate; @@ -1183,30 +1047,17 @@ void EDL::insert_asset(Asset *asset, channels = new_asset->channels; } - for( ; - current && vtrack < layers; - current = NEXT) - { - if(!current->record || - current->data_type != TRACK_VIDEO) - continue; - - current->insert_asset(new_asset, - new_nested_edl, - length, - position, - vtrack); - - vtrack++; + for( ; current && vtrackrecord || current->data_type != TRACK_VIDEO ) continue; + current->insert_asset(new_asset, new_nested_edl, + length, position, vtrack++); } int atrack = 0; - if(new_asset) - { - if(new_asset->audio_length < 0) - { + if( new_asset ) { + if( new_asset->audio_length < 0 ) { // Insert 1 frame for undefined length & video - if(new_asset->video_data) + if( new_asset->video_data ) length = (double)1.0 / new_asset->frame_rate; else // Insert 1 second for undefined length & no video @@ -1217,29 +1068,16 @@ void EDL::insert_asset(Asset *asset, new_asset->sample_rate; } - for(current = tracks->first; - current && atrack < channels; - current = NEXT) - { - if(!current->record || - current->data_type != TRACK_AUDIO) - continue; - - current->insert_asset(new_asset, - new_nested_edl, - length, - position, - atrack); - - - atrack++; + current = tracks->first; + for( ; current && atrack < channels; current=NEXT ) { + if( !current->record || current->data_type != TRACK_AUDIO ) continue; + current->insert_asset(new_asset, new_nested_edl, + length, position, atrack++); } // Insert labels from a recording window. - if(labels) - { - for(RecordLabel *label = labels->first; label; label = label->next) - { + if( labels ) { + for( RecordLabel *label=labels->first; label; label=label->next ) { this->labels->toggle_label(label->position, label->position); } } @@ -1249,31 +1087,32 @@ void EDL::insert_asset(Asset *asset, void EDL::set_index_file(Indexable *indexable) { - if(indexable->is_asset) + if( indexable->is_asset ) assets->update_index((Asset*)indexable); else - nested_edls->update_index((EDL*)indexable); + nested_edls.update_index((EDL*)indexable); } void EDL::optimize() { //printf("EDL::optimize 1\n"); - if(local_session->preview_start < 0) local_session->preview_start = 0; + if( local_session->preview_start < 0 ) local_session->preview_start = 0; double length = tracks->total_length(); - if(local_session->preview_end > length) local_session->preview_end = length; - if(local_session->preview_start >= local_session->preview_end ) { + if( local_session->preview_end > length ) local_session->preview_end = length; + if( local_session->preview_start >= local_session->preview_end ) { local_session->preview_start = 0; local_session->preview_end = length; } - for(Track *current = tracks->first; current; current = NEXT) + for( Track *current=tracks->first; current; current=NEXT ) current->optimize(); } int EDL::next_id() { - id_lock->lock("EDL::next_id"); + static Mutex id_lock; + id_lock.lock("EDL::next_id"); int result = EDLSession::current_id++; - id_lock->unlock(); + id_lock.unlock(); return result; } @@ -1282,46 +1121,27 @@ void EDL::get_shared_plugins(Track *source, int omit_recordable, int data_type) { - for(Track *track = tracks->first; track; track = track->next) - { - if(!track->record || !omit_recordable) - { - if(track != source && - track->data_type == data_type) - { - for(int i = 0; i < track->plugin_set.total; i++) - { - Plugin *plugin = track->get_current_plugin( - local_session->get_selectionstart(1), - i, - PLAY_FORWARD, - 1, - 0); - if(plugin && plugin->plugin_type == PLUGIN_STANDALONE) - { - plugin_locations->append(new SharedLocation(tracks->number_of(track), i)); - } - } - } + for( Track *track=tracks->first; track; track=track->next ) { + if( track->record && omit_recordable ) continue; + if( track == source || track->data_type != data_type ) continue; + for( int i=0; iplugin_set.size(); ++i ) { + Plugin *plugin = track->get_current_plugin( + local_session->get_selectionstart(1), + i, PLAY_FORWARD, 1, 0); + if( plugin && plugin->plugin_type != PLUGIN_STANDALONE ) continue; + plugin_locations->append(new SharedLocation(tracks->number_of(track), i)); } } } void EDL::get_shared_tracks(Track *track, ArrayList *module_locations, - int omit_recordable, - int data_type) + int omit_recordable, int data_type) { - for(Track *current = tracks->first; current; current = NEXT) - { - if(!omit_recordable || !current->record) - { - if(current != track && - current->data_type == data_type) - { - module_locations->append(new SharedLocation(tracks->number_of(current), 0)); - } - } + for( Track *current=tracks->first; current; current=NEXT ) { + if( omit_recordable && current->record ) continue; + if( current == track || current->data_type != data_type ) continue; + module_locations->append(new SharedLocation(tracks->number_of(current), 0)); } } @@ -1345,39 +1165,20 @@ double EDL::align_to_frame(double position, int round) void EDL::new_folder(const char *folder) { - for(int i = 0; i < folders.total; i++) - { - if(!strcasecmp(folders.values[i], folder)) return; - } - - char *new_folder; - folders.append(new_folder = new char[strlen(folder) + 1]); - strcpy(new_folder, folder); + for( int i=0; i= 0 && strcasecmp(folders[i], folder) ); + if( i >= 0 ) folders.remove_number(i); } int EDL::get_use_vconsole(VEdit* *playable_edit, - int64_t position, - int direction, - PlayableTracks *playable_tracks) + int64_t position, int direction, PlayableTracks *playable_tracks) { int share_playable_tracks = 1; int result = 0; @@ -1386,57 +1187,47 @@ int EDL::get_use_vconsole(VEdit* *playable_edit, *playable_edit = 0; // Calculate playable tracks when being called as a nested EDL - if(!playable_tracks) - { + if( !playable_tracks ) { share_playable_tracks = 0; playable_tracks = new PlayableTracks(this, - position, - direction, - TRACK_VIDEO, - 1); + position, direction, TRACK_VIDEO, 1); } // Total number of playable tracks is 1 - if(playable_tracks->size() != 1) - { + if( playable_tracks->size() != 1 ) { result = 1; } - else - { + else { playable_track = (VTrack*)playable_tracks->get(0); } // Don't need playable tracks anymore - if(!share_playable_tracks) - { + if( !share_playable_tracks ) { delete playable_tracks; } -if(debug) printf("EDL::get_use_vconsole %d playable_tracks->size()=%d\n", -__LINE__, -playable_tracks->size()); - if(result) return 1; +if( debug ) printf("EDL::get_use_vconsole %d playable_tracks->size()=%d\n", + __LINE__, playable_tracks->size()); + if( result ) return 1; // Test mutual conditions between direct copy rendering and this. - if(!playable_track->direct_copy_possible(position, + if( !playable_track->direct_copy_possible(position, direction, - 1)) + 1) ) return 1; -if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__); +if( debug ) printf("EDL::get_use_vconsole %d\n", __LINE__); *playable_edit = (VEdit*)playable_track->edits->editof(position, - direction, - 0); + direction, 0); // No edit at current location - if(!*playable_edit) return 1; -if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__); + if( !*playable_edit ) return 1; +if( debug ) printf("EDL::get_use_vconsole %d\n", __LINE__); // Edit is nested EDL - if((*playable_edit)->nested_edl) - { + if( (*playable_edit)->nested_edl ) { // Test nested EDL EDL *nested_edl = (*playable_edit)->nested_edl; int64_t nested_position = (int64_t)((position - @@ -1447,23 +1238,23 @@ if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__); VEdit *playable_edit_temp = 0; - if(session->output_w != nested_edl->session->output_w || + if( session->output_w != nested_edl->session->output_w || session->output_h != nested_edl->session->output_h || nested_edl->get_use_vconsole(&playable_edit_temp, nested_position, direction, - 0)) + 0) ) return 1; return 0; } -if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__); +if( debug ) printf("EDL::get_use_vconsole %d\n", __LINE__); // Edit is not a nested EDL Asset *asset = (*playable_edit)->asset; // Edit is silence - if(!asset) return 1; -if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__); + if( !asset ) return 1; +if( debug ) printf("EDL::get_use_vconsole %d\n", __LINE__); // Asset and output device must have the same dimensions if( asset->width != session->output_w || @@ -1471,7 +1262,7 @@ if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__); return 1; -if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__); +if( debug ) printf("EDL::get_use_vconsole %d\n", __LINE__); // Asset and output device must have same resulting de-interlacing method if( ilaceautofixmethod2(session->interlace_mode, asset->interlace_autofixoption, asset->interlace_mode, @@ -1541,19 +1332,16 @@ int64_t EDL::get_video_frames() void EDL::remove_vwindow_edls() { - for(int i = 0; i < total_vwindow_edls(); i++) - { - get_vwindow_edl(i)->Garbage::remove_user(); + for( int i=0; iremove_user(); } vwindow_edls.remove_all(); } void EDL::remove_vwindow_edl(EDL *edl) { - if(vwindow_edls.number_of(edl) >= 0) - { - edl->Garbage::remove_user(); - + if( vwindow_edls.number_of(edl) >= 0 ) { + edl->remove_user(); vwindow_edls.remove(edl); } } @@ -1573,7 +1361,7 @@ void EDL::append_vwindow_edl(EDL *edl, int increase_counter) { if(vwindow_edls.number_of(edl) >= 0) return; - if(increase_counter) edl->Garbage::add_user(); + if(increase_counter) edl->add_user(); vwindow_edls.append(edl); } diff --git a/cinelerra-5.1/cinelerra/edl.h b/cinelerra-5.1/cinelerra/edl.h index e5955664..60784dcf 100644 --- a/cinelerra-5.1/cinelerra/edl.h +++ b/cinelerra-5.1/cinelerra/edl.h @@ -40,7 +40,7 @@ #include "localsession.inc" #include "maxchannels.h" #include "mutex.inc" -#include "nestededls.inc" +#include "clipedls.h" #include "playabletracks.inc" #include "playbackconfig.h" #include "pluginserver.h" @@ -80,14 +80,11 @@ public: void boundaries(); // Create tracks using existing configuration int create_default_tracks(); - int load_xml(FileXML *file, - uint32_t load_flags); - int save_xml(FileXML *xml, - const char *output_path, - int is_clip, - int is_vwindow); - int load_audio_config(FileXML *file, int append_mode, uint32_t load_flags); - int load_video_config(FileXML *file, int append_mode, uint32_t load_flags); + int load_xml(FileXML *file, uint32_t load_flags); + int read_xml(FileXML *file, uint32_t load_flags); + int save_xml(FileXML *xml, const char *output_path); + int load_audio_config(FileXML *file, int append_mode, uint32_t load_flags); + int load_video_config(FileXML *file, int append_mode, uint32_t load_flags); // Return 1 if rendering requires a virtual console. int get_use_vconsole(VEdit* *playable_edit, @@ -105,6 +102,15 @@ public: // Scale all sample values since everything is locked to audio void rechannel(); void resample(double old_rate, double new_rate, int data_type); + int copy(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it); + int copy_clip(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it); + int copy_nested_edl(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it); + int copy_vwindow_edl(double start, double end, int all, + FileXML *file, const char *output_path, int rewind_it); + void copy_tracks(EDL *edl); // Copies project path, folders, EDLSession, and LocalSession from edl argument. // session_only - used by preferences and format specify @@ -113,6 +119,7 @@ public: int copy_all(EDL *edl); void copy_assets(EDL *edl); void copy_clips(EDL *edl); + void copy_nested(EDL *edl); void copy_mixers(EDL *edl); // Copy pan and fade settings from edl void synchronize_params(EDL *edl); @@ -169,29 +176,20 @@ public: int edit_autos); // Editing functions - int copy_assets(double start, - double end, - FileXML *file, - int all, - const char *output_path); - int copy(double start, - double end, - int all, // Ignore recordable status of tracks for saving - int is_clip, - int is_vwindow, - FileXML *file, - const char *output_path, - int rewind_it); // Rewind EDL for easy pasting - void paste_silence(double start, - double end, + int copy_assets(double start, double end, + FileXML *file, int all, const char *output_path); + int copy(double start, double end, int all, + const char *closer, FileXML *file, + const char *output_path, int rewind_it); + int to_nested(EDL *nested_edl); + void paste_silence(double start, double end, int edit_labels /* = 1 */, int edit_plugins, int edit_autos); void remove_from_project(ArrayList *assets); void remove_from_project(ArrayList *clips); int blade(double position); - int clear(double start, - double end, + int clear(double start, double end, int clear_labels, int clear_plugins, int edit_autos); @@ -243,10 +241,8 @@ public: // Titles of all subfolders ArrayList folders; -// Clips - ArrayList clips; -// Nested EDLs - NestedEDLs *nested_edls; +// Clips, Nested EDLs + ClipEDLs clips, nested_edls; // EDLs being shown in VWindows ArrayList vwindow_edls; // is the vwindow_edl shared and therefore should not be deleted in destructor @@ -257,8 +253,6 @@ public: // Shared between all EDLs Assets *assets; - - Tracks *tracks; Labels *labels; // Shared between all EDLs in a tree, for projects. @@ -266,17 +260,8 @@ public: // Specific to this EDL, for clips. LocalSession *local_session; - - - - - // Use parent Assets if nonzero EDL *parent_edl; - - - static Mutex *id_lock; - }; #endif diff --git a/cinelerra-5.1/cinelerra/edlsession.C b/cinelerra-5.1/cinelerra/edlsession.C index 5c663922..292de030 100644 --- a/cinelerra-5.1/cinelerra/edlsession.C +++ b/cinelerra-5.1/cinelerra/edlsession.C @@ -71,7 +71,7 @@ EDLSession::EDLSession(EDL *edl) cwindow_scrollbars = 0; cwindow_xscroll = cwindow_yscroll = 0; cwindow_zoom = 1.0; - cwindow_click2play = 1; + cwindow_click2play = 0; strcpy(default_atransition, ""); strcpy(default_vtransition, ""); default_transition_length = 1.0; @@ -141,7 +141,7 @@ EDLSession::EDLSession(EDL *edl) view_follows_playback = 1; vwindow_meter = 0; vwindow_zoom = 1.; - vwindow_click2play = 1; + vwindow_click2play = 0; playback_config = new PlaybackConfig; } @@ -245,7 +245,7 @@ int EDLSession::load_defaults(BC_Hash *defaults) cwindow_xscroll = defaults->get("CWINDOW_XSCROLL", 0); cwindow_yscroll = defaults->get("CWINDOW_YSCROLL", 0); cwindow_zoom = defaults->get("CWINDOW_ZOOM", (float)1); - cwindow_click2play = defaults->get("CWINDOW_CLICK2PLAY", 1); + cwindow_click2play = defaults->get("CWINDOW_CLICK2PLAY", 0); sprintf(default_atransition, _("Crossfade")); defaults->get("DEFAULT_ATRANSITION", default_atransition); sprintf(default_vtransition, _("Dissolve")); @@ -328,7 +328,7 @@ int EDLSession::load_defaults(BC_Hash *defaults) view_follows_playback = defaults->get("VIEW_FOLLOWS_PLAYBACK", 1); vwindow_meter = defaults->get("VWINDOW_METER", 0); vwindow_zoom = defaults->get("VWINDOW_ZOOM", (float)1); - vwindow_click2play = defaults->get("VWINDOW_CLICK2PLAY", 1); + vwindow_click2play = defaults->get("VWINDOW_CLICK2PLAY", 0); decode_subtitles = defaults->get("DECODE_SUBTITLES", decode_subtitles); subtitle_number = defaults->get("SUBTITLE_NUMBER", subtitle_number); diff --git a/cinelerra-5.1/cinelerra/localsession.C b/cinelerra-5.1/cinelerra/localsession.C index 0008bcd3..771f7f5e 100644 --- a/cinelerra-5.1/cinelerra/localsession.C +++ b/cinelerra-5.1/cinelerra/localsession.C @@ -24,6 +24,7 @@ #include "clip.h" #include "bchash.h" #include "edl.h" +#include "filesystem.h" #include "filexml.h" #include "floatauto.h" #include "language.h" @@ -474,6 +475,12 @@ int LocalSession::outpoint_valid() return out_point >= 0; } - +void LocalSession::set_clip_path(Indexable *indexable) +{ + char string[BCTEXTLEN]; + FileSystem fs; + fs.extract_name(string, indexable->path); + strcpy(clip_title, string); +} diff --git a/cinelerra-5.1/cinelerra/localsession.h b/cinelerra-5.1/cinelerra/localsession.h index e2ee664e..7c987937 100644 --- a/cinelerra-5.1/cinelerra/localsession.h +++ b/cinelerra-5.1/cinelerra/localsession.h @@ -63,6 +63,7 @@ public: void load_xml(FileXML *file, unsigned long load_flags); int load_defaults(BC_Hash *defaults); int save_defaults(BC_Hash *defaults); + void set_clip_path(Indexable *indexable); // Used to copy parameters that affect rendering. void synchronize_params(LocalSession *that); diff --git a/cinelerra-5.1/cinelerra/main.C b/cinelerra-5.1/cinelerra/main.C index e7fe8f67..92a6a821 100644 --- a/cinelerra-5.1/cinelerra/main.C +++ b/cinelerra-5.1/cinelerra/main.C @@ -118,7 +118,6 @@ int main(int argc, char *argv[]) config_path[0] = 0; batch_path[0] = 0; deamon_path[0] = 0; - EDL::id_lock = new Mutex("EDL::id_lock"); Units::init(); File::init_cin_path(); @@ -407,7 +406,6 @@ DISABLE_BUFFER } filenames.remove_all_objects(); - delete EDL::id_lock; EDL::id_lock = 0; Units::finit(); return 0; diff --git a/cinelerra-5.1/cinelerra/mainmenu.C b/cinelerra-5.1/cinelerra/mainmenu.C index 67a7ee31..699caa33 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.C +++ b/cinelerra-5.1/cinelerra/mainmenu.C @@ -861,7 +861,7 @@ int ClearDefaultKeyframe::handle_event() } Cut::Cut(MWindow *mwindow) - : BC_MenuItem(_("Cut"), "x", 'x') + : BC_MenuItem(_("Split | Cut"), "x", 'x') { this->mwindow = mwindow; } diff --git a/cinelerra-5.1/cinelerra/mainundo.C b/cinelerra-5.1/cinelerra/mainundo.C index a0aec63b..4a921cf4 100644 --- a/cinelerra-5.1/cinelerra/mainundo.C +++ b/cinelerra-5.1/cinelerra/mainundo.C @@ -22,6 +22,7 @@ #include "asset.h" #include "assets.h" #include "bctimer.h" +#include "clipedls.h" #include "edl.h" #include "filexml.h" #include "mainindexes.h" @@ -30,7 +31,6 @@ #include "mainundo.h" #include "mwindow.h" #include "mwindowgui.h" -#include "nestededls.h" #include #include "undostack.h" @@ -55,10 +55,7 @@ void MainUndo::update_undo_entry(const char *description, { FileXML file; - mwindow->edl->save_xml(&file, - "", - 0, - 0); + mwindow->edl->save_xml(&file, ""); file.terminate_string(); if(changes_made) mwindow->session->changes_made = 1; @@ -264,16 +261,11 @@ int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags) if( load_flags & LOAD_SESSION ) mwindow->close_mixers(); mwindow->edl->load_xml(file, load_flags); - for(Asset *asset = mwindow->edl->assets->first; - asset; - asset = asset->next) - { + for( Asset *asset=mwindow->edl->assets->first; asset; asset=asset->next ) { mwindow->mainindexes->add_next_asset(0, asset); } - - for(int i = 0; i < mwindow->edl->nested_edls->size(); i++) - { - EDL *nested_edl = mwindow->edl->nested_edls->get(i); + for( int i=0; iedl->nested_edls.size(); ++i ) { + EDL *nested_edl = mwindow->edl->nested_edls[i]; mwindow->mainindexes->add_next_asset(0, nested_edl); } mwindow->mainindexes->start_build(); @@ -286,10 +278,7 @@ int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags) void MainUndo::reset_creators() { - for(UndoStackItem *current = undo_stack->first; - current; - current = NEXT) - { + for( UndoStackItem *current=undo_stack->first; current; current=NEXT ) { current->set_creator(0); } } diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 53b5a193..de11d94e 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -38,6 +38,7 @@ #include "channeldb.h" #include "channelinfo.h" #include "clip.h" +#include "clipedls.h" #include "bccmodels.h" #include "commercials.h" #include "cplayback.h" @@ -80,7 +81,6 @@ #include "mutex.h" #include "mwindowgui.h" #include "mwindow.h" -#include "nestededls.h" #include "new.h" #include "panautos.h" #include "patchbay.h" @@ -1943,7 +1943,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); nested_edl->set_path(filenames->get(i)); nested_edl->load_xml(&xml_file, LOAD_ALL); //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path); - edl_to_nested(new_edl, nested_edl); + new_edl->to_nested(nested_edl); + new_edl->local_session->set_clip_path(nested_edl); nested_edl->Garbage::remove_user(); } else { @@ -2027,40 +2028,33 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // Add new assets to EDL and schedule assets for index building. int got_indexes = 0; - for(int i = 0; i < new_edls.size(); i++) - { + for( int i=0; inested_edls->size(); j++) - { - mainindexes->add_next_asset(0, - new_edl->nested_edls->get(j)); + for( int j=0; jnested_edls.size(); ++j ) { + mainindexes->add_next_asset(0, new_edl->nested_edls[j]); + edl->nested_edls.update_index(new_edl->nested_edls[j]); got_indexes = 1; - edl->nested_edls->update_index(new_edl->nested_edls->get(j)); } } if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - for(int i = 0; i < new_assets.size(); i++) - { + for( int i=0; iasset->path, - new_asset->path)) - { + if( !strcmp(new_file->asset->path, new_asset->path) ) { got_it = 1; break; } } mainindexes->add_next_asset(got_it ? new_file : 0, new_asset); - got_indexes = 1; edl->assets->update(new_asset); + got_indexes = 1; } if(debug) printf("MWindow::load_filenames %d\n", __LINE__); @@ -3206,38 +3200,6 @@ if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__); return 0; } -int MWindow::edl_to_nested(EDL *new_edl, - EDL *nested_edl) -{ - -// Keep frame rate, sample rate, and output size unchanged. -// These parameters would revert the project if VWindow displayed an asset -// of different size than the project. - - - -// Nest all video & audio outputs - new_edl->session->video_tracks = 1; - new_edl->session->audio_tracks = nested_edl->session->audio_channels; - new_edl->create_default_tracks(); - - - - new_edl->insert_asset(0, - nested_edl, - 0, - 0, - 0); - - char string[BCTEXTLEN]; - FileSystem fs; - fs.extract_name(string, nested_edl->path); -//printf("MWindow::edl_to_nested %p %s\n", nested_edl, nested_edl->path); - - strcpy(new_edl->local_session->clip_title, string); - - return 0; -} // Reset everything after a load. void MWindow::update_project(int load_mode) @@ -3373,7 +3335,7 @@ void MWindow::save_backup() char backup_path[BCTEXTLEN]; snprintf(backup_path, sizeof(backup_path), "%s/%s", File::get_config_path(), BACKUP_FILE); - edl->save_xml(&file, backup_path, 0, 0); + edl->save_xml(&file, backup_path); file.terminate_string(); FileSystem fs; fs.complete_path(backup_path); diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index 49e36552..dfce9b11 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -146,10 +146,6 @@ public: int asset_to_edl(EDL *new_edl, Asset *new_asset, RecordLabels *labels = 0); -// Convert nested_edl to a nested EDL in new_edl -// suitable for pasting in paste_edls - int edl_to_nested(EDL *new_edl, - EDL *nested_edl); // Entry point to insert assets and insert edls. Called by TrackCanvas // and AssetPopup when assets are dragged in from AWindow. diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index c8619a1c..7b06f5ef 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -194,7 +194,7 @@ void MWindow::asset_to_all() edl->session->aspect_h, w, h); - for( Track *current = edl->tracks->first; current; current = NEXT ) { + for( Track *current=edl->tracks->first; current; current=NEXT ) { if( current->data_type == TRACK_VIDEO /* && current->record */ ) { current->track_w = w; @@ -420,7 +420,7 @@ int MWindow::copy(double start, double end) if( start == end ) return 1; FileXML file; - edl->copy(start, end, 0, 0, 0, &file, "", 1); + edl->copy(start, end, 0, &file, "", 1); const char *file_string = file.string(); long file_length = strlen(file_string); gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION); @@ -541,7 +541,7 @@ void MWindow::cut(double start, double end, double new_position) edl->optimize(); save_backup(); - undo->update_undo_after(_("cut"), LOAD_EDITS | LOAD_TIMEBAR); + undo->update_undo_after(_("split | cut"), LOAD_EDITS | LOAD_TIMEBAR); if( new_position >= 0 ) { edl->local_session->set_selectionstart(new_position); edl->local_session->set_selectionend(new_position); @@ -715,7 +715,7 @@ void MWindow::insert_effects_canvas(double start, undo->update_undo_before(); - for( int i = 0; i < session->drag_pluginservers->total; i++ ) { + for( int i=0; idrag_pluginservers->total; ++i ) { PluginServer *plugin = session->drag_pluginservers->values[i]; insert_effect(plugin->title, 0, dest_track, i == 0 ? session->pluginset_highlighted : 0, @@ -745,7 +745,7 @@ void MWindow::insert_effects_cwindow(Track *dest_track) edl->local_session->get_selectionstart(); } - for( int i = 0; i < session->drag_pluginservers->total; i++ ) { + for( int i=0; idrag_pluginservers->total; ++i ) { PluginServer *plugin = session->drag_pluginservers->values[i]; insert_effect(plugin->title, 0, dest_track, 0, start, length, PLUGIN_STANDALONE); @@ -768,7 +768,7 @@ void MWindow::insert_effect(char *title, SharedLocation shared_location_local; shared_location_local.copy_from(shared_location); int first_track = 1; - for( ; current; current = NEXT) { + for( ; current; current=NEXT ) { if( current->data_type == data_type && current->record ) { insert_effect(title, &shared_location_local, @@ -1074,8 +1074,7 @@ void MWindow::overwrite(EDL *source) overwrite_len = dst_len; } - source->copy(src_start, src_start + overwrite_len, - 0, 0, 0, &file, "", 1); + source->copy(src_start, src_start + overwrite_len, 0, &file, "", 1); // HACK around paste_edl get_start/endselection on its own // so we need to clear only when not using both io points @@ -1198,7 +1197,7 @@ if( debug ) printf("MWindow::load_assets %d\n", __LINE__); if( position < 0 ) position = edl->local_session->get_selectionstart(); ArrayList new_edls; - for( int i = 0; i < new_assets->total; i++ ) { + for( int i=0; itotal; ++i ) { Indexable *indexable = new_assets->get(i); if( indexable->is_asset ) { remove_asset_from_caches((Asset*)indexable); @@ -1208,19 +1207,18 @@ if( debug ) printf("MWindow::load_assets %d\n", __LINE__); new_edl->copy_session(edl); new_edls.append(new_edl); - - if( indexable->is_asset ) { -if( debug ) printf("MWindow::load_assets %d\n", __LINE__); -if( debug ) ((Asset*)indexable)->dump(); - asset_to_edl(new_edl, (Asset*)indexable); + if( !indexable->is_asset ) { + EDL *nested_edl = (EDL*)indexable; + new_edl->to_nested(nested_edl); + new_edl->local_session->set_clip_path(nested_edl); + } + else { + Asset *asset = (Asset*)indexable; + asset_to_edl(new_edl, asset); } - else - edl_to_nested(new_edl, (EDL*)indexable); -if( debug ) printf("MWindow::load_assets %d\n", __LINE__); - if( labels ) { - for( RecordLabel *label = labels->first; label; label = label->next ) { + for( RecordLabel *label=labels->first; label; label=label->next ) { new_edl->labels->toggle_label(label->position, label->position); } } @@ -1232,7 +1230,7 @@ if( debug ) printf("MWindow::load_assets %d\n", __LINE__); if( debug ) printf("MWindow::load_assets %d\n", __LINE__); save_backup(); - for( int i = 0; i < new_edls.size(); i++ ) + for( int i=0; iGarbage::remove_user(); if( debug ) printf("MWindow::load_assets %d\n", __LINE__); @@ -1351,33 +1349,30 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, load_mode == LOADMODE_NEW_TRACKS ) { need_new_tracks = 1; - for( int i = 0; i < new_edls->total; i++ ) { + for( int i=0; itotal; ++i ) { EDL *new_edl = new_edls->values[i]; - for( Track *current = new_edl->tracks->first; - current; - current = NEXT ) { - if( current->data_type == TRACK_VIDEO ) { + for( Track *current=new_edl->tracks->first; current; current=NEXT ) { + switch( current->data_type ) { + case TRACK_VIDEO: edl->tracks->add_video_track(0, 0); if( current->draw ) edl->tracks->last->draw = 1; - destination_tracks.append(edl->tracks->last); - } - else - if( current->data_type == TRACK_AUDIO ) { + break; + case TRACK_AUDIO: edl->tracks->add_audio_track(0, 0); - destination_tracks.append(edl->tracks->last); - } - else - if( current->data_type == TRACK_SUBTITLE ) { + break; + case TRACK_SUBTITLE: edl->tracks->add_subttl_track(0, 0); - destination_tracks.append(edl->tracks->last); + break; + default: + continue; } - edl->session->highlighted_track = edl->tracks->total() - 1; + destination_tracks.append(edl->tracks->last); } // Base track count on first EDL only for concatenation if( load_mode == LOADMODE_REPLACE_CONCATENATE ) break; } - + edl->session->highlighted_track = edl->tracks->total() - 1; } else // Recycle existing tracks of master EDL @@ -1390,13 +1385,12 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, // then be shifted back to their original locations without recursively // shifting back every paste. if( (load_mode == LOADMODE_PASTE || load_mode == LOADMODE_NESTED) && - edl->session->labels_follow_edits ) + edl->session->labels_follow_edits ) edl->labels->clear(edl->local_session->get_selectionstart(), - edl->local_session->get_selectionend(), - 1); + edl->local_session->get_selectionend(), 1); Track *current = first_track ? first_track : edl->tracks->first; - for( ; current; current = NEXT) { + for( ; current; current=NEXT ) { if( current->record ) { destination_tracks.append(current); } @@ -1409,7 +1403,7 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, double *paste_position = new double[destination_tracks.total]; // Iterate through the edls - for( int i = 0; i < new_edls->total; i++ ) { + for( int i=0; itotal; ++i ) { EDL *new_edl = new_edls->values[i]; double edl_length = new_edl->local_session->clipboard_length ? @@ -1430,9 +1424,8 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, TRACK_VIDEO); //PRINT_TRACE // Add assets and prepare index files - for( Asset *new_asset = new_edl->assets->first; - new_asset; - new_asset = new_asset->next ) { + for( Asset *new_asset=new_edl->assets->first; + new_asset; new_asset=new_asset->next ) { mainindexes->add_next_asset(0, new_asset); } // Capture index file status from mainindex test @@ -1458,7 +1451,7 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, case LOADMODE_NESTED: destination_track = 0; if( i == 0 ) { - for( int j = 0; j < destination_tracks.total; j++ ) { + for( int j=0; j= 0) ? current_position : edl->local_session->get_selectionstart(); @@ -1489,14 +1482,13 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, edit_labels); //PRINT_TRACE - for( Track *new_track = new_edl->tracks->first; - new_track; - new_track = new_track->next ) { + for( Track *new_track=new_edl->tracks->first; + new_track; new_track=new_track->next ) { // Get destination track of same type as new_track for( int k = 0; - k < destination_tracks.total && - destination_tracks.values[destination_track]->data_type != new_track->data_type; - k++, destination_track++ ) { + k < destination_tracks.total && + destination_tracks.values[destination_track]->data_type != new_track->data_type; + ++k, ++destination_track ) { if( destination_track >= destination_tracks.total - 1 ) destination_track = 0; } @@ -1558,11 +1550,14 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, // strange issue, for index not being shown // Assume any paste operation from the same EDL won't contain any clips. // If it did it would duplicate every clip here. - for( int i = 0; i < new_edls->total; i++ ) { - EDL *new_edl = new_edls->values[i]; + for( int i=0; itotal; ++i ) { + EDL *new_edl = new_edls->get(i); - for( int j = 0; j < new_edl->clips.total; j++ ) { - edl->add_clip(new_edl->clips.values[j]); + for( int j=0; jclips.size(); ++j ) { + edl->add_clip(new_edl->clips[j]); + } + for( int j=0; jnested_edls.size(); ++j ) { + edl->nested_edls.get_copy(new_edl->nested_edls[j]); } if( new_edl->total_vwindow_edls() ) { @@ -1572,7 +1567,7 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, // edl->vwindow_edl->create_objects(); // edl->vwindow_edl->copy_all(new_edl->vwindow_edl); - for( int j = 0; j < new_edl->total_vwindow_edls(); j++ ) { + for( int j=0; jtotal_vwindow_edls(); ++j ) { EDL *vwindow_edl = new EDL(edl); vwindow_edl->create_objects(); vwindow_edl->copy_all(new_edl->get_vwindow_edl(j)); @@ -1866,7 +1861,7 @@ void MWindow::redo_entry(BC_WindowBase *calling_window_gui) close_mixers(); cwindow->gui->lock_window("MWindow::redo_entry 1"); - for( int i = 0; i < vwindows.size(); i++ ) { + for( int i=0; iis_running() ) { if( calling_window_gui != vwindows.get(i)->gui ) { vwindows.get(i)->gui->lock_window("MWindow::redo_entry 2"); @@ -1887,7 +1882,7 @@ void MWindow::redo_entry(BC_WindowBase *calling_window_gui) cwindow->update(1, 1, 1, 1, 1); cwindow->gui->unlock_window(); - for( int i = 0; i < vwindows.size(); i++ ) { + for( int i=0; i < vwindows.size(); ++i ) { if( vwindows.get(i)->is_running() ) { if( calling_window_gui != vwindows.get(i)->gui ) { vwindows.get(i)->gui->unlock_window(); @@ -2001,7 +1996,7 @@ void MWindow::splice(EDL *source) undo->update_undo_before(); double source_start = source->local_session->get_selectionstart(); double source_end = source->local_session->get_selectionend(); - source->copy(source_start, source_end, 1, 0, 0, &file, "", 1); + source->copy(source_start, source_end, 1, &file, "", 1); //file.dump(); double start = edl->local_session->get_selectionstart(); //double end = edl->local_session->get_selectionend(); @@ -2075,6 +2070,7 @@ void MWindow::save_clip(EDL *new_edl, const char *txt) gui->unlock_window(); awindow->clip_edit->create_clip(new_edl, cur_x, cur_y); + new_edl->remove_user(); gui->lock_window("MWindow::save_clip"); save_backup(); @@ -2095,7 +2091,7 @@ void MWindow::to_clip(EDL *edl, const char *txt) } // Don't copy all since we don't want the clips twice. - edl->copy(start, end, 0, 0, 0, &file, "", 1); + edl->copy(start, end, 0, &file, "", 1); EDL *new_edl = new EDL(edl); new_edl->create_objects(); @@ -2180,7 +2176,7 @@ void MWindow::undo_entry(BC_WindowBase *calling_window_gui) close_mixers(); cwindow->gui->lock_window("MWindow::undo_entry 1"); - for( int i = 0; i < vwindows.size(); i++ ) { + for( int i=0; iis_running() ) { if( calling_window_gui != vwindows.get(i)->gui ) { vwindows.get(i)->gui->lock_window("MWindow::undo_entry 4"); @@ -2201,7 +2197,7 @@ void MWindow::undo_entry(BC_WindowBase *calling_window_gui) cwindow->update(1, 1, 1, 1, 1); cwindow->gui->unlock_window(); - for( int i = 0; i < vwindows.size(); i++ ) { + for( int i=0; iis_running() ) { if( calling_window_gui != vwindows.get(i)->gui ) { vwindows.get(i)->gui->unlock_window(); @@ -2269,13 +2265,13 @@ void MWindow::remap_audio(int pattern) { int current_channel = 0; int current_track = 0; - for( Track *current = edl->tracks->first; current; current = NEXT ) { + for( Track *current=edl->tracks->first; current; current=NEXT ) { if( current->data_type == TRACK_AUDIO && current->record ) { Autos *pan_autos = current->automation->autos[AUTOMATION_PAN]; PanAuto *pan_auto = (PanAuto*)pan_autos->get_auto_for_editing(-1); - for( int i = 0; i < MAXCHANNELS; i++ ) { + for( int i=0; i < MAXCHANNELS; ++i ) { pan_auto->values[i] = 0.0; } @@ -2366,9 +2362,9 @@ void MWindow::set_proxy(int use_scaler, int new_scale, int auto_scale, Asset *proxy_asset = edl->assets->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 ) { + 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 ) { + 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; @@ -2395,9 +2391,9 @@ void MWindow::add_proxy(int use_scaler, Asset *proxy_asset = edl->assets->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 ) { + 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 ) { + 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/nestededls.C b/cinelerra-5.1/cinelerra/nestededls.C deleted file mode 100644 index 5ef38e23..00000000 --- a/cinelerra-5.1/cinelerra/nestededls.C +++ /dev/null @@ -1,99 +0,0 @@ -#include "bcsignals.h" -#include "edl.h" -#include "filexml.h" -#include "indexstate.h" -#include "nestededls.h" - - -NestedEDLs::NestedEDLs() -{ -} - -NestedEDLs::~NestedEDLs() -{ - for(int i = 0; i < nested_edls.size(); i++) - nested_edls.get(i)->Garbage::remove_user(); - nested_edls.remove_all(); -} - -int NestedEDLs::size() -{ - return nested_edls.size(); -} - -EDL* NestedEDLs::get(int number) -{ - return nested_edls.get(number); -} - -EDL* NestedEDLs::get_copy(EDL *src) -{ - if(!src) return 0; - for(int i = 0; i < nested_edls.size(); i++) - { - EDL *dst = nested_edls.get(i); - if(!strcmp(dst->path, src->path)) - return dst; - } - - EDL *dst = new EDL; - dst->create_objects(); - dst->copy_all(src); - nested_edls.append(dst); - return dst; -} - -EDL* NestedEDLs::get(char *path) -{ - for(int i = 0; i < nested_edls.size(); i++) - { - EDL *dst = nested_edls.get(i); - if(!strcmp(dst->path, path)) - return dst; - } - - EDL *dst = new EDL; - dst->create_objects(); - FileXML xml_file; - xml_file.read_from_file(path); -//printf("NestedEDLs::get %d %s\n", __LINE__, path); - dst->load_xml(&xml_file, LOAD_ALL); - -// Override path EDL was saved to with the path it was loaded from. - dst->set_path(path); - nested_edls.append(dst); - return dst; -} - -void NestedEDLs::clear() -{ - for(int i = 0; i < nested_edls.size(); i++) - nested_edls.get(i)->Garbage::remove_user(); - nested_edls.remove_all(); -} - - -void NestedEDLs::update_index(EDL *nested_edl) -{ - for(int i = 0; i < nested_edls.size(); i++) - { - EDL *current = nested_edls.get(i); - if(!strcmp(current->path, nested_edl->path)) - { -// printf("NestedEDLs::update_index %d %p %d\n", -// __LINE__, -// current->index_state, -// nested_edl->index_state->index_status); - current->update_index(nested_edl); - } - } -} - -void NestedEDLs::remove_edl(EDL *nested_edl) -{ - nested_edls.remove(nested_edl); - nested_edl->Garbage::remove_user(); -} - - - diff --git a/cinelerra-5.1/cinelerra/nestededls.h b/cinelerra-5.1/cinelerra/nestededls.h deleted file mode 100644 index 2138e50c..00000000 --- a/cinelerra-5.1/cinelerra/nestededls.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef NESTEDEDLS_H -#define NESTEDEDLS_H - - -#include "arraylist.h" -#include "edl.inc" - -class NestedEDLs -{ -public: - NestedEDLs(); - ~NestedEDLs(); - -// Return copy of the src EDL which belongs to the current object. - EDL* get_copy(EDL *src); -// Return new EDL loaded from path - EDL* get(char *path); - int size(); - EDL* get(int number); - void clear(); - void update_index(EDL *nested_edl); - void remove_edl(EDL *nested_edl); - - ArrayList nested_edls; -}; - - -#endif - - diff --git a/cinelerra-5.1/cinelerra/nestededls.inc b/cinelerra-5.1/cinelerra/nestededls.inc deleted file mode 100644 index 1d26cb49..00000000 --- a/cinelerra-5.1/cinelerra/nestededls.inc +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NESTEDEDLS_INC -#define NESTEDEDLS_INC - - -class NestedEDLs; - - -#endif - - - diff --git a/cinelerra-5.1/cinelerra/renderfarm.C b/cinelerra-5.1/cinelerra/renderfarm.C index cdfd18f0..c8f19f13 100644 --- a/cinelerra-5.1/cinelerra/renderfarm.C +++ b/cinelerra-5.1/cinelerra/renderfarm.C @@ -512,10 +512,7 @@ void RenderFarmServerThread::send_edl() FileXML file; // Save the XML - server->edl->save_xml(&file, - 0, - 0, - 0); + server->edl->save_xml(&file, 0); file.terminate_string(); //printf("RenderFarmServerThread::send_edl\n%s\n\n", file.string); diff --git a/cinelerra-5.1/cinelerra/savefile.C b/cinelerra-5.1/cinelerra/savefile.C index 00dee981..fc757cec 100644 --- a/cinelerra-5.1/cinelerra/savefile.C +++ b/cinelerra-5.1/cinelerra/savefile.C @@ -89,10 +89,7 @@ int Save::handle_event() // save it // TODO: Move this into mwindow. FileXML file; - mwindow->edl->save_xml(&file, - mwindow->session->filename, - 0, - 0); + mwindow->edl->save_xml(&file, mwindow->session->filename); file.terminate_string(); if(file.write_to_file(mwindow->session->filename)) @@ -195,10 +192,7 @@ void SaveAs::run() mwindow->gui->lock_window("SaveAs::run 1"); // update the project name mwindow->set_filename(filename); - mwindow->edl->save_xml(&file, - filename, - 0, - 0); + mwindow->edl->save_xml(&file, filename); mwindow->gui->unlock_window(); file.terminate_string(); diff --git a/cinelerra-5.1/cinelerra/tracks.C b/cinelerra-5.1/cinelerra/tracks.C index 4df74492..08952e42 100644 --- a/cinelerra-5.1/cinelerra/tracks.C +++ b/cinelerra-5.1/cinelerra/tracks.C @@ -201,31 +201,23 @@ int Tracks::load(FileXML *xml, xml->tag.get_property("TYPE", string); if((load_flags & LOAD_ALL) == LOAD_ALL || - (load_flags & LOAD_EDITS)) - { - if(!strcmp(string, "VIDEO")) - { - add_video_track(0, 0); + (load_flags & LOAD_EDITS)) { + if(!strcmp(string, "VIDEO")) { + track = add_video_track(0, 0); } - else - if(!strcmp(string, "SUBTTL")) - { - add_subttl_track(0, 0); + else if(!strcmp(string, "SUBTTL")) { + track = add_subttl_track(0, 0); } - else - { - add_audio_track(0, 0); // default to audio + else { + track = add_audio_track(0, 0); // default to audio } - track = last; } - else - { - track = get_item_number(track_offset); - track_offset++; + else { + track = get_item_number(track_offset++); } // load it - if(track) track->load(xml, track_offset, load_flags); + if( track ) track->load(xml, track_offset, load_flags); return 0; } diff --git a/cinelerra-5.1/cinelerra/vwindow.C b/cinelerra-5.1/cinelerra/vwindow.C index 243327cd..7a24e1bc 100644 --- a/cinelerra-5.1/cinelerra/vwindow.C +++ b/cinelerra-5.1/cinelerra/vwindow.C @@ -255,7 +255,7 @@ void VWindow::change_source(Indexable *indexable) if(asset) mwindow->asset_to_edl(this->edl, asset); else - mwindow->edl_to_nested(this->edl, nested_edl); + this->edl->to_nested(nested_edl); // Update GUI gui->change_source(this->edl, title); @@ -421,14 +421,7 @@ void VWindow::copy() double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); FileXML file; - edl->copy(start, - end, - 0, - 0, - 0, - &file, - "", - 1); + edl->copy(start, end, 0, &file, "", 1); const char *file_string = file.string(); long file_length = strlen(file_string); mwindow->gui->lock_window(); diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index e94bae85..58f0ef94 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -165,62 +165,36 @@ void VWindowGUI::change_source(EDL *edl, const char *title) void VWindowGUI::update_sources(const char *title) { lock_window("VWindowGUI::update_sources"); - -//printf("VWindowGUI::update_sources 1\n"); sources.remove_all_objects(); -//printf("VWindowGUI::update_sources 2\n"); - - - for(int i = 0; - i < mwindow->edl->clips.total; - i++) - { + for( int i=0; iedl->clips.size(); ++i ) { char *clip_title = mwindow->edl->clips.values[i]->local_session->clip_title; int exists = 0; - for(int j = 0; j < sources.total; j++) - { - if(!strcasecmp(sources.values[j]->get_text(), clip_title)) - { + for( int j=0; !exists && jget_text(), clip_title) ) exists = 1; - } } - if(!exists) - { + if( !exists ) sources.append(new BC_ListBoxItem(clip_title)); - } } -//printf("VWindowGUI::update_sources 3\n"); FileSystem fs; - for(Asset *current = mwindow->edl->assets->first; - current; - current = NEXT) - { + for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) { char clip_title[BCTEXTLEN]; fs.extract_name(clip_title, current->path); int exists = 0; - for(int j = 0; j < sources.total; j++) - { - if(!strcasecmp(sources.values[j]->get_text(), clip_title)) - { + for( int j=0; !exists && jget_text(), clip_title) ) exists = 1; - } } - if(!exists) - { + if( !exists ) sources.append(new BC_ListBoxItem(clip_title)); - } } -//printf("VWindowGUI::update_sources 4\n"); - -// source->update_list(&sources); -// source->update(title); unlock_window(); } diff --git a/cinelerra-5.1/guicast/arraylist.h b/cinelerra-5.1/guicast/arraylist.h index ae8d90dd..ef27522f 100644 --- a/cinelerra-5.1/guicast/arraylist.h +++ b/cinelerra-5.1/guicast/arraylist.h @@ -43,7 +43,7 @@ public: } void remove_number(int n) { if( n >= total ) return; - for(int i=n+1; i