static int config_input_overlay(AVFilterLink *inlink)

{

    AVFilterContext *ctx  = inlink->dst;

    OverlayContext  *over = inlink->dst->priv;

    char *expr;

    double var_values[VAR_VARS_NB], res;

    int ret;

    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);



    av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc);



    /* Finish the configuration by evaluating the expressions

       now when both inputs are configured. */

    var_values[VAR_MAIN_W   ] = var_values[VAR_MW] = ctx->inputs[MAIN   ]->w;

    var_values[VAR_MAIN_H   ] = var_values[VAR_MH] = ctx->inputs[MAIN   ]->h;

    var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w;

    var_values[VAR_OVERLAY_H] = var_values[VAR_OH] = ctx->inputs[OVERLAY]->h;



    if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)

        goto fail;

    over->x = res;

    if ((ret = av_expr_parse_and_eval(&res, (expr = over->y_expr), var_names, var_values,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)))

        goto fail;

    over->y = res;

    /* x may depend on y */

    if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)

        goto fail;

    over->x = res;



    over->overlay_is_packed_rgb =

        ff_fill_rgba_map(over->overlay_rgba_map, inlink->format) >= 0;

    over->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);



    av_log(ctx, AV_LOG_VERBOSE,

           "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",

           ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,

           av_get_pix_fmt_name(ctx->inputs[MAIN]->format),

           over->x, over->y,

           ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,

           av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));



    if (over->x < 0 || over->y < 0 ||

        over->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] ||

        over->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) {

        av_log(ctx, AV_LOG_ERROR,

               "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",

               over->x, over->y,

               (int)(over->x + var_values[VAR_OVERLAY_W]),

               (int)(over->y + var_values[VAR_OVERLAY_H]),

               (int)var_values[VAR_MAIN_W], (int)var_values[VAR_MAIN_H]);

        return AVERROR(EINVAL);

    }

    return 0;



fail:

    av_log(NULL, AV_LOG_ERROR,

           "Error when evaluating the expression '%s'\n", expr);

    return ret;

}

static int config_input_overlay(AVFilterLink *inlink)

{

    AVFilterContext *ctx  = inlink->dst;

    OverlayContext  *over = inlink->dst->priv;

    char *expr;

    double var_values[VAR_VARS_NB], res;

    int ret;

    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);



    av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc);



    



    var_values[VAR_MAIN_W   ] = var_values[VAR_MW] = ctx->inputs[MAIN   ]->w;

    var_values[VAR_MAIN_H   ] = var_values[VAR_MH] = ctx->inputs[MAIN   ]->h;

    var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w;

    var_values[VAR_OVERLAY_H] = var_values[VAR_OH] = ctx->inputs[OVERLAY]->h;



    if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)

        goto fail;

    over->x = res;

    if ((ret = av_expr_parse_and_eval(&res, (expr = over->y_expr), var_names, var_values,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)))

        goto fail;

    over->y = res;

    

    if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)

        goto fail;

    over->x = res;



    over->overlay_is_packed_rgb =

        ff_fill_rgba_map(over->overlay_rgba_map, inlink->format) >= 0;

    over->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);



    av_log(ctx, AV_LOG_VERBOSE,

           "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",

           ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,

           av_get_pix_fmt_name(ctx->inputs[MAIN]->format),

           over->x, over->y,

           ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,

           av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));



    if (over->x < 0 || over->y < 0 ||

        over->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] ||

        over->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) {

        av_log(ctx, AV_LOG_ERROR,

               "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",

               over->x, over->y,

               (int)(over->x + var_values[VAR_OVERLAY_W]),

               (int)(over->y + var_values[VAR_OVERLAY_H]),

               (int)var_values[VAR_MAIN_W], (int)var_values[VAR_MAIN_H]);

        return AVERROR(EINVAL);

    }

    return 0;



fail:

    av_log(NULL, AV_LOG_ERROR,

           "Error when evaluating the expression '%s'\n", expr);

    return ret;

}

static int FUNC_0(AVFilterLink *VAR_0)

{

    AVFilterContext *ctx  = VAR_0->dst;

    OverlayContext  *over = VAR_0->dst->priv;

    char *VAR_1;

    double VAR_2[VAR_VARS_NB], res;

    int VAR_3;

    const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_0->format);



    av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, VAR_4);



    



    VAR_2[VAR_MAIN_W   ] = VAR_2[VAR_MW] = ctx->inputs[MAIN   ]->w;

    VAR_2[VAR_MAIN_H   ] = VAR_2[VAR_MH] = ctx->inputs[MAIN   ]->h;

    VAR_2[VAR_OVERLAY_W] = VAR_2[VAR_OW] = ctx->inputs[OVERLAY]->w;

    VAR_2[VAR_OVERLAY_H] = VAR_2[VAR_OH] = ctx->inputs[OVERLAY]->h;



    if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)

        goto fail;

    over->x = res;

    if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->y_expr), var_names, VAR_2,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)))

        goto fail;

    over->y = res;

    

    if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,

                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)

        goto fail;

    over->x = res;



    over->overlay_is_packed_rgb =

        ff_fill_rgba_map(over->overlay_rgba_map, VAR_0->format) >= 0;

    over->overlay_has_alpha = ff_fmt_is_in(VAR_0->format, alpha_pix_fmts);



    av_log(ctx, AV_LOG_VERBOSE,

           "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",

           ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,

           av_get_pix_fmt_name(ctx->inputs[MAIN]->format),

           over->x, over->y,

           ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,

           av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));



    if (over->x < 0 || over->y < 0 ||

        over->x + VAR_2[VAR_OVERLAY_W] > VAR_2[VAR_MAIN_W] ||

        over->y + VAR_2[VAR_OVERLAY_H] > VAR_2[VAR_MAIN_H]) {

        av_log(ctx, AV_LOG_ERROR,

               "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",

               over->x, over->y,

               (int)(over->x + VAR_2[VAR_OVERLAY_W]),

               (int)(over->y + VAR_2[VAR_OVERLAY_H]),

               (int)VAR_2[VAR_MAIN_W], (int)VAR_2[VAR_MAIN_H]);

        return AVERROR(EINVAL);

    }

    return 0;



fail:

    av_log(NULL, AV_LOG_ERROR,

           "Error when evaluating the expression '%s'\n", VAR_1);

    return VAR_3;

}

static int FUNC_0(AVFilterLink *VAR_0)
{ AVFilterContext *ctx  = VAR_0->dst; OverlayContext  *over = VAR_0->dst->priv; char *VAR_1; double VAR_2[VAR_VARS_NB], res; int VAR_3; const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_0->format); av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, VAR_4); VAR_2[VAR_MAIN_W   ] = VAR_2[VAR_MW] = ctx->inputs[MAIN   ]->w; VAR_2[VAR_MAIN_H   ] = VAR_2[VAR_MH] = ctx->inputs[MAIN   ]->h; VAR_2[VAR_OVERLAY_W] = VAR_2[VAR_OW] = ctx->inputs[OVERLAY]->w; VAR_2[VAR_OVERLAY_H] = VAR_2[VAR_OH] = ctx->inputs[OVERLAY]->h; if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail; over->x = res; if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->y_expr), var_names, VAR_2,
NULL, NULL, NULL, NULL, NULL, 0, ctx)))
goto fail; over->y = res; if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail; over->x = res; over->overlay_is_packed_rgb =
ff_fill_rgba_map(over->overlay_rgba_map, VAR_0->format) >= 0; over->overlay_has_alpha = ff_fmt_is_in(VAR_0->format, alpha_pix_fmts); av_log(ctx, AV_LOG_VERBOSE,
"main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",
ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
av_get_pix_fmt_name(ctx->inputs[MAIN]->format),
over->x, over->y,
ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format)); if (over->x < 0 || over->y < 0 ||
over->x + VAR_2[VAR_OVERLAY_W] > VAR_2[VAR_MAIN_W] ||
over->y + VAR_2[VAR_OVERLAY_H] > VAR_2[VAR_MAIN_H]) { av_log(ctx, AV_LOG_ERROR,
"Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
over->x, over->y,
(int)(over->x + VAR_2[VAR_OVERLAY_W]),
(int)(over->y + VAR_2[VAR_OVERLAY_H]),
(int)VAR_2[VAR_MAIN_W], (int)VAR_2[VAR_MAIN_H]); return AVERROR(EINVAL); } return 0; fail:
av_log(NULL, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", VAR_1); return VAR_3; }