From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E3CF4487E4 for ; Mon, 18 Dec 2023 10:00:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B7C8B68D2D7; Mon, 18 Dec 2023 11:58:20 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF50F68D234 for ; Mon, 18 Dec 2023 11:57:59 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 323CA1CAF for ; Mon, 18 Dec 2023 10:57:56 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id KRJPtCu_xxjO for ; Mon, 18 Dec 2023 10:57:55 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 75CBA1BA2 for ; Mon, 18 Dec 2023 10:57:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 47FC63A0706 for ; Mon, 18 Dec 2023 10:57:44 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Dec 2023 10:57:10 +0100 Message-ID: <20231218095722.25879-8-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231218095722.25879-1-anton@khirnov.net> References: <20231218095722.25879-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/20] fftools/cmdutils: include OPT_PERFILE in OPT_OFFSET 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: And analogously OPT_OFFSET in OPT_SPEC. Previously the inclusion would be implicit and required all code to remember this. --- fftools/cmdutils.c | 6 +++--- fftools/cmdutils.h | 21 +++++++++++++-------- fftools/ffmpeg_opt.c | 14 ++++++-------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 38f4f542d3..6ca2efef4a 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -237,13 +237,13 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, { /* new-style options contain an offset into optctx, old-style address of * a global var*/ - void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? + void *dst = po->flags & OPT_FLAG_OFFSET ? (uint8_t *)optctx + po->u.off : po->u.dst_ptr; int *dstcount; double num; int ret; - if (po->flags & OPT_SPEC) { + if (po->flags & OPT_FLAG_SPEC) { SpecifierOpt **so = dst; char *p = strchr(opt, ':'); char *str; @@ -660,7 +660,7 @@ static int finish_group(OptionParseContext *octx, int group_idx, static int add_opt(OptionParseContext *octx, const OptionDef *opt, const char *key, const char *val) { - int global = !(opt->flags & (OPT_PERFILE | OPT_SPEC | OPT_OFFSET)); + int global = !(opt->flags & OPT_PERFILE); OptionGroup *g = global ? &octx->global_opts : &octx->cur_group; int ret; diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 8e22560fc6..dc99573d80 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -135,17 +135,22 @@ typedef struct OptionDef { #define OPT_AUDIO (1 << 4) #define OPT_SUBTITLE (1 << 5) #define OPT_DATA (1 << 6) -/* The option is per-file (currently ffmpeg-only). Implied by OPT_OFFSET or - * OPT_SPEC. At least one of OPT_INPUT or OPT_OUTPUT must be set when this flag - * is in use. +/* The option is per-file (currently ffmpeg-only). At least one of OPT_INPUT or + * OPT_OUTPUT must be set when this flag is in use. */ #define OPT_PERFILE (1 << 7) -/* Option is specified as an offset in a passed optctx */ -#define OPT_OFFSET (1 << 8) -/* Option is to be stored in an array of SpecifierOpt. Implies OPT_OFFSET. + +/* Option is specified as an offset in a passed optctx. + * Always use as OPT_OFFSET in option definitions. */ +#define OPT_FLAG_OFFSET (1 << 8) +#define OPT_OFFSET (OPT_FLAG_OFFSET | OPT_PERFILE) + +/* Option is to be stored in an array of SpecifierOpt. Next element after the offset is an int containing element count in the - array. */ -#define OPT_SPEC (1 << 9) + array. + Always use as OPT_SPEC in option definitions. */ +#define OPT_FLAG_SPEC (1 << 9) +#define OPT_SPEC (OPT_FLAG_SPEC | OPT_OFFSET) /* ffmpeg-only - specifies whether an OPT_PERFILE option applies to input, * output, or both. */ #define OPT_INPUT (1 << 10) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index cf382759d8..6f997a803a 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -109,7 +109,7 @@ static void uninit_options(OptionsContext *o) while (po->name) { void *dst = (uint8_t*)o + po->u.off; - if (po->flags & OPT_SPEC) { + if (po->flags & OPT_FLAG_SPEC) { SpecifierOpt **so = dst; int i, *count = (int*)(so + 1); for (i = 0; i < *count; i++) { @@ -119,7 +119,7 @@ static void uninit_options(OptionsContext *o) } av_freep(so); *count = 0; - } else if (po->flags & OPT_OFFSET && po->type == OPT_TYPE_STRING) + } else if (po->flags & OPT_FLAG_OFFSET && po->type == OPT_TYPE_STRING) av_freep(dst); po++; } @@ -1181,8 +1181,6 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * void show_help_default(const char *opt, const char *arg) { - /* per-file options have at least one of those set */ - const int per_file = OPT_SPEC | OPT_OFFSET | OPT_PERFILE; int show_advanced = 0, show_avoptions = 0; if (opt && *opt) { @@ -1209,17 +1207,17 @@ void show_help_default(const char *opt, const char *arg) show_help_options(options, "Global options (affect whole program " "instead of just one file):", - 0, per_file | OPT_EXIT | OPT_EXPERT, 0); + 0, OPT_PERFILE | OPT_EXIT | OPT_EXPERT, 0); if (show_advanced) show_help_options(options, "Advanced global options:", OPT_EXPERT, - per_file | OPT_EXIT, 0); + OPT_PERFILE | OPT_EXIT, 0); show_help_options(options, "Per-file main options:", 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | - OPT_EXIT, per_file); + OPT_EXIT, OPT_PERFILE); if (show_advanced) show_help_options(options, "Advanced per-file options:", - OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, per_file); + OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, OPT_PERFILE); show_help_options(options, "Video options:", OPT_VIDEO, OPT_EXPERT | OPT_AUDIO, 0); -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".