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
1515
1616 API changes, most recent first:
1717
18+2014-05-xx - xxxxxxx - lavu 52.81.0 - opt.h
19+ Add av_opt_set_dict2() function.
20+
1821 2014-04-xx - xxxxxxx - lavc 55.50.3 - avcodec.h
1922 Deprecate CODEC_FLAG_MV0. It is replaced by the flag "mv0" in the
2023 "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
14151415 av_freep((uint8_t *)obj + o->offset);
14161416 }
14171417
1418−int av_opt_set_dict(void *obj, AVDictionary **options)
1418+int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
14191419 {
14201420 AVDictionaryEntry *t = NULL;
14211421 AVDictionary *tmp = NULL;
@@ -1425,7 +1425,7 @@ int av_opt_set_dict(void *obj, AVDictionary **options) · 3 unmodified lines
14251425 return 0;
14261426
14271427 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);
14291429 if (ret == AVERROR_OPTION_NOT_FOUND)
14301430 av_dict_set(&tmp, t->key, t->value, 0);
14311431 else if (ret < 0) {
@@ -1439,6 +1439,11 @@ int av_opt_set_dict(void *obj, AVDictionary **options) · 7 unmodified lines
14391439 return ret;
14401440 }
14411441
1442+int av_opt_set_dict(void *obj, AVDictionary **options)
1443+{
1444+ return av_opt_set_dict2(obj, options, 0);
1445+}
1446+
14421447 const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
14431448 int opt_flags, int search_flags)
14441449 {
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
541541 */
542542 int av_opt_set_dict(void *obj, struct AVDictionary **options);
543543
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+ */
560+int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags);
561+
544562 /**
545563 * Extract a key-value pair from the beginning of a string.
546564 *
libavutil/version.h+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
5656 */
5757
5858 #define LIBAVUTIL_VERSION_MAJOR 52
59−#define LIBAVUTIL_VERSION_MINOR 80
59+#define LIBAVUTIL_VERSION_MINOR 81
6060 #define LIBAVUTIL_VERSION_MICRO 100
6161
6262 #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