[vlc-devel] [PATCH 1/3] avcommon: add an helper to parse private options

Rafaël Carré funman at videolan.org
Sun Apr 15 23:46:51 CEST 2012


---
 modules/codec/avcodec/avcommon.h |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index 29dca20..18b812c 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -26,6 +26,8 @@
 #endif
 
 #include <vlc_avcodec.h>
+#include <vlc_configuration.h>
+#include <vlc_variables.h>
 
 #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
 # include <libavformat/avformat.h>
@@ -53,3 +55,28 @@ static inline void vlc_init_avcodec(void)
     vlc_avcodec_unlock();
 }
 #endif
+
+#ifdef HAVE_LIBAVUTIL_AVUTIL_H
+# include <libavutil/avutil.h>
+# if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 51, 7, 0 )
+#  include <libavutil/dict.h>
+
+#define AV_OPTIONS_TEXT     "FFmpeg private options."
+#define AV_OPTIONS_LONGTEXT "FFmpeg private options, in the form {opt=val,opt2=val2} ."
+
+static inline AVDictionary *vlc_av_get_options(const char *psz_opts)
+{
+    AVDictionary *options = NULL;
+    config_chain_t *cfg;
+    config_ChainParseOptions(&cfg, psz_opts);
+    while (cfg) {
+        config_chain_t *next = cfg->p_next;
+        av_dict_set(&options, cfg->psz_name, cfg->psz_value,
+            AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
+        free(cfg);
+        cfg = next;
+    }
+    return options;
+}
+# endif
+#endif
-- 
1.7.9.5



More information about the vlc-devel mailing list