summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-10-04 22:56:46 +0100
committerCarl Hetherington <cth@carlh.net>2015-10-04 22:56:46 +0100
commit276a8f49c94cc80a7b29d5ecd8c7584e7ddcd87c (patch)
treeebc33b78c70b83d8ae51082b1e2d7aefa57e8cde /src/lib
parent29c0f7573ddab036f6219c88333a3404db736fd3 (diff)
Fix subtitle timing under trim.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/player.cc10
-rw-r--r--src/lib/player.h1
2 files changed, 10 insertions, 1 deletions
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<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 ());
}
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<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 */