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

Michael Niedermayer michaelni
Fri Jul 16 21:01:37 CEST 2010


On Fri, Jul 16, 2010 at 04:21:03PM +0300, Martin Storsj? wrote:
> Hi,
> 
> As in $subj - even if the underlying protocol is seekable (such as when 
> reading a plain file over http), doing small seeks forward is 
> prohibitively expensive (and sometimes errorprone, too) compared to simply 
> skipping data.
> 
> Some demuxers (flvdec is the one I've been testing with) triggers these 
> very often, sometimes after every few 100 KB or so.
> 
> This issue can be solved at two levels, both within aviobuf and within the 
> http protocol - both have their advantages and disadvantages. See the 
> attached patches - what do you prefer, or do you want it solved at both 
> levels?
> 
> // Martin
>  aviobuf.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 5a9197d19797b7b6e676233f18a1a20212b68f4f  0001-aviobuf-Do-short-seeks-forward-by-reading-instead-of.patch
> From a75e45742885d0eb825f0aa96d862534dbb6de30 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 |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 9f1187e..2fbde48 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -153,7 +153,9 @@ 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 &&
> +    } else if ((s->is_streamed ||
> +               s->buffer + offset1 < s->buf_ptr + s->buffer_size) &&
> +               !s->write_flag && offset1 >= 0 &&
>                (whence != SEEK_END || force)) {

arbitrary and obfuscated
there should be a #define that specifyies at what threshold to apply a seek

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100716/43acc57a/attachment.pgp>



More information about the ffmpeg-devel mailing list