[vlc-commits] avcodec: vlc_av_get_options: Append to a potentially existing dict

Hugo Beauzée-Luyssen git at videolan.org
Tue Apr 11 09:42:57 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Apr 11 09:35:38 2017 +0200| [667c3a73b19d056821ba7a64420a4623aae40222] | committer: Hugo Beauzée-Luyssen

avcodec: vlc_av_get_options: Append to a potentially existing dict

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=667c3a73b19d056821ba7a64420a4623aae40222
---

 modules/access/avio.c            | 4 ++--
 modules/codec/avcodec/avcodec.c  | 2 +-
 modules/codec/avcodec/avcommon.h | 6 ++----
 modules/codec/avcodec/encoder.c  | 2 +-
 modules/codec/avcodec/subtitle.c | 2 +-
 modules/demux/avformat/demux.c   | 2 +-
 modules/demux/avformat/mux.c     | 2 +-
 7 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/modules/access/avio.c b/modules/access/avio.c
index 2181eaf2b2..cc4c0debbf 100644
--- a/modules/access/avio.c
+++ b/modules/access/avio.c
@@ -159,7 +159,7 @@ int OpenAvio(vlc_object_t *object)
     AVDictionary *options = NULL;
     char *psz_opts = var_InheritString(access, "avio-options");
     if (psz_opts) {
-        options = vlc_av_get_options(psz_opts);
+        vlc_av_get_options(psz_opts, &options);
         free(psz_opts);
     }
     ret = avio_open2(&sys->context, url, AVIO_FLAG_READ, &cb, &options);
@@ -239,7 +239,7 @@ int OutOpenAvio(vlc_object_t *object)
     AVDictionary *options = NULL;
     char *psz_opts = var_InheritString(access, "sout-avio-options");
     if (psz_opts) {
-        options = vlc_av_get_options(psz_opts);
+        vlc_av_get_options(psz_opts, &options);
         free(psz_opts);
     }
     ret = avio_open2(&sys->context, access->psz_path, AVIO_FLAG_WRITE,
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index f491dc5a54..291ed0ac48 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -366,7 +366,7 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
     int ret;
 
     if (psz_opts) {
-        options = vlc_av_get_options(psz_opts);
+        vlc_av_get_options(psz_opts, &options);
         free(psz_opts);
     }
 
diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index a0ae844a61..5b8deb19aa 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -45,20 +45,18 @@
 #define AV_OPTIONS_TEXT     "Advanced options"
 #define AV_OPTIONS_LONGTEXT "Advanced options, in the form {opt=val,opt2=val2}."
 
-static inline AVDictionary *vlc_av_get_options(const char *psz_opts)
+static inline void vlc_av_get_options(const char *psz_opts, AVDictionary** pp_dict)
 {
-    AVDictionary *options = NULL;
     config_chain_t *cfg = NULL;
     config_ChainParseOptions(&cfg, psz_opts);
     while (cfg) {
         config_chain_t *next = cfg->p_next;
-        av_dict_set(&options, cfg->psz_name, cfg->psz_value, 0);
+        av_dict_set(pp_dict, cfg->psz_name, cfg->psz_value, 0);
         free(cfg->psz_name);
         free(cfg->psz_value);
         free(cfg);
         cfg = next;
     }
-    return options;
 }
 
 static inline void vlc_init_avutil(vlc_object_t *obj)
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 29627011bd..c5fd771259 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -915,7 +915,7 @@ int OpenEncoder( vlc_object_t *p_this )
     char *psz_opts = var_InheritString(p_enc, ENC_CFG_PREFIX "options");
     AVDictionary *options = NULL;
     if (psz_opts) {
-        options = vlc_av_get_options(psz_opts);
+        vlc_av_get_options(psz_opts, &options);
         free(psz_opts);
     }
 
diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index b48dea381b..e0dedf1d4b 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -90,7 +90,7 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
     char *psz_opts = var_InheritString(dec, "avcodec-options");
     AVDictionary *options = NULL;
     if (psz_opts) {
-        options = vlc_av_get_options(psz_opts);
+        vlc_av_get_options(psz_opts, &options);
         free(psz_opts);
     }
 
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 4824215c02..0c1a67e67a 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -337,7 +337,7 @@ int OpenDemux( vlc_object_t *p_this )
     for (unsigned i = 1; i < nb_streams; i++)
         options[i] = NULL;
     if (psz_opts) {
-        options[0] = vlc_av_get_options(psz_opts);
+        vlc_av_get_options(psz_opts, &options[0]);
         for (unsigned i = 1; i < nb_streams; i++) {
             av_dict_copy(&options[i], options[0], 0);
         }
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 9072c2f8e1..1d4a9715d8 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -404,7 +404,7 @@ static int Mux( sout_mux_t *p_mux )
         char *psz_opts = var_GetNonEmptyString( p_mux, "sout-avformat-options" );
         AVDictionary *options = NULL;
         if (psz_opts) {
-            options = vlc_av_get_options(psz_opts);
+            vlc_av_get_options(psz_opts, &options);
             free(psz_opts);
         }
         av_dict_set( &p_sys->oc->metadata, "encoding_tool", "VLC "VERSION, 0 );



More information about the vlc-commits mailing list