diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-17 20:49:09 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-17 20:49:09 +0000 |
| commit | 3882d34aed9dee417ceed93bf0bf5372b3970ff6 (patch) | |
| tree | dfa0dde1c150487b5ea3300020e31148c3fb6a4f /src/lib | |
| parent | 4870ce43dd314d557f7b14938456138c746fd617 (diff) | |
Basics of doing trim using asset entry point / duration.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/encoder.cc | 32 | ||||
| -rw-r--r-- | src/lib/film.cc | 34 | ||||
| -rw-r--r-- | src/lib/film.h | 2 | ||||
| -rw-r--r-- | src/lib/make_dcp_job.cc | 7 |
4 files changed, 7 insertions, 68 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 35b43e334..c32d68834 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -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) { diff --git a/src/lib/film.cc b/src/lib/film.cc index 8fe03184d..2af8d3c14 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -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 - ) - ); -} diff --git a/src/lib/film.h b/src/lib/film.h index 4cecf663c..b03d84920 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -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 (); diff --git a/src/lib/make_dcp_job.cc b/src/lib/make_dcp_job.cc index fcb10069d..3603298d9 100644 --- a/src/lib/make_dcp_job.cc +++ b/src/lib/make_dcp_job.cc @@ -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 (); } |
