mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-01 18:21:04 +00:00
avfilter/vf_qp: split expression parsing out of loop
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
625bd463cd
commit
a8fb8f6112
@ -50,26 +50,31 @@ static int config_input(AVFilterLink *inlink)
|
|||||||
AVFilterContext *ctx = inlink->dst;
|
AVFilterContext *ctx = inlink->dst;
|
||||||
QPContext *s = ctx->priv;
|
QPContext *s = ctx->priv;
|
||||||
int i;
|
int i;
|
||||||
|
int ret;
|
||||||
|
AVExpr *e = NULL;
|
||||||
|
static const char *var_names[] = { "known", "qp", NULL };
|
||||||
|
|
||||||
if (!s->qp_expr_str)
|
if (!s->qp_expr_str)
|
||||||
return 0;
|
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->h = (inlink->h + 15) >> 4;
|
||||||
s->qstride = (inlink->w + 15) >> 4;
|
s->qstride = (inlink->w + 15) >> 4;
|
||||||
for (i = -129; i < 128; i++) {
|
for (i = -129; i < 128; i++) {
|
||||||
double var_values[] = { i != -129, i, 0};
|
double var_values[] = { i != -129, i, 0};
|
||||||
static const char *var_names[] = { "known", "qp", NULL };
|
double temp_val = av_expr_eval(e, var_values, NULL);
|
||||||
double temp_val;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = av_expr_parse_and_eval(&temp_val, s->qp_expr_str,
|
if (isnan(temp_val)) {
|
||||||
var_names, var_values,
|
av_expr_free(e);
|
||||||
NULL, NULL, NULL, NULL, 0, 0, ctx);
|
return AVERROR(EINVAL);
|
||||||
if (ret < 0)
|
}
|
||||||
return ret;
|
|
||||||
|
|
||||||
s->lut[i + 129] = lrintf(temp_val);
|
s->lut[i + 129] = lrintf(temp_val);
|
||||||
}
|
}
|
||||||
|
av_expr_free(e);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user