[FFmpeg-devel] [PATCH] avidec: index also AVDISCARD_ALL streams

Reimar Döffinger Reimar.Doeffinger
Tue Aug 25 10:00:16 CEST 2009


On Fri, Aug 21, 2009 at 11:18:06AM +0200, Michael Niedermayer wrote:
> > Should url_fskip set eof_reached when url_fseek fails? Or should it have
> > a return value? Or...?
> 
> i think giving url_fskip() a return value is a good idea

Hm, looks to me like url_fskip is part of the public API?
Unless you think it's not, I'd suggest attached patch instead.
(adding "ret" and thus giving the return value a sense obviously
can be applied separately or not at all if you prefer).
-------------- next part --------------
Index: libavformat/avidec.c
===================================================================
--- libavformat/avidec.c	(revision 19668)
+++ libavformat/avidec.c	(working copy)
@@ -995,8 +995,10 @@
     ByteIOContext *pb = s->pb;
     uint32_t tag, size;
     int64_t pos= url_ftell(pb);
+    int ret = -1;
 
-    url_fseek(pb, avi->movi_end, SEEK_SET);
+    if (url_fseek(pb, avi->movi_end, SEEK_SET) < 0)
+        goto the_end; // maybe truncated file
 #ifdef DEBUG_SEEK
     printf("movi_end=0x%"PRIx64"\n", avi->movi_end);
 #endif
@@ -1017,19 +1019,20 @@
         case MKTAG('i', 'd', 'x', '1'):
             if (avi_read_idx1(s, size) < 0)
                 goto skip;
-            else
+            ret = 0;
                 goto the_end;
             break;
         default:
         skip:
             size += (size & 1);
-            url_fskip(pb, size);
+            if (url_fseek(pb, size, SEEK_CUR) < 0)
+                goto the_end; // something is wrong here
             break;
         }
     }
  the_end:
     url_fseek(pb, pos, SEEK_SET);
-    return 0;
+    return ret;
 }
 
 static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)



More information about the ffmpeg-devel mailing list