Basics of doing trim using asset entry point / duration.
authorCarl Hetherington <cth@carlh.net>
Thu, 17 Jan 2013 20:49:09 +0000 (20:49 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 17 Jan 2013 20:49:09 +0000 (20:49 +0000)
src/lib/encoder.cc
src/lib/film.cc
src/lib/film.h
src/lib/make_dcp_job.cc

index 35b43e334b8d49b414c89692c01c6e258950dc86..c32d688342e994ab81c32c8d5786c44953e1c17c 100644 (file)
@@ -286,14 +286,6 @@ Encoder::process_video (shared_ptr<Image> image, bool same, boost::shared_ptr<Su
                return;
        }
 
-       if (_film->video_range ()) {
-               pair<SourceFrame, SourceFrame> const r = _film->video_range().get();
-               if (_video_frame < r.first || _video_frame >= r.second) {
-                       ++_video_frame;
-                       return;
-               }
-       }
-
        boost::mutex::scoped_lock lock (_worker_mutex);
 
        /* Wait until the queue has gone down a bit */
@@ -343,30 +335,6 @@ Encoder::process_video (shared_ptr<Image> image, bool same, boost::shared_ptr<Su
 void
 Encoder::process_audio (shared_ptr<AudioBuffers> data)
 {
-       if (_film->audio_range ()) {
-               shared_ptr<AudioBuffers> trimmed (new AudioBuffers (*data.get ()));
-               
-               /* Range that we are encoding */
-               pair<int64_t, int64_t> required_range = _film->audio_range().get();
-               /* Range of this block of data */
-               pair<int64_t, int64_t> this_range (_audio_frame, _audio_frame + trimmed->frames());
-
-               if (this_range.second < required_range.first || required_range.second < this_range.first) {
-                       /* No part of this audio is within the required range */
-                       return;
-               } else if (required_range.first >= this_range.first && required_range.first < this_range.second) {
-                       /* Trim start */
-                       int64_t const shift = required_range.first - this_range.first;
-                       trimmed->move (shift, 0, trimmed->frames() - shift);
-                       trimmed->set_frames (trimmed->frames() - shift);
-               } else if (required_range.second >= this_range.first && required_range.second < this_range.second) {
-                       /* Trim end */
-                       trimmed->set_frames (required_range.second - this_range.first);
-               }
-
-               data = trimmed;
-       }
-
 #if HAVE_SWRESAMPLE
        /* Maybe sample-rate convert */
        if (_swr_context) {
index 8fe03184d405657239dc4bf774ac4517b71394e3..2af8d3c142161006aa23de3bc518c97397151c54 100644 (file)
@@ -1450,37 +1450,3 @@ Film::multichannel_audio_out_path (int c, bool t) const
        return s.str ();
 }
 
-boost::optional<pair<SourceFrame, SourceFrame> >
-Film::video_range () const
-{
-       if (!dcp_length()) {
-               return boost::optional<pair<SourceFrame, SourceFrame> > ();
-       }
-       
-       return make_pair (trim_start(), trim_start() + dcp_length().get());
-}
-
-boost::optional<pair<int64_t, int64_t> >
-Film::audio_range () const
-{
-       boost::optional<pair<SourceFrame, SourceFrame> > vr = video_range ();
-       if (!vr || !audio_stream()) {
-               return boost::optional<pair<int64_t, int64_t> > ();
-       }
-
-       DCPFrameRate dfr (frames_per_second ());
-       return make_pair (
-               
-               video_frames_to_audio_frames (
-                       vr.get().first,
-                       dcp_audio_sample_rate (audio_stream()->sample_rate()),
-                       dfr.frames_per_second
-                       ),
-               
-               video_frames_to_audio_frames (
-                       vr.get().second,
-                       dcp_audio_sample_rate (audio_stream()->sample_rate()),
-                       dfr.frames_per_second
-                       )
-               );
-}
index 4cecf663c676b2c5f9f0fc5176a81964ae92ce43..b03d84920363d4aab83b614e610c5072ac102408 100644 (file)
@@ -101,8 +101,6 @@ public:
        }
 
        int audio_channels () const;
-       boost::optional<std::pair<SourceFrame, SourceFrame> > video_range () const;
-       boost::optional<std::pair<int64_t, int64_t> > audio_range () const;
 
        void set_dci_date_today ();
 
index fcb10069dabbca86bbfe0e3d1aa80160357375dc..3603298d9085e0c52a0f98458e081cb6034281dc 100644 (file)
@@ -142,6 +142,9 @@ MakeDCPJob::run ()
                                _film->format()->dcp_size().height
                                )
                        );
+
+               pa->set_entry_point (_film->trim_start ());
+               pa->set_duration (_film->duration ());
        
                ascend ();
                
@@ -161,6 +164,10 @@ MakeDCPJob::run ()
                                        dcp_audio_channels (_film->audio_channels())
                                        )
                                );
+
+                       sa->set_entry_point (_film->trim_start ());
+                       sa->set_duration (_film->duration ());
+                       
                        ascend ();
                }