[FFmpeg-devel] [PATCH 3/4] avcodec/x264: use av_dict_parse_string for x264opts

Michael Niedermayer michaelni at gmx.at
Sat Jul 20 18:55:04 CEST 2013


This should add escaping support

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/libx264.c |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 0a134126..b48f4e8 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -344,15 +344,18 @@ static av_cold int X264_init(AVCodecContext *avctx)
     OPT_STR("level", x4->level);
 
     if(x4->x264opts){
-        const char *p= x4->x264opts;
-        while(p){
-            char param[256]={0}, val[256]={0};
-            if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
-                OPT_STR(param, "1");
-            }else
-                OPT_STR(param, val);
-            p= strchr(p, ':');
-            p+=!!p;
+        AVDictionary *dict    = NULL;
+        AVDictionaryEntry *en = NULL;
+        if (!av_dict_parse_string(&dict, x4->x264opts, "=", ":", AV_DICT_ALLOW_NULLVAL)) {
+            while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) {
+                if (en->value) {
+                    OPT_STR(en->key, en->value);
+                } else {
+                    OPT_STR(en->key, "1");
+                }
+            }
+
+            av_dict_free(&dict);
         }
     }
 
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list