History

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.

Lukasz Marek committed 12 years ago

Commit ba52fb11 parent db4b0314 files · +29 −3Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/opt.c +7 −2
  3. libavutil/opt.h +18 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182014-05-xx - xxxxxxx - lavu 52.81.0 - opt.h
19 Add av_opt_set_dict2() function.
20
182014-04-xx - xxxxxxx - lavc 55.50.3 - avcodec.h212014-04-xx - xxxxxxx - lavc 55.50.3 - avcodec.h
19 Deprecate CODEC_FLAG_MV0. It is replaced by the flag "mv0" in the22 Deprecate CODEC_FLAG_MV0. It is replaced by the flag "mv0" in the
20 "mpv_flags" private option of the mpegvideo encoders.23 "mpv_flags" private option of the mpegvideo encoders.
libavutil/opt.c+7−2
@@ -1415,7 +1415,7 @@ void av_opt_free(void *obj) · 1414 unmodified lines
1415 av_freep((uint8_t *)obj + o->offset);1415 av_freep((uint8_t *)obj + o->offset);
1416}1416}
1417 1417
1418int av_opt_set_dict(void *obj, AVDictionary **options)1418int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
1419{1419{
1420 AVDictionaryEntry *t = NULL;1420 AVDictionaryEntry *t = NULL;
1421 AVDictionary *tmp = NULL;1421 AVDictionary *tmp = NULL;
@@ -1425,7 +1425,7 @@ int av_opt_set_dict(void *obj, AVDictionary **options) · 3 unmodified lines
1425 return 0;1425 return 0;
1426 1426
1427 while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) {1427 while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) {
1428 ret = av_opt_set(obj, t->key, t->value, 0);1428 ret = av_opt_set(obj, t->key, t->value, search_flags);
1429 if (ret == AVERROR_OPTION_NOT_FOUND)1429 if (ret == AVERROR_OPTION_NOT_FOUND)
1430 av_dict_set(&tmp, t->key, t->value, 0);1430 av_dict_set(&tmp, t->key, t->value, 0);
1431 else if (ret < 0) {1431 else if (ret < 0) {
@@ -1439,6 +1439,11 @@ int av_opt_set_dict(void *obj, AVDictionary **options) · 7 unmodified lines
1439 return ret;1439 return ret;
1440}1440}
1441 1441
1442int av_opt_set_dict(void *obj, AVDictionary **options)
1443{
1444 return av_opt_set_dict2(obj, options, 0);
1445}
1446
1442const AVOption *av_opt_find(void *obj, const char *name, const char *unit,1447const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
1443 int opt_flags, int search_flags)1448 int opt_flags, int search_flags)
1444{1449{
libavutil/opt.h+18−0
@@ -541,6 +541,24 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) · 540 unmodified lines
541 */541 */
542int av_opt_set_dict(void *obj, struct AVDictionary **options);542int av_opt_set_dict(void *obj, struct AVDictionary **options);
543 543
544
545/**
546 * Set all the options from a given dictionary on an object.
547 *
548 * @param obj a struct whose first element is a pointer to AVClass
549 * @param options options to process. This dictionary will be freed and replaced
550 * by a new one containing all options not found in obj.
551 * Of course this new dictionary needs to be freed by caller
552 * with av_dict_free().
553 * @param search_flags A combination of AV_OPT_SEARCH_*.
554 *
555 * @return 0 on success, a negative AVERROR if some option was found in obj,
556 * but could not be set.
557 *
558 * @see av_dict_copy()
559 */
560int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags);
561
544/**562/**
545 * Extract a key-value pair from the beginning of a string.563 * Extract a key-value pair from the beginning of a string.
546 *564 *
libavutil/version.h+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
56 */56 */
57 57
58#define LIBAVUTIL_VERSION_MAJOR 5258#define LIBAVUTIL_VERSION_MAJOR 52
59#define LIBAVUTIL_VERSION_MINOR 8059#define LIBAVUTIL_VERSION_MINOR 81
60#define LIBAVUTIL_VERSION_MICRO 10060#define LIBAVUTIL_VERSION_MICRO 100
61 61
62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t