aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-28 15:17:36 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-28 15:17:36 +0100
commita8fb8f6112296c5a46f03002c977b59a8d9ef476 (patch)
treed8f89f110dffa40550e7ace44207d387d43b1c81
parent625bd463cde81244169bce99d3afc0b3c73304c2 (diff)
downloadffmpeg-a8fb8f6112296c5a46f03002c977b59a8d9ef476.tar.gz
avfilter/vf_qp: split expression parsing out of loop
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavfilter/vf_qp.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/libavfilter/vf_qp.c b/libavfilter/vf_qp.c
index d9766344c9..8aa670b96b 100644
--- a/libavfilter/vf_qp.c
+++ b/libavfilter/vf_qp.c
@@ -50,26 +50,31 @@ static int config_input(AVFilterLink *inlink)
AVFilterContext *ctx = inlink->dst;
QPContext *s = ctx->priv;
int i;
+ int ret;
+ AVExpr *e = NULL;
+ static const char *var_names[] = { "known", "qp", NULL };
if (!s->qp_expr_str)
return 0;
+ ret = av_expr_parse(&e, s->qp_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx);
+ if (ret < 0)
+ return ret;
+
s->h = (inlink->h + 15) >> 4;
s->qstride = (inlink->w + 15) >> 4;
for (i = -129; i < 128; i++) {
- double var_values[] = { i != -129, i, 0 };
- static const char *var_names[] = { "known", "qp", NULL };
- double temp_val;
- int ret;
+ double var_values[] = { i != -129, i, 0};
+ double temp_val = av_expr_eval(e, var_values, NULL);
- ret = av_expr_parse_and_eval(&temp_val, s->qp_expr_str,
- var_names, var_values,
- NULL, NULL, NULL, NULL, 0, 0, ctx);
- if (ret < 0)
- return ret;
+ if (isnan(temp_val)) {
+ av_expr_free(e);
+ return AVERROR(EINVAL);
+ }
s->lut[i + 129] = lrintf(temp_val);
}
+ av_expr_free(e);
return 0;
}