[FFmpeg-devel] [RFC] seek when streamed

Baptiste Coudurier baptiste.coudurier
Tue Nov 13 00:31:55 CET 2007


Hi,

Michael Niedermayer wrote:
> On Sun, Oct 07, 2007 at 10:59:33PM +0200, Baptiste Coudurier wrote:
> 
>>Hi
>>
>>I noticed a weird behaviour (bug ?) when seeking is requested when file
>>is streamed:
>>
>>in url_fseek:
>>    } else if(s->is_streamed && !s->write_flag &&
>>         offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){
>>        while(s->pos < offset && !s->eof_reached)
>>            fill_buffer(s);
>>        s->buf_ptr = s->buf_end + offset - s->pos;
>>
>>if eof_is_reached then s->pos might be < offset, therefore buf_ptr might
>>be > buf_end. Next get_buffer will memcpy negative size:
>>
>>int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
>>{
>>    int len, size1;
>>
>>    size1 = size;
>>    while (size > 0) {
>>        len = s->buf_end - s->buf_ptr;
>>        if (len > size)
>>            len = size;
>>        if (len == 0) {
>>	   [...]
>>	} else {
>>	    memcpy(buf, s->buf_ptr, len);
>>            buf += len;
>>	[...]
>>
>>Note that url_fseek clear eof_reached.
>>
>>That will only happen when reading a streamed file.
>>Im submitting the attached patch, but Im not sure what the correct
>>behaviour should be. Any suggestion welcome.
> 
> 
> i think returning some error for attempts to seek after the end of the
> file seems appropriate
> 

Ok, patch attached.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
SMARTJOG S.A.                                    http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: eof_seek.patch
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071113/1c013ae9/attachment.txt>



More information about the ffmpeg-devel mailing list