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"
42 #include "nestededls.h"
45 #include "playbackconfig.h"
46 #include "playabletracks.h"
48 #include "preferences.h"
49 #include "recordconfig.h"
50 #include "recordlabel.h"
51 #include "sharedlocation.h"
54 #include "transportque.inc"
55 #include "versioninfo.h"
62 Mutex* EDL::id_lock = 0;
66 EDL::EDL(EDL *parent_edl)
69 this->parent_edl = parent_edl;
74 // vwindow_edl_shared = 0;
76 folders.set_array_delete();
78 new_folder(CLIP_FOLDER);
80 new_folder(MEDIA_FOLDER);
101 delete local_session;
105 remove_vwindow_edls();
107 // if(vwindow_edl && !vwindow_edl_shared)
108 // vwindow_edl->Garbage::remove_user();
117 folders.remove_all_objects();
118 for(int i = 0; i < clips.size(); i++)
119 clips.get(i)->Garbage::remove_user();
126 void EDL::create_objects()
128 tracks = new Tracks(this);
131 assets = new Assets(this);
132 session = new EDLSession(this);
136 assets = parent_edl->assets;
137 session = parent_edl->session;
140 local_session = new LocalSession(this);
141 labels = new Labels(this, "LABELS");
142 nested_edls = new NestedEDLs;
143 // last_playback_position = 0;
146 EDL& EDL::operator=(EDL &edl)
148 printf("EDL::operator= 1\n");
153 int EDL::load_defaults(BC_Hash *defaults)
156 session->load_defaults(defaults);
158 local_session->load_defaults(defaults);
162 int EDL::save_defaults(BC_Hash *defaults)
165 session->save_defaults(defaults);
167 local_session->save_defaults(defaults);
171 void EDL::boundaries()
173 session->boundaries();
174 local_session->boundaries();
177 int EDL::create_default_tracks()
180 for(int i = 0; i < session->video_tracks; i++)
182 tracks->add_video_track(0, 0);
184 for(int i = 0; i < session->audio_tracks; i++)
186 tracks->add_audio_track(0, 0);
191 int EDL::load_xml(FileXML *file,
195 // Track numbering offset for replacing undo data.
196 int track_offset = 0;
199 folders.remove_all_objects();
201 if((load_flags & LOAD_ALL) == LOAD_ALL)
203 remove_vwindow_edls();
207 // Search for start of master EDL.
209 // The parent_edl test caused clip creation to fail since those XML files
210 // contained an EDL tag.
212 // The parent_edl test is required to make EDL loading work because
213 // when loading an EDL the EDL tag is already read by the parent.
218 result = file->read_tag();
220 !file->tag.title_is("XML") &&
221 !file->tag.title_is("EDL"));
226 // Get path for backups
228 file->tag.get_property("path", path);
231 if((load_flags & LOAD_ALL) == LOAD_ALL ||
232 (load_flags & LOAD_EDITS) == LOAD_EDITS)
234 while(tracks->last) delete tracks->last;
237 if((load_flags & LOAD_ALL) == LOAD_ALL)
239 for(int i = 0; i < clips.size(); i++)
240 clips.get(i)->Garbage::remove_user();
244 if(load_flags & LOAD_TIMEBAR)
246 while(labels->last) delete labels->last;
247 local_session->unset_inpoint();
248 local_session->unset_outpoint();
251 // This was originally in LocalSession::load_xml
252 if(load_flags & LOAD_SESSION)
254 local_session->clipboard_length = 0;
258 result = file->read_tag();
262 if(file->tag.title_is("/XML") ||
263 file->tag.title_is("/EDL") ||
264 file->tag.title_is("/CLIP_EDL") ||
265 file->tag.title_is("/VWINDOW_EDL"))
270 if(file->tag.title_is("CLIPBOARD"))
272 local_session->clipboard_length =
273 file->tag.get_property("LENGTH", (double)0);
276 if(file->tag.title_is("VIDEO"))
278 if((load_flags & LOAD_VCONFIG) &&
279 (load_flags & LOAD_SESSION))
280 session->load_video_config(file, 0, load_flags);
283 if(file->tag.title_is("AUDIO"))
285 if((load_flags & LOAD_ACONFIG) &&
286 (load_flags & LOAD_SESSION))
287 session->load_audio_config(file, 0, load_flags);
290 if(file->tag.title_is("FOLDER"))
292 char folder[BCTEXTLEN];
293 strcpy(folder, file->read_text());
297 if(file->tag.title_is("ASSETS"))
299 if(load_flags & LOAD_ASSETS)
300 assets->load(file, load_flags);
303 if(file->tag.title_is(labels->xml_tag))
305 if(load_flags & LOAD_TIMEBAR)
306 labels->load(file, load_flags);
309 if(file->tag.title_is("LOCALSESSION"))
311 if((load_flags & LOAD_SESSION) ||
312 (load_flags & LOAD_TIMEBAR))
313 local_session->load_xml(file, load_flags);
316 if(file->tag.title_is("SESSION"))
318 if((load_flags & LOAD_SESSION) &&
320 session->load_xml(file, 0, load_flags);
323 if(file->tag.title_is("TRACK"))
325 tracks->load(file, track_offset, load_flags);
329 // Causes clip creation to fail because that involves an opening EDL tag.
330 if(file->tag.title_is("CLIP_EDL") && !parent_edl)
332 EDL *new_edl = new EDL(this);
333 new_edl->create_objects();
334 new_edl->load_xml(file, LOAD_ALL);
336 if((load_flags & LOAD_ALL) == LOAD_ALL)
337 clips.append(new_edl);
339 new_edl->Garbage::remove_user();
342 if(file->tag.title_is("VWINDOW_EDL") && !parent_edl)
344 EDL *new_edl = new EDL(this);
345 new_edl->create_objects();
346 new_edl->load_xml(file, LOAD_ALL);
349 if((load_flags & LOAD_ALL) == LOAD_ALL)
351 // if(vwindow_edl && !vwindow_edl_shared)
352 // vwindow_edl->Garbage::remove_user();
353 // vwindow_edl_shared = 0;
354 // vwindow_edl = new_edl;
356 append_vwindow_edl(new_edl, 0);
360 // Discard if not replacing EDL
362 new_edl->Garbage::remove_user();
375 // Output path is the path of the output file if name truncation is desired.
376 // It is a "" if complete names should be used.
377 // Called recursively by copy for clips, thus the string can't be terminated.
378 // The string is not terminated in this call.
379 int EDL::save_xml(FileXML *file,
380 const char *output_path,
385 tracks->total_length(),
395 int EDL::copy_all(EDL *edl)
397 if(this == edl) return 0;
399 nested_edls->clear();
403 tracks->copy_from(edl->tracks);
404 labels->copy_from(edl->labels);
408 void EDL::copy_clips(EDL *edl)
410 if(this == edl) return;
412 remove_vwindow_edls();
414 // if(vwindow_edl && !vwindow_edl_shared)
415 // vwindow_edl->Garbage::remove_user();
417 // vwindow_edl_shared = 0;
419 for(int i = 0; i < edl->total_vwindow_edls(); i++)
421 EDL *new_edl = new EDL(this);
422 new_edl->create_objects();
423 new_edl->copy_all(edl->get_vwindow_edl(i));
424 append_vwindow_edl(new_edl, 0);
427 for(int i = 0; i < clips.size(); i++)
428 clips.get(i)->Garbage::remove_user();
430 for(int i = 0; i < edl->clips.total; i++)
432 add_clip(edl->clips.values[i]);
436 void EDL::copy_assets(EDL *edl)
438 if(this == edl) return;
442 assets->copy_from(edl->assets);
446 void EDL::copy_session(EDL *edl, int session_only)
448 if(this == edl) return;
452 strcpy(this->path, edl->path);
453 //printf("EDL::copy_session %p %s\n", this, this->path);
455 folders.remove_all_objects();
456 for(int i = 0; i < edl->folders.total; i++)
459 folders.append(new_folder = new char[strlen(edl->folders.values[i]) + 1]);
460 strcpy(new_folder, edl->folders.values[i]);
466 session->copy(edl->session);
471 local_session->copy_from(edl->local_session);
475 int EDL::copy_assets(double start,
479 const char *output_path)
481 ArrayList<Asset*> asset_list;
484 file->tag.set_title("ASSETS");
486 file->append_newline();
488 // Copy everything for a save
491 for(Asset *asset = assets->first;
495 asset_list.append(asset);
499 // Copy just the ones being used.
501 for(current = tracks->first;
507 current->copy_assets(start,
514 // Paths relativised here
515 for(int i = 0; i < asset_list.total; i++)
517 asset_list.values[i]->write(file,
522 file->tag.set_title("/ASSETS");
524 file->append_newline();
525 file->append_newline();
529 int EDL::copy(double start,
535 const char *output_path,
538 //printf("EDL::copy 1\n");
541 file->tag.set_title("CLIP_EDL");
544 file->tag.set_title("VWINDOW_EDL");
547 file->tag.set_title("EDL");
548 file->tag.set_property("VERSION", CINELERRA_VERSION);
549 // Save path for restoration of the project title from a backup.
552 file->tag.set_property("PATH", path);
557 file->append_newline();
559 // Set clipboard samples only if copying to clipboard
562 file->tag.set_title("CLIPBOARD");
563 file->tag.set_property("LENGTH", end - start);
565 file->tag.set_title("/CLIPBOARD");
567 file->append_newline();
568 file->append_newline();
570 //printf("EDL::copy 1\n");
573 local_session->save_xml(file, start);
575 //printf("EDL::copy 1\n");
580 // Need to copy all this from child EDL if pasting is desired.
582 session->save_xml(file);
583 session->save_video_config(file);
584 session->save_audio_config(file);
587 for(int i = 0; i < folders.total; i++)
589 file->tag.set_title("FOLDER");
591 file->append_text(folders.values[i]);
592 file->tag.set_title("/FOLDER");
594 file->append_newline();
598 // Don't replicate all assets for every clip.
599 // The assets for the clips are probably in the mane EDL.
608 // Don't want this if using clipboard
611 for(int i = 0; i < total_vwindow_edls(); i++)
613 get_vwindow_edl(i)->save_xml(file,
619 for(int i = 0; i < clips.total; i++)
620 clips.values[i]->save_xml(file,
626 file->append_newline();
627 file->append_newline();
631 //printf("EDL::copy 1\n");
633 labels->copy(start, end, file);
634 //printf("EDL::copy 1\n");
635 tracks->copy(start, end, all, file, output_path);
636 //printf("EDL::copy 2\n");
640 file->tag.set_title("/CLIP_EDL");
643 file->tag.set_title("/VWINDOW_EDL");
645 file->tag.set_title("/EDL");
647 file->append_newline();
650 // For editing operations we want to rewind it for immediate pasting.
651 // For clips and saving to disk leave it alone.
654 file->terminate_string();
660 void EDL::rechannel()
662 for(Track *current = tracks->first; current; current = NEXT)
664 if(current->data_type == TRACK_AUDIO)
666 PanAutos *autos = (PanAutos*)current->automation->autos[AUTOMATION_PAN];
667 ((PanAuto*)autos->default_auto)->rechannel();
668 for(PanAuto *keyframe = (PanAuto*)autos->first;
670 keyframe = (PanAuto*)keyframe->next)
672 keyframe->rechannel();
678 void EDL::resample(double old_rate, double new_rate, int data_type)
680 for(Track *current = tracks->first; current; current = NEXT)
682 if(current->data_type == data_type)
684 current->resample(old_rate, new_rate);
690 void EDL::synchronize_params(EDL *edl)
692 local_session->synchronize_params(edl->local_session);
693 for(Track *this_track = tracks->first, *that_track = edl->tracks->first;
694 this_track && that_track;
695 this_track = this_track->next,
696 that_track = that_track->next)
698 this_track->synchronize_params(that_track);
702 int EDL::trim_selection(double start,
717 tracks->total_length(),
726 int EDL::equivalent(double position1, double position2)
728 double threshold = (double).5 / session->frame_rate;
729 if(session->cursor_on_frames)
730 threshold = (double).5 / session->frame_rate;
732 threshold = (double)1 / session->sample_rate;
734 if(fabs(position2 - position1) < threshold)
740 double EDL::equivalent_output(EDL *edl)
743 session->equivalent_output(edl->session, &result);
744 tracks->equivalent_output(edl->tracks, &result);
749 void EDL::set_path(char *path)
751 strcpy(this->path, path);
754 void EDL::set_inpoint(double position)
756 if(equivalent(local_session->get_inpoint(), position) &&
757 local_session->get_inpoint() >= 0)
759 local_session->unset_inpoint();
763 local_session->set_inpoint(align_to_frame(position, 0));
764 if(local_session->get_outpoint() <= local_session->get_inpoint())
765 local_session->unset_outpoint();
769 void EDL::set_outpoint(double position)
771 if(equivalent(local_session->get_outpoint(), position) &&
772 local_session->get_outpoint() >= 0)
774 local_session->unset_outpoint();
778 local_session->set_outpoint(align_to_frame(position, 0));
779 if(local_session->get_inpoint() >= local_session->get_outpoint())
780 local_session->unset_inpoint();
785 int EDL::clear(double start,
794 tracks->clear_handle(start,
800 if(clear_labels && distance > 0)
801 labels->paste_silence(start,
816 // Need to put at beginning so a subsequent paste operation starts at the
818 double position = local_session->get_selectionstart();
819 local_session->set_selectionend(position);
820 local_session->set_selectionstart(position);
824 void EDL::modify_edithandles(double oldposition,
832 tracks->modify_edithandles(oldposition,
839 labels->modify_handles(oldposition,
846 void EDL::modify_pluginhandles(double oldposition,
854 tracks->modify_pluginhandles(oldposition,
864 void EDL::paste_silence(double start,
871 labels->paste_silence(start, end);
872 tracks->paste_silence(start,
879 void EDL::remove_from_project(ArrayList<EDL*> *clips)
881 for(int i = 0; i < clips->size(); i++)
883 for(int j = 0; j < this->clips.size(); j++)
885 if(this->clips.get(j) == clips->values[i])
887 EDL *clip = this->clips.get(j);
888 this->clips.remove(clip);
889 clip->Garbage::remove_user();
895 void EDL::remove_from_project(ArrayList<Indexable*> *assets)
899 for(int j = 0; j < clips.total; j++)
901 clips.values[j]->remove_from_project(assets);
904 // Remove from VWindow EDLs
905 for(int i = 0; i < total_vwindow_edls(); i++)
906 get_vwindow_edl(i)->remove_from_project(assets);
908 for(int i = 0; i < assets->size(); i++)
910 // Remove from tracks
911 for(Track *track = tracks->first; track; track = track->next)
913 track->remove_asset(assets->get(i));
916 // Remove from assets
917 if(!parent_edl && assets->get(i)->is_asset)
919 this->assets->remove_asset((Asset*)assets->get(i));
922 if(!parent_edl && !assets->get(i)->is_asset)
924 this->nested_edls->remove_edl((EDL*)assets->get(i));
929 void EDL::update_assets(EDL *src)
931 for(Asset *current = src->assets->first;
935 assets->update(current);
939 int EDL::get_tracks_height(Theme *theme)
941 int total_pixels = 0;
942 for(Track *current = tracks->first;
946 total_pixels += current->vertical_span(theme);
951 int64_t EDL::get_tracks_width()
953 int64_t total_pixels = 0;
954 for(Track *current = tracks->first;
958 int64_t pixels = current->horizontal_span();
959 if(pixels > total_pixels) total_pixels = pixels;
961 //printf("EDL::get_tracks_width %d\n", total_pixels);
965 // int EDL::calculate_output_w(int single_channel)
967 // if(single_channel) return session->output_w;
970 // for(int i = 0; i < session->video_channels; i++)
972 // if(session->vchannel_x[i] + session->output_w > widest) widest = session->vchannel_x[i] + session->output_w;
977 // int EDL::calculate_output_h(int single_channel)
979 // if(single_channel) return session->output_h;
982 // for(int i = 0; i < session->video_channels; i++)
984 // if(session->vchannel_y[i] + session->output_h > tallest) tallest = session->vchannel_y[i] + session->output_h;
989 // Get the total output size scaled to aspect ratio
990 void EDL::calculate_conformed_dimensions(int single_channel, float &w, float &h)
992 w = session->output_w;
993 h = session->output_h;
995 if((float)session->output_w / session->output_h > get_aspect_ratio())
998 (session->output_w / get_aspect_ratio() / session->output_h);
1003 (h * get_aspect_ratio() / session->output_w);
1007 float EDL::get_aspect_ratio()
1009 return session->aspect_w / session->aspect_h;
1012 int EDL::dump(FILE *fp)
1015 fprintf(fp,"CLIP\n");
1017 fprintf(fp,"EDL\n");
1018 fprintf(fp," clip_title: %s\n"
1019 " parent_edl: %p\n", local_session->clip_title, parent_edl);
1020 fprintf(fp," selectionstart %f\n selectionend %f\n loop_start %f\n loop_end %f\n",
1021 local_session->get_selectionstart(1),
1022 local_session->get_selectionend(1),
1023 local_session->loop_start,
1024 local_session->loop_end);
1025 for(int i = 0; i < TOTAL_PANES; i++)
1027 fprintf(fp," pane %d view_start=%jd track_start=%jd\n", i,
1028 local_session->view_start[i],
1029 local_session->track_start[i]);
1034 fprintf(fp,"audio_channels: %d audio_tracks: %d sample_rate: %jd\n",
1035 session->audio_channels,
1036 session->audio_tracks,
1037 session->sample_rate);
1038 fprintf(fp," video_channels: %d\n"
1039 " video_tracks: %d\n"
1040 " frame_rate: %.2f\n"
1041 " frames_per_foot: %.2f\n"
1046 " color_model: %d\n",
1047 session->video_channels,
1048 session->video_tracks,
1049 session->frame_rate,
1050 session->frames_per_foot,
1055 session->color_model);
1057 fprintf(fp," CLIPS\n");
1058 fprintf(fp," total: %d\n", clips.total);
1060 for(int i = 0; i < clips.total; i++)
1063 clips.values[i]->dump(fp);
1067 fprintf(fp," VWINDOW EDLS\n");
1068 fprintf(fp," total: %d\n", total_vwindow_edls());
1070 for(int i = 0; i < total_vwindow_edls(); i++)
1072 fprintf(fp," %s\n", get_vwindow_edl(i)->local_session->clip_title);
1075 fprintf(fp," ASSETS\n");
1078 fprintf(fp," LABELS\n");
1080 fprintf(fp," TRACKS\n");
1082 //printf("EDL::dump 2\n");
1086 EDL* EDL::add_clip(EDL *edl)
1088 // Copy argument. New edls are deleted from MWindow::load_filenames.
1089 EDL *new_edl = new EDL(this);
1090 new_edl->create_objects();
1091 new_edl->copy_all(edl);
1092 clips.append(new_edl);
1096 void EDL::insert_asset(Asset *asset,
1100 RecordLabels *labels)
1102 // Insert asset into asset table
1103 Asset *new_asset = 0;
1104 EDL *new_nested_edl = 0;
1106 if(asset) new_asset = assets->update(asset);
1107 if(nested_edl) new_nested_edl = nested_edls->get_copy(nested_edl);
1111 Track *current = first_track ? first_track : tracks->first;
1114 // Fix length of single frame
1121 length = new_nested_edl->tracks->total_playable_length();
1123 channels = new_nested_edl->session->audio_channels;
1128 // Insert 1 frame for undefined length
1129 if(new_asset->video_length < 0)
1131 length = session->si_useduration ?
1132 session->si_duration :
1133 1.0 / session->frame_rate;
1136 length = new_asset->frame_rate > 0 ?
1137 (double)new_asset->video_length / new_asset->frame_rate :
1138 1.0 / session->frame_rate;
1140 layers = new_asset->layers;
1141 channels = new_asset->channels;
1145 current && vtrack < layers;
1148 if(!current->record ||
1149 current->data_type != TRACK_VIDEO)
1152 current->insert_asset(new_asset,
1164 if(new_asset->audio_length < 0)
1166 // Insert 1 frame for undefined length & video
1167 if(new_asset->video_data)
1168 length = (double)1.0 / new_asset->frame_rate;
1170 // Insert 1 second for undefined length & no video
1174 length = (double)new_asset->audio_length /
1175 new_asset->sample_rate;
1178 for(current = tracks->first;
1179 current && atrack < channels;
1182 if(!current->record ||
1183 current->data_type != TRACK_AUDIO)
1186 current->insert_asset(new_asset,
1196 // Insert labels from a recording window.
1199 for(RecordLabel *label = labels->first; label; label = label->next)
1201 this->labels->toggle_label(label->position, label->position);
1208 void EDL::set_index_file(Indexable *indexable)
1210 if(indexable->is_asset)
1211 assets->update_index((Asset*)indexable);
1213 nested_edls->update_index((EDL*)indexable);
1216 void EDL::optimize()
1218 //printf("EDL::optimize 1\n");
1219 if(local_session->preview_start < 0) local_session->preview_start = 0;
1220 double length = tracks->total_length();
1221 if(local_session->preview_end > length) local_session->preview_end = length;
1222 if(local_session->preview_start >= local_session->preview_end ) {
1223 local_session->preview_start = 0;
1224 local_session->preview_end = length;
1226 for(Track *current = tracks->first; current; current = NEXT)
1227 current->optimize();
1232 id_lock->lock("EDL::next_id");
1233 int result = EDLSession::current_id++;
1238 void EDL::get_shared_plugins(Track *source,
1239 ArrayList<SharedLocation*> *plugin_locations,
1240 int omit_recordable,
1243 for(Track *track = tracks->first; track; track = track->next)
1245 if(!track->record || !omit_recordable)
1247 if(track != source &&
1248 track->data_type == data_type)
1250 for(int i = 0; i < track->plugin_set.total; i++)
1252 Plugin *plugin = track->get_current_plugin(
1253 local_session->get_selectionstart(1),
1258 if(plugin && plugin->plugin_type == PLUGIN_STANDALONE)
1260 plugin_locations->append(new SharedLocation(tracks->number_of(track), i));
1268 void EDL::get_shared_tracks(Track *track,
1269 ArrayList<SharedLocation*> *module_locations,
1270 int omit_recordable,
1273 for(Track *current = tracks->first; current; current = NEXT)
1275 if(!omit_recordable || !current->record)
1277 if(current != track &&
1278 current->data_type == data_type)
1280 module_locations->append(new SharedLocation(tracks->number_of(current), 0));
1286 // Convert position to frames if cursor alignment is enabled
1287 double EDL::align_to_frame(double position, int round)
1289 //printf("EDL::align_to_frame 1 %f\n", position);
1290 if(session->cursor_on_frames)
1292 // Seconds -> Frames
1293 double temp = (double)position * session->frame_rate;
1294 //printf("EDL::align_to_frame 2 %f\n", temp);
1296 // Assert some things
1297 if(session->sample_rate == 0)
1298 printf("EDL::align_to_frame: sample_rate == 0\n");
1300 if(session->frame_rate == 0)
1301 printf("EDL::align_to_frame: frame_rate == 0\n");
1304 // Always round down negative numbers
1305 // but round up only if requested
1308 temp = Units::round(temp);
1317 temp = Units::to_int64(temp);
1319 //printf("EDL::align_to_frame 3 %f\n", temp);
1321 // Frames -> Seconds
1322 temp /= session->frame_rate;
1324 //printf("EDL::align_to_frame 5 %f\n", temp);
1328 //printf("EDL::align_to_frame 3 %d\n", position);
1335 void EDL::new_folder(const char *folder)
1337 for(int i = 0; i < folders.total; i++)
1339 if(!strcasecmp(folders.values[i], folder)) return;
1343 folders.append(new_folder = new char[strlen(folder) + 1]);
1344 strcpy(new_folder, folder);
1347 void EDL::delete_folder(const char *folder)
1350 for(i = 0; i < folders.total; i++)
1352 if(!strcasecmp(folders.values[i], folder))
1358 if(i < folders.total) delete folders.values[i];
1360 for( ; i < folders.total - 1; i++)
1362 folders.values[i] = folders.values[i + 1];
1366 int EDL::get_use_vconsole(VEdit* *playable_edit,
1369 PlayableTracks *playable_tracks)
1371 int share_playable_tracks = 1;
1373 VTrack *playable_track = 0;
1374 const int debug = 0;
1377 // Calculate playable tracks when being called as a nested EDL
1378 if(!playable_tracks)
1380 share_playable_tracks = 0;
1381 playable_tracks = new PlayableTracks(this,
1389 // Total number of playable tracks is 1
1390 if(playable_tracks->size() != 1)
1396 playable_track = (VTrack*)playable_tracks->get(0);
1399 // Don't need playable tracks anymore
1400 if(!share_playable_tracks)
1402 delete playable_tracks;
1405 if(debug) printf("EDL::get_use_vconsole %d playable_tracks->size()=%d\n",
1407 playable_tracks->size());
1408 if(result) return 1;
1411 // Test mutual conditions between direct copy rendering and this.
1412 if(!playable_track->direct_copy_possible(position,
1416 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1418 *playable_edit = (VEdit*)playable_track->edits->editof(position,
1421 // No edit at current location
1422 if(!*playable_edit) return 1;
1423 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1426 // Edit is nested EDL
1427 if((*playable_edit)->nested_edl)
1430 EDL *nested_edl = (*playable_edit)->nested_edl;
1431 int64_t nested_position = (int64_t)((position -
1432 (*playable_edit)->startproject +
1433 (*playable_edit)->startsource) *
1434 nested_edl->session->frame_rate /
1435 session->frame_rate);
1438 VEdit *playable_edit_temp = 0;
1439 if(session->output_w != nested_edl->session->output_w ||
1440 session->output_h != nested_edl->session->output_h ||
1441 nested_edl->get_use_vconsole(&playable_edit_temp,
1450 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1451 // Edit is not a nested EDL
1452 Asset *asset = (*playable_edit)->asset;
1454 if(!asset) return 1;
1455 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1457 // Asset and output device must have the same dimensions
1458 if( asset->width != session->output_w ||
1459 asset->height != session->output_h )
1463 if(debug) printf("EDL::get_use_vconsole %d\n", __LINE__);
1464 // Asset and output device must have same resulting de-interlacing method
1465 if( ilaceautofixmethod2(session->interlace_mode,
1466 asset->interlace_autofixoption, asset->interlace_mode,
1467 asset->interlace_fixmethod) != BC_ILACE_FIXMETHOD_NONE )
1470 // If we get here the frame is going to be directly copied. Whether it is
1471 // decompressed in hardware depends on the colormodel.
1477 int EDL::get_audio_channels()
1479 return session->audio_channels;
1482 int EDL::get_sample_rate()
1484 return session->sample_rate;
1487 int64_t EDL::get_audio_samples()
1489 return (int64_t)(tracks->total_playable_length() *
1490 session->sample_rate);
1493 int EDL::have_audio()
1498 int EDL::have_video()
1506 return session->output_w;
1511 return session->output_h;
1514 double EDL::get_frame_rate()
1516 return session->frame_rate;
1519 int EDL::get_video_layers()
1524 int64_t EDL::get_video_frames()
1526 return (int64_t)(tracks->total_playable_length() *
1527 session->frame_rate);
1531 void EDL::remove_vwindow_edls()
1533 for(int i = 0; i < total_vwindow_edls(); i++)
1535 get_vwindow_edl(i)->Garbage::remove_user();
1537 vwindow_edls.remove_all();
1540 void EDL::remove_vwindow_edl(EDL *edl)
1542 if(vwindow_edls.number_of(edl) >= 0)
1544 edl->Garbage::remove_user();
1546 vwindow_edls.remove(edl);
1551 EDL* EDL::get_vwindow_edl(int number)
1553 return vwindow_edls.get(number);
1556 int EDL::total_vwindow_edls()
1558 return vwindow_edls.size();
1561 void EDL::append_vwindow_edl(EDL *edl, int increase_counter)
1563 if(vwindow_edls.number_of(edl) >= 0) return;
1565 if(increase_counter) edl->Garbage::add_user();
1566 vwindow_edls.append(edl);