From patchwork Mon Nov 5 23:48:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Boushley X-Patchwork-Id: 10944 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 4DAB544CE24 for ; Tue, 6 Nov 2018 01:48:19 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B7D5168A812; Tue, 6 Nov 2018 01:47:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5CF2668A6EB for ; Tue, 6 Nov 2018 01:47:43 +0200 (EET) Received: by mail-pg1-f176.google.com with SMTP id z17-v6so4957311pgv.3 for ; Mon, 05 Nov 2018 15:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=VAb5rWtcMFHVnEElG1gOpXINHKsyIBcMNFXI7baEUEA=; b=BpKfllrR7+YifJrtKDOxpg0aZu7iqLG39hbXBadWlYd2h0yPvdN/V/KcmtV3HL13Kc Q8VqUNhdl4jknpodPDVewzeqfqfXEh7heISbDij4k/XnbwHyacAPBY6v9/C1GuoLIMM8 sMYNnuNG/dGpURis1Md9EucIio9anzEQmZc2jst/YGtsTXSWGqr+SmJszAAZy/9TNRzB R9z+LlJUya4UAPy8Qk8LrTqPCtEQr9LRjKLTCAN079vmgCLtaPu1nr9q56sLt7XgYKKe W4sBMZDLU0zwX2mr6CrG0NMbe0DFH+qaxlucXNz+LWAsAv4xoI8E2jq04NCCHNNNeBvm c4vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=VAb5rWtcMFHVnEElG1gOpXINHKsyIBcMNFXI7baEUEA=; b=o0JPfXUzul1wRUhOZjsRUumw4xgJ+R6PE83kN4NuMpU+foPAqJHNK4miWNz43xCbT/ KgFd2Leonf2zxs38z9Pb9QJiyEJgFmfsdq8j1aWuJ7ek5taLbXZ5LBBfvK9+aoP/Kp8a +3bo7oaiylqqA/QMlhUn4I50j0UN/5ClSLScVIz80dATtNN9ogNeqIsunQ4pKRBcUJUA vptGBrQ5L5AVGOLlwJDQqmY6oQ8cxc4HWWg5DtQYGOjhrpgM9LIiZ4/8n7IcK1JEn3BA I1FZgIviTBJ4XmIL8UWlp2sP/ZWLt7HSZ/hKaN3C5BXYl3+ghpvrRttj1zC5/yiQdqja oXxg== X-Gm-Message-State: AGRZ1gID8zLtdgQCdJ1kx4omjwp/lOkx+6rYmE22YD/IeI1KqmOusR56 DeDW9iZrSJAMHt4Op7QRLFbl1BXh X-Google-Smtp-Source: AJdET5cGVUwyrpw5vqAOjbxLwz/lxVWq0GHqz1Q9nzb8o4ZR4OuOEtYh9qpDjTPVdipTP+UKCbQQ1g== X-Received: by 2002:a65:5bc4:: with SMTP id o4mr8343516pgr.426.1541461695004; Mon, 05 Nov 2018 15:48:15 -0800 (PST) Received: from [10.141.32.145] ([66.162.141.14]) by smtp.gmail.com with ESMTPSA id m12-v6sm50326745pgd.81.2018.11.05.15.48.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 15:48:13 -0800 (PST) To: ffmpeg-devel@ffmpeg.org From: Aaron Boushley Message-ID: <5c2b3be1-1345-1196-dd7a-bea83e804746@gmail.com> Date: Mon, 5 Nov 2018 15:48:13 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing (Take 2) 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" Sorry for the second thread, first one was corrupted with a newline because I attempted an inline patch. Hopefully the mime-type will be set correctly on this one. --- When parsing a fragmented MP4 with the use_mfra_for option set so that the mfra box is parsed we currently continue to parse all the top level boxes in the mp4. We also avoid using the index in mov_seek_fragment unless the fragment index is marked as complete, which the mfra parsing code never does. This updates the mfra parsing code to mark the fragment index as complete, similar to the way the sidx parsing code does. With this change in place mov_read_default stops parsing top level boxes in a fragmented mp4 and uses the mfra data for mov_seek_fragment calls (assuming a use_mfra_for option is passed). When loading the file over a network this results in significantly better performance since avformat_open_input doesn't require a scan of the entire file. Aaron From 61412c5990037484e13c7daa60d83b8ba548b8a6 Mon Sep 17 00:00:00 2001 From: Aaron Boushley Date: Mon, 5 Nov 2018 11:02:00 -0800 Subject: [PATCH] libavformat/mov: Speed up fragmented mp4 parsing When parsing a fragmented MP4 with the use_mfra_for option set so that the mfra box is parsed we currently continue to parse all the top level boxes in the mp4. We also avoid using the index in mov_seek_fragment unless the fragment index is marked as complete, which the mfra parsing code never does. This updates the mfra parsing code to mark the fragment index as complete, similar to the way the sidx parsing code does. With this change in place mov_read_default stops parsing top level boxes in a fragmented mp4 and uses the mfra data for mov_seek_fragment calls (assuming a use_mfra_for option is passed). When loading the file over a network this results in significantly better performance since avformat_open_input doesn't require a scan of the entire file. Signed-off-by: Aaron Boushley --- libavformat/mov.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index ec57a05803..34ba7ffe61 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7344,6 +7344,7 @@ static int mov_read_mfra(MOVContext *c, AVIOContext *f) if (ret < 0) goto fail; } while (!ret); + c->frag_index.complete = 1; ret = 0; fail: seek_ret = avio_seek(f, original_pos, SEEK_SET);