Fix invalid Interop subtitle times in some cases.
authorCarl Hetherington <cth@carlh.net>
Thu, 15 Oct 2015 08:13:33 +0000 (09:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 15 Oct 2015 08:13:33 +0000 (09:13 +0100)
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
src/lib/player.cc
src/lib/subrip_decoder.cc

index 1c3285d2dcac223a1156e9df79e7087c735a65a4..21eb2f7ea48d116f828d9955ff93ca817687636f 100644 (file)
@@ -176,8 +176,8 @@ DCPDecoder::text_subtitles_during (ContentTimePeriod period, bool starting) cons
                int64_t const entry_point = r->main_subtitle()->entry_point ();
 
                list<dcp::SubtitleString> 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
                        );
 
index c484ecc9a2de03243ebf2bbd3e091615ee4751a0..6c3d959fa4488b360352e440babc91ce25b3556d 100644 (file)
@@ -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 ());
                        }
index 2de27248111eb17eaddd8f93f2afcf095522224d..32d50d86b14e62ad44b0f28015799fea1ce1514b 100644 (file)
@@ -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)
                                        )
                                );
                }