+ double var_values[VARS_NB], res;
+ char *expr;
+ int ret;
+
+ var_values[VAR_PI] = M_PI;
+ var_values[VAR_PHI] = M_PHI;
+ var_values[VAR_E] = M_E;
+ var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
+ var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
+ var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
+ var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
+ var_values[VAR_DAR] = var_values[VAR_A] = (double) inlink->w / inlink->h;
+ var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
+ (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
+ var_values[VAR_HSUB] = 1 << desc->log2_chroma_w;
+ var_values[VAR_VSUB] = 1 << desc->log2_chroma_h;
+
+ /* evaluate width and height */
+ av_expr_parse_and_eval(&res, (expr = scale->w_expr),
+ var_names, var_values,
+ NULL, NULL, NULL, NULL, NULL, 0, ctx);
+ scale->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
+ if ((ret = av_expr_parse_and_eval(&res, (expr = scale->h_expr),
+ var_names, var_values,
+ NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
+ goto fail;
+ scale->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
+ /* evaluate again the width, as it may depend on the output height */
+ if ((ret = av_expr_parse_and_eval(&res, (expr = scale->w_expr),
+ var_names, var_values,
+ NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
+ goto fail;
+ scale->w = res;
+
+ w = scale->w;
+ h = scale->h;
+
+ /* sanity check params */
+ if (w < -1 || h < -1) {
+ av_log(ctx, AV_LOG_ERROR, "Size values less than -1 are not acceptable.\n");
+ return AVERROR(EINVAL);
+ }
+ if (w == -1 && h == -1)
+ scale->w = scale->h = 0;