From patchwork Sat Dec 25 08:45:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 32911 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp8759219iog; Sat, 25 Dec 2021 00:46:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8MsxDtX/wQHr9+9UevXRKrPck2L3xp2ThONRMeXbWjVmz12uoXNlFz8xPLeVQJAE6Q9Yl X-Received: by 2002:a17:906:4556:: with SMTP id s22mr7637426ejq.321.1640421977717; Sat, 25 Dec 2021 00:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640421977; cv=none; d=google.com; s=arc-20160816; b=utu5IAtYl+jp0HesbmC3Eqaf8igwS6ruy1HZVfCBZXoA2ZDyN42A/XObdgaOfm5V+9 wAk2wuKguG8ALC1Ss6uUMWx5OcOThNjH9LvMdswaUITurpNjGRGrKulVE2hIFJsrcZ9y dH6iSKmZMsVMC/B3mn7mGv10bVp42zG4f68kbD3TvlWSovwzCGXID4M0N0uQRPP8sBz0 uBzrL86dDsfK8XyCmYP/31qBbEI8mLp31mli95bn0ezIy2k9BX0uKMSS5hgxZ6aFoCR7 G0uF264A/u1U8YM8yv75mbRzDM/Ck5w22Ru2i/xtr/AaoFvfUCfHOccmlcFc/J4wcqrM iWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:date:to:from:message-id :dkim-signature:delivered-to; bh=P3cMsjApxcRUsksFHM+lOyTyT1IwIkv/j27tjszjgOc=; b=xAK0FpyYkVfR29aLo8oqUP/99wM3pbSqImxnz7LpOBwgbeIlmtCKPuWWVow6DBZRLF KEteBUIte5u4jLy/5NubcQJGAEmsjbvmwSGb7lw51li4nNmOB6QnQYDGII+Vr/3qCwhx yKduQZjwzQs+4fGqrEcM9jaFdGVdMbAKP/W04SD3UqPvt/Hd0BSvIdcwwkuzorxnvwq1 95FJ07DdfsWdR0q35i2yoG5dgy4YjUa9o0Uqb13tDb9Vq0yGzQRmSNWRKSGF+6R/edSG kaNJRbyeaYAXnogWOKTcHRYQ6n8ArF4EHSVCe1rr3Wi1Bzv3FXGIwmxd2lbWtYEVUY0E Uzlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=kMthuXwk; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q8si4328591ejr.467.2021.12.25.00.46.16; Sat, 25 Dec 2021 00:46:17 -0800 (PST) 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=@foxmail.com header.s=s201512 header.b=kMthuXwk; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F323568B009; Sat, 25 Dec 2021 10:46:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-57-210.mail.qq.com (out162-62-57-210.mail.qq.com [162.62.57.210]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F369D68B004 for ; Sat, 25 Dec 2021 10:46:04 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1640421958; bh=vywEIqRLzGm0S8iXCR0Ps53LGtIkRvPc+J9BC31HSh0=; h=From:To:Cc:Subject:Date; b=kMthuXwkd4keMmlf7ZDcZW3CB061AyNRlyPSrkOMm6WvTMStwljNQCD7OimTELr6m KFDjTsK783iycWH3fN8KxZEysa68ywRSd1DCh/dZOFM2vDRvtWuKg+BQbqE0wFlfH4 9A6h6wxpx1i+S4Y2hQMt1lU+S0sn/YKKan98EXeE= Received: from ZHILIZHAO-MB2.tencent.com ([113.87.131.148]) by newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP id B78A5C6C; Sat, 25 Dec 2021 16:45:56 +0800 X-QQ-mid: xmsmtpt1640421956t763y0ogg Message-ID: X-QQ-XMAILINFO: NhDhJCJPIfnTWNxaWVh/+nbZwaPV+P9VM9dN+5cIEbIJTD+ySH6zCcW8dNd8Ea JfGSJoZtd7str5DLzLbMv5xWA/7MeGiK7hQIKsdyX61sql4KRRr2Cg5m/KI7nZfYWn9LHI1U5KK5 Ddrzw6YLkN7n42BSa078qNHYOTOYdjzxFjo364dWT+vkHDKXjNknDtSncGLSP3WdSt+U6jsCQMoD mWigGauMP5LuA4RUBbI9o1+A+8r+MlSh3CG8o+ajOdJ090/w00muWL8OzCs02rYykBNSKJPP0Of3 VYVCc/AVBhKWGkX2wjREaaKWgJ/t0KmdJH/m34LneMY4Ft5vcJJ4VP+v3P28Tkbi6jh3dEkFxBSr zW+GVkAn+4BMmN8+dieUn833Mpu8QqCLMg5bPJQ5BQzoJSlI7m1JkGl++EILjrwlxWxq7b1hAV78 SnSow2gyZRG0vYVA72YpHs6xypIeGEFH5zbNge8N7ASKldfxgxntC1uGrTfe1/fLMAA79if0QULK PC37qhh5Pjgfd/c0I+9nJs04GPVILW7y4Njbb4yqm2Q+pIx3PHNXWNymk5/37jor1T61rFQCIx2S 5k4o+cYUMVD6n6edxiuHLE0kwKHEVPaFa1MwfzqPptlBydsPffHFET2WZabZebZjdO9YTXG0CJHI 1mm2XFYqpCfFApwsg1N6ylHHSGcTrPL4WwgC1D6p0972LV5CyWGKmRZEuDU211tL8UpzzyhkhnER jC76GHiVWb7O62Rdye42r1HU9aSFBVcafhlFjIy0hkKCJAYECMuynhjKTP5jxdT5JABpqZHSpnpn zXkVAgWiQ2ZZKoqYQAV7iv/604pf+EV2gP4w+jjT7gVdkb0gkDNdusMyvgCAdrCWvUQ6HYh5peNw == From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 Dec 2021 16:45:53 +0800 X-OQ-MSGID: <20211225084554.43114-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/mov: skip moof and sidx before found moov X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qkQFyVldVbpS It's required for #8883. VLC and quicktime player can handle the sample file. --- libavformat/mov.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2aed6e80ef..ea2f010aa0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7366,6 +7366,21 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) break; a.size = FFMIN(a.size, atom.size - total_size); + if (!c->found_moov) { + static uint32_t skip_before_moov[] = { + MKTAG('m', 'o', 'o', 'f'), + MKTAG('s', 'i', 'd', 'x'), + }; + for (size_t i = 0; i < FF_ARRAY_ELEMS(skip_before_moov); i++) { + if (a.type == skip_before_moov[i]) { + av_log(c->fc, AV_LOG_WARNING, "Skip %s atom before moov.\n", + av_fourcc2str(a.type)); + parse = NULL; + goto skip; + } + } + } + for (i = 0; mov_default_parse_table[i].type; i++) if (mov_default_parse_table[i].type == a.type) { parse = mov_default_parse_table[i].parse; @@ -7386,6 +7401,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) parse = mov_read_keys; } +skip: if (!parse) { /* skip leaf atoms data */ avio_skip(pb, a.size); } else {