From patchwork Tue Dec 7 09:56:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 32105 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp6025794iog; Tue, 7 Dec 2021 01:56:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJynDyIfOmohnKvt35PHLhgpTh2OKChIAczRov2IM7i8+u9nBeru2P0aCFPwMcvz47wsdj25 X-Received: by 2002:a17:906:b1c6:: with SMTP id bv6mr3964358ejb.30.1638870985790; Tue, 07 Dec 2021 01:56:25 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z2si24006699ejm.238.2021.12.07.01.56.25; Tue, 07 Dec 2021 01:56:25 -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=@outlook.com header.s=selector1 header.b=ar1wuLd1; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3AB1968AE83; Tue, 7 Dec 2021 11:56:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2084.outbound.protection.outlook.com [40.92.91.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 187A768AE0F for ; Tue, 7 Dec 2021 11:56:17 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BCFrzyxfWmILobGtF9Ubi/o+CqTPl9vysrclvkuHRN6hNAoPAoDqpqINrgM1pQBcnsqnCOwqN7xjnsAzoUl1ENqKLddRCExE/owcFkDt/bbtuMgy25oSYzbcVJ2Rge/oHJfIABnCxLTgGW4+o7w12ZZ1N6G6aGKhIzC6Xq5Bu7+aDIN+s+A2kJfqEYgGtslNf8gh5JTysJsDvLGSqHzENmuKFoLDQnBevGNMey7p5nGhljoysobqYGsghaDluF/nzdB9hq+oA0Cp0sASzB0l+1FhDdMALqBBI6/tzu45xHgg9UQHAmOs5YS0YDK7ForsEaFLS02VFWAMQ6cW71/NFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IDHdsrVIyIQxt2XW8X6Awbg2X03WjuxAwO3TKlyCT/A=; b=ad14nuCsznTs22H6kGAHaZADPB76/m+/5K9Yk51RF6xoybIbCnLgfdvEJmR0fc1frtbLOlCQ/n7mVVq6Zna/2/LvT1Qrayd8TCKO3eOIpuQ3EstZ5BFs2l+yxbGd1AgZkpavMxt536PxurzK4bySv9cJ66Hw30oS8hGOhNJD3YuBYX0Qd+P3x/FKvwmxtIZOvIinL0+G2sFAvT0XaxGn63gXW5ItXJpLqqvYr7ap9gWrlEZ09AlP2DPVdXzVHnjLANUG/hfJXW1l4Td46ezaVaaOt8/VbV+3Q/uOuzo2SvIeInpYMDvuwijcvUCKCVIALNwGFjtt7e26JV7Xgg5sug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IDHdsrVIyIQxt2XW8X6Awbg2X03WjuxAwO3TKlyCT/A=; b=ar1wuLd12RO6u8OwT/FjiuOmA4b7Lsf4a2Q05RZDP0XFJEfOO1fW5eSsHVfexTaFmXg+QLBn6lt+PXDE25hhXFJn8Gx5Kr/vH+SVBWWPyG6Mts8Px3k7ORMrd0XXDBDOKWaolx9UfYD/KCsM0gVxlMkB/2MzNm446BtbDpKh/CpWHwGx+DujyePvMOO/AoJBvtIR06njoF0SXmovGla/RM4nfduDp8po4tx7tQzNn6MNAmPsFexNoleNM3uU6t4NORDzGRwuBVMb0wI4rNUw+qP04hPRvVjYm9hfjd9p2qwTRg+jMiMtJHQdOl0IrRY5pipPZAv7EuU1LOFQZ2qRcg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB5299.eurprd03.prod.outlook.com (2603:10a6:20b:c4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Tue, 7 Dec 2021 09:56:15 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca%4]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 09:56:15 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 7 Dec 2021 10:56:06 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [+Wxv8jFBi5yJopJCwDcEfnHUp6g84h3+] X-ClientProxiedBy: AM4PR07CA0001.eurprd07.prod.outlook.com (2603:10a6:205:1::14) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211207095606.433838-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.248.74) by AM4PR07CA0001.eurprd07.prod.outlook.com (2603:10a6:205:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Tue, 7 Dec 2021 09:56:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a46a2974-45c5-4f40-8eb7-08d9b967cf00 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSZafVhYkhL3gJcf531Of0WSvxhd8P8hiIG/bhDalVI31KaLF+tVmr4j6kV7EYE63wUhWxaLN41CvEnvE79SCJEYuaIIN5KZLxDZgEByC7LIJC0aMjKo9qId4kNi5av5mhpRGj1DE9B0HckAUx5jHds0uqWwrTH6rH+RejMm8ZWKdlaDxCzLHGw4dsPPDI1JKv2WPcwWt2iZdc5tgUpASYFuCcsCdZC8DDc3JyzFjCtIEBOqbhNhJBpuMXd6TPKewu3j8B+7zoxt4Y5d9UW21ipxH5ba0ayk5EeavAYvpbCNbvB9B3yPnIqbSJwTr1LU2QBEoW65Mz3tKEPYkpSssJOn0pXwT19g1sjLqFUKE/X+OWK9GppfzLi0SjQcFgTBirB7otCJKFhVZFV9+esQknKHozu/L9rb4BZlA2oC+CXGPKlhrRK0zHDU2L2SBWFNEaiGL3UKYC9fNABEozWNdaExx7Fujxy1+vLrdYO9NaRGJKgf2urrUNWYchhZT9bcIQEOKsKm7AiSzfLzybCddijXUCaVVXEF/8Z0donrK2I+BhRCU3qMrxtTW+J4qPnGmOE7z9MkC8B+G3TcI6oXNN2qZdUsCyP+bmQ2TkWqhRh81PqTg3zZmOwtXDKoCe8/jbwRvTAfxNErT4CMiO0ZNeQgsgQzV/ErWv5B5REpOg8Nij1jXn0VQWmYuLF9ESJOHqRZpqKBfRyWLNXnu4TcQqA7MxUOoNpYzf1j/60E6Bck8ceHsaKcjqE9e1Y73uWsAg= X-MS-TrafficTypeDiagnostic: AM6PR03MB5299:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KdEDAPG4AlFd6DYKOKqf22XYVCXLPwtBv3JW0XNFvlWmV5934idDnxtT1ZJDhztavHwxRmyD251MFiffQPuIiYgt3Y68nASMkn4OyaJuNUc+yqsfQ5lqiE/JLWyLkhdMymDQU7LDBGgQc6xg8TDWAnj+JooYDSVITQhWoUrIuo1P8RqiJzLI1cYVXu/lXl2zpr1FnKWsAboxfQ+RItCTU8dkQ8yhoutk0qRME2LG1ep3B5hP1DbpUcaYCMVOlFHKyZZibQo0roAlsT/FcpyX/ofk8eGgyJkT5WZ9N0YYK3ZVnWUSsIYHnMPkCvUZ+Yjdv4V9KjlnFdNosaD3yTgB5fCy/EpA6SixSPPYV8C+Vv/hNECfoZiMwBNa9rIUNQM331eWfmnxK4Ay5I2YyW3y+r9lDkrPavrxISFI8KZrJud7OHbvSdaAHc2PsuLMLh2m1BuOtbn2LHtHiKjNm0LvFb6lxsbiqnQ3lMTRobvPchU4jOsDM6XWWRkAx8XhApX0R2y416/rGu/evtzc7piTbLhr8+k5kdo0+y5JqvTeppAWSQWLt93PcWjuE2Qr2uJppxQcFaL7y4/FBQEToarCsg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MkCALNSEPOx72F6lxfljWktZTW0X7TRtLASgnijHPeqnN1aqyT2V2xRq5Iyr/2QmaVBBdHruieEvmvvBlpG0ulfbBylYp1Ay5fj9L/uWJQOlSZjoidLNvaG3VfCs7tzJfJ7OvRdpxXCxkah+xSiPHIXQiB70EVkm6kM+s7jMsGt6JTmhuX751CL3Uo1A0J9Igsw+2ZjLs7KfQiC681W2TvOEz62b+MmSY+/LrvT5GZO/VsPKI1CqyIwYrn3RwS3PcaYUSQyDY9f9/IIyNreJGufApSkCASlxmbOPNkOi2rT66ji73+aTSjSBTe116/0PAo9pDKfEezMhRciUrqkxaGP98khyV+ayxQUQUQPM78izdfDgCZH0/h4EOYNB0tx2/gUk7ve3/bzZa3L3mNoT300fJ6IPUi2JtyTeeM2sVdsa+69GkfEUVba8WpMDLhcVQ8R8YYsZe9xzNWsHWhLlQEv9wBoGna9HBs5uAt3ptiSm95rdZqVaVccQSmJtgaBwLZw1IG1Q+dqJaL4a5HA/1s3x2ZZtVgBoKgAe5W9XpsgnhTGqMUjvNI2qGIfjK0+rJMaqKpeCFDZbnvrqGGlTmEtIa/r1MmRJ4cGx8RV7W7fXhKlaK39rPAQGCtkmnHHL3r2zeTYek/qOCmdKW2K3y4C+rutJBe7dWYQMKBRvZEdh4anVjMjeWfXTi5xEW8BH7swt2hwtsDpYJv6gW+aEkKSn/gOKLDaO68TQ//1D2+NRdhhnShPmEr8n+v24PEpf3EfcpQNhVVgU5kK8FTs7XZES3ssvo+N2GCssQrd7L6RjLIZ6+WbAbLuQ1lPQ2bbzC0Ci1L7mqlbT3qn5eTtcBIf+5LLD8XR94BNY5T/uG/CUXcxqCKLpi6dWP6M9G4yLjaJ+kdFfZAYEaTXuMu4o4TSRE2mu7vVMm0JxedJYPY6FmM/YnlHjij4uopRdZX82CzirrXFTR+JrczwBedZ3Mg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a46a2974-45c5-4f40-8eb7-08d9b967cf00 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 09:56:15.7200 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5299 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/utils: Add const where appropriate 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: c0lh7r1upc/O Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 2 +- libavformat/utils.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 20e93d9267..cdc398c49e 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -619,7 +619,7 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf, * Find stream index based on format-specific stream ID * @return stream index, or < 0 on error */ -int ff_find_stream_index(AVFormatContext *s, int id); +int ff_find_stream_index(const AVFormatContext *s, int id); /** * Internal version of av_index_search_timestamp diff --git a/libavformat/utils.c b/libavformat/utils.c index 827e7c8d5a..fe1699136c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1263,7 +1263,7 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf, } } -int ff_find_stream_index(AVFormatContext *s, int id) +int ff_find_stream_index(const AVFormatContext *s, int id) { for (unsigned i = 0; i < s->nb_streams; i++) if (s->streams[i]->id == id) @@ -1406,8 +1406,9 @@ AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *f * 0 if st is NOT a matching stream * >0 if st is a matching stream */ -static int match_stream_specifier(AVFormatContext *s, AVStream *st, - const char *spec, const char **indexptr, AVProgram **p) +static int match_stream_specifier(const AVFormatContext *s, const AVStream *st, + const char *spec, const char **indexptr, + const AVProgram **p) { int match = 1; /* Stores if the specifier matches so far. */ while (*spec) { @@ -1474,7 +1475,7 @@ static int match_stream_specifier(AVFormatContext *s, AVStream *st, return AVERROR(EINVAL); return match && (stream_id == st->id); } else if (*spec == 'm' && *(spec + 1) == ':') { - AVDictionaryEntry *tag; + const AVDictionaryEntry *tag; char *key, *val; int ret; @@ -1499,7 +1500,7 @@ static int match_stream_specifier(AVFormatContext *s, AVStream *st, } return match && ret; } else if (*spec == 'u' && *(spec + 1) == '\0') { - AVCodecParameters *par = st->codecpar; + const AVCodecParameters *par = st->codecpar; int val; switch (par->codec_type) { case AVMEDIA_TYPE_AUDIO: @@ -1535,7 +1536,7 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, int ret, index; char *endptr; const char *indexptr = NULL; - AVProgram *p = NULL; + const AVProgram *p = NULL; int nb_streams; ret = match_stream_specifier(s, st, spec, &indexptr, &p); @@ -1558,7 +1559,7 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, /* If we requested a matching stream index, we have to ensure st is that. */ nb_streams = p ? p->nb_stream_indexes : s->nb_streams; for (int i = 0; i < nb_streams && index >= 0; i++) { - AVStream *candidate = p ? s->streams[p->stream_index[i]] : s->streams[i]; + const AVStream *candidate = s->streams[p ? p->stream_index[i] : i]; ret = match_stream_specifier(s, candidate, spec, NULL, NULL); if (ret < 0) goto error;