You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

91 lines
2.7 KiB

--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -290,12 +290,6 @@ typedef struct AVIOContext {
*/
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;
/**
* Threshold to favor readahead over seek.
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -33,7 +33,7 @@
#include "url.h"
#include <stdarg.h>
-#define IO_BUFFER_SIZE 32768
+#define IO_BUFFER_SIZE 262144
/**
* Do seeks within this distance ahead of the current buffer by skipping
@@ -90,7 +90,6 @@ int ffio_init_context(AVIOContext *s,
memset(s, 0, sizeof(AVIOContext));
s->buffer = buffer;
- s->orig_buffer_size =
s->buffer_size = buffer_size;
s->buf_ptr = buffer;
s->buf_ptr_max = buffer;
@@ -570,16 +569,16 @@ static void fill_buffer(AVIOContext *s)
}
/* make buffer smaller in case it ended up large after probing */
- if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {
+ if (s->read_packet && s->buffer_size > max_buffer_size) {
if (dst == s->buffer && s->buf_ptr != dst) {
- int ret = ffio_set_buf_size(s, s->orig_buffer_size);
+ int ret = ffio_set_buf_size(s, max_buffer_size);
if (ret < 0)
av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n");
s->checksum_ptr = dst = s->buffer;
}
- av_assert0(len >= s->orig_buffer_size);
- len = s->orig_buffer_size;
+ av_assert0(len >= max_buffer_size);
+ len = max_buffer_size;
}
len = read_packet_wrapper(s, dst, len);
@@ -1087,7 +1086,6 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
av_free(s->buffer);
s->buffer = buffer;
- s->orig_buffer_size =
s->buffer_size = buf_size;
s->buf_ptr = s->buf_ptr_max = buffer;
url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -138,6 +138,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif
#endif
+void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
+{
+ if (min_size < *size)
+ return ptr;
+
+ min_size = FFMAX(17 * min_size / 16 + 32, min_size);
+
+ ptr = av_realloc(ptr, min_size);
+ /* we could set this to the unmodified min_size but this is safer
+ * if the user lost the ptr and uses NULL now
+ */
+ if (!ptr)
+ min_size = 0;
+
+ *size = min_size;
+
+ return ptr;
+}
+
int64_t av_stream_get_end_pts(const AVStream *st)
{
if (st->internal->priv_pts) {