Commit 4852a88d authored by Muhammad Faiz's avatar Muhammad Faiz Committed by Michael Niedermayer

avutil/opt: set_string_number(): remove unneeded copy

also remove unused variables
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent ca6b33b8
...@@ -191,22 +191,20 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con ...@@ -191,22 +191,20 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con
} }
for (;;) { for (;;) {
int i, den = 1; int i = 0;
char buf[256]; char buf[256];
int cmd = 0; int cmd = 0;
double d, num = 1; double d;
int64_t intnum = 1; int64_t intnum = 1;
i = 0; if (o->type == AV_OPT_TYPE_FLAGS) {
if (*val == '+' || *val == '-') { if (*val == '+' || *val == '-')
if (o->type == AV_OPT_TYPE_FLAGS)
cmd = *(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; const AVOption *o_named;
int res; int res;
...@@ -241,7 +239,8 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con ...@@ -241,7 +239,8 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con
const_names [ci] = NULL; const_names [ci] = NULL;
const_values[ci] = 0; 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) { if (res < 0) {
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val); av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
return res; return res;
...@@ -256,7 +255,7 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con ...@@ -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) if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0)
return ret; return ret;
val += i; val += i;
if (!*val) if (o->type != AV_OPT_TYPE_FLAGS || !*val)
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment