aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2010-07-22 11:58:26 +0000
committerReinhard Tartler <siretart@tauware.de>2010-07-22 11:58:26 +0000
commit84e6629de31cad467b7d9378a1faf2358b4f15b4 (patch)
tree6b6f151564daabb066007e69e90cd6f161ce3eda
parentfc038df32e43c94a23933f8e8ccef09c11c97cd7 (diff)
downloadffmpeg-84e6629de31cad467b7d9378a1faf2358b4f15b4.tar.gz
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 Originally committed as revision 24428 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
-rw-r--r--libavformat/aviobuf.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 93efd65d0b..9650ecfc9d 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -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, int64_t offset, int whence)
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)