From patchwork Thu Dec 23 07:10:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 32848 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp7037215iog; Wed, 22 Dec 2021 23:11:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzc/HaKwYxse/LaKTIgkLNss64W+CZ4RnAypPtY61ZCjS58rC/wSjnlBtkI8/8DrPopwe06 X-Received: by 2002:a17:906:18b2:: with SMTP id c18mr907320ejf.403.1640243503877; Wed, 22 Dec 2021 23:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640243503; cv=none; d=google.com; s=arc-20160816; b=ZBzHmCfXJ6tvUBfm2J6nYUqoGikOOuFZsEp0sNcdbE1Sfce0C4JLN8KSm9vDKn3Aj0 sqZu8M2U+3Lh6rFo6goBhyXK3P9Esq899Rd2sGyq//NaFIa2nvYeuFb1nz3+4XUmf06V NwVWG75h/DHKpAgbMdH7pn0V5hEzIFGP/pAqrjhddaVn1TQnlWhnhqf0OiqGeQILEehV M79ORk3Pq8PK5FOJ3XWnpAqWNwa7aGxGMuTI8PbnuYLQwqmEPvDKuaNQ/DLscrGO2I2+ sRYoewb1F5t053tqZYvQ5n0V4SoKhXOtbNlTUrjC+MxxUfDQK8sqxfPIvpWovjGZ8sqo meHw== 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:feedback-id:mime-version:message-id:date :to:from:delivered-to; bh=h8VQpWcV3XJZwoCXxBrl5UnnC2FghH5XPc8HS48oqyM=; b=blHFJefW3F6nXe07wS/2Hws0H9oPTVnB8fSS7+e91PniTX8NLov2YCPOx1M6hLzFNF SyNGwWgyz93+yQwj/w3DvyC9kRiX5Ou1Xim+VcmGYn3EyYDCZ03FPJhet1dapKNnAg/l +32BTQWnSitfbVCDSbybuZCI8CK1U5Gq/nk4YJeF2u2DA8IEgH6hLJHEZk6pTi0g8qR1 y7ILNg8+9TQD4rgizsszLrqGv4bISu2zU+wP7t5vuO3n+Ofz0rfsXXO9eppXTVByLpUf lipx5iBvDWDp6LurgWPEInxpG7NURBLAMR4RLWzEmOXyTQtd7e99BkZI6QqRbrmYcDzl V5qg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z16si1998460edi.484.2021.12.22.23.11.42; Wed, 22 Dec 2021 23:11:43 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B4DD68B113; Thu, 23 Dec 2021 09:11:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg587.qq.com (smtpbg126.qq.com [106.55.201.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2027D68B0FC for ; Thu, 23 Dec 2021 09:11:30 +0200 (EET) X-QQ-mid: bizesmtp49t1640243415ty7axu8q Received: from localhost (unknown [103.107.216.237]) by esmtp6.qq.com (ESMTP) with id ; Thu, 23 Dec 2021 15:10:14 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000B00A0000000 X-QQ-FEAT: FXvDfBZI5O4YAs+Qc/0uXkVG7CvPUay4MfnHUHjjPbcUawnF4rgvKCJrs8ubx DQT01h4HLv2nzznaL+mbPRohYe29RyrdDX0z+VzImQfqNATlJqW93GKRvIxPnnx7VGOt9DF 6JVRaSArqXfWNMzvCQZ0ynlpc48x4iCZLHtVEyuzDlctAopVP/kJT2tFNcjsV4CUVGwu2PQ 51FbKkquFsJ+Zh0W2v15fW0Hjd1lFBFQ95ZxJhCMDjggUO1XHcGocalihmt+Ok7nMioqAWN h8yINk7GVQ76Lg3zpX52UzKxYHewqCgn/Hf+tXvPcer/CVLw6sHO4n+R/6KxTS6/432A== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Dec 2021 15:10:12 +0800 Message-Id: <20211223071012.52638-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgspam:qybgspam2 Subject: [FFmpeg-devel] [PATCH] avformat/mov: add ignore_hoov option to ignore hoov atom 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: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7v/F2zY8oytl Try to get context from the moov atom when the hoov before moov atom, because the streams info get a possible incorrect when there have both hoov and moov atom. So add and ignore_hoov option for try to get moov context by user. Signed-off-by: Steven Liu --- doc/demuxers.texi | 6 ++++++ libavformat/isom.h | 2 ++ libavformat/mov.c | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index cab8a7072c..d23c118210 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -660,6 +660,11 @@ to demuxing linearly from the beginning. Default is true. Ignore any edit list atoms. The demuxer, by default, modifies the stream index to reflect the timeline described by the edit list. Default is false. +@item ignore_hoov +Ignore hoov atom. The demuxer, by default, use hoov atom when there have hoov before moov atom. +You can try ignore hoov atom try the moov atom. +Default is false. + @item advanced_editlist Modify the stream index to reflect the timeline described by the edit list. @code{ignore_editlist} must be set to false for this option to be effective. diff --git a/libavformat/isom.h b/libavformat/isom.h index ef8f19b18c..6aa2b40c94 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -255,6 +255,7 @@ typedef struct MOVContext { AVFormatContext *fc; int time_scale; int64_t duration; ///< duration of the longest track + int found_hoov; ///< 'hoov' atom has been found int found_moov; ///< 'moov' atom has been found int found_mdat; ///< 'mdat' atom has been found int found_hdlr_mdta; ///< 'hdlr' atom with type 'mdta' has been found @@ -273,6 +274,7 @@ typedef struct MOVContext { unsigned int nb_chapter_tracks; int use_absolute_path; int ignore_editlist; + int ignore_hoov; int advanced_editlist; int ignore_chapters; int seek_individually; diff --git a/libavformat/mov.c b/libavformat/mov.c index 2aed6e80ef..cd775b219f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1159,8 +1159,11 @@ static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (c->found_moov) { av_log(c->fc, AV_LOG_WARNING, "Found duplicated MOOV Atom. Skipped it\n"); - avio_skip(pb, atom.size); - return 0; + if (!c->found_hoov) { + avio_skip(pb, atom.size); + return 0; + } + c->found_hoov = 0; } if ((ret = mov_read_default(c, pb, atom)) < 0) @@ -4239,6 +4242,9 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOVStreamContext *sc; int ret; + if (c->found_hoov) + return 0; + st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = -1; @@ -7329,6 +7335,8 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) a.size >= 8 && c->fc->strict_std_compliance < FF_COMPLIANCE_STRICT) { uint32_t type; + if (c->ignore_hoov) + c->found_hoov = 1; avio_skip(pb, 4); type = avio_rl32(pb); if (avio_feof(pb)) @@ -8541,6 +8549,8 @@ static const AVOption mov_options[] = { 0, 1, FLAGS}, {"ignore_editlist", "Ignore the edit list atom.", OFFSET(ignore_editlist), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, + {"ignore_hoov", "Ignore the hoov atom.", OFFSET(ignore_hoov), AV_OPT_TYPE_BOOL, {.i64 = 0}, + 0, 1, FLAGS}, {"advanced_editlist", "Modify the AVIndex according to the editlists. Use this option to decode in the order specified by the edits.", OFFSET(advanced_editlist), AV_OPT_TYPE_BOOL, {.i64 = 1},