#include "atrack.h"
#include "autoconf.h"
#include "automation.h"
-#include "awindowgui.inc"
+#include "awindowgui.h"
+#include "bccmodels.h"
+#include "bchash.h"
#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"
#include "filexml.h"
+#include "floatauto.h"
+#include "floatautos.h"
#include "guicast.h"
#include "indexstate.h"
#include "interlacemodes.h"
tracks = 0;
labels = 0;
local_session = 0;
- folders.set_array_delete();
id = next_id();
path[0] = 0;
}
delete assets;
delete session;
}
- folders.remove_all_objects();
}
int EDL::load_xml(FileXML *file, uint32_t load_flags)
{
int result = 0;
-
-// Clear objects
- folders.remove_all_objects();
+ folders.clear();
if( (load_flags & LOAD_ALL) == LOAD_ALL ) {
remove_vwindow_edls();
result = file->skip_tag();
}
else
- if( file->tag.title_is("FOLDER") ) {
- char folder[BCTEXTLEN];
- strcpy(folder, file->read_text());
- new_folder(folder);
+ if( file->tag.title_is("FOLDERS") ) {
+ result = folders.load_xml(file);
}
else
if( file->tag.title_is("MIXERS") ) {
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_edls.get_nested(nested_edl);
nested_edl->remove_user();
}
else
int EDL::copy_all(EDL *edl)
{
if( this == edl ) return 0;
+ folder_no = edl->folder_no;
update_index(edl);
copy_session(edl);
copy_assets(edl);
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.size(); ++i )
- folders.append(cstrdup(edl->folders[i]));
+ folders.copy_from(&edl->folders);
}
if( !parent_edl ) {
session->copy(edl->session);
}
- if( !session_only ) {
+ if( session_only <= 0 ) {
local_session->copy_from(edl->local_session);
}
}
session->save_xml(file);
session->save_video_config(file);
session->save_audio_config(file);
-
-// Folders
- for( int i=0; i<folders.size(); ++i ) {
- file->tag.set_title("FOLDER");
- file->append_tag();
- file->append_text(folders[i]);
- file->tag.set_title("/FOLDER");
- file->append_tag();
- file->append_newline();
- }
+ folders.save_xml(file);
if( !parent_edl )
copy_assets(start, end, file, all, output_path);
void EDL::set_path(const char *path)
{
+ if( &this->path[0] == path ) return;
strcpy(this->path, path);
}
EDL *new_edl = new EDL(this);
new_edl->create_objects();
new_edl->copy_all(edl);
+ new_edl->folder_no = AW_CLIP_FOLDER;
clips.append(new_edl);
return new_edl;
}
void EDL::optimize()
{
//printf("EDL::optimize 1\n");
- 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 ) {
- local_session->preview_start = 0;
- local_session->preview_end = length;
- }
+ double preview_start = local_session->preview_start;
+ double preview_end = local_session->preview_end;
+ if( preview_end < 0 || preview_end > length )
+ preview_end = length;
+ if( preview_start == 0 && preview_end >= length )
+ local_session->preview_end = -1;
+ if( preview_start > preview_end )
+ local_session->preview_start = preview_end;
for( Track *current=tracks->first; current; current=NEXT )
current->optimize();
}
}
-void EDL::new_folder(const char *folder)
+BinFolder *EDL::get_folder(int no)
{
- for( int i=0; i<folders.size(); ++i )
- if( !strcasecmp(folders[i], folder) ) return;
- folders.append(cstrdup(folder));
+ for( int i=0; i<folders.size(); ++i ) {
+ BinFolder *fp = folders[i];
+ if( no == fp->awindow_folder ) return fp;
+ }
+ return 0;
}
-void EDL::delete_folder(const char *folder)
+int EDL::get_folder_number(const char *title)
{
- int i = folders.size();
- while( --i >= 0 && strcasecmp(folders[i], folder) );
- if( i >= 0 ) folders.remove_number(i);
+ for( int i=0; i<AWINDOW_FOLDERS; ++i ) {
+ if( !strcmp(title, AWindowGUI::folder_names[i]) )
+ return i;
+ }
+ for( int i=0; i<folders.size(); ++i ) {
+ if( !strcmp(title, folders[i]->title) )
+ return folders[i]->awindow_folder;
+ }
+ return AW_NO_FOLDER;
+}
+
+const char *EDL::get_folder_name(int no)
+{
+ if( no >= 0 && no<AWINDOW_FOLDERS )
+ return AWindowGUI::folder_names[no];
+ BinFolder *fp = get_folder(no);
+ return !fp ? "" : fp->title;
+}
+
+int EDL::new_folder(const char *title, int is_clips)
+{
+ if( !title[0] ) return 1;
+ int ret = get_folder_number(title);
+ if( ret >= 0 ) return 1;
+ int idx = AWINDOW_FOLDERS;
+ for( int i=0; i<folders.size(); ++i ) {
+ BinFolder *fp = folders[i];
+ int no = fp->awindow_folder;
+ if( no >= idx ) idx = no+1;
+ }
+ folders.append(new BinFolder(idx, is_clips, title));
+ return 0;
+}
+
+int EDL::delete_folder(const char *title)
+{
+ int k = folders.size();
+ while( --k >= 0 && strcmp(title, folders[k]->title) );
+ if( k >= 0 )
+ folders.remove_object_number(k);
+ return k;
}
int EDL::get_use_vconsole(VEdit* *playable_edit,
session->frame_rate);
}
-
void EDL::remove_vwindow_edls()
{
for( int i=0; i<total_vwindow_edls(); ++i ) {
return new_position;
}
+void EDL::rescale_proxy(int orig_scale, int new_scale)
+{
+ if( orig_scale == new_scale ) return;
+// project size
+ float orig_w = (float)session->output_w * orig_scale;
+ float orig_h = (float)session->output_h * orig_scale;
+ if( !parent_edl ) {
+ session->output_w = Units::round(orig_w / new_scale);
+ session->output_h = Units::round(orig_h / new_scale);
+ }
+
+// track sizes
+ for( Track *track=tracks->first; track; track=track->next ) {
+ if( track->data_type != TRACK_VIDEO ) continue;
+ orig_w = (float)track->track_w * orig_scale;
+ orig_h = (float)track->track_h * orig_scale;
+ track->track_w = Units::round(orig_w / new_scale);
+ track->track_h = Units::round(orig_h / new_scale);
+ ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->
+ set_proxy(orig_scale, new_scale);
+ ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_X])->
+ set_proxy(orig_scale, new_scale);
+ ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_Y])->
+ set_proxy(orig_scale, new_scale);
+ ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_X])->
+ set_proxy(orig_scale, new_scale);
+ ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_Y])->
+ set_proxy(orig_scale, new_scale);
+ }
+}
+
+void EDL::set_proxy(int new_scale, int use_scaler,
+ ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+{
+ int orig_scale = session->proxy_scale;
+ int orig_use_scaler = session->proxy_use_scaler;
+
+// rescale to full size asset in read_frame
+ session->proxy_scale = new_scale;
+ session->proxy_use_scaler = use_scaler;
+
+ if( use_scaler ) {
+ for( int i=0; i<proxy_assets->size(); ++i ) {
+ Asset *proxy_asset = (Asset *)proxy_assets->get(i);
+ proxy_asset->width = orig_assets->get(i)->get_w();
+ proxy_asset->height = orig_assets->get(i)->get_h();
+ }
+ new_scale = 1;
+ }
+
+ if( !orig_use_scaler )
+ rescale_proxy(orig_scale, new_scale);
+
+// change original assets to proxy assets
+ int folder_no = use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER;
+ for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
+ const char *orig_path = orig_assets->get(i)->path;
+ Indexable *proxy_idxbl = proxy_assets->get(i);
+ proxy_idxbl->folder_no = folder_no;
+ Asset *proxy_asset = proxy_idxbl->is_asset ? assets->update((Asset *)proxy_idxbl) : 0;
+ if( proxy_asset && proxy_idxbl ) {
+ proxy_asset->width = proxy_idxbl->get_w();
+ proxy_asset->height = proxy_idxbl->get_h();
+ }
+ EDL *proxy_edl = !proxy_idxbl->is_asset ? (EDL *)proxy_idxbl : 0;
+// replace track contents
+ for( Track *track=tracks->first; track; track=track->next ) {
+ if( track->data_type != TRACK_VIDEO ) continue;
+ for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+ Indexable *idxbl = (Indexable *)edit->asset;
+ if( !idxbl ) idxbl = (Indexable *)edit->nested_edl;
+ if( !idxbl ) continue;
+ if( strcmp(idxbl->path, orig_path) ) continue;
+ edit->asset = proxy_asset;
+ edit->nested_edl = proxy_edl;
+ }
+ }
+ for( int j=0,m=clips.size(); j<m; ++j ) {
+ EDL *clip = clips[j];
+ int has_proxy = 0;
+ for( Track *track=clip->tracks->first; track; track=track->next ) {
+ if( track->data_type != TRACK_VIDEO ) continue;
+ for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+ Indexable *idxbl = (Indexable *)edit->asset;
+ if( !idxbl ) idxbl = (Indexable *)edit->nested_edl;
+ if( !idxbl ) continue;
+ if( strcmp(idxbl->path, orig_path) ) continue;
+ edit->asset = proxy_asset;
+ edit->nested_edl = proxy_edl;
+ has_proxy = 1;
+ }
+ }
+ if( has_proxy && !orig_use_scaler )
+ clip->rescale_proxy(orig_scale, new_scale);
+ }
+ }
+}
+
+void EDL::add_proxy(int use_scaler,
+ ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+{
+ if( use_scaler ) {
+ for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
+ Asset *proxy_asset = (Asset *)proxy_assets->get(i);
+ proxy_asset->width = orig_assets->get(i)->get_w();
+ proxy_asset->height = orig_assets->get(i)->get_h();
+ }
+ }
+
+// change original assets to proxy assets
+ for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
+ Asset *proxy_asset = assets->update((Asset *)proxy_assets->get(i));
+ proxy_asset->folder_no = AW_PROXY_FOLDER;
+// replace track contents
+ for( Track *track=tracks->first; track; track=track->next ) {
+ if( track->data_type != TRACK_VIDEO ) continue;
+ for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+ if( !edit->asset ) continue;
+ if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) {
+ edit->asset = proxy_asset;
+ }
+ }
+ }
+ }
+}
+
+Asset *EDL::get_proxy_asset()
+{
+ return folder_no == AW_PROXY_FOLDER ?
+ tracks->first->edits->first->asset : 0;
+}
+
+double EDL::get_cursor_position(int cursor_x, int pane_no)
+{
+ return (double)cursor_x * local_session->zoom_sample / session->sample_rate +
+ (double)local_session->view_start[pane_no] *
+ local_session->zoom_sample / session->sample_rate;
+}
+