s/use_template/take_settings_from/g
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index 5e2cb8638804b328e36e1c89cd127e3e449d2535..26b1d4bf8081b7dc1e536c2b0473c919721f9398 100644 (file)
@@ -78,7 +78,7 @@ using boost::optional;
 using boost::dynamic_pointer_cast;
 using dcp::Size;
 
-FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> log)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> log, bool fast)
        : FFmpeg (c)
        , _log (log)
        , _have_current_subtitle (false)
@@ -94,11 +94,12 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log>
        }
 
        if (c->audio) {
-               audio.reset (new AudioDecoder (this, c->audio, log));
+               audio.reset (new AudioDecoder (this, c->audio, log, fast));
        }
 
        if (c->subtitle) {
-               subtitle.reset (new SubtitleDecoder (this, c->subtitle, log));
+               /* XXX: this time here should be the time of the first subtitle, not 0 */
+               subtitle.reset (new SubtitleDecoder (this, c->subtitle, log, ContentTime()));
        }
 
        _next_time.resize (_format_context->nb_streams);
@@ -562,6 +563,8 @@ FFmpegDecoder::decode_subtitle_packet ()
        _have_current_subtitle = true;
        if (sub_period.to) {
                _current_subtitle_to = *sub_period.to + _pts_offset;
+       } else {
+               _current_subtitle_to = optional<ContentTime>();
        }
 
        for (unsigned int i = 0; i < sub.num_rects; ++i) {
@@ -582,6 +585,10 @@ FFmpegDecoder::decode_subtitle_packet ()
                }
        }
 
+       if (_current_subtitle_to) {
+               subtitle->emit_stop (*_current_subtitle_to);
+       }
+
        avsubtitle_free (&sub);
 }