From patchwork Thu Aug 8 11:32:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 14313 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4E14F4475F6 for ; Thu, 8 Aug 2019 14:39:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C72368A774; Thu, 8 Aug 2019 14:39:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 066D1680118 for ; Thu, 8 Aug 2019 14:39:26 +0300 (EEST) Received: by mail-pg1-f196.google.com with SMTP id x15so33581084pgg.8 for ; Thu, 08 Aug 2019 04:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tZepD/dVzaW7bwAvHQRIQxa77M1tHVzQN6KdvhskILY=; b=jUD8i8U+NzgFu44dbZxzo8jaraYNY6VOoSHVGzkEPO/0el4KZThXtFjEaxLdlRBDMx 2d9LDd4uakarHTqpQsriIhV7MjoLgLqP488yn4fZOdN9tzuYqWy+NJZKnyGrCKoVfAgr /1C636/BJJOtH243mbb9YbVoQLtZ7GK7l5kT1DdHQGDo+wxkiX3t6VhpXjsYfJqkfPtC 8UXU7EflUcuY3dbEXPYHlvrxINqEpaP02Xlgs2Uwo9xVFFPoPMd/WHmef4BFd/VxJ/KY swaMK30yjijHNQOP6mJwDIizo8+W4bsA0K2JUvTMXll3gbrlhYQ4HOTNUyh7ish1Al6z t0ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tZepD/dVzaW7bwAvHQRIQxa77M1tHVzQN6KdvhskILY=; b=K1/knn5hNbFqM5OOpcEdCdN9ZlCTpizYjuk6dlixGwMRpx4LGGpHX5Qe/iYkZbGXWk /9JvrgEJWGmusxIJ2oUf9dz0zCsIyrtV89OMAqJ4mT5Sg2ylBcElVI/Orfl20k94zFWC IDA/qZUtcr6BMPZlqSrA9ektnFikTttgd1HWZ9Hb4k0raPdD1m4Q8vlLQHpHfceGg5bk bAyjxMgZPI9iDBRcopndYu0owC1c9MdkBmhHWk/9NC5xkuxvlUCJceVquZql1WYp7+ui o2sQ9Qgr/agCZY4N59SuMmfQkcoLCQJJlAjkpUrLspL1QMg5dR57Zcxxg3v+4exfbCgI hWcg== X-Gm-Message-State: APjAAAULsRzJa0OHmfIdbCROWx/DBPQuFJ7tYbpxfeuCSQL9l7QGhLop O62wtOhDB+ymNUgYhCgIVyOeFXBm X-Google-Smtp-Source: APXvYqx22kWDdD31EEuPca3uyE82I3MyfhLQLM4/nNv3urYKwhcOYNNri3jbTgc1D1vFHOAVpdjzIQ== X-Received: by 2002:a17:90a:fa18:: with SMTP id cm24mr3524232pjb.120.1565263949229; Thu, 08 Aug 2019 04:32:29 -0700 (PDT) Received: from localhost.localdomain ([47.90.47.25]) by smtp.gmail.com with ESMTPSA id q8sm2063040pjq.20.2019.08.08.04.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Aug 2019 04:32:28 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Aug 2019 19:32:21 +0800 Message-Id: <1565263941-20590-2-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1565263941-20590-1-git-send-email-mypopydev@gmail.com> References: <1565263941-20590-1-git-send-email-mypopydev@gmail.com> Subject: [FFmpeg-devel] [PATCH V1 2/2] lavf/utils: fix error like "offset 0x1f85: partial file" X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Jun Zhao , tomajsjiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: tomajsjiang 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 Signed-off-by: Zhongxing Jiang --- libavformat/utils.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 6c6f4e1..b57e680 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); }