From patchwork Wed Sep 5 20:52:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2lncsOtw7B1ciBSZWfDrW5hIFNpZ3Vyw77Ds3JzZMOzdHRpcg==?= X-Patchwork-Id: 10242 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp1440jap; Wed, 5 Sep 2018 13:58:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaGlkzMCj4g5E7jVtu/CRytEnH0+uEhYVOo6+8dY/mk8r33sOjDex83BYmXk4VdU1gAIE37 X-Received: by 2002:adf:8167:: with SMTP id 94-v6mr28459359wrm.127.1536181131943; Wed, 05 Sep 2018 13:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536181131; cv=none; d=google.com; s=arc-20160816; b=bb3cpm+0lcM0KLH6tcVDWlsYm/FrpXcDflfEzWsEFFzS6NLTL8h4q++Xw1ahdc81E6 BE+iZcc9cfyAI18+J83GfC4Lf+Dkn71nYu/RPgROiiF4AsCQa0CC90eI9dsNENvbUyaf A18YFRU8sZ6RWfFit9uTsn35pfGGRdnoDrzHHvV4cwXNPE7+oX5c4suVgtu6wVnlR+Qq rNBYtivcXxf1qKbLL7zSTvvpdnMS2wDHSGo3hwHWyd2T+vy0Zwy20xl8o5RHx3q7EJQr qCfQ43VK9fPdBhXev3J9l6qvBAJs/DDOUAPTTUufn5Gi8Md0i6Cl7cfYuIhLGCvYS3b7 wdng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:message-id:date:from:mime-version :dkim-signature:delivered-to; bh=IcsB9u9vlKlZc2uscL3YWgD4Jo0UsBNHQs01M1APbWs=; b=aYkbzthb8u+2qSqDWAL4skwNBFsjCmtNfIEI3X5TGmDhACnDOLFpzWjTQ/N9J9sUIo 3MlWcbuCmUIcDxhZjmZH+vCUCTPVLOdLkdeMMi4bP1vFa2zA1hlRGsh4EGKkN3pfgRH1 Eu+Oj+7bxtFBFtKM9ZsteDWtAJhsHsjO/9uWayd+hgL9fJglY4chzSdvIp8LuOiGmKCz 43ESfqGS9g4k5caEBZMT3vUE6Fasa7Bv41+Bf7B1IM1I3VWWrx+tzQo3HlvCuyHkabY3 iWdehMAshn/dxSlicqUe9/WLtb36GHzugviM0SVhu1CbxQ8BeabqeRJIo4iUN3N+25Z3 XoGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=lMQ3TcK6; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u26-v6si2738253wra.247.2018.09.05.13.58.51; Wed, 05 Sep 2018 13:58:51 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=lMQ3TcK6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 52D70689ECE; Wed, 5 Sep 2018 23:58:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE4F0689A38 for ; Wed, 5 Sep 2018 23:58:35 +0300 (EEST) Received: by mail-qt0-f194.google.com with SMTP id n6-v6so9836316qtl.4 for ; Wed, 05 Sep 2018 13:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=+/EuSg3RTqhjZuGknY5eaJNETyua5Bbq4KlmKZv1Pg8=; b=lMQ3TcK6D07kEP9Lsqk+dxiP3GWkkqVXXCuAf5t0wUm719EJYxQ2PlAsXLu+Z52FQk rdSixJE5uQc/D5oHTscx/fLDHVnwyHlUBg3ey71xXSCea2TAGecvTDkfvpOT5B7QOaTT 7FvMwRzJINKQQATWCCIVHPqcuCq+Ef9usP/HuTDc2fi/LDVAdLoK0Z/pVDPa/9ICkSOk +XSD9ekxKJrSWTOlB9jwkjuLFcvZwW5vIXw8kobIY6QcaZy4+XDzPv1wgO3Xlw/EzKJs F4Lz1fVYuN0i/YLrdAFWRqzTlo02T1/VFtYyfi9qcHkA1gy6+x9xNyS6kCPta166dybn wduA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+/EuSg3RTqhjZuGknY5eaJNETyua5Bbq4KlmKZv1Pg8=; b=N1NGvlu8WobG9rHviREnuE1dLcud/A8kacEWqUdDHv2RJxA9qKoJieyVdBsf0kWiFl kx99i5+jbpP3JcMxWH6Z+xnTdl9gZKvQemgIE7VOWsfokV8XKbZ5kDV59trcrQfT21mw KJbxsVSTv9I62gxjppYF8bY9gJCYrYAd1jHBz1YqIYj3E1m+7NYBj/l2MICj3+1UciUA I5AZ231E3FDepNXBDgM4bp2qhNNe5b3QHl4b80gpzzxT+ExoCr3T5iwS3su4G3OdJr80 Qbdi9fnCTJCAzn7ae83TgFxIn/4M35uaQF4j88eR2a80VLlNrED3g69bosEHkpNxOPLz XW0A== X-Gm-Message-State: APzg51CmrTvR/BmnjWEBFZU2OeIkshQ1UuSW5ugHeSfFhvUHn613jGEr FrOvjhJHsVN3UmlQBm+L1/tnq0sqiWOH1VEq+jOwT05xx62tqg== X-Received: by 2002:a0c:b6c1:: with SMTP id h1-v6mr12913144qve.141.1536180772208; Wed, 05 Sep 2018 13:52:52 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?B?U2lncsOtw7B1ciBSZWfDrW5hIFNpZ3Vyw77Ds3JzZMOzdHRpcg==?= Date: Wed, 5 Sep 2018 16:52:41 -0400 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avformat/matroskaenc: add reserve free space option 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" --- Changelog | 1 + doc/muxers.texi | 4 ++++ libavformat/matroskaenc.c | 8 ++++++++ 3 files changed, 13 insertions(+) { "reserve_index_space", "Reserve a given amount of space (in bytes) at the beginning of the file for the index (cues).", OFFSET(reserve_cues_space), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, { "cluster_size_limit", "Store at most the provided amount of bytes in a cluster. ", OFFSET(cluster_size_limit), AV_OPT_TYPE_INT , { .i64 = -1 }, -1, INT_MAX, FLAGS }, { "cluster_time_limit", "Store at most the provided number of milliseconds in a cluster.", OFFSET(cluster_time_limit), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, diff --git a/Changelog b/Changelog index 0975fee..689b04c 100644 --- a/Changelog +++ b/Changelog @@ -21,6 +21,7 @@ version : - Brooktree ProSumer video decoder - MatchWare Screen Capture Codec decoder - WinCam Motion Video decoder +- Matroska muxer has optional free space for unspecified use at the beginning of the file. version 4.0: diff --git a/doc/muxers.texi b/doc/muxers.texi index f18543e..72da90e 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1213,6 +1213,10 @@ ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_ This muxer supports the following options: @table @option + +@item reserve_free_space +Reserve the specified amount of bytes for unspecified purpose within the file header. + @item reserve_index_space By default, this muxer writes the index for seeking (called cues in Matroska terms) at the end of the file, because it cannot know in advance how much space diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 09a62e1..2eb65f8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -144,6 +144,7 @@ typedef struct MatroskaMuxContext { int have_attachments; int have_video; + int reserve_free_space; int reserve_cues_space; int cluster_size_limit; int64_t cues_pos; @@ -2005,6 +2006,12 @@ static int mkv_write_header(AVFormatContext *s) ret = AVERROR(ENOMEM); goto fail; } + if (mkv->reserve_free_space) { + if (mkv->reserve_free_space == 1) + mkv->reserve_free_space++; + put_ebml_void(pb, mkv->reserve_free_space); + } + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && mkv->reserve_cues_space) { mkv->cues_pos = avio_tell(pb); if (mkv->reserve_cues_space == 1) @@ -2767,6 +2774,7 @@ static const AVCodecTag additional_subtitle_tags[] = { #define OFFSET(x) offsetof(MatroskaMuxContext, x) #define FLAGS AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { + {"reserve_free_space", "Reserve a given amount of space at the beginning og the file for unspecified purpose.", OFFSET(reserve_free_space), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },