From patchwork Fri Jul 19 12:23:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 13994 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 2088D449B95 for ; Fri, 19 Jul 2019 15:24:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B28668ACBF; Fri, 19 Jul 2019 15:24:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9D77668A119 for ; Fri, 19 Jul 2019 15:23:59 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id x6JCNwVI023920 for ; Fri, 19 Jul 2019 14:23:59 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id D2DD4E1DC8; Fri, 19 Jul 2019 14:23:58 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Jul 2019 14:23:54 +0200 Message-Id: <20190719122354.32460-3-george@nsup.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719122354.32460-1-george@nsup.org> References: <20190719122354.32460-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Fri, 19 Jul 2019 14:23:59 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 3/3] lavf/concat: implement FFSEEK_SIZE. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Nicolas George --- libavformat/concat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/concat.c b/libavformat/concat.c index 19c83c309a..ea3bc1dfde 100644 --- a/libavformat/concat.c +++ b/libavformat/concat.c @@ -38,6 +38,7 @@ struct concat_data { struct concat_nodes *nodes; ///< list of nodes to concat size_t length; ///< number of cat'ed nodes size_t current; ///< index of currently read node + uint64_t total_size; }; static av_cold int concat_close(URLContext *h) @@ -59,7 +60,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) { char *node_uri = NULL; int err = 0; - int64_t size; + int64_t size, total_size = 0; size_t len, i; URLContext *uc; struct concat_data *data = h->priv_data; @@ -112,6 +113,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) /* assembling */ nodes[i].uc = uc; nodes[i].size = size; + total_size += size; } av_free(node_uri); data->length = i; @@ -123,6 +125,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) err = AVERROR(ENOMEM); } else data->nodes = nodes; + data->total_size = total_size; return err; } @@ -158,6 +161,8 @@ static int64_t concat_seek(URLContext *h, int64_t pos, int whence) struct concat_nodes *nodes = data->nodes; size_t i; + if ((whence & AVSEEK_SIZE)) + return data->total_size; switch (whence) { case SEEK_END: for (i = data->length - 1; i && pos < -nodes[i].size; i--)