aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomajsjiang <tomajsjiang@tencent.com>2019-08-07 22:48:28 +0800
committerJun Zhao <barryjzhao@tencent.com>2019-08-15 09:27:18 +0800
commit9c3adb7ce23522dcceb264bc0bffd3592dd3e1a5 (patch)
tree74c275d1491a54ae2abbcb1b5d986477c8831b3a
parent3d1506c630eb59b428eb3585ccaa446fec7f3b0a (diff)
downloadffmpeg-9c3adb7ce23522dcceb264bc0bffd3592dd3e1a5.tar.gz
lavf/utils: fix error like "offset 0x1f85: partial file"
fix error like "offset 0x1f85: partial file", the root cause is when read the mp4 file from http, and the moov in the end of the mp4 file, reconfig the buffer will drop some data. Signed-off-by: Jun Zhao <barryjzhao@tencent.com> Signed-off-by: Zhongxing Jiang <tomajsjiang@tencent.com>
-rw-r--r--libavformat/utils.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6c6f4e1bd1..b57e680089 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2136,7 +2136,13 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
/* XXX This could be adjusted depending on protocol*/
if (s->pb->buffer_size < pos_delta && pos_delta < (1<<24)) {
av_log(s, AV_LOG_VERBOSE, "Reconfiguring buffers to size %"PRId64"\n", pos_delta);
- ffio_set_buf_size(s->pb, pos_delta);
+
+ /* realloc the buffer and the original data will be retained */
+ if (ffio_realloc_buf(s->pb, pos_delta)) {
+ av_log(s, AV_LOG_ERROR, "Realloc buffer fail.\n");
+ return;
+ }
+
s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, pos_delta/2);
}