Move two methods into Piece.
authorCarl Hetherington <cth@carlh.net>
Mon, 22 Jun 2020 22:23:58 +0000 (00:23 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 22 Jun 2020 22:23:58 +0000 (00:23 +0200)
src/lib/piece.cc
src/lib/piece.h
src/lib/player.cc
src/lib/player.h

index f3adc0aeff692c9ccf0ef062ec0136821e14c68e..57e00334b1b96c7faff2899899efed89fa2070f0 100644 (file)
@@ -18,6 +18,8 @@
 
 */
 
+
+#include "film.h"
 #include "piece.h"
 
 
@@ -67,3 +69,22 @@ Piece::video_crop () const
        return content->video->crop ();
 }
 
+
+DCPTime
+Piece::resampled_audio_to_dcp (shared_ptr<const Film> film, Frame f) const
+{
+       /* See notes in content_video_to_dcp */
+       return DCPTime::from_frames(f, film->audio_frame_rate())
+               - DCPTime(content->trim_start(), frc)
+               + position();
+}
+
+
+ContentTime
+Piece::dcp_to_content_time (shared_ptr<const Film> film, DCPTime t) const
+{
+       DCPTime s = t - position();
+       s = min(content->length_after_trim(film), s);
+       return max(ContentTime(), ContentTime(s, frc) + content->trim_start());
+}
+
index f6bf4b1b656f17eada5b3e092f6afcf621f93497..aa67316f16648dbff7e7a7713498b7ba292f4c1b 100644 (file)
@@ -44,6 +44,9 @@ public:
        dcpomatic::DCPTime end (boost::shared_ptr<const Film> film) const;
        dcpomatic::DCPTime content_video_to_dcp (Frame f) const;
        dcpomatic::DCPTime content_time_to_dcp (dcpomatic::ContentTime t) 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;
+
        Crop video_crop () const;
 
        boost::shared_ptr<Content> content;
index 62b90045937d997108556834c79fc5dfc5780b21..9630e6a9c5c1db45e595daabf6633c5d96b85749 100644 (file)
@@ -379,23 +379,6 @@ Player::black_player_video_frame (Eyes eyes) const
 }
 
 
-DCPTime
-Player::resampled_audio_to_dcp (shared_ptr<const Piece> piece, Frame f) const
-{
-       /* See notes in content_video_to_dcp */
-       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());
-}
-
 list<shared_ptr<Font> >
 Player::get_subtitle_fonts ()
 {
@@ -871,7 +854,7 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
        int const rfr = content->resampled_frame_rate (_film);
 
        /* Compute time in the DCP */
-       DCPTime time = resampled_audio_to_dcp (piece, content_audio.frame);
+       DCPTime time = piece->resampled_audio_to_dcp (_film, content_audio.frame);
        /* And the end of this block in the DCP */
        DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), rfr);
 
@@ -1067,11 +1050,11 @@ Player::seek (DCPTime time, bool accurate)
                           content we may not start right at the beginning of the next, causing a gap (if the next content has
                           been trimmed to a point between keyframes, or something).
                        */
-                       i->decoder->seek (dcp_to_content_time (i, i->content->position()), true);
+                       i->decoder->seek (i->dcp_to_content_time(_film, i->content->position()), true);
                        i->done = false;
                } else if (i->content->position() <= time && time < i->end(_film)) {
                        /* During; seek to position */
-                       i->decoder->seek (dcp_to_content_time (i, time), accurate);
+                       i->decoder->seek (i->dcp_to_content_time(_film, time), accurate);
                        i->done = false;
                } else {
                        /* After; this piece is done */
index 871f589594881b51594fe78ec845a3477388178f..dbd5cdf694a1548fce6ccfc8612014eaefd4b171 100644 (file)
@@ -126,8 +126,6 @@ private:
        void film_change (ChangeType, Film::Property);
        void playlist_change (ChangeType);
        void playlist_content_change (ChangeType, int, bool);
-       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;
        boost::shared_ptr<PlayerVideo> black_player_video_frame (Eyes eyes) const;
 
        void video (boost::weak_ptr<Piece>, ContentVideo);