Another small clean-up.
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index 2c5fcf70e1e09915245711103a1f76081a395680..2c888baaf087fa49a5c1239900db35617d2f5593 100644 (file)
@@ -393,28 +393,32 @@ FFmpegAudioStream::as_xml (xmlpp::Node* root) const
        mapping.as_xml (root->add_child("Mapping"));
 }
 
-int
-FFmpegStream::index (AVFormatContext const * fc) const
+bool
+FFmpegStream::uses_index (AVFormatContext const * fc, int index) const
 {
        if (_legacy_id) {
-               return id;
+               return id == index;
        }
        
        size_t i = 0;
        while (i < fc->nb_streams) {
                if (fc->streams[i]->id == id) {
-                       return i;
+                       return int (i) == index;
                }
                ++i;
        }
 
-       assert (false);
+       return false;
 }
 
 AVStream *
 FFmpegStream::stream (AVFormatContext const * fc) const
 {
        if (_legacy_id) {
+               if (id >= int (fc->nb_streams)) {
+                       return 0;
+               }
+               
                return fc->streams[id];
        }