4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "automation.h"
27 #include "awindowgui.inc"
28 #include "bcsignals.h"
30 #include "bccmodels.h"
34 #include "edlsession.h"
37 #include "indexstate.h"
38 #include "interlacemodes.h"
40 #include "localsession.h"
41 #include "maskautos.h"
43 #include "nestededls.h"
46 #include "playbackconfig.h"
47 #include "playabletracks.h"
49 #include "preferences.h"
50 #include "recordconfig.h"
51 #include "recordlabel.h"
52 #include "sharedlocation.h"
55 #include "transportque.inc"
56 #include "versioninfo.h"
63 Mutex* EDL::id_lock = 0;
67 EDL::EDL(EDL *parent_edl)
70 this->parent_edl = parent_edl;
75 // vwindow_edl_shared = 0;
77 folders.set_array_delete();
80 // new_folder(CLIP_FOLDER);
81 // new_folder(MEDIA_FOLDER);
102 delete local_session;
106 remove_vwindow_edls();
108 // if(vwindow_edl && !vwindow_edl_shared)
109 // vwindow_edl->Garbage::remove_user();
118 folders.remove_all_objects();
119 for(int i = 0; i < clips.size(); i++)
120 clips.get(i)->Garbage::remove_user();
127 void EDL::create_objects()
129 tracks = new Tracks(this);
132 assets = new Assets(this);
133 session = new EDLSession(this);
137 assets = parent_edl->assets;
138 session = parent_edl->session;
141 local_session = new LocalSession(this);
142 labels = new Labels(this, "LABELS");
143 nested_edls = new NestedEDLs;
144 // last_playback_position = 0;
147 EDL& EDL::operator=(EDL &edl)
149 printf("EDL::operator= 1\n");
154 int EDL::load_defaults(BC_Hash *defaults)
157 session->load_defaults(defaults);
159 local_session->load_defaults(defaults);
163 int EDL::save_defaults(BC_Hash *defaults)
166 session->save_defaults(defaults);
168 local_session->save_defaults(defaults);
172 void EDL::boundaries()
174 session->boundaries();
175 local_session->boundaries();
178 int EDL::create_default_tracks()
181 for(int i = 0; i < session->video_tracks; i++)
183 tracks->add_video_track(0, 0);
185 for(int i = 0; i < session->audio_tracks; i++)
187 tracks->add_audio_track(0, 0);
192 int EDL::load_xml(FileXML *file,
196 // Track numbering offset for replacing undo data.
197 int track_offset = 0;
200 folders.remove_all_objects();
202 if((load_flags & LOAD_ALL) == LOAD_ALL)
204 remove_vwindow_edls();
208 // Search for start of master EDL.
210 // The parent_edl test caused clip creation to fail since those XML files
211 // contained an EDL tag.
213 // The parent_edl test is required to make EDL loading work because
214 // when loading an EDL the EDL tag is already read by the parent.
219 result = file->read_tag();
221 !file->tag.title_is("XML") &&
222 !file->tag.title_is("EDL"));
227 // Get path for backups
229 file->tag.get_property("path", path);
232 if((load_flags & LOAD_ALL) == LOAD_ALL ||
233 (load_flags & LOAD_EDITS) == LOAD_EDITS)
235 while(tracks->last) delete tracks->last;
238 if((load_flags & LOAD_ALL) == LOAD_ALL)
240 for(int i = 0; i < clips.size(); i++)
241 clips.get(i)->Garbage::remove_user();
245 if(load_flags & LOAD_TIMEBAR)
247 while(labels->last) delete labels->last;
248 local_session->unset_inpoint();
249 local_session->unset_outpoint();
252 // This was originally in LocalSession::load_xml
253 if(load_flags & LOAD_SESSION)
255 local_session->clipboard_length = 0;
259 result = file->read_tag();
263 if(file->tag.title_is("/XML") ||
264 file->tag.title_is("/EDL") ||
265 file->tag.title_is("/CLIP_EDL") ||
266 file->tag.title_is("/VWINDOW_EDL"))
271 if(file->tag.title_is("CLIPBOARD"))
273 local_session->clipboard_length =
274 file->tag.get_property("LENGTH", (double)0);
277 if(file->tag.title_is("VIDEO"))
279 if((load_flags & LOAD_VCONFIG) &&
280 (load_flags & LOAD_SESSION))
281 session->load_video_config(file, 0, load_flags);
283 result = file->skip_tag();
286 if(file->tag.title_is("AUDIO"))
288 if((load_flags & LOAD_ACONFIG) &&
289 (load_flags & LOAD_SESSION))
290 session->load_audio_config(file, 0, load_flags);
292 result = file->skip_tag();
295 if(file->tag.title_is("FOLDER"))
297 char folder[BCTEXTLEN];
298 strcpy(folder, file->read_text());
302 if(file->tag.title_is("ASSETS"))
304 if(load_flags & LOAD_ASSETS)
305 assets->load(file, load_flags);
307 result = file->skip_tag();
310 if(file->tag.title_is(labels->xml_tag))
312 if(load_flags & LOAD_TIMEBAR)
313 labels->load(file, load_flags);
315 result = file->skip_tag();
318 if(file->tag.title_is("LOCALSESSION"))
320 if((load_flags & LOAD_SESSION) ||
321 (load_flags & LOAD_TIMEBAR))
322 local_session->load_xml(file, load_flags);
324 result = file->skip_tag();
327 if(file->tag.title_is("SESSION"))
329 if((load_flags & LOAD_SESSION) &&
331 session->load_xml(file, 0, load_flags);
333 result = file->skip_tag();
336 if(file->tag.title_is("TRACK"))
338 tracks->load(file, track_offset, load_flags);
342 // Causes clip creation to fail because that involves an opening EDL tag.
343 if(file->tag.title_is("CLIP_EDL") && !parent_edl)
345 EDL *new_edl = new EDL(this);
346 new_edl->create_objects();
347 new_edl->load_xml(file, LOAD_ALL);
349 if((load_flags & LOAD_ALL) == LOAD_ALL)
350 clips.append(new_edl);
352 new_edl->Garbage::remove_user();
355 if(file->tag.title_is("VWINDOW_EDL") && !parent_edl)
357 EDL *new_edl = new EDL(this);
358 new_edl->create_objects();
359 new_edl->load_xml(file, LOAD_ALL);
362 if((load_flags & LOAD_ALL) == LOAD_ALL)
364 // if(vwindow_edl && !vwindow_edl_shared)
365 // vwindow_edl->Garbage::remove_user();
366 // vwindow_edl_shared = 0;
367 // vwindow_edl = new_edl;
369 append_vwindow_edl(new_edl, 0);
373 // Discard if not replacing EDL
375 new_edl->Garbage::remove_user();
388 // Output path is the path of the output file if name truncation is desired.
389 // It is a "" if complete names should be used.
390 // Called recursively by copy for clips, thus the string can't be terminated.
391 // The string is not terminated in this call.
392 int EDL::save_xml(FileXML *file,
393 const char *output_path,
398 tracks->total_length(),
408 int EDL::copy_all(EDL *edl)
410 if(this == edl) return 0;
412 nested_edls->clear();
416 tracks->copy_from(edl->tracks);
417 labels->copy_from(edl->labels);
421 void EDL::copy_clips(EDL *edl)
423 if(this == edl) return;
425 remove_vwindow_edls();
427 // if(vwindow_edl && !vwindow_edl_shared)
428 // vwindow_edl->Garbage::remove_user();
430 // vwindow_edl_shared = 0;
432 for(int i = 0; i < edl->total_vwindow_edls(); i++)
434 EDL *new_edl = new EDL(this);
435 new_edl->create_objects();
436 new_edl->copy_all(edl->get_vwindow_edl(i));
437 append_vwindow_edl(new_edl, 0);
440 for(int i = 0; i < clips.size(); i++)
441 clips.get(i)->Garbage::remove_user();
443 for(int i = 0; i < edl->clips.total; i++)
445 add_clip(edl->clips.values[i]);
449 void EDL::copy_assets(EDL *edl)
451 if(this == edl) return;
455 assets->copy_from(edl->assets);
459 void EDL::copy_session(EDL *edl, int session_only)
461 if(this == edl) return;
465 strcpy(this->path, edl->path);
466 //printf("EDL::copy_session %p %s\n", this, this->path);
468 folders.remove_all_objects();
469 for(int i = 0; i < edl->folders.total; i++)
472 folders.append(new_folder = new char[strlen(edl->folders.values[i]) + 1]);
473 strcpy(new_folder, edl->folders.values[i]);
479 session->copy(edl->session);
484 local_session->copy_from(edl->local_session);
488 int EDL::copy_assets(double start,
492 const char *output_path)
494 ArrayList<Asset*> asset_list;
497 file->tag.set_title("ASSETS");
499 file->append_newline();
501 // Copy everything for a save
504 for(Asset *asset = assets->first;
508 asset_list.append(asset);
512 // Copy just the ones being used.
514 for(current = tracks->first;
520 current->copy_assets(start,
527 // Paths relativised here
528 for(int i = 0; i < asset_list.total; i++)
530 asset_list.values[i]->write(file,
535 file->tag.set_title("/ASSETS");
537 file->append_newline();
538 file->append_newline();
542 int EDL::copy(double start,
548 const char *output_path,
551 //printf("EDL::copy 1\n");
554 file->tag.set_title("CLIP_EDL");
557 file->tag.set_title("VWINDOW_EDL");
560 file->tag.set_title("EDL");
561 file->tag.set_property("VERSION", CINELERRA_VERSION);
562 // Save path for restoration of the project title from a backup.
565 file->tag.set_property("PATH", path);
570 file->append_newline();
572 // Set clipboard samples only if copying to clipboard
575 file->tag.set_title("CLIPBOARD");
576 file->tag.set_property("LENGTH", end - start);
578 file->tag.set_title("/CLIPBOARD");
580 file->append_newline();
581 file->append_newline();
583 //printf("EDL::copy 1\n");
586 local_session->save_xml(file, start);
588 //printf("EDL::copy 1\n");
593 // Need to copy all this from child EDL if pasting is desired.
595 session->save_xml(file);
596 session->save_video_config(file);
597 session->save_audio_config(file);
600 for(int i = 0; i < folders.total; i++)
602 file->tag.set_title("FOLDER");
604 file->append_text(folders.values[i]);
605 file->tag.set_title("/FOLDER");
607 file->append_newline();
611 // Don't replicate all assets for every clip.
612 // The assets for the clips are probably in the main EDL.
614 copy_assets(start, end, file, all, output_path);
616 // Don't want this if using clipboard
619 for(int i = 0; i < total_vwindow_edls(); i++)
621 get_vwindow_edl(i)->save_xml(file,
627 for(int i = 0; i < clips.total; i++)
628 clips.values[i]->save_xml(file,
634 file->append_newline();
635 file->append_newline();
639 //printf("EDL::copy 1\n");
641 labels->copy(start, end, file);
642 //printf("EDL::copy 1\n");
643 tracks->copy(start, end, all, file, output_path);
644 //printf("EDL::copy 2\n");
648 file->tag.set_title("/CLIP_EDL");
649 else if( is_vwindow )
650 file->tag.set_title("/VWINDOW_EDL");
652 file->tag.set_title("/EDL");
654 file->append_newline();
657 // For editing operations we want to rewind it for immediate pasting.
658 // For clips and saving to disk leave it alone.
661 file->terminate_string();
669 int min_w = session->output_w, min_h = session->output_h;
670 for( Track *track=tracks->first; track!=0; track=track->next ) {
671 if( track->data_type != TRACK_VIDEO ) continue;
672 int w = min_w, h = min_h;
673 for( Edit *current=track->edits->first; current!=0; current=NEXT ) {
674 Indexable* indexable = current->get_source();
675 if( !indexable ) continue;
676 int edit_w = indexable->get_w(), edit_h = indexable->get_h();
677 if( w < edit_w ) w = edit_w;
678 if( h < edit_h ) h = edit_h;
680 if( track->track_w == w && track->track_h == h ) continue;
681 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->
682 translate_masks( (w - track->track_w) / 2, (h - track->track_h) / 2);
683 track->track_w = w; track->track_h = h;
687 void EDL::rechannel()
689 for(Track *current = tracks->first; current; current = NEXT)
691 if(current->data_type == TRACK_AUDIO)
693 PanAutos *autos = (PanAutos*)current->automation->autos[AUTOMATION_PAN];
694 ((PanAuto*)autos->default_auto)->rechannel();
695 for(PanAuto *keyframe = (PanAuto*)autos->first;
697 keyframe = (PanAuto*)keyframe->next)
699 keyframe->rechannel();
705 void EDL::resample(double old_rate, double new_rate, int data_type)
707 for(Track *current = tracks->first; current; current = NEXT)
709 if(current->data_type == data_type)
711 current->resample(old_rate, new_rate);
717 void EDL::synchronize_params(EDL *edl)
719 local_session->synchronize_params(edl->local_session);
720 for(Track *this_track = tracks->first, *that_track = edl->tracks->first;
721 this_track && that_track;
722 this_track = this_track->next,
723 that_track = that_track->next)
725 this_track->synchronize_params(that_track);
729 int EDL::trim_selection(double start,
744 tracks->total_length(),
753 int EDL::equivalent(double position1, double position2)
755 double threshold = (double).5 / session->frame_rate;
756 if(session->cursor_on_frames)
757 threshold = (double).5 / session->frame_rate;
759 threshold = (double)1 / session->sample_rate;
761 if(fabs(position2 - position1) < threshold)
767 double EDL::equivalent_output(EDL *edl)
770 session->equivalent_output(edl->session, &result);
771 tracks->equivalent_output(edl->tracks, &result);
776 void EDL::set_path(const char *path)
778 strcpy(this->path, path);
781 void EDL::set_inpoint(double position)
783 if(equivalent(local_session->get_inpoint(), position) &&
784 local_session->get_inpoint() >= 0)
786 local_session->unset_inpoint();
790 local_session->set_inpoint(align_to_frame(position, 0));
791 if(local_session->get_outpoint() <= local_session->get_inpoint())
792 local_session->unset_outpoint();
796 void EDL::set_outpoint(double position)
798 if(equivalent(local_session->get_outpoint(), position) &&
799 local_session->get_outpoint() >= 0)
801 local_session->unset_outpoint();
805 local_session->set_outpoint(align_to_frame(position, 0));
806 if(local_session->get_inpoint() >= local_session->get_outpoint())
807 local_session->unset_inpoint();
812 int EDL::clear(double start,
821 tracks->clear_handle(start,
827 if(clear_labels && distance > 0)
828 labels->paste_silence(start,
843 // Need to put at beginning so a subsequent paste operation starts at the
845 double position = local_session->get_selectionstart();
846 local_session->set_selectionend(position);
847 local_session->set_selectionstart(position);
851 void EDL::modify_edithandles(double oldposition,
859 tracks->modify_edithandles(oldposition,
866 labels->modify_handles(oldposition,
873 void EDL::modify_pluginhandles(double oldposition,
881 tracks->modify_pluginhandles(oldposition,
891 void EDL::paste_silence(double start,
898 labels->paste_silence(start, end);
899 tracks->paste_silence(start,
906 void EDL::remove_from_project(ArrayList<EDL*> *clips)
908 for(int i = 0; i < clips->size(); i++)
910 for(int j = 0; j < this->clips.size(); j++)
912 if(this->clips.get(j) == clips->values[i])
914 EDL *clip = this->clips.get(j);
915 this->clips.remove(clip);
916 clip->Garbage::remove_user();
922 void EDL::remove_from_project(ArrayList<Indexable*> *assets)
926 for(int j = 0; j < clips.total; j++)
928 clips.values[j]->remove_from_project(assets);
931 // Remove from VWindow EDLs
932 for(int i = 0; i < total_vwindow_edls(); i++)
933 get_vwindow_edl(i)->remove_from_project(assets);
935 for(int i = 0; i < assets->size(); i++)
937 // Remove from tracks
938 for(Track *track = tracks->first; track; track = track->next)
940 track->remove_asset(assets->get(i));
943 // Remove from assets
944 if(!parent_edl && assets->get(i)->is_asset)
946 this->assets->remove_asset((Asset*)assets->get(i));
949 if(!parent_edl && !assets->get(i)->is_asset)
951 this->nested_edls->remove_edl((EDL*)assets->get(i));
956 void EDL::update_assets(EDL *src)
958 for(Asset *current = src->assets->first;
962 assets->update(current);
966 int EDL::get_tracks_height(Theme *theme)
968 int total_pixels = 0;
969 for(Track *current = tracks->first;
973 total_pixels += current->vertical_span(theme);
978 int64_t EDL::get_tracks_width()
980 int64_t total_pixels = 0;
981 for(Track *current = tracks->first;
985 int64_t pixels = current->horizontal_span();
986 if(pixels > total_pixels) total_pixels = pixels;
988 //printf("EDL::get_tracks_width %d\n", total_pixels);
992 // int EDL::calculate_output_w(int single_channel)
994 // if(single_channel) return session->output_w;
997 // for(int i = 0; i < session->video_channels; i++)
999 // if(session->vchannel_x[i] + session->output_w > widest) widest = session->vchannel_x[i] + session->output_w;
1004 // int EDL::calculate_output_h(int single_channel)
1006 // if(single_channel) return session->output_h;
1009 // for(int i = 0; i < session->video_channels; i++)
1011 // if(session->vchannel_y[i] + session->output_h > tallest) tallest = session->vchannel_y[i] + session->output_h;
1016 // Get the total output size scaled to aspect ratio
1017 void EDL::calculate_conformed_dimensions(int single_channel, float &w, float &h)
1019 if((float)session->output_w / session->output_h > get_aspect_ratio())
1020 h = (w = session->output_w) / get_aspect_ratio();
1022 w = (h = session->output_h) * get_aspect_ratio();
1025 float EDL::get_aspect_ratio()
1027 return session->aspect_w / session->aspect_h;
1030 int EDL::dump(FILE *fp)
1033 fprintf(fp,"CLIP\n");
1035 fprintf(fp,"EDL\n");
1036 fprintf(fp," clip_title: %s\n"
1037 " parent_edl: %p\n", local_session->clip_title, parent_edl);
1038 fprintf(fp," selectionstart %f\n selectionend %f\n loop_start %f\n loop_end %f\n",
1039 local_session->get_selectionstart(1),
1040 local_session->get_selectionend(1),
1041 local_session->loop_start,
1042 local_session->loop_end);
1043 for(int i = 0; i < TOTAL_PANES; i++)
1045 fprintf(fp," pane %d view_start=%jd track_start=%d\n", i,
1046 local_session->view_start[i],
1047 local_session->track_start[i]);
1052 fprintf(fp,"audio_channels: %d audio_tracks: %d sample_rate: %jd\n",
1053 session->audio_channels,
1054 session->audio_tracks,
1055 session->sample_rate);
1056 fprintf(fp," video_channels: %d\n"
1057 " video_tracks: %d\n"
1058 " frame_rate: %.2f\n"
1059 " frames_per_foot: %.2f\n"
1064 " color_model: %d\n",
1065 session->video_channels,
1066 session->video_tracks,
1067 session->frame_rate,
1068 session->frames_per_foot,
1073 session->color_model);
1075 fprintf(fp," CLIPS\n");
1076 fprintf(fp," total: %d\n", clips.total);
1078 for(int i = 0; i < clips.total; i++)
1081 clips.values[i]->dump(fp);
1085 fprintf(fp," VWINDOW EDLS\n");
1086 fprintf(fp," total: %d\n", total_vwindow_edls());
1088 for(int i = 0; i < total_vwindow_edls(); i++)
1090 fprintf(fp," %s\n", get_vwindow_edl(i)->local_session->clip_title);
1093 fprintf(fp," ASSETS\n");
1096 fprintf(fp," LABELS\n");
1098 fprintf(fp," TRACKS\n");
1100 //printf("EDL::dump 2\n");
1104 EDL* EDL::add_clip(EDL *edl)
1106 // Copy argument. New edls are deleted from MWindow::load_filenames.
1107 EDL *new_edl = new EDL(this);
1108 new_edl->create_objects();
1109 new_edl->copy_all(edl);
1110 clips.append(new_edl);
1114 void EDL::insert_asset(Asset *asset,
1118 RecordLabels *labels)
1120 // Insert asset into asset table
1121 Asset *new_asset = 0;
1122 EDL *new_nested_edl = 0;
1124 if(asset) new_asset = assets->update(asset);
1125 if(nested_edl) new_nested_edl = nested_edls->get_copy(nested_edl);
1129 Track *current = first_track ? first_track : tracks->first;
1132 // Fix length of single frame
1139 length = new_nested_edl->tracks->total_playable_length();
1141 channels = new_nested_edl->session->audio_channels;
1146 // Insert 1 frame for undefined length
1147 if(new_asset->video_length < 0)
1149 length = session->si_useduration ?
1150 session->si_duration :
1151 1.0 / session->frame_rate;
1154 length = new_asset->frame_rate > 0 ?
1155 (double)new_asset->video_length / new_asset->frame_rate :
1156 1.0 / session->frame_rate;
1158 layers = new_asset->layers;
1159 channels = new_asset->channels;
1163 current && vtrack < layers;
1166 if(!current->record ||
1167 current->data_type != TRACK_VIDEO)
1170 current->insert_asset(new_asset,
1182 if(new_asset->audio_length < 0)
1184 // Insert 1 frame for undefined length & video
1185 if(new_asset->video_data)
1186 length = (double)1.0 / new_asset->frame_rate;
1188 // Insert 1 second for undefined length & no video
1192 length = (double)new_asset->audio_length /
1193 new_asset->sample_rate;
1196 for(current = tracks->first;
1197 current && atrack < channels;
1200 if(!current->record ||
1201 current->data_type != TRACK_AUDIO)
1204 current->insert_asset(new_asset,
1214 // Insert labels from a recording window.
1217 for(RecordLabel *label = labels->first; label; label = label->next)
1219 this->labels->toggle_label(label->position, label->position);
1226 void EDL::set_index_file(Indexable *indexable)
1228 if(indexable->is_asset)
1229 assets->update_index((Asset*)indexable);
1231 nested_edls->update_index((EDL*)indexable);
1234 void EDL::optimize()
1236 //printf("EDL::optimize 1\n");
1237 if(local_session->preview_start < 0) local_session->preview_start = 0;
1238 double length = tracks->total_length();
1239 if(local_session->preview_end > length) local_session->preview_end = length;
1240 if(local_session->preview_start >= local_session->preview_end ) {
1241 local_session->preview_start = 0;
1242 local_session->preview_end = length;
1244 for(Track *current = tracks->first; current; current = NEXT)
1245 current->optimize();
1250 id_lock->lock("EDL::next_id");
1251 int result = EDLSession::current_id++;
1256 void EDL::get_shared_plugins(Track *source,
1257 ArrayList<SharedLocation*> *plugin_locations,
1258 int omit_recordable,
1261 for(Track *track = tracks->first; track; track = track->next)
1263 if(!track->record || !omit_recordable)
1265 if(track != source &&
1266 track->data_type == data_type)
1268 for(int i = 0; i < track->plugin_set.total; i++)
1270 Plugin *plugin = track->get_current_plugin(
1271 local_session->get_selectionstart(1),
1276 if(plugin && plugin->plugin_type == PLUGIN_STANDALONE)
1278 plugin_locations->append(new SharedLocation(tracks->number_of(track), i));
1286 void EDL::get_shared_tracks(Track *track,
1287 ArrayList<SharedLocation*> *module_locations,
1288 int omit_recordable,
1291 for(Track *current = tracks->first; current; current = NEXT)
1293 if(!omit_recordable || !current->record)
1295 if(current != track &&
1296 current->data_type == data_type)
1298 module_locations->append(new SharedLocation(tracks->number_of(current), 0));
1304 // Convert position to frames if cursor alignment is enabled
1305 double EDL::align_to_frame(double position, int round)
1307 if( session->cursor_on_frames && session->frame_rate > 0 ) {
1308 double frame_no = position * session->frame_rate;
1309 int64_t frame_pos = frame_no + (round ? 0.5 : 1e-6);
1310 double pos = frame_pos / session->frame_rate;
1311 if( !EQUIV(pos, position) ) position = pos;
1317 void EDL::new_folder(const char *folder)
1319 for(int i = 0; i < folders.total; i++)
1321 if(!strcasecmp(folders.values[i], folder)) return;
1325 folders.append(new_folder = new char[strlen(folder) + 1]);
1326 strcpy(new_folder, folder);
1329 void EDL::delete_folder(const char *folder)
1332 for(i = 0; i < folders.total; i++)
1334 if(!strcasecmp(folders.values[i], folder))
1340 if(i < folders.total) delete folders.values[i];
1342 for( ; i < folders.total - 1; i++)
1344 folders.values[i] = folders.values[i + 1];
1348 int EDL::get_use_vconsole(VEdit* *playable_edit,
1351 PlayableTracks *playable_tracks)
1353 int share_playable_tracks = 1;
1355 VTrack *playable_track = 0;
1356 const int debug = 0;
1359 // Calculate playable tracks when being called as a nested EDL
1360 if(!playable_tracks)
1362 share_playable_tracks = 0;
1363 playable_tracks = new PlayableTracks(this,
1371 // Total number of playable tracks is 1
1372 if(playable_tracks->size() != 1)
1378 playable_track = (VTrack*)playable_tracks->get(0);
1381 // Don't need playable tracks anymore
1382 if(!share_playable_tracks)
1384 delete playable_tracks;
1387 if(debug) printf("EDL::get_use_vconsole %d playable_tracks->size()=%d\n",
1389 playable_tracks->size());
1390 if(result) return 1;
1393 // Test mutual conditions between direct copy rendering and this.
1394 if(!playable_track->direct_copy_possible(position,
1398 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1400 *playable_edit = (VEdit*)playable_track->edits->editof(position,
1403 // No edit at current location
1404 if(!*playable_edit) return 1;
1405 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1408 // Edit is nested EDL
1409 if((*playable_edit)->nested_edl)
1412 EDL *nested_edl = (*playable_edit)->nested_edl;
1413 int64_t nested_position = (int64_t)((position -
1414 (*playable_edit)->startproject +
1415 (*playable_edit)->startsource) *
1416 nested_edl->session->frame_rate /
1417 session->frame_rate);
1420 VEdit *playable_edit_temp = 0;
1421 if(session->output_w != nested_edl->session->output_w ||
1422 session->output_h != nested_edl->session->output_h ||
1423 nested_edl->get_use_vconsole(&playable_edit_temp,
1432 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1433 // Edit is not a nested EDL
1434 Asset *asset = (*playable_edit)->asset;
1436 if(!asset) return 1;
1437 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1439 // Asset and output device must have the same dimensions
1440 if( asset->width != session->output_w ||
1441 asset->height != session->output_h )
1445 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1446 // Asset and output device must have same resulting de-interlacing method
1447 if( ilaceautofixmethod2(session->interlace_mode,
1448 asset->interlace_autofixoption, asset->interlace_mode,
1449 asset->interlace_fixmethod) != ILACE_FIXMETHOD_NONE )
1452 // If we get here the frame is going to be directly copied. Whether it is
1453 // decompressed in hardware depends on the colormodel.
1459 int EDL::get_audio_channels()
1461 return session->audio_channels;
1464 int EDL::get_sample_rate()
1466 return session->sample_rate;
1469 int64_t EDL::get_audio_samples()
1471 return (int64_t)(tracks->total_playable_length() *
1472 session->sample_rate);
1475 int EDL::have_audio()
1480 int EDL::have_video()
1488 return session->output_w;
1493 return session->output_h;
1496 double EDL::get_frame_rate()
1498 return session->frame_rate;
1501 int EDL::get_video_layers()
1506 int64_t EDL::get_video_frames()
1508 return (int64_t)(tracks->total_playable_length() *
1509 session->frame_rate);
1513 void EDL::remove_vwindow_edls()
1515 for(int i = 0; i < total_vwindow_edls(); i++)
1517 get_vwindow_edl(i)->Garbage::remove_user();
1519 vwindow_edls.remove_all();
1522 void EDL::remove_vwindow_edl(EDL *edl)
1524 if(vwindow_edls.number_of(edl) >= 0)
1526 edl->Garbage::remove_user();
1528 vwindow_edls.remove(edl);
1533 EDL* EDL::get_vwindow_edl(int number)
1535 return vwindow_edls.get(number);
1538 int EDL::total_vwindow_edls()
1540 return vwindow_edls.size();
1543 void EDL::append_vwindow_edl(EDL *edl, int increase_counter)
1545 if(vwindow_edls.number_of(edl) >= 0) return;
1547 if(increase_counter) edl->Garbage::add_user();
1548 vwindow_edls.append(edl);