[FFmpeg-cvslog] r24428 - in branches/0.5: . libavformat/aviobuf.c

siretart subversion
Thu Jul 22 13:58:26 CEST 2010


Author: siretart
Date: Thu Jul 22 13:58:26 2010
New Revision: 24428

Log:
aviobuf: Do short seeks forward by reading and skipping data instead of a proper seek

This improves performance on e.g. seekable http.


backport r24280 by mstorsjo

Modified:
   branches/0.5/   (props changed)
   branches/0.5/libavformat/aviobuf.c

Modified: branches/0.5/libavformat/aviobuf.c
==============================================================================
--- branches/0.5/libavformat/aviobuf.c	Thu Jul 22 13:55:55 2010	(r24427)
+++ branches/0.5/libavformat/aviobuf.c	Thu Jul 22 13:58:26 2010	(r24428)
@@ -27,6 +27,13 @@
 
 #define IO_BUFFER_SIZE 32768
 
+/**
+ * Do seeks within this distance ahead of the current buffer by skipping
+ * data instead of calling the protocol seek function, for seekable
+ * protocols.
+ */
+#define SHORT_SEEK_THRESHOLD 4096
+
 static void fill_buffer(ByteIOContext *s);
 
 int init_put_byte(ByteIOContext *s,
@@ -151,8 +158,10 @@ int64_t url_fseek(ByteIOContext *s, int6
         offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
         /* can do the seek inside the buffer */
         s->buf_ptr = s->buffer + offset1;
-    } else if(s->is_streamed && !s->write_flag &&
-              offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){
+    } else if ((s->is_streamed ||
+               offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
+               !s->write_flag && offset1 >= 0 &&
+              (whence != SEEK_END || force)) {
         while(s->pos < offset && !s->eof_reached)
             fill_buffer(s);
         if (s->eof_reached)



More information about the ffmpeg-cvslog mailing list