From dac66da63db2eb3df1655d540084703dd93f82e4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 5 Sep 2011 08:15:32 +0200 Subject: AVOptions: add av_opt_set*(). Deprecate av_set_* New functions support setting values on children, return error codes instead of options and have consistent naming and signatures. --- libavutil/opt.h | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'libavutil/opt.h') diff --git a/libavutil/opt.h b/libavutil/opt.h index 6f0a03be3c..93da88c3cd 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -112,6 +112,7 @@ attribute_deprecated const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags); #endif +#if FF_API_OLD_AVOPTIONS /** * Set the field of obj with the given name to value. * @@ -136,12 +137,16 @@ const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int m * AVERROR_OPTION_NOT_FOUND if no matching option exists * AVERROR(ERANGE) if the value is out of range * AVERROR(EINVAL) if the value is not valid + * @deprecated use av_opt_set() */ +attribute_deprecated int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out); -const AVOption *av_set_double(void *obj, const char *name, double n); -const AVOption *av_set_q(void *obj, const char *name, AVRational n); -const AVOption *av_set_int(void *obj, const char *name, int64_t n); +attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n); +attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n); +attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n); +#endif + double av_get_double(void *obj, const char *name, const AVOption **o_out); AVRational av_get_q(void *obj, const char *name, const AVOption **o_out); int64_t av_get_int(void *obj, const char *name, const AVOption **o_out); @@ -296,4 +301,38 @@ void *av_opt_child_next(void *obj, void *prev); */ const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev); +/** + * @defgroup opt_set_funcs Option setting functions + * @{ + * Those functions set the field of obj with the given name to value. + * + * @param[in] obj A struct whose first element is a pointer to an AVClass. + * @param[in] name the name of the field to set + * @param[in] val The value to set. In case of av_opt_set() if the field is not + * of a string type, then the given string is parsed. + * SI postfixes and some named scalars are supported. + * If the field is of a numeric type, it has to be a numeric or named + * scalar. Behavior with more than one scalar and +- infix operators + * is undefined. + * If the field is of a flags type, it has to be a sequence of numeric + * scalars or named flags separated by '+' or '-'. Prefixing a flag + * with '+' causes it to be set without affecting the other flags; + * similarly, '-' unsets a flag. + * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN + * is passed here, then the option may be set on a child of obj. + * + * @return 0 if the value has been set, or an AVERROR code in case of + * error: + * AVERROR_OPTION_NOT_FOUND if no matching option exists + * AVERROR(ERANGE) if the value is out of range + * AVERROR(EINVAL) if the value is not valid + */ +int av_opt_set (void *obj, const char *name, const char *val, int search_flags); +int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags); +int av_opt_set_double(void *obj, const char *name, double val, int search_flags); +int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags); +/** + * @} + */ + #endif /* AVUTIL_OPT_H */ -- cgit v1.2.3