vf_pad: fix x, y option expression evaluation

Calculation of x an y based on width and height did not work when
width == 0 or height == 0.  "0" substitutes the input width and
height, but did so too late for x, y expression evaluation.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
John Stebbins 2015-10-25 11:36:10 -07:00 committed by Luca Barbato
parent e2854e731f
commit 2ec112f71c
1 changed files with 5 additions and 5 deletions

View File

@ -167,12 +167,17 @@ static int config_input(AVFilterLink *inlink)
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto eval_fail; goto eval_fail;
s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res; s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
if (!s->h)
var_values[VAR_OUT_H] = var_values[VAR_OH] = s->h = inlink->h;
/* evaluate the width again, as it may depend on the evaluated output height */ /* evaluate the width again, as it may depend on the evaluated output height */
if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr), if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr),
var_names, var_values, var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto eval_fail; goto eval_fail;
s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
if (!s->w)
var_values[VAR_OUT_W] = var_values[VAR_OW] = s->w = inlink->w;
/* evaluate x and y */ /* evaluate x and y */
av_expr_parse_and_eval(&res, (expr = s->x_expr), av_expr_parse_and_eval(&res, (expr = s->x_expr),
@ -197,11 +202,6 @@ static int config_input(AVFilterLink *inlink)
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if (!s->w)
s->w = inlink->w;
if (!s->h)
s->h = inlink->h;
s->w &= ~((1 << s->hsub) - 1); s->w &= ~((1 << s->hsub) - 1);
s->h &= ~((1 << s->vsub) - 1); s->h &= ~((1 << s->vsub) - 1);
s->x &= ~((1 << s->hsub) - 1); s->x &= ~((1 << s->hsub) - 1);