From patchwork Wed Nov 6 02:49:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16122 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 061A9447DB1 for ; Wed, 6 Nov 2019 04:50:52 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E5E1E68B080; Wed, 6 Nov 2019 04:50:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F040F68B05A for ; Wed, 6 Nov 2019 04:50:49 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id m17so1620671wmi.5 for ; Tue, 05 Nov 2019 18:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zkM+JkbFe1BGgRcTbpWpxLcfrqXBCuUj6NdcCGmPi7s=; b=qFD3vRWYjUriRxCAdgAQANaxNtGxIceZTq8EpV3O8Rh6vN5aeyLrSvPyQ0+u2r2pDd DIWT6yT2/NpsbIm+OtfX9c0UL/FEg8M+TaYPKuht07l9jOeUhO8iPvvzTHu5V10oZWIB cHsfesecKLvcJfZrjMk9Lk9Yi+1oRZc4dGI1KEm//ofJrUVwZ912PaHztpJkCXzbNDQm 184V5MNLR1lSfYeSYwh8bNDumfCUbVvVbc+8F1Usypi1q9CvANwmhm89w8lclXz5ny1L 6gQmJ4Aeyt2lWT7wS0cDi8icfO9SWy7RHDEPpKquBfMl6cDHCqrrrzmXHqm6YCqjsG7y EFnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zkM+JkbFe1BGgRcTbpWpxLcfrqXBCuUj6NdcCGmPi7s=; b=Tc+WE/y0dzfeu6NptLDGEL2frEYcTp2XvQfPoiTfO1oe068WC4p1YIGOan68mBtoUF yDCCtU749NVh80ZkfwBMDZNjILfE/En8/hyn/fZXNn47noSPihITZYZ+iUKfCFV8RR5e 7nhrw02TGnqY8k4DiVgn9ugy281LrmqZTTQuDB8E41HD2cwq53KyyZulNFgkGhbygnIY eg4jluTWB0u816I1ULaBnUh2V+1Pz3hWqu/RK3JOWXeJKeJpaSLmGGSMRuJpiyOEtcPA SS5c37rBpYIx2tL3zU4iXw7g/y3xTheNiq7BmyG2jLFxdaF+bv+IY6eJpH/7AZ0ClOff Vk1Q== X-Gm-Message-State: APjAAAUvKbYa1m1G1HGXDTTdeGVAGMhPtQkssY3XMZUf0HOoEWozQLWM mSxjgFid8vbkPXxEtyi3jnecTGjO X-Google-Smtp-Source: APXvYqz9tUxwhPlq8rc1OCZJK1th97VsX8RU309D4vdE6HwNPl61VBTP6Q8wBrCJq7yQeZ2Hslt3+w== X-Received: by 2002:a1c:9d4a:: with SMTP id g71mr346600wme.66.1573008649168; Tue, 05 Nov 2019 18:50:49 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08937.dynamic.kabel-deutschland.de. [188.192.137.55]) by smtp.gmail.com with ESMTPSA id l13sm1281710wmh.12.2019.11.05.18.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 18:50:48 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Nov 2019 03:49:11 +0100 Message-Id: <20191106024922.19228-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191106024922.19228-1-andreas.rheinhardt@gmail.com> References: <20191106024922.19228-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/23] avformat/matroskaenc: Add check for using explicit track number 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When creating dash streams, the track number is externally prescribed and not derived from the number of streams in the AVFormatContext. Up until now, a track number of zero was allowed, although this is an illegal track number. Furthermore, it was not checked whether the number of tracks for a file using an explicit track number was more than one, as such a file would be invalid (it would be impossible to tell to which track a block belongs if different tracks share the same track number). Besides that, use the macro MAX_TRACKS macro for the maximum of dash_track_number. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index aacd602221..dd25172eeb 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2649,6 +2649,9 @@ static int mkv_init(struct AVFormatContext *s) track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks; } + if (mkv->is_dash && nb_tracks != 1) + return AVERROR(EINVAL); + if (nb_tracks > MAX_TRACKS) { av_log(s, AV_LOG_ERROR, "%d > "AV_STRINGIFY(MAX_TRACKS)" tracks (excluding attachments)" @@ -2711,7 +2714,7 @@ static const AVOption options[] = { { "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 }, { "dash", "Create a WebM file conforming to WebM DASH specification", OFFSET(is_dash), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, - { "dash_track_number", "Track number for the DASH stream", OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 127, FLAGS }, + { "dash_track_number", "Track number for the DASH stream", OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, MAX_TRACKS, FLAGS }, { "live", "Write files assuming it is a live stream.", OFFSET(is_live), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "allow_raw_vfw", "allow RAW VFW mode", OFFSET(allow_raw_vfw), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "write_crc32", "write a CRC32 element inside every Level 1 element", OFFSET(write_crc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },