From: Carl Hetherington Date: Tue, 6 Oct 2015 15:29:37 +0000 (+0100) Subject: 1. Set correct FrameRateChanges for subtitle content; they should X-Git-Tag: v2.4.2~2 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=daba5abc608788795de727121bcd1a83ef9caecb;ds=sidebyside 1. Set correct FrameRateChanges for subtitle content; they should 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. --- diff --git a/ChangeLog b/ChangeLog index e3265c5e9..da4b2a8fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-10-06 Carl Hetherington + * Fix subtitle timing when the DCP rate + is different to their native rate. + * Fix invalid SMPTE subtitle output in some cases. diff --git a/src/lib/player.cc b/src/lib/player.cc index 29523b1ee..5e0d3b315 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -107,30 +107,6 @@ Player::setup_pieces () shared_ptr decoder; optional 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 best_overlap; - BOOST_FOREACH (shared_ptr j, _playlist->content ()) { - shared_ptr vc = dynamic_pointer_cast (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 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 fc = dynamic_pointer_cast (i); if (fc) { @@ -166,21 +142,43 @@ Player::setup_pieces () shared_ptr sc = dynamic_pointer_cast (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 best_overlap; + BOOST_FOREACH (shared_ptr j, _playlist->content ()) { + shared_ptr vc = dynamic_pointer_cast (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 rc = dynamic_pointer_cast (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 dsc = dynamic_pointer_cast (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 vd = dynamic_pointer_cast (decoder);