Add and use Piece::position().
authorCarl Hetherington <cth@carlh.net>
Sun, 21 Jun 2020 23:01:23 +0000 (01:01 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 21 Jun 2020 23:01:23 +0000 (01:01 +0200)
src/lib/piece.h
src/lib/player.cc

index 440beecf4bd6af079bd5b552fae0fddd3ead7a44..f4496c08e4240874e65fc8cfee706da04b04d17d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 #ifndef DCPOMATIC_PIECE_H
 #define DCPOMATIC_PIECE_H
 
-#include "types.h"
+#include "content.h"
+#include "dcpomatic_time.h"
 #include "frame_rate_change.h"
+#include "types.h"
 
 class Content;
 class Decoder;
@@ -37,6 +39,10 @@ public:
                , done (false)
        {}
 
+       dcpomatic::DCPTime position () const {
+               return content->position ();
+       }
+
        boost::shared_ptr<Content> content;
        boost::shared_ptr<Decoder> decoder;
        FrameRateChange frc;
index f3aa97cb0b9160b82d76706ef16c94f4e48f835a..c9679adfe03af8fb4a7b88798facadb6cefe9fd8 100644 (file)
@@ -390,7 +390,7 @@ Player::content_video_to_dcp (shared_ptr<const Piece> piece, Frame f) const
           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->content->position();
+       return d + piece->position();
 }
 
 
@@ -400,13 +400,13 @@ 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->content->position();
+               + piece->position();
 }
 
 ContentTime
 Player::dcp_to_content_time (shared_ptr<const Piece> piece, DCPTime t) const
 {
-       DCPTime s = t - piece->content->position ();
+       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());
 }
@@ -414,7 +414,7 @@ Player::dcp_to_content_time (shared_ptr<const Piece> piece, DCPTime t) const
 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->content->position());
+       return max (DCPTime (), DCPTime (t - piece->content->trim_start(), piece->frc) + piece->position());
 }
 
 list<shared_ptr<Font> >
@@ -795,7 +795,7 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
           if it's after the content's period here as in that case we still need to fill any gap between
           `now' and the end of the content's period.
        */
-       if (time < piece->content->position() || (_last_video_time && time < *_last_video_time)) {
+       if (time < piece->position() || (_last_video_time && time < *_last_video_time)) {
                return;
        }
 
@@ -805,7 +805,7 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
        DCPTime fill_to = min (time, piece->content->end(_film));
 
        if (_last_video_time) {
-               DCPTime fill_from = max (*_last_video_time, piece->content->position());
+               DCPTime fill_from = max (*_last_video_time, piece->position());
 
                /* Fill if we have more than half a frame to do */
                if ((fill_to - fill_from) > one_video_frame() / 2) {
@@ -898,8 +898,8 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
        DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), rfr);
 
        /* Remove anything that comes before the start or after the end of the content */
-       if (time < piece->content->position()) {
-               pair<shared_ptr<AudioBuffers>, DCPTime> cut = discard_audio (content_audio.audio, time, piece->content->position());
+       if (time < piece->position()) {
+               pair<shared_ptr<AudioBuffers>, DCPTime> cut = discard_audio (content_audio.audio, time, piece->position());
                if (!cut.first) {
                        /* This audio is entirely discarded */
                        return;