diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-10-18 17:30:37 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-10-18 17:30:37 +0000 |
commit | 4589dc5c4d1d84e34da6e2318358e33396d6c326 (patch) | |
tree | 805b4087dbb1e89cdf606ddfa6ba144d6a6c1f11 /libavformat | |
parent | 8ddd280d2d8eea8ca22a39cfed17b17f4b420cac (diff) | |
download | ffmpeg-4589dc5c4d1d84e34da6e2318358e33396d6c326.tar.gz |
Append read data onto the buffer instead of overwriting, this ensures
that the whole buffer is available for seeking back.
Fixes issue480
Originally committed as revision 15634 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/aviobuf.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 46458db20f..344664c191 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -290,20 +290,25 @@ void put_tag(ByteIOContext *s, const char *tag) static void fill_buffer(ByteIOContext *s) { - int len=0; + uint8_t *dst= s->buf_end - s->buffer < s->buffer_size ? s->buf_ptr : s->buffer; + int len= s->buffer_size - (dst - s->buffer); + + assert(s->buf_ptr == s->buf_end); /* no need to do anything if EOF already reached */ if (s->eof_reached) return; - if(s->update_checksum){ + if(s->update_checksum && dst == s->buffer){ if(s->buf_end > s->checksum_ptr) s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_end - s->checksum_ptr); s->checksum_ptr= s->buffer; } if(s->read_packet) - len = s->read_packet(s->opaque, s->buffer, s->buffer_size); + len = s->read_packet(s->opaque, dst, len); + else + len = 0; if (len <= 0) { /* do not modify buffer if EOF reached so that a seek back can be done without rereading data */ @@ -312,8 +317,8 @@ static void fill_buffer(ByteIOContext *s) s->error= len; } else { s->pos += len; - s->buf_ptr = s->buffer; - s->buf_end = s->buffer + len; + s->buf_ptr = dst; + s->buf_end = dst + len; } } |