From patchwork Sun Sep 12 10:53:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 30191 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp3084242iov; Sun, 12 Sep 2021 03:54:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4/M+6tgVEnT5FbnNR4WbDDnjccsdFfSnnfVQFuHrJNfr5zhZlkrTOdvpt57QtA0MEvfBO X-Received: by 2002:a17:906:f11:: with SMTP id z17mr7036291eji.385.1631444071783; Sun, 12 Sep 2021 03:54:31 -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 y6si4350814edm.581.2021.09.12.03.54.31; Sun, 12 Sep 2021 03:54:31 -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=OAxCX+mG; 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 55EDD68A923; Sun, 12 Sep 2021 13:54:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2054.outbound.protection.outlook.com [40.92.91.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BFBE68A87F for ; Sun, 12 Sep 2021 13:54:07 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OuztNYRi5Sqjw4BPANuMd3NZDrLbEWcX1gC9yA2sZ0s9A37ICsd0CwhI4iVS/8GtK0j7r2ZEm9LhbLYf5GRXuMytrcqhJ+kToNwqxT4KjPpoPb82FQgTbyTVbTH9ZbUObSkiVjAmPs0p2xlcGU1OATHlRka3njMS3Ra036DOk5vHKVkx80O2yTfjuetJ8VJCJodthTlAkDyCt7Va6m+enVUNSkGky4sBW1WvcwowRns0Y3RfR/iyzk8Af2OKwqv374GH5LmeLyY4anYyx7l02Ng3KHLHJa7XIhpuePYIYkXLjhKHE/8WMEzf9J19rPiKtS5WdDTZdMG0JxnNMyiL2Q== 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=4WKJe+fYBLq7URi3ezRla6i1p/s3czLWwUqFDbn2hmQ=; b=YnBqPdZmfAKH4Nktvemfm8PMqG97oUEYf2j1vTLlvT0Sv51UQqFAgerUBx7Fy82Pv+P88AH16w7BzYHLulC/mxbfTn1hr1bXi3dncffYv7ZQ22Jo8wzgShMW0+IhUJMlj6Tr+CQt78GK0JPnaCQP/UJ6zeyJZQ/TKvlY5HTqvkprzGqa2cJpb2v6lTBl1qHk4NJPD+GQaLLKepd6zx0wmcq/ZEud8Hb8ua3fg0paq/LTI7MWaXzMO+u9f738lqiV2lxUV760/lAz+X9DEybyFKQLPc0VlVhZDEt4ka9DHmmwH9hFXDPavCPqFf3NEVyM0qd91ROZMTJHii13EP6FLw== 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=4WKJe+fYBLq7URi3ezRla6i1p/s3czLWwUqFDbn2hmQ=; b=OAxCX+mGn1nSIhGVNIvnfOYlbh5F7Qeo2dLhr/R9fLq1juvxbOfePXrHgeZVeFNhZzibOs3Qsb9g4VUL+T1kXISWEWu98LSdrqSWYNBOs9lXE53NoUSGT0VFwt+g4+pJfAg9sIvd8hjgPdahL6xuQ4OTe+u9nKV2aoU+JqW/GBMQbqDLtyKPTIIRP8Q152o+4Yc0vaOXnajtD8i5+CBOAO5RPBZigsBS/TeuOn2RlrDmvnzxCa43GdBtEmhB6i8U1gjw/MoZlbZxZOAAqRLoKfwFx2G11TZvUAzv1IkTYpIfcZsLJvX0ivx//EGDc2noTWqm+0IzDvkx4aglZIx6fQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB7158.eurprd03.prod.outlook.com (2603:10a6:20b:2e9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Sun, 12 Sep 2021 10:54:06 +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.018; Sun, 12 Sep 2021 10:54:06 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Sep 2021 12:53:23 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [ygOfwlRFyhEWPLml9tPJ9/hZ+OeetOO3] X-ClientProxiedBy: PR3P191CA0049.EURP191.PROD.OUTLOOK.COM (2603:10a6:102:55::24) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210912105330.2310204-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.142.38) by PR3P191CA0049.EURP191.PROD.OUTLOOK.COM (2603:10a6:102:55::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.15 via Frontend Transport; Sun, 12 Sep 2021 10:54:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9244ff24-1eb1-4707-46a0-08d975dba3e6 X-MS-Exchange-SLBlob-MailProps: ERoE7pfUhoZGVchj8I9Akwve2PC2v2qPpN7mZhrewg+itUxncK11bwkqDWb0yDyrlGxQYajWJ6stUrWR9aNLk/mSxGvwl1qmtL/9z2qQiXQZBteFr1KBGI67qPKZY5MznSwWTY52ZQEg8fW5aL6eZPVrkd0zNnDKK0Ym3JJuICN9IpsoSi0B6xO5Q0M63eRXPOMtDqliDM0frniZq1NW13vLC3JTmaiGwehcisz+l28W/LV3eJ3L3xLCKa24G9C5hlBDmV/BsltokmbK0yhXNEot90NJm/rpsaEe/1RNiDHG7d9kDuXN1ST6gyot/CE3faXAZ7/9nLaOMoXcAQH0XkOkyP+wDcuWoeliiyvMr0t/67rlSm9YarmbTdRT8D4PddZ5lAK0CiZs+6qt+5otFX9RnViZ/PtZu7sajJj0BcA5ebqQ8JDZTty995csC5kjQypZzA8hN238Qo8YH97mnISwJSEAojsyG1tfh8+fbd/GkVAQK+CMWeViSrabQ1eXls0JdA2tzLrvPf9fdLPZk5rK57U2ODB5uHyDPI0kCvNqybdwxXeQ2yKA+9cUAjmzjOhZz/Ns8XJpjz2En54jUTBC8fpdg1pc+KiA2aWqb/jh9H+2AnvgR8YIB7i4+/kCOcKFYd2d9LbvmtAVg0MiWY7LzrHUYX1uvwkG4c1Yld6jeTRccfmx5Q== X-MS-TrafficTypeDiagnostic: AS8PR03MB7158: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r+iO5Qnp+khYCXm9XP6DbpbcfW0RWW8DrI0zbe5O+op9yNft/dHHdLigzQiFKV2Hy36JINmlly4uo2UWNjjM31pSzBR0+Smlo58O+keZ0vWlYZOxwv7e1bfRcp+I7MAeXdbFixTPX5lsZ9zSFwWwJz8QgtWcAOaWFIp1cThBW0168mxqJwpo0zqkm0CjDPQtYcVaOzSt+5YF+JWkEGm1sRnyQuNSCHaG3vMadCoe6Jx+4eHNdk187PEktMSfGBAvTaxCCvZoh1QG8JTU57L+wFip64Up+cduoGJtkcXwXFOiGhTNtSDe87NZCS9WllsHeF5Eoec8868Y5OV1ZGWi0+qjkNddLDb9XMRv+VjVItb7Pf4471UjYY+P8VcRp8a5tZt1Tj+qSD3QHqpwyinxn03X4RLQg8pnBNLsbkKU1GtpLr351eEgB1GxgyKcdgI5 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I7wSr1eT2a5vsMFGruKgPGuqApx1nRKRDu34VAKkftovX2geV2MSBNieg2hrQwOkqLh1MZ9U9TMD/nnjdmgzdRzeoeGWJYO80FR8APArTNs8cfcOdGeC0P0nh0bKzycc135rNcErpUnleZ+QBan2MA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9244ff24-1eb1-4707-46a0-08d975dba3e6 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2021 10:54:05.9861 (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: AS8PR03MB7158 Subject: [FFmpeg-devel] [PATCH 25/38] avfilter/avfilter: Honour the short options 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: YApZRyv/7lWe The documentation for filter arguments states that short options must precede long options (i.e. those of the form key=value). Yet if process_options() encounters arguments not abiding by this, it simply treats short options after a long option as if it were parsing short options for the first time. In particular, it overwrites options already set earlier, possibly via other short options. This is not how it is intended (as a comment in the code indicates). This commit modifies the code to reject further shorthand options after a long option has been encountered. After all, avfilter_init_str() errors out upon unrecognized options, so it is intended to be picky. Signed-off-by: Andreas Rheinhardt --- The while loop that is removed below is actually just an elaborate "o = NULL", which av_opt_next() interprets as "start the iteration". libavfilter/avfilter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index cc499fd5ed..165ab1f44a 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -814,6 +814,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, const AVOption *o = NULL; int ret; char *av_uninit(parsed_key), *av_uninit(value); + const AVClass *priv = ctx->filter->priv_class; const char *key; int offset= -1; @@ -824,8 +825,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, const char *shorthand = NULL; int flags = AV_DICT_DONT_STRDUP_VAL; - o = av_opt_next(ctx->priv, o); - if (o) { + if (priv && (o = av_opt_next(ctx->priv, o))) { if (o->type == AV_OPT_TYPE_CONST || o->offset == offset) continue; offset = o->offset; @@ -848,7 +848,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, if (parsed_key) { key = parsed_key; flags |= AV_DICT_DONT_STRDUP_KEY; - while ((o = av_opt_next(ctx->priv, o))); /* discard all remaining shorthand */ + priv = NULL; /* reject all remaining shorthand */ } else { key = shorthand; }