aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-06-30 18:15:50 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-07-04 19:13:38 +0200
commit2ca48e466675a8a3630061cd2c15325eab8eda97 (patch)
tree230416e83253a2eb33f50fcbecea5cbde5ef6278 /libavformat
parentbf18abb2eb79c00c69f6f83ede64536e3297793c (diff)
downloadffmpeg-2ca48e466675a8a3630061cd2c15325eab8eda97.tar.gz
avformat: Append data in fill_buffer() when possible
Data is appended in fill_buffer() when there is sufficient space left and the data pointer only reset when needed. Previously the data pointer was more often reset, loosing more seekback space than otherwise needed. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/aviobuf.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 966e0e6a3d..790c26155f 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -392,12 +392,11 @@ void avio_wb24(AVIOContext *s, unsigned int val)
static void fill_buffer(AVIOContext *s)
{
- uint8_t *dst = !s->max_packet_size &&
- s->buf_end - s->buffer < s->buffer_size ?
- s->buf_end : s->buffer;
- int len = s->buffer_size - (dst - s->buffer);
int max_buffer_size = s->max_packet_size ?
s->max_packet_size : IO_BUFFER_SIZE;
+ uint8_t *dst = s->buf_end - s->buffer + max_buffer_size < s->buffer_size ?
+ s->buf_end : s->buffer;
+ int len = s->buffer_size - (dst - s->buffer);
/* can't fill the buffer without read_packet, just set EOF if appropriate */
if (!s->read_packet && s->buf_ptr >= s->buf_end)
@@ -416,10 +415,13 @@ static void fill_buffer(AVIOContext *s)
/* make buffer smaller in case it ended up large after probing */
if (s->read_packet && s->buffer_size > max_buffer_size) {
- ffio_set_buf_size(s, max_buffer_size);
+ if (dst == s->buffer) {
+ ffio_set_buf_size(s, max_buffer_size);
- s->checksum_ptr = dst = s->buffer;
- len = s->buffer_size;
+ s->checksum_ptr = dst = s->buffer;
+ }
+ av_assert0(len >= max_buffer_size);
+ len = max_buffer_size;
}
if (s->read_packet)