From patchwork Tue Aug 16 13:30:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 37316 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3d0d:b0:8d:a68e:8a0e with SMTP id y13csp1868229pzi; Tue, 16 Aug 2022 06:31:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR56d8MLl7vj28RyDsgCAjA24Gy+YeEWbi9Ng+CM8wGqT3nGoVgpp1AZBd1cL7BhFcluXwFS X-Received: by 2002:a17:907:2d0b:b0:730:63dd:748e with SMTP id gs11-20020a1709072d0b00b0073063dd748emr13716651ejc.307.1660656695088; Tue, 16 Aug 2022 06:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660656695; cv=none; d=google.com; s=arc-20160816; b=chv6pG2uo+oa8q7Yiq/Jq3zbqad5EiDsmha+7SgD/jRfkdDPkep9dAsTD7rBTDeH2Q 8i0OjZH2Z1NwK4UbvEEgoXNxBt27AO0u6MK3zLZXOXbZmSAyJx/iec4E6RWxbMVpOOl0 Y6pXzFIPMoCDglarYSXacNum4UX6c6aOPy2Uet0vbQoCAq22ajNNJl3ET1TXf4lpAY3r but2Mrlxtnx8ZBqelcYK8UW3lYn7TNLPf9GwbDiay+v4hUlht0uWMEhbEX1N1Q154zfU moQjQ50C397TF6Z4OvD9CbTC6prGseozTjfWdXcw33sj38e9P2wiMYCuHhyM8a4/4f73 6fzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=vqK9PWtFjbeqehEvtZxuNQbQSJ5KmGsKwsvseVM8gzc=; b=NflDjsxvsxdPSIzb2hcfeGb2NPfcuAmJWRkRUYdRJaVqJIggoinQLn1mvxf+0Thpyo fw2d1vdrlp9FvPLgsjpOEtnv0IEQHsgyt1fX+yJakkh/q8OcDtbkmdQk2FVK7I+V3dEp am9WvAvvytwpwbrYzi0VZIK19lxhShtRxT0qZxuVvl66Byyt5w31hFs9SG4Twvuaa41i XTpBT+LwP2oEEPPIrN/ilrxJjzpUsGB+YfkfGyf5lwfeuc8tYxv3EkT51FLJybAgXVu6 Zqq0Ox0U4uw9YKeEBw8wjLa9m9dt/iCjDdj49qOAeVixQ1L78WtQDVzXj4yrPGb9f541 Ec3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b="MdC//XZr"; 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=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d14-20020a056402144e00b0043d5dd96fcfsi8759750edx.272.2022.08.16.06.31.34; Tue, 16 Aug 2022 06:31:35 -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=@mail.de header.s=mailde202009 header.b="MdC//XZr"; 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=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C810C68B205; Tue, 16 Aug 2022 16:31:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout01.mail.de (shout01.mail.de [62.201.172.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1300A68B205 for ; Tue, 16 Aug 2022 16:30:53 +0300 (EEST) Received: from postfix03.mail.de (postfix03.bt.mail.de [10.0.121.127]) by shout01.mail.de (Postfix) with ESMTP id B188DA09CA for ; Tue, 16 Aug 2022 15:30:52 +0200 (CEST) Received: from smtp04.mail.de (smtp04.bt.mail.de [10.0.121.214]) by postfix03.mail.de (Postfix) with ESMTP id 96C8680127; Tue, 16 Aug 2022 15:30:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1660656652; bh=cggqMXDrXlikqW6eDMcJrixnhOxnmsRU1j7VbRKUK/I=; h=From:To:Cc:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=MdC//XZr1RSCPq77LtvnDZrR4ujJN7h9bbiufbYz6ewk6BwvFvjGp7puV8ZHqAQQ6 7ToUIqpOgFlgKY5+hSF6Ax+sn5b6MOsqxM8TUecYBiThIAZ4495fQb28G6pUIDNNPm 28HV8hEDw31RTOSdqB9oH1TC85+WgNdk0/VPz/q+GBpm5tRflbjMWGS1G/rNSpCwFS fhnpEIuOEOE4zMjFItAS0maoyahErQ0hOoJHNz3+RkWpHvoJQn1rOb0LWQVLLVqioM lWe54kUOl1MA245GGQS4jwGSH5QxM2F4vGEXngFBIVss1mHBTytRRscTNA8KPbGJ9g faJygWrdkLyYg== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp04.mail.de (Postfix) with ESMTPSA id 43AF5C2081; Tue, 16 Aug 2022 15:30:52 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Aug 2022 15:30:45 +0200 Message-Id: <20220816133046.70846-4-thilo.borgmann@mail.de> In-Reply-To: <20220816133046.70846-1-thilo.borgmann@mail.de> References: <20220816133046.70846-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 3604 X-purgate-ID: 154282::1660656652-000016C9-AF428384/0/0 Subject: [FFmpeg-devel] [PATCH 4/5] ffmpeg: Allow printing of option arguments in help output 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: Thilo Borgmann Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RUrNsy5CyHLL --- fftools/cmdutils.c | 5 +++++ libavutil/opt.c | 14 +++++++++++++- libavutil/opt.h | 8 ++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 22ba654bb0..dae018f83a 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -172,6 +172,11 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, av_strlcat(buf, po->argname, sizeof(buf)); } printf("-%-17s %s\n", buf, po->help); + + if (po->args) { + const AVClass *p = po->args; + av_arg_show(&p, NULL); + } } printf("\n"); } diff --git a/libavutil/opt.c b/libavutil/opt.c index a3940f47fb..89ef111690 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1256,7 +1256,7 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); else av_log(av_log_obj, AV_LOG_INFO, " %s%-17s ", - (opt->flags & AV_OPT_FLAG_FILTERING_PARAM) ? " " : "-", + (opt->flags & (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_ARGUMENT)) ? " " : "-", opt->name); switch (opt->type) { @@ -1329,6 +1329,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); break; } + if (!(opt->flags & AV_OPT_FLAG_ARGUMENT)) { av_log(av_log_obj, AV_LOG_INFO, "%c%c%c%c%c%c%c%c%c%c%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.', (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.', @@ -1341,6 +1342,7 @@ FF_ENABLE_DEPRECATION_WARNINGS (opt->flags & AV_OPT_FLAG_BSF_PARAM) ? 'B' : '.', (opt->flags & AV_OPT_FLAG_RUNTIME_PARAM) ? 'T' : '.', (opt->flags & AV_OPT_FLAG_DEPRECATED) ? 'P' : '.'); + } if (opt->help) av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); @@ -1456,6 +1458,16 @@ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags) return 0; } +int av_arg_show(void *obj, void *av_log_obj) +{ + if (!obj) + return -1; + + opt_list(obj, av_log_obj, NULL, AV_OPT_FLAG_ARGUMENT, 0, -1); + + return 0; +} + void av_opt_set_defaults(void *s) { av_opt_set_defaults2(s, 0, 0); diff --git a/libavutil/opt.h b/libavutil/opt.h index 461b5d3b6b..dce3483237 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -297,6 +297,7 @@ typedef struct AVOption { #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering #define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is deprecated, users should refer to AVOption.help text for more information #define AV_OPT_FLAG_CHILD_CONSTS (1<<18) ///< set if option constants can also reside in child objects +#define AV_OPT_FLAG_ARGUMENT (1<<19) ///< set if option is an argument to another option //FIXME think about enc-audio, ... style flags /** @@ -386,6 +387,13 @@ typedef struct AVOptionRanges { */ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags); +/** + * Show the obj arguments. + * + * @param av_log_obj log context to use for showing the options + */ +int av_arg_show(void *obj, void *av_log_obj); + /** * Set the values of all AVOption fields to their default values. *