[FFmpeg-cvslog] lavu/opt: add av_opt_set_dict2() function

Lukasz Marek git at videolan.org
Fri May 2 19:02:15 CEST 2014


ffmpeg | branch: master | Lukasz Marek <lukasz.m.luki2 at gmail.com> | Tue Apr 29 23:57:24 2014 +0200| [ba52fb11dc6305ec2ded10ad172ebb28e6583038] | committer: Lukasz Marek

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 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba52fb11dc6305ec2ded10ad172ebb28e6583038
---

 doc/APIchanges      |    3 +++
 libavutil/opt.c     |    9 +++++++--
 libavutil/opt.h     |   18 ++++++++++++++++++
 libavutil/version.h |    2 +-
 4 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 7e3c592..b4fa99f 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 33ebe52..199eadb 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 6a1ae43..1e1dd69 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 a17cb50..3cb5b66 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, \



More information about the ffmpeg-cvslog mailing list