X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=5e0d3b315b01f96d6d7e92f947d1e0e025b2f3f6;hb=daba5abc608788795de727121bcd1a83ef9caecb;hp=29523b1eec108e7b1dadd6118735bdc6307ddc65;hpb=a6791850f8bf56f4a08cf860fdce8df2d3e13405;p=dcpomatic.git 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);