--- doc/APIchanges | 3 +++ libavutil/opt.c | 14 ++++++++++++++ libavutil/opt.h | 5 +++++ libavutil/version.h | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-)
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. + */ +#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 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".