Fix rounding of timecodes in at least some cases (#323).
[dcpomatic.git] / src / lib / player.cc
index ce51097334be3e6a48107033e8446568d2dc0c4f..59db923be79503d4425122f24c320690e3d961ed 100644 (file)
@@ -62,6 +62,8 @@ public:
                , decoder (d)
                , video_position (c->position ())
                , audio_position (c->position ())
+               , repeat_to_do (0)
+               , repeat_done (0)
        {}
 
        /** Set this piece to repeat a video frame a given number of times */
@@ -454,6 +456,10 @@ Player::setup_pieces ()
 
        for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
 
+               if (!(*i)->paths_valid ()) {
+                       continue;
+               }
+
                shared_ptr<Piece> piece (new Piece (*i));
 
                /* XXX: into content? */
@@ -521,7 +527,11 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent)
                _have_valid_pieces = false;
                Changed (frequent);
 
-       } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET || property == SubtitleContentProperty::SUBTITLE_SCALE) {
+       } else if (
+               property == SubtitleContentProperty::SUBTITLE_X_OFFSET ||
+               property == SubtitleContentProperty::SUBTITLE_Y_OFFSET ||
+               property == SubtitleContentProperty::SUBTITLE_SCALE
+               ) {
 
                update_subtitle ();
                Changed (frequent);
@@ -535,6 +545,7 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent)
 
        } else if (property == ContentProperty::PATH) {
 
+               _have_valid_pieces = false;
                Changed (frequent);
        }
 }
@@ -658,7 +669,8 @@ Player::update_subtitle ()
        dcpomatic::Rect<double> in_rect = _in_subtitle.rect;
        libdcp::Size scaled_size;
 
-       in_rect.y += sc->subtitle_offset ();
+       in_rect.x += sc->subtitle_x_offset ();
+       in_rect.y += sc->subtitle_y_offset ();
 
        /* We will scale the subtitle up to fit _video_container_size, and also by the additional subtitle_scale */
        scaled_size.width = in_rect.width * _video_container_size.width * sc->subtitle_scale ();
@@ -695,7 +707,7 @@ Player::update_subtitle ()
                to = rint (to * vc->video_frame_rate() / _film->video_frame_rate());
        }
        
-       _out_subtitle.from = from * piece->content->position ();
+       _out_subtitle.from = from + piece->content->position ();
        _out_subtitle.to = to + piece->content->position ();
 }