From: Carl Hetherington Date: Thu, 17 Jan 2013 20:49:09 +0000 (+0000) Subject: Basics of doing trim using asset entry point / duration. X-Git-Tag: v2.0.48~1337^2~746 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=3882d34aed9dee417ceed93bf0bf5372b3970ff6;p=dcpomatic.git Basics of doing trim using asset entry point / duration. --- 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, bool same, boost::shared_ptrvideo_range ()) { - pair 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, bool same, boost::shared_ptr data) { - if (_film->audio_range ()) { - shared_ptr trimmed (new AudioBuffers (*data.get ())); - - /* Range that we are encoding */ - pair required_range = _film->audio_range().get(); - /* Range of this block of data */ - pair 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 > -Film::video_range () const -{ - if (!dcp_length()) { - return boost::optional > (); - } - - return make_pair (trim_start(), trim_start() + dcp_length().get()); -} - -boost::optional > -Film::audio_range () const -{ - boost::optional > vr = video_range (); - if (!vr || !audio_stream()) { - return boost::optional > (); - } - - 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 > video_range () const; - boost::optional > 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 (); }