Make content_video_to_dcp private.
authorCarl Hetherington <cth@carlh.net>
Tue, 4 May 2021 20:23:27 +0000 (22:23 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 May 2021 07:29:59 +0000 (09:29 +0200)
src/lib/piece.cc
src/lib/piece.h
src/lib/piece_video.h
src/lib/player.cc

index 12b62e8246dd9d6a4ea8c3adf4c419cecd4759b6..10ae02c1d68a4204edc9041f6ce4924514a82cfe 100644 (file)
@@ -87,7 +87,7 @@ Piece::Piece (weak_ptr<const Film> film, shared_ptr<Content> content, shared_ptr
 void
 Piece::video (shared_ptr<const ImageProxy> image, Frame frame, Eyes eyes, Part part)
 {
-       Video (PieceVideo(image, frame, eyes, part));
+       Video (PieceVideo(image, frame, content_video_to_dcp(frame), eyes, part));
 }
 
 
index d1b3b7dc5bd0b86a7220674448acab5ecd1b204c..18306a2c9630e51d7d13d34c1c321f7a49c6410a 100644 (file)
@@ -40,8 +40,9 @@ class Content;
 class Decoder;
 class PlayerVideo;
 class Resampler;
-struct overlap_video_test1;
 struct check_reuse_old_data_test;
+struct overlap_video_test1;
+struct player_time_calculation_test2;
 
 
 class Piece
@@ -52,7 +53,6 @@ public:
        void update_pull_to (dcpomatic::DCPTime& pull_to) const;
        void set_last_push_end (AudioStreamPtr stream, dcpomatic::DCPTime last_push_end);
 
-       dcpomatic::DCPTime content_video_to_dcp (Frame f) const;
        dcpomatic::DCPTime resampled_audio_to_dcp (Frame f) const;
        boost::optional<dcpomatic::DCPTime> content_time_to_dcp (std::shared_ptr<const Content> content, dcpomatic::ContentTime t) const;
 
@@ -97,6 +97,7 @@ public:
 private:
        friend struct overlap_video_test1;
        friend struct check_reuse_old_data_test;
+       friend struct player_time_calculation_test2;
 
        void video (std::shared_ptr<const ImageProxy> image, Frame frame, Eyes eyes, Part part);
        void audio (std::shared_ptr<AudioStream> stream, std::shared_ptr<const AudioBuffers> audio, Frame frame);
@@ -108,6 +109,7 @@ private:
        void flush ();
        bool done () const;
 
+       dcpomatic::DCPTime content_video_to_dcp (Frame f) const;
        dcpomatic::ContentTime dcp_to_content_time (dcpomatic::DCPTime t) const;
 
        std::weak_ptr<const Film> _film;
index 263637b619b28c88890b285098478830cbe0fc4e..0480b703e56b81aab515d4495601802860bb7f4e 100644 (file)
@@ -23,6 +23,7 @@
 #define DCPOMATIC_PIECE_VIDEO_H
 
 
+#include "dcpomatic_time.h"
 #include "types.h"
 
 
@@ -37,15 +38,17 @@ class PieceVideo
 public:
        PieceVideo () {}
 
-       PieceVideo (std::shared_ptr<const ImageProxy> i, Frame f, Eyes e, Part p)
+       PieceVideo (std::shared_ptr<const ImageProxy> i, Frame f, dcpomatic::DCPTime t, Eyes e, Part p)
                : image (i)
                , frame (f)
+               , time (t)
                , eyes (e)
                , part (p)
        {}
 
        std::shared_ptr<const ImageProxy> image;
        Frame frame = 0;
+       dcpomatic::DCPTime time;
        Eyes eyes = Eyes::LEFT;
        Part part = Part::WHOLE;
 };
index 590fddb7c2bd859a0793e30be76a1761565b5b71..95993c3b9e7686b66e83d100d75170d085e4e64f 100644 (file)
@@ -821,26 +821,24 @@ Player::video (weak_ptr<Piece> wp, PieceVideo video)
                return;
        }
 
-       /* Time of the first frame we will emit */
-       DCPTime const time = piece->content_video_to_dcp (video.frame);
-       LOG_DEBUG_PLAYER("Received video frame %1 at %2", video.frame, to_string(time));
+       LOG_DEBUG_PLAYER("Received video frame %1 at %2", video.frame, to_string(video.time));
 
        /* Discard if it's before the content's period or the last accurate seek.  We can't discard
           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->position() || (_last_video_time && time < *_last_video_time)) {
+       if (video.time < piece->position() || (_last_video_time && video.time < *_last_video_time)) {
                return;
        }
 
-       if (piece->ignore_video_at(time)) {
+       if (piece->ignore_video_at(video.time)) {
                return;
        }
 
        /* Fill gaps that we discover now that we have some video which needs to be emitted.
           This is where we need to fill to.
        */
-       DCPTime fill_to = min (time, piece->end());
+       DCPTime fill_to = min (video.time, piece->end());
 
        if (_last_video_time) {
                DCPTime fill_from = max (*_last_video_time, piece->position());
@@ -891,7 +889,7 @@ Player::video (weak_ptr<Piece> wp, PieceVideo video)
 
        _last_video[wp] = piece->player_video (video, _video_container_size);
 
-       DCPTime t = time;
+       DCPTime t = video.time;
        for (int i = 0; i < frc.repeat; ++i) {
                if (t < piece->end()) {
                        emit_video (_last_video[wp], t);