Revision 7939d0ed

View differences:

libavformat/aviobuf.c
28 28

  
29 29
#define IO_BUFFER_SIZE 32768
30 30

  
31
/**
32
 * Do seeks within this distance ahead of the current buffer by skipping
33
 * data instead of calling the protocol seek function, for seekable
34
 * protocols.
35
 */
36
#define SHORT_SEEK_THRESHOLD 4096
37

  
31 38
static void fill_buffer(ByteIOContext *s);
32 39
#if LIBAVFORMAT_VERSION_MAJOR >= 53
33 40
static int url_resetbuf(ByteIOContext *s, int flags);
......
153 160
        offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {
154 161
        /* can do the seek inside the buffer */
155 162
        s->buf_ptr = s->buffer + offset1;
156
    } else if(s->is_streamed && !s->write_flag && offset1 >= 0 &&
163
    } else if ((s->is_streamed ||
164
               offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
165
               !s->write_flag && offset1 >= 0 &&
157 166
              (whence != SEEK_END || force)) {
158 167
        while(s->pos < offset && !s->eof_reached)
159 168
            fill_buffer(s);

Also available in: Unified diff