avfilter/vf_drawbox: Fix handling of max values

Fixes Ticket4332

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/117/head
Michael Niedermayer 10 years ago
parent 85108195c5
commit 047fd986bf
  1. 7
      libavfilter/vf_drawbox.c

@ -47,6 +47,7 @@ static const char *const var_names[] = {
"h", ///< height of the rendered box "h", ///< height of the rendered box
"w", ///< width of the rendered box "w", ///< width of the rendered box
"t", "t",
"max",
NULL NULL
}; };
@ -63,6 +64,7 @@ enum var_name {
VAR_H, VAR_H,
VAR_W, VAR_W,
VAR_T, VAR_T,
VAR_MAX,
VARS_NB VARS_NB
}; };
@ -142,30 +144,35 @@ static int config_input(AVFilterLink *inlink)
for (i = 0; i <= NUM_EXPR_EVALS; i++) { for (i = 0; i <= NUM_EXPR_EVALS; i++) {
/* evaluate expressions, fail on last iteration */ /* evaluate expressions, fail on last iteration */
var_values[VAR_MAX] = inlink->w;
if ((ret = av_expr_parse_and_eval(&res, (expr = s->x_expr), if ((ret = av_expr_parse_and_eval(&res, (expr = s->x_expr),
var_names, var_values, var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS) NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
goto fail; goto fail;
s->x = var_values[VAR_X] = res; s->x = var_values[VAR_X] = res;
var_values[VAR_MAX] = inlink->h;
if ((ret = av_expr_parse_and_eval(&res, (expr = s->y_expr), if ((ret = av_expr_parse_and_eval(&res, (expr = s->y_expr),
var_names, var_values, var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS) NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
goto fail; goto fail;
s->y = var_values[VAR_Y] = res; s->y = var_values[VAR_Y] = res;
var_values[VAR_MAX] = inlink->w - s->x;
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 && i == NUM_EXPR_EVALS) NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
goto fail; goto fail;
s->w = var_values[VAR_W] = res; s->w = var_values[VAR_W] = res;
var_values[VAR_MAX] = inlink->h - s->y;
if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr), if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr),
var_names, var_values, var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS) NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
goto fail; goto fail;
s->h = var_values[VAR_H] = res; s->h = var_values[VAR_H] = res;
var_values[VAR_MAX] = INT_MAX;
if ((ret = av_expr_parse_and_eval(&res, (expr = s->t_expr), if ((ret = av_expr_parse_and_eval(&res, (expr = s->t_expr),
var_names, var_values, var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS) NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)

Loading…
Cancel
Save