Commit 61b5ef77 authored by Michael Niedermayer's avatar Michael Niedermayer

libavformat/aviobuf: keep track of the original buffer-size and restore it after…

libavformat/aviobuf: keep track of the original buffer-size and restore it after probe/ensure-seekback
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 0d4a66ee
...@@ -146,6 +146,13 @@ typedef struct AVIOContext { ...@@ -146,6 +146,13 @@ typedef struct AVIOContext {
* This field is internal to libavformat and access from outside is not allowed. * This field is internal to libavformat and access from outside is not allowed.
*/ */
int writeout_count; int writeout_count;
/**
* Original buffer size
* used internally after probing and ensure seekback to reset the buffer size
* This field is internal to libavformat and access from outside is not allowed.
*/
int orig_buffer_size;
} AVIOContext; } AVIOContext;
/* unbuffered I/O */ /* unbuffered I/O */
......
...@@ -78,6 +78,7 @@ int ffio_init_context(AVIOContext *s, ...@@ -78,6 +78,7 @@ int ffio_init_context(AVIOContext *s,
int64_t (*seek)(void *opaque, int64_t offset, int whence)) int64_t (*seek)(void *opaque, int64_t offset, int whence))
{ {
s->buffer = buffer; s->buffer = buffer;
s->orig_buffer_size =
s->buffer_size = buffer_size; s->buffer_size = buffer_size;
s->buf_ptr = buffer; s->buf_ptr = buffer;
s->opaque = opaque; s->opaque = opaque;
...@@ -434,14 +435,14 @@ static void fill_buffer(AVIOContext *s) ...@@ -434,14 +435,14 @@ static void fill_buffer(AVIOContext *s)
} }
/* make buffer smaller in case it ended up large after probing */ /* make buffer smaller in case it ended up large after probing */
if (s->read_packet && s->buffer_size > max_buffer_size) { if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {
if (dst == s->buffer) { if (dst == s->buffer) {
ffio_set_buf_size(s, max_buffer_size); ffio_set_buf_size(s, s->orig_buffer_size);
s->checksum_ptr = dst = s->buffer; s->checksum_ptr = dst = s->buffer;
} }
av_assert0(len >= max_buffer_size); av_assert0(len >= s->orig_buffer_size);
len = max_buffer_size; len = s->orig_buffer_size;
} }
if (s->read_packet) if (s->read_packet)
...@@ -792,6 +793,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size) ...@@ -792,6 +793,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
av_free(s->buffer); av_free(s->buffer);
s->buffer = buffer; s->buffer = buffer;
s->orig_buffer_size =
s->buffer_size = buf_size; s->buffer_size = buf_size;
s->buf_ptr = buffer; s->buf_ptr = buffer;
url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ); url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment