changeset 4957:911053932726 libavformat

Workaround broken AVI files from DC-XZ6. Fixes issue897.
author michael
date Mon, 25 May 2009 18:28:26 +0000
parents 95ea72d4e51d
children a73454df532f
files avidec.c
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/avidec.c	Sun May 24 22:59:25 2009 +0000
+++ b/avidec.c	Mon May 25 18:28:26 2009 +0000
@@ -955,19 +955,30 @@
     int i;
     int64_t last_start=0;
     int64_t first_end= INT64_MAX;
+    int64_t oldpos= url_ftell(s->pb);
 
     for(i=0; i<s->nb_streams; i++){
         AVStream *st = s->streams[i];
         int n= st->nb_index_entries;
+        unsigned int size;
 
         if(n <= 0)
             continue;
 
+        if(n >= 2){
+            int64_t pos= st->index_entries[0].pos;
+            url_fseek(s->pb, pos + 4, SEEK_SET);
+            size= get_le32(s->pb);
+            if(pos + size > st->index_entries[1].pos)
+                last_start= INT64_MAX;
+        }
+
         if(st->index_entries[0].pos > last_start)
             last_start= st->index_entries[0].pos;
         if(st->index_entries[n-1].pos < first_end)
             first_end= st->index_entries[n-1].pos;
     }
+    url_fseek(s->pb, oldpos, SEEK_SET);
     return last_start > first_end;
 }