From patchwork Sun Mar 29 20:32:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stebbins X-Patchwork-Id: 18495 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 0A4EE44BB02 for ; Sun, 29 Mar 2020 23:33:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D749D68B68D; Sun, 29 Mar 2020 23:33:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.jetheaddev.com (mail.jetheaddev.com [70.164.99.34]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3283568AFA6 for ; Sun, 29 Mar 2020 23:33:02 +0300 (EEST) Received: from dionysus.jetheaddev.com (10.13.8.112) by cas.jetheaddev.com (192.168.13.27) with Microsoft SMTP Server (TLS) id 14.3.351.0; Sun, 29 Mar 2020 13:32:59 -0700 Received: from dionysus.jetheaddev.com (localhost [127.0.0.1]) by dionysus.jetheaddev.com (8.15.2/8.14.7) with ESMTP id 02TKWxOb225738 for ; Sun, 29 Mar 2020 13:32:59 -0700 Received: (from jstebbins@localhost) by dionysus.jetheaddev.com (8.15.2/8.15.2/Submit) id 02TKWwbu225737 for ffmpeg-devel@ffmpeg.org; Sun, 29 Mar 2020 13:32:58 -0700 From: John Stebbins To: Date: Sun, 29 Mar 2020 13:32:45 -0700 Message-ID: <20200329203245.225679-1-jstebbins@jetheaddev.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.13.8.112] Subject: [FFmpeg-devel] [PATCH] mov: fix seek to next root atom in fragmented mp4 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" If some but not all moof's are referenced in an sidx, whole fragments were being skipped. Fixes tickets 7377, 7389, and 8502 May also fix 8070 but the sample links expired, so I can't test. --- libavformat/mov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index f280f360b6..8ed8b7f6e9 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7724,7 +7724,8 @@ static int mov_switch_root(AVFormatContext *s, int64_t target, int index) mov->next_root_atom = 0; if (index < 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 < mov->frag_index.nb_items && + mov->frag_index.item[index].moof_offset == target) { 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)