lavu/opt: do not filter out the initial sign character except for flags
authorJustin Ruggles <justin.ruggles@gmail.com>
Sat, 29 Sep 2012 04:34:28 +0000 (00:34 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Wed, 5 Dec 2012 16:23:36 +0000 (11:23 -0500)
This allows parsing of special-case negative numbers like decibels.

libavutil/opt.c

index d2cb9ef..e199170 100644 (file)
@@ -154,10 +154,15 @@ static int set_string_number(void *obj, const AVOption *o, const char *val, void
         double d, num = 1;
         int64_t intnum = 1;
 
-        if (*val == '+' || *val == '-')
-            cmd = *(val++);
+        i = 0;
+        if (*val == '+' || *val == '-') {
+            if (o->type == AV_OPT_TYPE_FLAGS)
+                cmd = *(val++);
+            else if (!notfirst)
+                buf[i++] = *val;
+        }
 
-        for (i = 0; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++)
+        for (; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++)
             buf[i] = val[i];
         buf[i] = 0;