summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-06-23 22:48:29 +0200
committerCarl Hetherington <cth@carlh.net>2020-12-01 16:38:52 +0100
commit50d75c93a6430fd82e839f9d575d54e90f26dc92 (patch)
tree8016f935b775c434004cc375140ec4645fb2a099
parent61798477a11c99ba22b4dd733cb0678403e738af (diff)
Move time calculation methods.
-rw-r--r--src/lib/piece.h5
-rw-r--r--src/lib/player.cc38
-rw-r--r--src/lib/player.h4
3 files changed, 5 insertions, 42 deletions
diff --git a/src/lib/piece.h b/src/lib/piece.h
index 0adc8fb32..deeecfa2f 100644
--- a/src/lib/piece.h
+++ b/src/lib/piece.h
@@ -40,6 +40,11 @@ public:
dcpomatic::DCPTime position () const;
dcpomatic::DCPTime end (boost::shared_ptr<const Film> film) const;
+ dcpomatic::DCPTime content_video_to_dcp (Frame f) const;
+ dcpomatic::DCPTime resampled_audio_to_dcp (boost::shared_ptr<const Film> film, Frame f) const;
+ dcpomatic::ContentTime dcp_to_content_time (boost::shared_ptr<const Film> film, dcpomatic::DCPTime t) const;
+ dcpomatic::DCPTime content_time_to_dcp (dcpomatic::ContentTime t) const;
+
private:
std::vector<boost::shared_ptr<Content> > _content;
std::vector<boost::shared_ptr<Decoder> > _decoder;
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 5e04271e2..2aa23bc15 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -387,44 +387,6 @@ Player::black_player_video_frame (Eyes eyes) const
}
-DCPTime
-Player::content_video_to_dcp (shared_ptr<const Piece> piece, Frame f) const
-{
- /* It might seem more logical here to convert s to a ContentTime (using the FrameRateChange)
- then convert that ContentTime to frames at the content's rate. However this fails for
- situations like content at 29.9978733fps, DCP at 30fps. The accuracy of the Time type is not
- enough to distinguish between the two with low values of time (e.g. 3200 in Time units).
-
- Instead we convert the DCPTime using the DCP video rate then account for any skip/repeat.
- */
- DCPTime const d = DCPTime::from_frames (f * piece->frc.factor(), piece->frc.dcp) - DCPTime(piece->content->trim_start(), piece->frc);
- return d + piece->position();
-}
-
-
-DCPTime
-Player::resampled_audio_to_dcp (shared_ptr<const Piece> piece, Frame f) const
-{
- /* See comment in dcp_to_content_video */
- return DCPTime::from_frames (f, _film->audio_frame_rate())
- - DCPTime (piece->content->trim_start(), piece->frc)
- + piece->position();
-}
-
-ContentTime
-Player::dcp_to_content_time (shared_ptr<const Piece> piece, DCPTime t) const
-{
- DCPTime s = t - piece->position ();
- s = min (piece->content->length_after_trim(_film), s);
- return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start());
-}
-
-DCPTime
-Player::content_time_to_dcp (shared_ptr<const Piece> piece, ContentTime t) const
-{
- return max (DCPTime (), DCPTime (t - piece->content->trim_start(), piece->frc) + piece->position());
-}
-
list<shared_ptr<Font> >
Player::get_subtitle_fonts ()
{
diff --git a/src/lib/player.h b/src/lib/player.h
index eb1f34f59..eb1b4ea36 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -126,10 +126,6 @@ private:
void film_change (ChangeType, Film::Property);
void playlist_change (ChangeType);
void playlist_content_change (ChangeType, int, bool);
- dcpomatic::DCPTime content_video_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const;
- dcpomatic::DCPTime resampled_audio_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const;
- dcpomatic::ContentTime dcp_to_content_time (boost::shared_ptr<const Piece> piece, dcpomatic::DCPTime t) const;
- dcpomatic::DCPTime content_time_to_dcp (boost::shared_ptr<const Piece> piece, dcpomatic::ContentTime t) const;
boost::shared_ptr<PlayerVideo> black_player_video_frame (Eyes eyes) const;
void video (boost::weak_ptr<Piece>, ContentVideo);