yuv colorspace/range + prefs, ffmpeg colorrange probe, x11 direct force colormodel...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edl.C
index 3dc2153e7c7d09cb6d83c5bec671842e0f7ed058..7298baa32cac604c0548507e0c171122114a05ae 100644 (file)
@@ -240,6 +240,7 @@ int EDL::load_xml(FileXML *file,
                        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_TIMEBAR)
@@ -299,6 +300,14 @@ int EDL::load_xml(FileXML *file,
                                        new_folder(folder);
                                }
                                else
+                               if(file->tag.title_is("MIXERS"))
+                               {
+                                       if((load_flags & LOAD_SESSION))
+                                               mixers.load(file);
+                                       else
+                                               result = file->skip_tag();
+                               }
+                               else
                                if(file->tag.title_is("ASSETS"))
                                {
                                        if(load_flags & LOAD_ASSETS)
@@ -413,6 +422,7 @@ int EDL::copy_all(EDL *edl)
        copy_session(edl);
        copy_assets(edl);
        copy_clips(edl);
+       copy_mixers(edl);
        tracks->copy_from(edl->tracks);
        labels->copy_from(edl->labels);
        return 0;
@@ -456,6 +466,12 @@ void EDL::copy_assets(EDL *edl)
        }
 }
 
+void EDL::copy_mixers(EDL *edl)
+{
+       if(this == edl) return;
+       mixers.copy_from(edl->mixers);
+}
+
 void EDL::copy_session(EDL *edl, int session_only)
 {
        if(this == edl) return;
@@ -609,14 +625,9 @@ int EDL::copy(double start,
 
 // Media
 // Don't replicate all assets for every clip.
-// The assets for the clips are probably in the mane EDL.
-               if(!is_clip)
-                       copy_assets(start,
-                               end,
-                               file,
-                               all,
-                               output_path);
-
+// The assets for the clips are probably in the main EDL.
+               if( !is_clip )
+                       copy_assets(start, end, file, all, output_path);
 // Clips
 // Don't want this if using clipboard
                if(all)
@@ -634,6 +645,7 @@ int EDL::copy(double start,
                                        output_path,
                                        1,
                                        0);
+                       mixers.save(file);
                }
 
                file->append_newline();
@@ -649,10 +661,9 @@ int EDL::copy(double start,
 //printf("EDL::copy 2\n");
 
 // terminate file
-       if(is_clip)
+       if( is_clip )
                file->tag.set_title("/CLIP_EDL");
-       else
-       if(is_vwindow)
+       else if( is_vwindow )
                file->tag.set_title("/VWINDOW_EDL");
        else
                file->tag.set_title("/EDL");
@@ -814,12 +825,19 @@ void EDL::set_outpoint(double position)
        }
 }
 
+void EDL::unset_inoutpoint()
+{
+       local_session->unset_inpoint();
+       local_session->unset_outpoint();
+}
 
-int EDL::clear(double start,
-       double end,
-       int clear_labels,
-       int clear_plugins,
-       int edit_autos)
+int EDL::blade(double position)
+{
+       return tracks->blade(position);
+}
+
+int EDL::clear(double start, double end,
+       int clear_labels, int clear_plugins, int edit_autos)
 {
        if(start == end)
        {
@@ -1142,7 +1160,7 @@ void EDL::insert_asset(Asset *asset,
 
        if(new_nested_edl)
        {
-               length = new_nested_edl->tracks->total_playable_length();
+               length = new_nested_edl->tracks->total_length();
                layers = 1;
                channels = new_nested_edl->session->audio_channels;
        }
@@ -1307,15 +1325,20 @@ void EDL::get_shared_tracks(Track *track,
        }
 }
 
-// Convert position to frames if cursor alignment is enabled
+// aligned frame time
+double EDL::frame_align(double position, int round)
+{
+       double frame_pos = position * session->frame_rate;
+       frame_pos = (int64_t)(frame_pos + (round ? 0.5 : 1e-6));
+       position = frame_pos / session->frame_rate;
+       return position;
+}
+
+// Convert position to frames if alignment is enabled.
 double EDL::align_to_frame(double position, int round)
 {
-       if( session->cursor_on_frames && session->frame_rate > 0 ) {
-               double frame_no = position * session->frame_rate;
-               int64_t frame_pos = frame_no + (round ? 0.5 : 1e-6);
-               double pos = frame_pos / session->frame_rate;
-               if( !EQUIV(pos, position) ) position = pos;
-       }
+       if( session->cursor_on_frames )
+               position = frame_align(position, round);
        return position;
 }
 
@@ -1474,7 +1497,7 @@ int EDL::get_sample_rate()
 
 int64_t EDL::get_audio_samples()
 {
-       return (int64_t)(tracks->total_playable_length() *
+       return (int64_t)(tracks->total_length() *
                session->sample_rate);
 }
 
@@ -1511,7 +1534,7 @@ int EDL::get_video_layers()
 
 int64_t EDL::get_video_frames()
 {
-       return (int64_t)(tracks->total_playable_length() *
+       return (int64_t)(tracks->total_length() *
                session->frame_rate);
 }
 
@@ -1555,3 +1578,51 @@ void EDL::append_vwindow_edl(EDL *edl, int increase_counter)
 }
 
 
+double EDL::next_edit(double position)
+{
+       Units::fix_double(&position);
+       double new_position = tracks->total_length();
+
+       double max_rate = get_frame_rate();
+       int sample_rate = get_sample_rate();
+       if( sample_rate > max_rate ) max_rate = sample_rate;
+       double min_movement = max_rate > 0 ? 1. / max_rate : 1e-6;
+
+// Test for edit handles after position
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( !track->record ) continue;
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       double edit_end = track->from_units(edit->startproject + edit->length);
+                       Units::fix_double(&edit_end);
+                       if( fabs(edit_end-position) < min_movement ) continue;
+                       if( edit_end > position && edit_end < new_position )
+                               new_position = edit_end;
+               }
+       }
+       return new_position;
+}
+
+double EDL::prev_edit(double position)
+{
+       Units::fix_double(&position);
+       double new_position = -1;
+
+       double max_rate = get_frame_rate();
+       int sample_rate = get_sample_rate();
+       if( sample_rate > max_rate ) max_rate = sample_rate;
+       double min_movement = max_rate > 0 ? 1. / max_rate : 1e-6;
+
+// Test for edit handles before cursor position
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( !track->record ) continue;
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       double edit_end = track->from_units(edit->startproject);
+                       Units::fix_double(&edit_end);
+                       if( fabs(edit_end-position) < min_movement ) continue;
+                       if( edit_end < position && edit_end > new_position )
+                               new_position = edit_end;
+               }
+       }
+       return new_position;
+}
+