Small cleanup.
authorCarl Hetherington <cth@carlh.net>
Fri, 21 Feb 2014 09:51:34 +0000 (09:51 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 21 Feb 2014 09:51:34 +0000 (09:51 +0000)
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_decoder.cc

index 2c5fcf70e1e09915245711103a1f76081a395680..221a262ef6e9308cf4b2e2f4490e98aee730afbf 100644 (file)
@@ -415,6 +415,10 @@ AVStream *
 FFmpegStream::stream (AVFormatContext const * fc) const
 {
        if (_legacy_id) {
+               if (id >= int (fc->nb_streams)) {
+                       return 0;
+               }
+               
                return fc->streams[id];
        }
        
index c3709166e6c8c1bb7c33d4a2c902ff436db0c15f..587c794955c614a79a9bb896f52d9b22c0600d36 100644 (file)
@@ -516,15 +516,19 @@ FFmpegDecoder::setup_subtitle ()
 {
        boost::mutex::scoped_lock lm (_mutex);
        
-       if (!_ffmpeg_content->subtitle_stream() || _ffmpeg_content->subtitle_stream()->index (_format_context) >= int (_format_context->nb_streams)) {
+       if (!_ffmpeg_content->subtitle_stream()) {
                return;
        }
 
        _subtitle_codec_context = _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec;
+       if (_subtitle_codec_context == 0) {
+               throw DecodeError (N_("could not find subtitle stream"));
+       }
+
        _subtitle_codec = avcodec_find_decoder (_subtitle_codec_context->codec_id);
 
        if (_subtitle_codec == 0) {
-               throw DecodeError (_("could not find subtitle decoder"));
+               throw DecodeError (N_("could not find subtitle decoder"));
        }
        
        if (avcodec_open2 (_subtitle_codec_context, _subtitle_codec, 0) < 0) {