OSDN Git Service

Fix for some non interleaved avi files that gets played twice or won't end
authorJoakim Plate <elupus@ecce.se>
Sun, 11 Sep 2011 16:21:07 +0000 (18:21 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 11 Sep 2011 16:21:07 +0000 (18:21 +0200)
This changes so we assume EOF when we can't find the next
streams index entry for non interleaved file.

http://trac.xbmc.org/ticket/5585

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/avidec.c

index db0ed3c..2c72329 100644 (file)
@@ -1038,7 +1038,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
             }
         }
         if(!best_st)
-            return -1;
+            return AVERROR_EOF;
 
         best_ast = best_st->priv_data;
         best_ts = av_rescale_q(best_ts, (AVRational){FFMAX(1, best_ast->sample_size), AV_TIME_BASE}, best_st->time_base);
@@ -1054,7 +1054,8 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
         if(i>=0){
             int64_t pos= best_st->index_entries[i].pos;
             pos += best_ast->packet_size - best_ast->remaining;
-            avio_seek(s->pb, pos + 8, SEEK_SET);
+            if(avio_seek(s->pb, pos + 8, SEEK_SET) < 0)
+              return AVERROR_EOF;
 //        av_log(s, AV_LOG_DEBUG, "pos=%"PRId64"\n", pos);
 
             assert(best_ast->remaining <= best_ast->packet_size);
@@ -1064,6 +1065,8 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
                 best_ast->packet_size=
                 best_ast->remaining= best_st->index_entries[i].size;
         }
+        else
+          return AVERROR_EOF;
     }
 
 resync: