- shared_ptr<Decoder> decoder;
- optional<FrameRateChange> frc;
-
- /* FFmpeg */
- shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (i);
- if (fc) {
- decoder.reset (new FFmpegDecoder (fc, _film->log(), _fast));
- frc = FrameRateChange (fc->video->video_frame_rate(), _film->video_frame_rate());
- }
-
- shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (i);
- if (dc) {
- decoder.reset (new DCPDecoder (dc, _film->log(), _fast));
- frc = FrameRateChange (dc->video->video_frame_rate(), _film->video_frame_rate());
- }
-
- /* ImageContent */
- shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (i);
- if (ic) {
- /* See if we can re-use an old ImageDecoder */
- for (list<shared_ptr<Piece> >::const_iterator j = old_pieces.begin(); j != old_pieces.end(); ++j) {
- shared_ptr<ImageDecoder> imd = dynamic_pointer_cast<ImageDecoder> ((*j)->decoder);
- if (imd && imd->content() == ic) {
- decoder = imd;
- }
- }
-
- if (!decoder) {
- decoder.reset (new ImageDecoder (ic, _film->log()));
- }
-
- frc = FrameRateChange (ic->video->video_frame_rate(), _film->video_frame_rate());
- }
-
- /* SndfileContent */
- shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (i);
- if (sc) {
- decoder.reset (new SndfileDecoder (sc, _fast, _film->log()));
-
- /* Work out a FrameRateChange for the best overlap video for this content */
- DCPTime best_overlap_t;
- shared_ptr<Content> best_overlap;
- BOOST_FOREACH (shared_ptr<Content> j, _playlist->content ()) {
- if (!j->video) {
- continue;
- }
-
- DCPTime const overlap = min (j->end(), i->end()) - max (j->position(), i->position());
- if (overlap > best_overlap_t) {
- best_overlap = j;
- best_overlap_t = overlap;
- }
- }
-
- if (best_overlap) {
- frc = FrameRateChange (best_overlap->video->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 ());
- }
- }
-
- /* It's questionable whether subtitle content should have a video frame rate; perhaps
- it should be assumed that any subtitle content has been prepared at the same rate
- as simultaneous video content (like we do with audio).
- */
-
- /* TextSubtitleContent */
- shared_ptr<const TextSubtitleContent> rc = dynamic_pointer_cast<const TextSubtitleContent> (i);
- if (rc) {
- decoder.reset (new TextSubtitleDecoder (rc));
- frc = FrameRateChange (rc->subtitle->subtitle_video_frame_rate(), _film->video_frame_rate());
- }