diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 0da1e0579b..8f3e511fc4 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -452,7 +452,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) len = s->buf_end - s->buf_ptr; if (len > size) len = size; - if (len == 0) { + if (len == 0 || s->write_flag) { if(size > s->buffer_size && !s->update_checksum){ if(s->read_packet) len = s->read_packet(s->opaque, buf, size); @@ -497,6 +497,13 @@ int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size) if (size < 0) return -1; + if (s->read_packet && s->write_flag) { + len = s->read_packet(s->opaque, buf, size); + if (len > 0) + s->pos += len; + return len; + } + len = s->buf_end - s->buf_ptr; if (len == 0) { fill_buffer(s);