From patchwork Fri May 22 05:41:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rcombs X-Patchwork-Id: 19804 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 280EB44B2A8 for ; Fri, 22 May 2020 08:42:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F10468AE4C; Fri, 22 May 2020 08:42:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from so254-54.mailgun.net (so254-54.mailgun.net [198.61.254.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D7ED68A82D for ; Fri, 22 May 2020 08:42:22 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=rcombs.me; q=dns/txt; s=mx; t=1590126144; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: To: From: Sender; bh=QjqDvMdnBcIuQ42tlG9muWvrUsnmXLzGU847rvgFrbc=; b=aoQZ672+7Bhb98FsnNiSntS35k1PjmSh7dpE9rjIEj0ituv5Xtdj6DWJLb7YuAMNyg6bpPek SP/C5ES0vwU4ReM72lwBZa94UZSnCVBgIiYlpWTFlctPTjPO3fsWbnRfvednSw+GuvfPrpL9 I74SBhZ5ipZGQ/pdl7FxNyG8bq4= X-Mailgun-Sending-Ip: 198.61.254.54 X-Mailgun-Sid: WyJiZDU1MSIsICJmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZyIsICJiMGJhIl0= Received: from rcombs-mbp.localdomain ( [24.14.135.13]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 5ec7662e45598550e6170ed7 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 22 May 2020 05:42:06 GMT From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 May 2020 00:41:59 -0500 Message-Id: <20200522054200.74203-2-rcombs@rcombs.me> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522054200.74203-1-rcombs@rcombs.me> References: <20200522054200.74203-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavf/movdec: allow setting the header size in advance 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" This is useful for chained demuxers, to avoid reading past the end of a shared initialization segment and into the first data segment unnecessarily. --- libavformat/isom.h | 1 + libavformat/mov.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 41a9c64c11..3479553da6 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -291,6 +291,7 @@ typedef struct MOVContext { int decryption_key_len; int enable_drefs; int32_t movie_display_matrix[3][3]; ///< display matrix from mvhd + int64_t header_size; } MOVContext; int ff_mp4_read_descr_len(AVIOContext *pb); diff --git a/libavformat/mov.c b/libavformat/mov.c index e11c9f4457..51d3204582 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7574,6 +7574,9 @@ static int mov_read_header(AVFormatContext *s) else atom.size = INT64_MAX; + if (mov->header_size > 0) + atom.size = mov->header_size; + /* check MOV header */ do { if (mov->moov_retry) @@ -7591,6 +7594,9 @@ static int mov_read_header(AVFormatContext *s) } av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb)); + if (mov->header_size > 0) + mov->next_root_atom = mov->header_size; + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { if (mov->nb_chapter_tracks > 0 && !mov->ignore_chapters) mov_read_chapters(s); @@ -8162,7 +8168,9 @@ static const AVOption mov_options[] = { { "decryption_key", "The media decryption key (hex)", OFFSET(decryption_key), AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM }, { "enable_drefs", "Enable external track support.", OFFSET(enable_drefs), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, - + { "header_size", "size of initial header, ", + OFFSET(header_size), AV_OPT_TYPE_INT64, {.i64 = -1}, + -1, INT64_MAX, FLAGS }, { NULL }, };