From patchwork Tue May 17 22:08:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Juteau X-Patchwork-Id: 35811 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp33203pzb; Tue, 17 May 2022 15:08:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznrpQdxS1hxmdOy+BcUBwqQr03S12WBjBRBJwDQ4FMFG5in1SSBq/pv5vaQqlAGnVS3ROA X-Received: by 2002:a17:906:65c4:b0:6fe:8829:b8e4 with SMTP id z4-20020a17090665c400b006fe8829b8e4mr330992ejn.291.1652825338900; Tue, 17 May 2022 15:08:58 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x14-20020a05640226ce00b00427e10fe80dsi502497edd.547.2022.05.17.15.08.57; Tue, 17 May 2022 15:08:58 -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=@outlook.com header.s=selector1 header.b=rozNMl6d; 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 38D7C68B425; Wed, 18 May 2022 01:08:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2082.outbound.protection.outlook.com [40.92.42.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 55D8C68B1A6 for ; Wed, 18 May 2022 01:08:47 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CM04CxtTN4kS+h2cbnNBzX5KDeAeLFHPwTlW1ib1kczstSodz5kqWrYItFk+I7infF18uOfKj1YiyVenBGFXIDno0oqOfXM+nfm8cXzeO3S3qZQ4Yu4yY1Ev+FHIMrwM4aBXNcvTMtMAgQ6LwMRZDph5vlH9A3r6ELhEF9vu4sxK0Iy+4sXdYbwEs1aAJMNjruOE1Q1kCw7MF8J1IMAXQ9mHXapshRrfb8JXKvWr8uf/zbPvU/wnEyGWXI8BFezjxwI5jb2V0rXf8str4RErjSG+k3Pcj1sEwas9CO8DQe9+Brb3+/KCpHOWSyDbGNfAgxbg5B4EhJ/5OdCi7RJuAA== 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=Mi6ZNb+u/MTULDX8VGNpTDQRic5uYerXpL/o1pYj48A=; b=EU4fUvYqrk4PHUEJDpJhUTFVD9P1dNMf628TEPijhZzlAzfZoP7kHJ0NxPbqdhhwY3Bn1eeVs94Z0ZqN8eaS+ExL9AX3+lBPvDHRUveuv6Ja81rg3Lpx0vT38MPJxBhA9IS3Z6ebBb4kK0dOcrBTsIDgiV/4UWrrDnVMSwTQIbha3thUR5CyB0CFn2ll1kEH/bCptSF2UeoolS7I6FskFpEAj9cTMtd/x+O+MtzW7VKW9YOjFislVScXF0jdm4UZGPOvK6tCY4ov8d8HIXdEls87KFu0jFc/tcKEW4U6AfbM/jeg9EmryeZupk+0oDVlH/FTmvLxRbfc9nTzX6e88Q== 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=Mi6ZNb+u/MTULDX8VGNpTDQRic5uYerXpL/o1pYj48A=; b=rozNMl6dSMJMHFbgwjQExhzihEgQx6vY+DF9srDHszCQh47arSzP1U+Aqo7OoY3bEi/2BEiu3QR3FbRE+fr6EN2YMah5QfuTTYkO5O26RktMXHXSGIheSyjROGOfYkea+iZBydUuZp/BrVSWpbXo/STmU9ZucHht/llNbGVLfTxej1by1k1twrNBZgtMyamoeMWHBGvFq5dgyeVOUohymuOb4GqkqlLD3RtlpTUpiqmKNmQQhwsEB7xYfZ69qvTIC/xJdngZcxvLlAv6N64JFz41HiYiLFYLB8HZlYBYXdbXpYGJZP3Qm/FqBd9MZZ64Rh8rouueM2lVNUqK4TK8YA== Received: from CY4PR0501MB3730.namprd05.prod.outlook.com (2603:10b6:910:8e::20) by DM6PR05MB6330.namprd05.prod.outlook.com (2603:10b6:5:12c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.10; Tue, 17 May 2022 22:08:44 +0000 Received: from CY4PR0501MB3730.namprd05.prod.outlook.com ([fe80::6582:13c3:f51:7e8b]) by CY4PR0501MB3730.namprd05.prod.outlook.com ([fe80::6582:13c3:f51:7e8b%4]) with mapi id 15.20.5273.013; Tue, 17 May 2022 22:08:43 +0000 From: Eric Juteau To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH] libavformat/avformat: Check codec whitelist Thread-Index: AdhqOdI4IVULhS6qSdysUd8K5QPgKg== Date: Tue, 17 May 2022 22:08:43 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=608ac5dc-7a35-4be1-8a24-c9c32e64b152; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2022-05-17T22:07:58Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; x-tmn: [meL/bJMxyrDfbVqdBYXsP04TG0zEboBC] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4f6d49d8-fb13-416d-31a3-08da3851cece x-ms-traffictypediagnostic: DM6PR05MB6330:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vhjzXvfbacqcfOTeZYuLgu4qI9mn+ODv0xgG+mMa3FjN2tYJSCx+xbXhYbjpifimVFlSwrtoZ47JheK8jGXhAiPQPPUcdEU6MKpiidmGQ18CKIYbB40bUihHZlvF9zflZVgqUlhlZIvxV7Nv+5BBUfxWeJOUJgh9e3HiNvIiWoDfdkeQl69f74MHRMr4XRTeHKKXuNjItZ09HRO8GstP7dRYGFuGCD/iTdQ02fZ/5ZLMTDwnwpWSTaOgAvkpCstV06bC3THRsRc0bPNfBJaVz1bTSek7Ga0R4t/b4qmjFGl3e8ZKLWQhWp9FxSeTAwGsmGNYU84sUb2VDhCc5XX2TkKRHnE0AjmvEgQB3NgjqDIJjs0q5ylp1BVy73oUbiiRwM8y2fY01CP6tKWsKLTU0+LiyzwRxNFqP+PjxTnhqUMguvn10j28BZifygRHbejgkToTkjWuwhWCTXbdM+KoPR49YFJeYcmSI2D7jGoDS3nBR4CZH4rCsecgWNmUNsHSP6OTyQY4u7nj1Um4fOQuu1SF6+C9DLE/QV2H7bRh8u9pfTNGVf4ickOuypf+4rpfZnWKirlYlLkiBkB06ULtPQ== x-ms-exchange-antisp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wDcIEQMYUnh/2ig7DnDrRU733nXGDy/ecTROAccakugmUtVUEYJed1fCsSHk5q+ykqcJsnzJGV7X+u55QjUMTXbBCwZQS43u0DOB7OXwvljQ0ygijwdKz9J5d/HcKiIYfR7PJ1stqAoMGMmiQgFDzDP6o5dAsjca30bxfqR2Z3XQhZzucrGq1nyAqfh9x381ijgyN0l6NQlVBkcLV+kW1dZZQiFVY2HaBXoeD0Q20VO8uLYg/zBSPnwfgyhtNGZ4KLZaqTD9j3HmO25jmBiaS8lUp9AtdNYnU8DM3ncG9G5xeq8BA1L3ue+p3jKn2bEuu0PDw/nTzo324ZeGaBagvArWmaakGxVZvCdFpgklApZfo/tnfvxTQWDDg== MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR0501MB3730.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 4f6d49d8-fb13-416d-31a3-08da3851cece X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2022 22:08:43.9316 (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: DM6PR05MB6330 Subject: [FFmpeg-devel] [PATCH] libavformat/avformat: Check codec whitelist 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 310pdOqorxDa Modified the function av_find_best_stream() such that, when a list of allowed codecs is supplied in the format context, and when the caller is requesting a decoder be returned, the function will select the best stream that has a decoder in the allowed decoders list. Signed-off-by: Eric Juteau Signed-off-by: Eric Juteau --- libavformat/avformat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 30d6ea6a49..396c1affa1 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -376,7 +376,8 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, continue; if (decoder_ret) { decoder = ff_find_decoder(ic, st, par->codec_id); - if (!decoder) { + if ((!decoder) || + (ic->codec_whitelist && av_match_list(decoder->name, ic->codec_whitelist, ',') <= 0)) { if (ret < 0) ret = AVERROR_DECODER_NOT_FOUND; continue;