From patchwork Wed Sep 26 13:33:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Ryan X-Patchwork-Id: 10494 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:1286:0:0:0:0:0 with SMTP id 6-v6csp742791jap; Wed, 26 Sep 2018 06:33:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV60XxQ9q+MjtWyTbZ1xi+Eap6MU8s7hVcn6keOD3LNm+G6pktkXB4kVDJpKVg59fVVlI1ryG X-Received: by 2002:a1c:1bca:: with SMTP id b193-v6mr4392210wmb.6.1537968805041; Wed, 26 Sep 2018 06:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537968805; cv=none; d=google.com; s=arc-20160816; b=g0tlkfqSe6tKJEeN3yHq+Ucun397BHAWbv2qwJ81R44NoXirscAjPZR6cobFGyZ3Rr lXH27SHRaHpguQVUJl9h4K1bpwyOUroJNZGorCKeJr+hHpxTLO+8ngugFvFe5PNMZEJL vkz2UzwXQkO0MgxyjfBy2bb2ekGrEAXw6TD7XTshIyYxdqJh60BTPw2FN27lANGjRUju 4h/a9aW0WaAtzbLVR29DsOuwbpPzle/QnsNUM3wBDUe7B0Gj9SoKjOIqAlPf+/xadqt6 PwaNJb6vhqhpvEZQQnaFQmPv0LMOoV9uVJ/EFNPVMXqW/O3TwSRYCPtLmN4he65OIj/g 80mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Ds7uo3TLX1cixlqzZSf4Rec9J9YtC9+qS63M4CLUrlI=; b=QDQkOdeIN0jUTGnVAlhpxMSry4pSPF2ioE06YpsAKFaXFzo6ui3L67nntswX5oqNy7 CsKM8MVWRI8DB5VG80GG3tD9ev+v2GdDi6P6uVb9HPBrYD/oMa2ilLWFFss4enciNmxg //qPc6hTO4BVg2o7r2nuzkRbWjvNSwzpZwlDLWYy8h3CAPrG0etKesN2Y/nFWn6F2Bmr Zu0um1/s3gaDTmDr711PXbCfIEUKnLEwtXmVXNj7aehABU+MLCWMP66keSiJvlHr8I3D ADVjNSOHdMDYMCcF2R33bqymhG6EiBSLol98ateb2aNn2IJgkN1z6i2McgWwpJxuFI34 hqYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=tvxjDpqz; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h4-v6si4841049wmh.91.2018.09.26.06.33.24; Wed, 26 Sep 2018 06:33:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=tvxjDpqz; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B6E1C68A5A6; Wed, 26 Sep 2018 16:33:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6FC5368A590 for ; Wed, 26 Sep 2018 16:32:54 +0300 (EEST) Received: by mail-wm1-f44.google.com with SMTP id o2-v6so2353024wmh.5 for ; Wed, 26 Sep 2018 06:33:11 -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=aIoQ+NrvLXs1sErhy5qWnVBz9B+hbxaBzkyxxuoqodE=; b=tvxjDpqzEY0Ju6Gb+//ep1K3Mgy7u1Tb/r4zVum/3XPSFUiS48PiY4+S3TcYPjQ31t AH1bJJ2hPxlSFDJOH28X6QNLHKqRwWTyCF0wH852e7CPgcf7dH8E9+ka9q3GZWOnXveX JsLXPO7RguVRtw7BHmUiYqfCfcJmmnFt3tE/k0r+52lBJciOe/462cl6VszrLIvyQdtI muMSiJaexX8YbAb0s1yLbkYROorgA16tKE7QhDKRfA6qKU/LAZFE6D8Yhzp+VtHYXyHF vziB1rjTAOzHykik45KngutXVmxH+B4oDmvZeCsqiv3K2QQRum+7LP6LUu1EW+wqY9wk YtpQ== 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=aIoQ+NrvLXs1sErhy5qWnVBz9B+hbxaBzkyxxuoqodE=; b=NSteiEyUVVxr6iZaU9x/tt4ORJ6S6quEbdaGXGpEBrSmHs3fsbAJuHLQdnlYm7VNYU bPsPSrAsDT7YC8wdXwZHAIokNfAs/3MInLrMSsi3rN2NIAv+U+VNkyIwsufQyb7aIyTH YeUZd+d19Ip/s4wXk8lvt8SOzfoSZ/g5uugGgvqe7iyZJHrfzhFGcm0BuvPAjRIj9fHk zVPCU3m7vgzBUlPN+5UYbat5E17J0EvQNg2Gey5G/UgSWYdiGagYwCpJNJ2qOmCzhpHe VBrvzlTolwdntCSPVUBn1yWPqyufb2RNLNvDqv1IvjYFteOVvNuqn00srXhSzyuoREXw LEog== X-Gm-Message-State: ABuFfog1U2lSzEKwWdQ7woX9UMtkCoaWzKamM1Ld3i1P8OkiP2JDAkj3 +zHlAICzC/fkC0mGqgktRyTcFTBI X-Received: by 2002:a1c:d109:: with SMTP id i9-v6mr4722345wmg.5.1537968790274; Wed, 26 Sep 2018 06:33:10 -0700 (PDT) Received: from mechagodzilla.com ([213.86.121.134]) by smtp.gmail.com with ESMTPSA id r14-v6sm3292880wrt.0.2018.09.26.06.33.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Sep 2018 06:33:09 -0700 (PDT) From: Nick Ryan To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Sep 2018 14:33:01 +0100 Message-Id: <20180926133301.16657-2-nick.paul.ryan@gmail.com> X-Mailer: git-send-email 2.17.1 (Apple Git-112) In-Reply-To: <20180926133301.16657-1-nick.paul.ryan@gmail.com> References: <20180926133301.16657-1-nick.paul.ryan@gmail.com> Subject: [FFmpeg-devel] [PATCH 1/1] Trying to fix trac ticket #7359 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: Nick Ryan MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Nick Ryan --- libavformat/mov.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 67015a72a1..587513e06e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7605,15 +7605,15 @@ static int mov_switch_root(AVFormatContext *s, int64_t target, int index) if (index >= 0 && index < mov->frag_index.nb_items) target = mov->frag_index.item[index].moof_offset; - if (avio_seek(s->pb, target, SEEK_SET) != target) { + if (target >= 0 && avio_seek(s->pb, target, SEEK_SET) != target) { av_log(mov->fc, AV_LOG_ERROR, "root atom offset 0x%"PRIx64": partial file\n", target); return AVERROR_INVALIDDATA; } mov->next_root_atom = 0; - if (index < 0 || index >= mov->frag_index.nb_items) + if ((index < 0 && target >= 0) || index >= mov->frag_index.nb_items) index = search_frag_moof_offset(&mov->frag_index, target); - if (index < mov->frag_index.nb_items) { + if (index >= 0 && index < mov->frag_index.nb_items) { if (index + 1 < mov->frag_index.nb_items) mov->next_root_atom = mov->frag_index.item[index + 1].moof_offset; if (mov->frag_index.item[index].headers_read) @@ -7663,9 +7663,22 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) AVIndexEntry *sample; AVStream *st = NULL; int64_t current_index; + int i; int ret; mov->fc = s; retry: + if (s->pb->pos == 0) { + mov->frag_index.nb_items = 0; + mov->frag_index.current = -1; + for (i = 0; i < s->nb_streams; i++) { + AVStream *avst = s->streams[i]; + avst->index_entries = NULL; + avst->index_entries_allocated_size = 0; + avst->nb_index_entries = 0; + } + if ((ret = mov_switch_root(s, -1, -1)) < 0) + return ret; + } sample = mov_find_next_sample(s, &st); if (!sample || (mov->next_root_atom && sample->pos > mov->next_root_atom)) { if (!mov->next_root_atom)