summaryrefslogtreecommitdiff
path: root/libavutil/opt.c
diff options
context:
space:
mode:
authorMuhammad Faiz <mfcc64@gmail.com>2014-07-21 23:39:43 -0700
committerMichael Niedermayer <michaelni@gmx.at>2014-07-22 16:58:41 +0200
commit4852a88dfbda7673793500e6fae645c72e618b5c (patch)
treea5650161f1cd5790ee7cbdbc45858916b8d59a31 /libavutil/opt.c
parentca6b33b8bd5e2a046fd67480a709d7cf063d3a98 (diff)
avutil/opt: set_string_number(): remove unneeded copy
also remove unused variables Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r--libavutil/opt.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 40c944dd7a..08f6f1517f 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -191,22 +191,20 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con
}
for (;;) {
- int i, den = 1;
+ int i = 0;
char buf[256];
int cmd = 0;
- double d, num = 1;
+ double d;
int64_t intnum = 1;
- i = 0;
- if (*val == '+' || *val == '-') {
- if (o->type == AV_OPT_TYPE_FLAGS)
+ if (o->type == AV_OPT_TYPE_FLAGS) {
+ if (*val == '+' || *val == '-')
cmd = *(val++);
+ for (; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++)
+ buf[i] = val[i];
+ buf[i] = 0;
}
- for (; i < sizeof(buf) - 1 && val[i] && (o->type != AV_OPT_TYPE_FLAGS || val[i] != '+' && val[i] != '-'); i++)
- buf[i] = val[i];
- buf[i] = 0;
-
{
const AVOption *o_named;
int res;
@@ -241,7 +239,8 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con
const_names [ci] = NULL;
const_values[ci] = 0;
- res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
+ res = av_expr_parse_and_eval(&d, (o->type == AV_OPT_TYPE_FLAGS) ? buf : val, const_names,
+ const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
if (res < 0) {
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
return res;
@@ -256,7 +255,7 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con
if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0)
return ret;
val += i;
- if (!*val)
+ if (o->type != AV_OPT_TYPE_FLAGS || !*val)
return 0;
}