From patchwork Mon Sep 13 23:23:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 30224 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4466904iov; Mon, 13 Sep 2021 16:25:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJbmviAte/klcFV8XeaYceEyUBK1fC5LIo3AmTXCKHDAgTG2rw0UDt8k/z1bh7qdIEG9NB X-Received: by 2002:a17:906:942:: with SMTP id j2mr5880567ejd.303.1631575509051; Mon, 13 Sep 2021 16:25:09 -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 ji22si9263912ejc.361.2021.09.13.16.25.08; Mon, 13 Sep 2021 16:25:09 -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=r0UWK8oD; 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 74B6D68AEEB; Tue, 14 Sep 2021 02:24:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071091.outbound.protection.outlook.com [40.92.71.91]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EED9268A903 for ; Tue, 14 Sep 2021 02:24:28 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XLEhJS3m95QI8WfZ4GtqkSmYY7vvEDXsCAL3lvLji+POzAQS0f+sCAW5LA9w22up6gyZRH4dkHfufBMJrShW9PUro/amMvSsGurjFXFskzpr7yWxQ3HTeklNKs5yvEmyGMthlyXIB7d3dM7Q7CUa6motGkXnLcmmaqZX/b3K3ylp4fAdOmyNFge5Bz1edwpeY817cIW02QJeNDNnEZftvxnmLXeGalWj68bmHQCYQCvNOBhHUcB0w5VcZ1futUwGEUUi94fRlf1rbKr7RO30zC7ccN+w9ZUfCzm9Daa273ohvt9FFMNqdzsv9PZqWAZpluQWYLi2GVvANIMHp7Echw== 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; bh=ObQHVKHJJbcVfTEliOGI/NLoSQ9ZFsVzdKeX6Y40Npo=; b=BLQJsw1hWlTFQYRuI3iv0jPXRPp/JeVQXkihyj0gtMkioJzjNr9nuu0eqJV+tNPtL4RvqHEyc1g3hnMafVU8nvOGATHhGpS17wYrPpxogz114S/IHb9aIqT/yxzjOYu9CvH/dddKGRMtULvFTxqrxhYdBGYYXHgFkKmKujBAST2fjvWBEqCYCQB1Z4ZKwuEf4TZK3uz1ie5faZQqQhNOGo2Bz0DamT2POsoZaBBZR2+XgDXoUqso/56rWgG4IKwSTP292lDjx51sLcsiWD3w6pDDiY5xbBCkQSPJm7fZt/FlfgbtTX8hEgV4S+2/iM4XcNCi/tS1QAOEtdHoYCTRMg== 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=ObQHVKHJJbcVfTEliOGI/NLoSQ9ZFsVzdKeX6Y40Npo=; b=r0UWK8oDoC31klWxCpl+kco8Y9zyQnmOFtOdaqhbF96MASefxefm3cooai/AzjL2FQLCVm7j1vHvVqWBN3/ObcdxhjiDUF5tV/h1v20pN8EFR1mu4bmlerGsv5SEiiGyb72yC3xCE0LtoBfOzHljUT2PoPic0X1PtYRXJ5qHJhALgUfhjYsJXmdk/93lzdKjcIKiojuBNzURBJZj7dV3G/YaDdOpWu6uU6TOG31v/T0rjq6dzeiLv0Gk7TtuDR9+vODElpco0DtEJungcZrh8ru4ol0u3NPqLmIuIKPBCRf6MFNuFkpUWA4zQfrxC09679NvuopkXumzT9J8eh8ERQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4216.eurprd03.prod.outlook.com (2603:10a6:20b:d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Mon, 13 Sep 2021 23:24:27 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::787b:2156:ca99:fe00]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::787b:2156:ca99:fe00%4]) with mapi id 15.20.4500.019; Mon, 13 Sep 2021 23:24:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 14 Sep 2021 01:23:34 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [KTt/kTTdCGJqgjP9tZHDT8xKSnajwRbS] X-ClientProxiedBy: AM4P190CA0008.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::18) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210913232339.3115725-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.142.38) by AM4P190CA0008.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 23:24:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f287708-5736-4be0-2412-08d9770da120 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNXSr2fKdz7sYt6AgME9bwCsXmVZ4i+SeRTGtYtAADX/FzF0O/q1sl3A6w/JJUylblf8ieF8V+7wzqDu0+0Kykaz98cdi9F4SDHbvIwtdW+tcakLEnFPIqLFvC6rsTcGr9DUhvANs3tKUE53MCGNJzlFbkasYzluhQwBDQYscBMcsrMXEC/4ZP0vTJf3mwtUeDRVkSuY2huZGnF1J/6x8+QhIyOBy11zqu7gPnvaFIwM+XpMsOn0+go5VFvr/Uds+K+S1T/dbTyqA+fWHlvWN+cqBERO60YxSMSZf+2rIDW64GBtAbzkESrLIGA16FL5kREpHxN9L3mU3QTquQcPxz50FJbGgHzvofRr9NEeHHmhIc45RhiYI3K4KguiRagQowhl8TixdG9tKnviGQWnVnV/zG5AsypxtUKeI6tSurkzYNvlETkhCaYuFZ7LsMeMmFv/TACk+l+qJd31HyfzBCF+e+xIFkscD0CnA30EVywG8p3xJQatgfAsjqcsRLx7sAJFCQ1TnjHZK5tu6HzbZB44/41THB9C/gG8+lJypbr8iAeo5JulJ7Ro9dLcIjP6nJm9ipL26RlKublWjo9XsRdmZDzRIH6/JP7J57hQjvuoDJC37xaltpOWYCCwQbQTPgEvi3Jyf7tWPJ5MZOvay6QlVWiKNU2pFE+/KMefwW5Xgze7UukCoZgS1TUdwJRltpsLS4gCCnfxG5BLpmVCg4mGmTzkCvAxB1s= X-MS-TrafficTypeDiagnostic: AM6PR03MB4216: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FDPxuPdNOTTjEEI55P/rQ3MkH/tAay2/nBnev4SnotK1Uo3fl2MktIsmwTI2/vk77piluXLuBOQiESHkuCm8bK4A56tV384JUA4G3KRSmsceUTbH5Cjltjqeezzd3f26GGzQ3UMKw+rb7YsfEYCiAWdiTYt1hRDltvQbKz72WJf0DjVgIEaVLP9ZfZsZlr4oIU7iwoZWaqNPOkjjMT2u6Gd7uvslubUTv839YAKfm0/gT4n+RhEBeiARWZ+yNeWfG4nwrERifhvSyqeTn5r6IfKs0ssfflwzE1Bb53Wmqjz3qz343TiwkSohlZcrdEr1JIuWFharwEcgur52w5ZOh9nCl6tPjf5VYo8IRzDLdH+gMhE9ECiy0M/AhTvLruv97s9IDt+JIRpvNYwe4a4sxQrUoTznfQdUEveyNOjTfEiWZTJ48+6NgS6ZgZuEHP1h X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pqlhSlkS2QIvdwn5EblVPMYOGJFY0jrZPROA+UNa+TWHuBBjRZ2ZIMmefLQGRS8et8pSYbTq0fioJ071jKz5BfnvC7h4kHrnJKzBkZlz1OhS3NgcgqTqpDyjUdupDRS9WOg1eoc4HQEOy20NuoZ04A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f287708-5736-4be0-2412-08d9770da120 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 23:24:27.3165 (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: AM6PR03MB4216 Subject: [FFmpeg-devel] [PATCH v2 09/14] avfilter/vf_scale: Honour the AVFilter.init_dict documentation 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: 0Xbh9daTkz5w The documentation states that unrecognized options need to be returned (just as av_opt_set_dict() would do). Yet the scale and scale2ref filters didn't abide by this: They simply copied all options and in case it contained an unrecognized option was among them, they would error out later in config_props. This violates the documentation of av_filter_init_dict(). Fix this by only keeping the recognized options and returning the unrecognized ones. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_scale.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index a1902a13cf..c31b92b847 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -269,6 +269,8 @@ revert: static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts) { + const AVClass *class = sws_get_class(); + const AVDictionaryEntry *entry = NULL; ScaleContext *scale = ctx->priv; int ret; @@ -312,15 +314,23 @@ static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts) scale->flags = 0; if (scale->flags_str && *scale->flags_str) { - const AVClass *class = sws_get_class(); const AVOption *o = av_opt_find(&class, "sws_flags", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ); int ret = av_opt_eval_flags(&class, o, scale->flags_str, &scale->flags); if (ret < 0) return ret; } - scale->opts = *opts; - *opts = NULL; + FFSWAP(AVDictionary *, *opts, scale->opts); + /* Now move all the unrecognized options back to opts. */ + while (entry = av_dict_get(scale->opts, "", entry, AV_DICT_IGNORE_SUFFIX)) { + if (!av_opt_find(&class, entry->key, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) { + if ((ret = av_dict_set(opts, entry->key, entry->value, 0)) < 0 || + (ret = av_dict_set(&scale->opts, entry->key, NULL, 0)) < 0) + return ret; + /* Removing the entry from scale->opts invalidated entry. */ + entry = NULL; + } + } return 0; }