Fix subtitle controls in the viewer.
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index 67587a56499b8438de1b9d53d12c155a2ebe1937..7ebb31084799b252e8d6cf3cd6d3c34c68c2fa0e 100644 (file)
@@ -31,7 +31,6 @@
 #include <stdint.h>
 #include <boost/lexical_cast.hpp>
 extern "C" {
-#include <tiffio.h>
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 #include <libswscale/swscale.h>
@@ -64,7 +63,7 @@ using libdcp::Size;
 
 boost::mutex FFmpegDecoder::_mutex;
 
-FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio, bool subtitles)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio)
        : Decoder (f)
        , VideoDecoder (f, c)
        , AudioDecoder (f, c)
@@ -80,7 +79,6 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegC
        , _subtitle_codec (0)
        , _decode_video (video)
        , _decode_audio (audio)
-       , _decode_subtitles (subtitles)
 {
        setup_general ();
        setup_video ();
@@ -248,7 +246,9 @@ FFmpegDecoder::pass ()
                if (_ffmpeg_content->audio_stream() && _decode_audio) {
                        decode_audio_packet ();
                }
-                       
+
+               /* Stop us being asked for any more data */
+               _next_video = _next_audio = _ffmpeg_content->length ();
                return;
        }
 
@@ -258,7 +258,7 @@ FFmpegDecoder::pass ()
                decode_video_packet ();
        } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _decode_audio) {
                decode_audio_packet ();
-       } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && _decode_subtitles) {
+       } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id) {
 
                int got_subtitle;
                AVSubtitle sub;
@@ -278,6 +278,8 @@ FFmpegDecoder::pass ()
                        }
                        avsubtitle_free (&sub);
                }
+       } else {
+               cout << "[ffmpeg] other packet.\n";
        }
 
        av_free_packet (&_packet);
@@ -444,6 +446,7 @@ void
 FFmpegDecoder::seek (Time t)
 {
        do_seek (t, false, false);
+       VideoDecoder::seek (t);
 }
 
 void
@@ -454,6 +457,7 @@ FFmpegDecoder::seek_back ()
        }
        
        do_seek (next() - 2.5 * TIME_HZ / video_frame_rate(), true, true);
+       VideoDecoder::seek_back ();
 }
 
 void
@@ -464,6 +468,7 @@ FFmpegDecoder::seek_forward ()
        }
        
        do_seek (next() - 0.5 * TIME_HZ / video_frame_rate(), true, true);
+       VideoDecoder::seek_forward ();
 }
 
 void