diff --git a/doc/APIchanges b/doc/APIchanges index 7e3c592d75..b4fa99f2d4 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2014-05-xx - xxxxxxx - lavu 52.81.0 - opt.h + Add av_opt_set_dict2() function. + 2014-04-xx - xxxxxxx - lavc 55.50.3 - avcodec.h Deprecate CODEC_FLAG_MV0. It is replaced by the flag "mv0" in the "mpv_flags" private option of the mpegvideo encoders. diff --git a/libavutil/opt.c b/libavutil/opt.c index 33ebe52749..199eadbc05 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1415,7 +1415,7 @@ void av_opt_free(void *obj) av_freep((uint8_t *)obj + o->offset); } -int av_opt_set_dict(void *obj, AVDictionary **options) +int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags) { AVDictionaryEntry *t = NULL; AVDictionary *tmp = NULL; @@ -1425,7 +1425,7 @@ int av_opt_set_dict(void *obj, AVDictionary **options) return 0; while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) { - ret = av_opt_set(obj, t->key, t->value, 0); + ret = av_opt_set(obj, t->key, t->value, search_flags); if (ret == AVERROR_OPTION_NOT_FOUND) av_dict_set(&tmp, t->key, t->value, 0); else if (ret < 0) { @@ -1439,6 +1439,11 @@ int av_opt_set_dict(void *obj, AVDictionary **options) return ret; } +int av_opt_set_dict(void *obj, AVDictionary **options) +{ + return av_opt_set_dict2(obj, options, 0); +} + const AVOption *av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags) { diff --git a/libavutil/opt.h b/libavutil/opt.h index 6a1ae4354a..1e1dd69b30 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -541,6 +541,24 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) */ int av_opt_set_dict(void *obj, struct AVDictionary **options); + +/** + * Set all the options from a given dictionary on an object. + * + * @param obj a struct whose first element is a pointer to AVClass + * @param options options to process. This dictionary will be freed and replaced + * by a new one containing all options not found in obj. + * Of course this new dictionary needs to be freed by caller + * with av_dict_free(). + * @param search_flags A combination of AV_OPT_SEARCH_*. + * + * @return 0 on success, a negative AVERROR if some option was found in obj, + * but could not be set. + * + * @see av_dict_copy() + */ +int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags); + /** * Extract a key-value pair from the beginning of a string. * diff --git a/libavutil/version.h b/libavutil/version.h index a17cb506de..3cb5b66666 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -56,7 +56,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 52 -#define LIBAVUTIL_VERSION_MINOR 80 +#define LIBAVUTIL_VERSION_MINOR 81 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \