1. Set correct FrameRateChanges for subtitle content; they should
authorCarl Hetherington <cth@carlh.net>
Tue, 6 Oct 2015 15:29:37 +0000 (16:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 6 Oct 2015 15:29:37 +0000 (16:29 +0100)
be made from the subtitle's "native" rate so that subtitle times
are corrected when the DCP rate is not the same.

2. After this we only need the best overlap rate for SndfileContent
so move the code.  Also fix it as it never found overlaps before.

ChangeLog
src/lib/player.cc

index e3265c5e9f7dc63c7ebe2507d8d9f17f0b3096ef..da4b2a8fd45f9d496e7d00f90e64b3cf50243afd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-10-06  Carl Hetherington  <cth@carlh.net>
 
+       * Fix subtitle timing when the DCP rate
+       is different to their native rate.
+
        * Fix invalid SMPTE subtitle output
        in some cases.
 
index 29523b1eec108e7b1dadd6118735bdc6307ddc65..5e0d3b315b01f96d6d7e92f947d1e0e025b2f3f6 100644 (file)
@@ -107,30 +107,6 @@ Player::setup_pieces ()
                shared_ptr<Decoder> decoder;
                optional<FrameRateChange> frc;
 
-               /* Work out a FrameRateChange for the best overlap video for this content, in case we need it below */
-               DCPTime best_overlap_t;
-               shared_ptr<VideoContent> best_overlap;
-               BOOST_FOREACH (shared_ptr<Content> j, _playlist->content ()) {
-                       shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (j);
-                       if (!vc) {
-                               continue;
-                       }
-
-                       DCPTime const overlap = max (vc->position(), i->position()) - min (vc->end(), i->end());
-                       if (overlap > best_overlap_t) {
-                               best_overlap = vc;
-                               best_overlap_t = overlap;
-                       }
-               }
-
-               optional<FrameRateChange> best_overlap_frc;
-               if (best_overlap) {
-                       best_overlap_frc = FrameRateChange (best_overlap->video_frame_rate(), _film->video_frame_rate ());
-               } else {
-                       /* No video overlap; e.g. if the DCP is just audio */
-                       best_overlap_frc = FrameRateChange (_film->video_frame_rate(), _film->video_frame_rate ());
-               }
-
                /* FFmpeg */
                shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (i);
                if (fc) {
@@ -166,21 +142,43 @@ Player::setup_pieces ()
                shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (i);
                if (sc) {
                        decoder.reset (new SndfileDecoder (sc, _fast));
-                       frc = best_overlap_frc;
+
+                       /* Work out a FrameRateChange for the best overlap video for this content */
+                       DCPTime best_overlap_t;
+                       shared_ptr<VideoContent> best_overlap;
+                       BOOST_FOREACH (shared_ptr<Content> j, _playlist->content ()) {
+                               shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (j);
+                               if (!vc) {
+                                       continue;
+                               }
+
+                               DCPTime const overlap = min (vc->end(), i->end()) - max (vc->position(), i->position());
+                               if (overlap > best_overlap_t) {
+                                       best_overlap = vc;
+                                       best_overlap_t = overlap;
+                               }
+                       }
+
+                       if (best_overlap) {
+                               frc = FrameRateChange (best_overlap->video_frame_rate(), _film->video_frame_rate ());
+                       } else {
+                               /* No video overlap; e.g. if the DCP is just audio */
+                               frc = FrameRateChange (_film->video_frame_rate(), _film->video_frame_rate ());
+                       }
                }
 
                /* SubRipContent */
                shared_ptr<const SubRipContent> rc = dynamic_pointer_cast<const SubRipContent> (i);
                if (rc) {
                        decoder.reset (new SubRipDecoder (rc));
-                       frc = best_overlap_frc;
+                       frc = FrameRateChange (rc->subtitle_video_frame_rate(), _film->video_frame_rate());
                }
 
                /* DCPSubtitleContent */
                shared_ptr<const DCPSubtitleContent> dsc = dynamic_pointer_cast<const DCPSubtitleContent> (i);
                if (dsc) {
                        decoder.reset (new DCPSubtitleDecoder (dsc));
-                       frc = best_overlap_frc;
+                       frc = FrameRateChange (dsc->subtitle_video_frame_rate(), _film->video_frame_rate());
                }
 
                shared_ptr<VideoDecoder> vd = dynamic_pointer_cast<VideoDecoder> (decoder);