[FFmpeg-devel] [PATCH] Do small seeks forward by skipping data instead of seeking, even for seekable protocols

Martin Storsjö martin
Sat Jul 17 07:28:18 CEST 2010


On Sat, 17 Jul 2010, Michael Niedermayer wrote:

> On Sat, Jul 17, 2010 at 02:28:12AM +0300, Martin Storsj? wrote:
> > On Fri, 16 Jul 2010, Michael Niedermayer wrote:
> > 
> > Added a define and reorganized the condition slightly - do you feel that 
> > this is less obfuscated?
> > 
> > // Martin
> >  aviobuf.c |    6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > a0c5539f4d6e0d880d9eaf25f5ece5a592eed128  0001-aviobuf-Do-short-seeks-forward-by-reading-instead-of.patch
> > From c49b24ffb6729acfbe97d9a312a0e02315a4acbc Mon Sep 17 00:00:00 2001
> > From: Martin Storsjo <martin at martin.st>
> > Date: Fri, 16 Jul 2010 15:43:54 +0300
> > Subject: [PATCH] aviobuf: Do short seeks forward by reading instead of calling the underlying protocol seek
> > 
> > ---
> >  libavformat/aviobuf.c |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> > 
> > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> > index d4db268..7a28ef1 100644
> > --- a/libavformat/aviobuf.c
> > +++ b/libavformat/aviobuf.c
> > @@ -28,6 +28,8 @@
> >  
> >  #define IO_BUFFER_SIZE 32768
> >  
> > +#define SHORT_SEEK_THRESHOLD 4096
> > +
> >  static void fill_buffer(ByteIOContext *s);
> >  #if LIBAVFORMAT_VERSION_MAJOR >= 53
> >  static int url_resetbuf(ByteIOContext *s, int flags);
> > @@ -153,7 +155,9 @@ int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence)
> 
> >          offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {
> 
> id try to write it similar to this test and i would suggest to doxument
> the define, except these, ok

Rewrote it to this style. I also slightly changed the semantics of the 
threshold define, so that it refers to the amount of data that we'd need 
to skip beyond what we have buffered, not the distance from the current 
offset as it originally meant. Applied with these changes.

// Martin



More information about the ffmpeg-devel mailing list