From 276a8f49c94cc80a7b29d5ecd8c7584e7ddcd87c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 4 Oct 2015 22:56:46 +0100 Subject: [PATCH] Fix subtitle timing under trim. --- ChangeLog | 4 ++++ cscript | 4 ++-- src/lib/player.cc | 10 +++++++++- src/lib/player.h | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index dbb74a071..ec0472e10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-10-04 Carl Hetherington + + * Fix subtitle timing under trim. + 2015-10-02 Carl Hetherington * Version 2.3.13 released. diff --git a/cscript b/cscript index b6ff8612a..acd33b38c 100644 --- 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 = '' diff --git a/src/lib/player.cc b/src/lib/player.cc index 751e681bd..29523b1ee 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -604,6 +604,12 @@ Player::dcp_to_content_subtitle (shared_ptr piece, DCPTime t) const return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start()); } +DCPTime +Player::content_subtitle_to_dcp (shared_ptr 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 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 ()); } diff --git a/src/lib/player.h b/src/lib/player.h index e52ad59c2..9bb84a11c 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -87,6 +87,7 @@ private: DCPTime content_video_to_dcp (boost::shared_ptr piece, Frame f) const; Frame dcp_to_resampled_audio (boost::shared_ptr piece, DCPTime t) const; ContentTime dcp_to_content_subtitle (boost::shared_ptr piece, DCPTime t) const; + DCPTime content_subtitle_to_dcp (boost::shared_ptr piece, ContentTime t) const; boost::shared_ptr black_player_video_frame (DCPTime) const; /** @return Pieces of content type C that overlap a specified time range in the DCP */ -- 2.30.2