diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-12-11 01:06:37 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-12-11 01:06:37 +0000 |
| commit | 14c5566fe90b2584c7474c3250e6506d70e81510 (patch) | |
| tree | a219ac33ceb407eb384e0781b4f4e741f99a374d /src/lib | |
| parent | f09e516b90f0b097c949926831ad1bc282ba41f7 (diff) | |
Fix various problems caused by non-integer-frame start trims,
and also by the inability of content_video_to_dcp to return
negative values. The latter is necessary for tests on "is this
content too early" to work.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/content.cc | 5 | ||||
| -rw-r--r-- | src/lib/content_factory.cc | 20 | ||||
| -rw-r--r-- | src/lib/player.cc | 4 | ||||
| -rw-r--r-- | src/lib/video_content.cc | 6 | ||||
| -rw-r--r-- | src/lib/video_content.h | 1 |
5 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc index 691d3a66a..f12464892 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -210,6 +210,11 @@ Content::set_position (DCPTime p) void Content::set_trim_start (ContentTime t) { + /* video content can modify its start trim */ + if (video) { + video->modify_trim_start (t); + } + { boost::mutex::scoped_lock lm (_mutex); _trim_start = t; diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index 8aa432b09..51dc4e1b3 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -119,6 +119,26 @@ content_factory (shared_ptr<const Film> film, cxml::NodePtr node, int version, l notes.push_back (note); } + /* ...or have a start trim which is an integer number of frames */ + ContentTime const old_trim = content->trim_start(); + content->set_trim_start(old_trim); + if (old_trim != content->trim_start()) { + string note = _("Your project contains video content whose trim was not aligned to a frame boundary."); + note += " "; + if (old_trim < content->trim_start()) { + note += String::compose( + _("The file %1 has been trimmed by %2 milliseconds more."), + content->path_summary(), ContentTime(content->trim_start() - old_trim).seconds() * 1000 + ); + } else { + note += String::compose( + _("The file %1 has been trimmed by %2 milliseconds less."), + content->path_summary(), ContentTime(old_trim - content->trim_start()).seconds() * 1000 + ); + } + notes.push_back (note); + } + return content; } diff --git a/src/lib/player.cc b/src/lib/player.cc index f91e3a7f2..0bc460465 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -346,8 +346,8 @@ DCPTime Player::content_video_to_dcp (shared_ptr<const Piece> piece, Frame f) const { /* See comment in dcp_to_content_video */ - DCPTime const d = DCPTime::from_frames (f * piece->frc.factor(), piece->frc.dcp) - DCPTime (piece->content->trim_start (), piece->frc); - return max (DCPTime (), d + piece->content->position ()); + DCPTime const d = DCPTime::from_frames (f * piece->frc.factor(), piece->frc.dcp) - DCPTime(piece->content->trim_start(), piece->frc); + return d + piece->content->position(); } Frame diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 92219b4c7..cd96e19bc 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -544,3 +544,9 @@ VideoContent::modify_position (DCPTime& pos) const { pos = pos.ceil (_parent->film()->video_frame_rate()); } + +void +VideoContent::modify_trim_start (ContentTime& trim) const +{ + trim = trim.ceil (_parent->video_frame_rate().get()); +} diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 19ea113f7..412d4d034 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -169,6 +169,7 @@ public: void add_properties (std::list<UserProperty> &) const; void modify_position (DCPTime& pos) const; + void modify_trim_start (ContentTime& pos) const; static boost::shared_ptr<VideoContent> from_xml (Content* parent, cxml::ConstNodePtr, int); |
