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.
92 lines
2.7 KiB
92 lines
2.7 KiB
7 years ago
|
--- a/libavformat/avio.h
|
||
|
+++ b/libavformat/avio.h
|
||
6 years ago
|
@@ -290,13 +290,6 @@ typedef struct AVIOContext {
|
||
7 years ago
|
*/
|
||
|
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;
|
||
6 years ago
|
-
|
||
7 years ago
|
/**
|
||
|
* Threshold to favor readahead over seek.
|
||
6 years ago
|
* This is current internal only, do not use from outside.
|
||
7 years ago
|
--- 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
|
||
7 years ago
|
@@ -90,7 +90,6 @@ int ffio_init_context(AVIOContext *s,
|
||
|
memset(s, 0, sizeof(AVIOContext));
|
||
|
|
||
7 years ago
|
s->buffer = buffer;
|
||
|
- s->orig_buffer_size =
|
||
|
s->buffer_size = buffer_size;
|
||
|
s->buf_ptr = buffer;
|
||
7 years ago
|
s->buf_ptr_max = buffer;
|
||
6 years ago
|
@@ -570,15 +569,16 @@ static void fill_buffer(AVIOContext *s)
|
||
7 years ago
|
}
|
||
|
|
||
|
/* make buffer smaller in case it ended up large after probing */
|
||
6 years ago
|
- if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size && len >= s->orig_buffer_size) {
|
||
7 years ago
|
+ if (s->read_packet && s->buffer_size > max_buffer_size) {
|
||
7 years ago
|
if (dst == s->buffer && s->buf_ptr != dst) {
|
||
7 years ago
|
- 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;
|
||
|
}
|
||
|
- len = s->orig_buffer_size;
|
||
|
+ av_assert0(len >= max_buffer_size);
|
||
|
+ len = max_buffer_size;
|
||
|
}
|
||
|
|
||
7 years ago
|
len = read_packet_wrapper(s, dst, len);
|
||
6 years ago
|
@@ -1086,7 +1086,6 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
|
||
7 years ago
|
|
||
|
av_free(s->buffer);
|
||
|
s->buffer = buffer;
|
||
|
- s->orig_buffer_size =
|
||
|
s->buffer_size = buf_size;
|
||
7 years ago
|
s->buf_ptr = s->buf_ptr_max = buffer;
|
||
7 years ago
|
url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);
|
||
|
--- a/libavformat/utils.c
|
||
|
+++ b/libavformat/utils.c
|
||
7 years ago
|
@@ -138,6 +138,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||
7 years ago
|
#endif
|
||
7 years ago
|
#endif
|
||
|
|
||
7 years ago
|
+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;
|
||
|
+}
|
||
7 years ago
|
+
|
||
7 years ago
|
int64_t av_stream_get_end_pts(const AVStream *st)
|
||
|
{
|
||
7 years ago
|
if (st->internal->priv_pts) {
|