int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,

                         AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr,

                         void *log_ctx)

{

    int index = 0, ret = 0;

    char chr = 0;



    AVFilterInOut *curr_inputs = NULL;

    AVFilterInOut *open_inputs  = open_inputs_ptr  ? *open_inputs_ptr  : NULL;

    AVFilterInOut *open_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL;



    do {

        AVFilterContext *filter;

        const char *filterchain = filters;

        filters += strspn(filters, WHITESPACES);



        if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)

            goto end;



        if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)

            goto end;



        if (filter->input_count == 1 && !curr_inputs && !index) {

            /* First input pad, assume it is "[in]" if not specified */

            const char *tmp = "[in]";

            if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)

                goto end;

        }



        if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)

            goto end;



        if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,

                                 log_ctx)) < 0)

            goto end;



        filters += strspn(filters, WHITESPACES);

        chr = *filters++;



        if (chr == ';' && curr_inputs) {

            av_log(log_ctx, AV_LOG_ERROR,

                   "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",

                   filterchain);

            ret = AVERROR(EINVAL);

            goto end;

        }

        index++;

    } while (chr == ',' || chr == ';');



    if (chr) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Unable to parse graph description substring: \"%s\"\n",

               filters - 1);

        ret = AVERROR(EINVAL);

        goto end;

    }



    if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {

        /* Last output pad, assume it is "[out]" if not specified */

        const char *tmp = "[out]";

        if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,

                                 log_ctx)) < 0)

            goto end;

    }



end:

    /* clear open_in/outputs only if not passed as parameters */

    if (open_inputs_ptr) *open_inputs_ptr = open_inputs;

    else avfilter_inout_free(&open_inputs);

    if (open_outputs_ptr) *open_outputs_ptr = open_outputs;

    else avfilter_inout_free(&open_outputs);

    avfilter_inout_free(&curr_inputs);



    if (ret < 0) {

        for (; graph->filter_count > 0; graph->filter_count--)

            avfilter_free(graph->filters[graph->filter_count - 1]);

        av_freep(&graph->filters);

    }

    return ret;

}

int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,

                         AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr,

                         void *log_ctx)

{

    int index = 0, ret = 0;

    char chr = 0;



    AVFilterInOut *curr_inputs = NULL;

    AVFilterInOut *open_inputs  = open_inputs_ptr  ? *open_inputs_ptr  : NULL;

    AVFilterInOut *open_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL;



    do {

        AVFilterContext *filter;

        const char *filterchain = filters;

        filters += strspn(filters, WHITESPACES);



        if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)

            goto end;



        if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)

            goto end;



        if (filter->input_count == 1 && !curr_inputs && !index) {

            

            const char *tmp = "[in]";

            if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)

                goto end;

        }



        if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)

            goto end;



        if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,

                                 log_ctx)) < 0)

            goto end;



        filters += strspn(filters, WHITESPACES);

        chr = *filters++;



        if (chr == ';' && curr_inputs) {

            av_log(log_ctx, AV_LOG_ERROR,

                   "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",

                   filterchain);

            ret = AVERROR(EINVAL);

            goto end;

        }

        index++;

    } while (chr == ',' || chr == ';');



    if (chr) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Unable to parse graph description substring: \"%s\"\n",

               filters - 1);

        ret = AVERROR(EINVAL);

        goto end;

    }



    if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {

        

        const char *tmp = "[out]";

        if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,

                                 log_ctx)) < 0)

            goto end;

    }



end:

    

    if (open_inputs_ptr) *open_inputs_ptr = open_inputs;

    else avfilter_inout_free(&open_inputs);

    if (open_outputs_ptr) *open_outputs_ptr = open_outputs;

    else avfilter_inout_free(&open_outputs);

    avfilter_inout_free(&curr_inputs);



    if (ret < 0) {

        for (; graph->filter_count > 0; graph->filter_count--)

            avfilter_free(graph->filters[graph->filter_count - 1]);

        av_freep(&graph->filters);

    }

    return ret;

}

int FUNC_0(AVFilterGraph *VAR_0, const char *VAR_1,

                         AVFilterInOut **VAR_2, AVFilterInOut **VAR_3,

                         void *VAR_4)

{

    int VAR_5 = 0, VAR_6 = 0;

    char VAR_7 = 0;



    AVFilterInOut *curr_inputs = NULL;

    AVFilterInOut *open_inputs  = VAR_2  ? *VAR_2  : NULL;

    AVFilterInOut *open_outputs = VAR_3 ? *VAR_3 : NULL;



    do {

        AVFilterContext *filter;

        const char *VAR_8 = VAR_1;

        VAR_1 += strspn(VAR_1, WHITESPACES);



        if ((VAR_6 = parse_inputs(&VAR_1, &curr_inputs, &open_outputs, VAR_4)) < 0)

            goto end;



        if ((VAR_6 = parse_filter(&filter, &VAR_1, VAR_0, VAR_5, VAR_4)) < 0)

            goto end;



        if (filter->input_count == 1 && !curr_inputs && !VAR_5) {

            

            const char *VAR_10 = "[in]";

            if ((VAR_6 = parse_inputs(&VAR_10, &curr_inputs, &open_outputs, VAR_4)) < 0)

                goto end;

        }



        if ((VAR_6 = link_filter_inouts(filter, &curr_inputs, &open_inputs, VAR_4)) < 0)

            goto end;



        if ((VAR_6 = parse_outputs(&VAR_1, &curr_inputs, &open_inputs, &open_outputs,

                                 VAR_4)) < 0)

            goto end;



        VAR_1 += strspn(VAR_1, WHITESPACES);

        VAR_7 = *VAR_1++;



        if (VAR_7 == ';' && curr_inputs) {

            av_log(VAR_4, AV_LOG_ERROR,

                   "Invalid VAR_8 containing an unlabelled output pad: \"%s\"\n",

                   VAR_8);

            VAR_6 = AVERROR(EINVAL);

            goto end;

        }

        VAR_5++;

    } while (VAR_7 == ',' || VAR_7 == ';');



    if (VAR_7) {

        av_log(VAR_4, AV_LOG_ERROR,

               "Unable to parse VAR_0 description substring: \"%s\"\n",

               VAR_1 - 1);

        VAR_6 = AVERROR(EINVAL);

        goto end;

    }



    if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {

        

        const char *VAR_10 = "[out]";

        if ((VAR_6 = parse_outputs(&VAR_10, &curr_inputs, &open_inputs, &open_outputs,

                                 VAR_4)) < 0)

            goto end;

    }



end:

    

    if (VAR_2) *VAR_2 = open_inputs;

    else avfilter_inout_free(&open_inputs);

    if (VAR_3) *VAR_3 = open_outputs;

    else avfilter_inout_free(&open_outputs);

    avfilter_inout_free(&curr_inputs);



    if (VAR_6 < 0) {

        for (; VAR_0->filter_count > 0; VAR_0->filter_count--)

            avfilter_free(VAR_0->VAR_1[VAR_0->filter_count - 1]);

        av_freep(&VAR_0->VAR_1);

    }

    return VAR_6;

}

int FUNC_0(AVFilterGraph *VAR_0, const char *VAR_1,
AVFilterInOut **VAR_2, AVFilterInOut **VAR_3,
void *VAR_4)
{ int VAR_5 = 0, VAR_6 = 0; char VAR_7 = 0; AVFilterInOut *curr_inputs = NULL; AVFilterInOut *open_inputs  = VAR_2  ? *VAR_2  : NULL; AVFilterInOut *open_outputs = VAR_3 ? *VAR_3 : NULL; do { AVFilterContext *filter; const char *VAR_8 = VAR_1; VAR_1 += strspn(VAR_1, WHITESPACES); if ((VAR_6 = parse_inputs(&VAR_1, &curr_inputs, &open_outputs, VAR_4)) < 0)
goto end; if ((VAR_6 = parse_filter(&filter, &VAR_1, VAR_0, VAR_5, VAR_4)) < 0)
goto end; if (filter->input_count == 1 && !curr_inputs && !VAR_5) { const char *VAR_10 = "[in]"; if ((VAR_6 = parse_inputs(&VAR_10, &curr_inputs, &open_outputs, VAR_4)) < 0)
goto end; } if ((VAR_6 = link_filter_inouts(filter, &curr_inputs, &open_inputs, VAR_4)) < 0)
goto end; if ((VAR_6 = parse_outputs(&VAR_1, &curr_inputs, &open_inputs, &open_outputs,
VAR_4)) < 0)
goto end; VAR_1 += strspn(VAR_1, WHITESPACES); VAR_7 = *VAR_1++; if (VAR_7 == ';' && curr_inputs) { av_log(VAR_4, AV_LOG_ERROR,
"Invalid VAR_8 containing an unlabelled output pad: \"%s\"\n",
VAR_8); VAR_6 = AVERROR(EINVAL); goto end; } VAR_5++; } while (VAR_7 == ',' || VAR_7 == ';'); if (VAR_7) { av_log(VAR_4, AV_LOG_ERROR,
"Unable to parse VAR_0 description substring: \"%s\"\n",
VAR_1 - 1); VAR_6 = AVERROR(EINVAL); goto end; } if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) { const char *VAR_10 = "[out]"; if ((VAR_6 = parse_outputs(&VAR_10, &curr_inputs, &open_inputs, &open_outputs,
VAR_4)) < 0)
goto end; } end:
if (VAR_2) *VAR_2 = open_inputs; else avfilter_inout_free(&open_inputs); if (VAR_3) *VAR_3 = open_outputs; else avfilter_inout_free(&open_outputs); avfilter_inout_free(&curr_inputs); if (VAR_6 < 0) { for (; VAR_0->filter_count > 0; VAR_0->filter_count--) avfilter_free(VAR_0->VAR_1[VAR_0->filter_count - 1]); av_freep(&VAR_0->VAR_1); } return VAR_6; }