Fix subtitle timing under trim.
authorCarl Hetherington <cth@carlh.net>
Sun, 4 Oct 2015 21:56:46 +0000 (22:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 4 Oct 2015 21:56:46 +0000 (22:56 +0100)
ChangeLog
cscript
src/lib/player.cc
src/lib/player.h

index dbb74a071a56b50c420a5d95dde2d4c12a8d993b..ec0472e105810e4c99b2fafa2a052ead65113e53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-10-04  Carl Hetherington  <cth@carlh.net>
+
+       * Fix subtitle timing under trim.
+
 2015-10-02  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.3.13 released.
diff --git a/cscript b/cscript
index b6ff8612af48d148f566b0856dba32ba9227d3b9..acd33b38cd4d370d8853675f3fbe7fc9072829de 100644 (file)
--- a/cscript
+++ b/cscript
@@ -252,8 +252,8 @@ def dependencies(target):
         ffmpeg_options = {}
 
     return (('ffmpeg-cdist', 'd0986a9', ffmpeg_options),
-            ('libdcp', 'de32e99'),
-            ('libsub', '2d6d0e0'))
+            ('libdcp', '3c7d752'),
+            ('libsub', '3ed0ae0'))
 
 def configure_options(target):
     opt = ''
index 751e681bd115c81a547c8484d3628f9f476ee642..29523b1eec108e7b1dadd6118735bdc6307ddc65 100644 (file)
@@ -604,6 +604,12 @@ Player::dcp_to_content_subtitle (shared_ptr<const Piece> piece, DCPTime t) const
        return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start());
 }
 
+DCPTime
+Player::content_subtitle_to_dcp (shared_ptr<const Piece> piece, ContentTime t) const
+{
+       return max (DCPTime (), DCPTime (t - piece->content->trim_start(), piece->frc) + piece->content->position());
+}
+
 /** @param burnt true to return only subtitles to be burnt, false to return only
  *  subtitles that should not be burnt.  This parameter will be ignored if
  *  _always_burn_subtitles is true; in this case, all subtitles will be returned.
@@ -651,7 +657,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt)
 
                list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting);
                BOOST_FOREACH (ContentTextSubtitle& ts, text) {
-                       BOOST_FOREACH (dcp::SubtitleString& s, ts.subs) {
+                       BOOST_FOREACH (dcp::SubtitleString s, ts.subs) {
                                s.set_h_position (s.h_position() + subtitle_content->subtitle_x_offset ());
                                s.set_v_position (s.v_position() + subtitle_content->subtitle_y_offset ());
                                float const xs = subtitle_content->subtitle_x_scale();
@@ -661,6 +667,8 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt)
                                if (fabs (1.0 - xs / ys) > dcp::ASPECT_ADJUST_EPSILON) {
                                        s.set_aspect_adjust (xs / ys);
                                }
+                               s.set_in (dcp::Time(content_subtitle_to_dcp (*j, ts.period().from).seconds()));
+                               s.set_out (dcp::Time(content_subtitle_to_dcp (*j, ts.period().to).seconds()));
                                ps.text.push_back (s);
                                ps.add_fonts (subtitle_content->fonts ());
                        }
index e52ad59c2f6014554bfaace206149a6494914e81..9bb84a11cac03ad86da1b41684f5e73677869bff 100644 (file)
@@ -87,6 +87,7 @@ private:
        DCPTime content_video_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const;
        Frame dcp_to_resampled_audio (boost::shared_ptr<const Piece> piece, DCPTime t) const;
        ContentTime dcp_to_content_subtitle (boost::shared_ptr<const Piece> piece, DCPTime t) const;
+       DCPTime content_subtitle_to_dcp (boost::shared_ptr<const Piece> piece, ContentTime t) const;
        boost::shared_ptr<PlayerVideo> black_player_video_frame (DCPTime) const;
 
        /** @return Pieces of content type C that overlap a specified time range in the DCP */