# HG changeset patch # User michael # Date 1268693662 0 # Node ID a9a36b4f83a257a6f954ab42fa377d561dd6b3fd # Parent 219b4cc8f37833c950cb5e7b62af036224200f1d Add AVSEEK_FORCE flag to indicate that the code should attempt to seek by any means. diff -r 219b4cc8f378 -r a9a36b4f83a2 avio.c --- a/avio.c Mon Mar 15 22:37:14 2010 +0000 +++ b/avio.c Mon Mar 15 22:54:22 2010 +0000 @@ -202,7 +202,7 @@ if (!h->prot->url_seek) return AVERROR(EPIPE); - ret = h->prot->url_seek(h, pos, whence); + ret = h->prot->url_seek(h, pos, whence & ~AVSEEK_FORCE); return ret; } diff -r 219b4cc8f378 -r a9a36b4f83a2 avio.h --- a/avio.h Mon Mar 15 22:37:14 2010 +0000 +++ b/avio.h Mon Mar 15 22:54:22 2010 +0000 @@ -192,6 +192,14 @@ */ #define AVSEEK_SIZE 0x10000 +/** + * Oring this flag as into the "whence" parameter to a seek function causes it to + * seek by any means (like reopening and linear reading) or other normally unreasonble + * means that can be extreemly slow. + * This may be ignored by the seek code. + */ +#define AVSEEK_FORCE 0x20000 + typedef struct URLProtocol { const char *name; int (*url_open)(URLContext *h, const char *url, int flags); diff -r 219b4cc8f378 -r a9a36b4f83a2 aviobuf.c --- a/aviobuf.c Mon Mar 15 22:37:14 2010 +0000 +++ b/aviobuf.c Mon Mar 15 22:54:22 2010 +0000 @@ -150,8 +150,9 @@ 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 && !s->write_flag && offset1 >= 0 && + ( offset1 < (s->buf_end - s->buffer) + (1<<16) + || (whence & AVSEEK_FORCE))){ while(s->pos < offset && !s->eof_reached) fill_buffer(s); if (s->eof_reached)