From 6708d52b5c2ff9ccb6ee99f3b793d791bb95f26b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 15 Oct 2015 09:13:33 +0100 Subject: [PATCH] Fix invalid Interop subtitle times in some cases. Use a much higher "timecode rate" (1000 rather than 24) when representing the time of subtitles internally so that accuracy is preserved and we don't end up rounding things up to give out of range results. --- src/lib/dcp_decoder.cc | 4 ++-- src/lib/player.cc | 6 +++--- src/lib/subrip_decoder.cc | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 1c3285d2d..21eb2f7ea 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -176,8 +176,8 @@ DCPDecoder::text_subtitles_during (ContentTimePeriod period, bool starting) cons int64_t const entry_point = r->main_subtitle()->entry_point (); list subs = r->main_subtitle()->subtitle_asset()->subtitles_during ( - dcp::Time (period.from.seconds ()) - dcp::Time (entry_point, vfr, vfr), - dcp::Time (period.to.seconds ()) - dcp::Time (entry_point, vfr, vfr), + dcp::Time (period.from.seconds(), 1000) - dcp::Time (entry_point, vfr, vfr), + dcp::Time (period.to.seconds(), 1000) - dcp::Time (entry_point, vfr, vfr), starting ); diff --git a/src/lib/player.cc b/src/lib/player.cc index c484ecc9a..6c3d959fa 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -248,7 +248,7 @@ Player::set_video_container_size (dcp::Size s) { _video_container_size = s; - _black_image.reset (new Image (PIX_FMT_RGB24, _video_container_size, true)); + _black_image.reset (new Image (AV_PIX_FMT_RGB24, _video_container_size, true)); _black_image->make_black (); } @@ -671,8 +671,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())); + s.set_in (dcp::Time(content_subtitle_to_dcp (*j, ts.period().from).seconds(), 1000)); + s.set_out (dcp::Time(content_subtitle_to_dcp (*j, ts.period().to).seconds(), 1000)); ps.text.push_back (s); ps.add_fonts (subtitle_content->fonts ()); } diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc index 2de272481..32d50d86b 100644 --- a/src/lib/subrip_decoder.cc +++ b/src/lib/subrip_decoder.cc @@ -67,8 +67,8 @@ SubRipDecoder::pass () dcp::Colour (j->colour.r * 255, j->colour.g * 255, j->colour.b * 255), j->font_size.points (72 * 11), 1.0, - dcp::Time (_subtitles[_next].from.all_as_seconds()), - dcp::Time (_subtitles[_next].to.all_as_seconds()), + dcp::Time (_subtitles[_next].from.all_as_seconds(), 1000), + dcp::Time (_subtitles[_next].to.all_as_seconds(), 1000), 0, dcp::HALIGN_CENTER, i->vertical_position.line.get() * (1.5 / 22) + 0.8, @@ -76,8 +76,8 @@ SubRipDecoder::pass () j->text, dcp::NONE, dcp::Colour (255, 255, 255), - 0, - 0 + dcp::Time (0, 1000), + dcp::Time (0, 1000) ) ); } -- 2.30.2