Browse Source

lavu/opt: add av_opt_set_dict2() function

Existing av_opt_set_dict doesn't accept flags.
It doesn't allow to pass options to nested structs.
New function alllows that.

Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
tags/n2.3
Lukasz Marek 11 years ago
parent
commit
ba52fb11dc
4 changed files with 29 additions and 3 deletions
  1. +3
    -0
      doc/APIchanges
  2. +7
    -2
      libavutil/opt.c
  3. +18
    -0
      libavutil/opt.h
  4. +1
    -1
      libavutil/version.h

+ 3
- 0
doc/APIchanges View File

@@ -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.


+ 7
- 2
libavutil/opt.c View File

@@ -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)
{


+ 18
- 0
libavutil/opt.h View File

@@ -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.
*


+ 1
- 1
libavutil/version.h View File

@@ -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, \


Loading…
Cancel
Save