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 E357D495B4 for ; Sun, 14 Apr 2024 20:30:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8588468D448; Sun, 14 Apr 2024 23:30:22 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E34DD68CF50 for ; Sun, 14 Apr 2024 23:30:16 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8D3F6EA3EC for ; Sun, 14 Apr 2024 22:30:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N_wcrv--xxPk for ; Sun, 14 Apr 2024 22:30:14 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id E07BAE9E47 for ; Sun, 14 Apr 2024 22:30:13 +0200 (CEST) Date: Sun, 14 Apr 2024 22:30:13 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20240414195720.21646-1-timo@rothenpieler.org> Message-ID: <4c7d22f2-1323-fffa-39ae-158a501f5f84@passwd.hu> References: <20240414195720.21646-1-timo@rothenpieler.org> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avutil/opt: add AV_OPT_FLAG_FORCE_CONST 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, 14 Apr 2024, Timo Rothenpieler wrote: > --- > doc/APIchanges | 3 +++ > libavutil/opt.c | 14 ++++++++++++++ > libavutil/opt.h | 5 +++++ > libavutil/version.h | 2 +- > 4 files changed, 23 insertions(+), 1 deletion(-) Where do you intend to use this flag? So some justification or description of your plans is missing from the commit message. > > diff --git a/doc/APIchanges b/doc/APIchanges > index 63e7a47126..da2c87909b 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 > > API changes, most recent first: > > +2024-04-xx - xxxxxxxxxx - lavu 59.15.101 - opt.h > + Add AV_OPT_FLAG_FORCE_CONST. > + > 2024-04-11 - xxxxxxxxxx - lavc 61.5.102 - avcodec.h > AVCodecContext.decoded_side_data may now be set by libavcodec after > calling avcodec_open2(). > diff --git a/libavutil/opt.c b/libavutil/opt.c > index d11e9d2ac5..9e51fa47f9 100644 > --- a/libavutil/opt.c > +++ b/libavutil/opt.c > @@ -365,6 +365,20 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con > if (o_named->flags & AV_OPT_FLAG_DEPRECATED) > av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", > o_named->name, o_named->help); > + } else if (o->flags & AV_OPT_FLAG_FORCE_CONST) { > + av_log(obj, AV_LOG_ERROR, "The \"%s\" option only accepts one of its pre-defined constant values", > + o->name); > + buf[0] = ':'; buf[1] = ' '; buf[2] = 0; > + for (o_named = NULL; o_named = av_opt_next(target_obj, o_named); ) { > + if (o_named->type == AV_OPT_TYPE_CONST && > + o_named->unit && o->unit && > + !strcmp(o_named->unit, o->unit)) { > + av_log(obj, AV_LOG_ERROR, "%s%s", buf, o_named->name); > + buf[0] = ','; > + } > + } > + av_log(obj, AV_LOG_ERROR, "\n"); > + return AVERROR(EINVAL); > } else { > if (o->unit) { > for (o_named = NULL; o_named = av_opt_next(target_obj, o_named); ) { > diff --git a/libavutil/opt.h b/libavutil/opt.h > index e6013662f6..67e2b687b2 100644 > --- a/libavutil/opt.h > +++ b/libavutil/opt.h > @@ -305,6 +305,11 @@ enum AVOptionType{ > * Set if option constants can also reside in child objects. > */ > #define AV_OPT_FLAG_CHILD_CONSTS (1 << 18) > +/** > + * The option will only accept AV_OPT_TYPE_CONST values. > + * Any other user supplied values will be rejected. > + */ What about built-in named constants, such as min/max/default? > +#define AV_OPT_FLAG_FORCE_CONST (1 << 19) > > /** > * May be set as default_val for AV_OPT_TYPE_FLAG_ARRAY options. > diff --git a/libavutil/version.h b/libavutil/version.h > index 1f2bddc022..5de2d92146 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -80,7 +80,7 @@ > > #define LIBAVUTIL_VERSION_MAJOR 59 > #define LIBAVUTIL_VERSION_MINOR 15 > -#define LIBAVUTIL_VERSION_MICRO 100 > +#define LIBAVUTIL_VERSION_MICRO 101 > > #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ > LIBAVUTIL_VERSION_MINOR, \ > -- > 2.34.1 Regards, Marton _______________________________________________ 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".