static int pick_formats(AVFilterGraph *graph)

{

    int i, j, ret;

    int change;



    do{

        change = 0;

        for (i = 0; i < graph->filter_count; i++) {

            AVFilterContext *filter = graph->filters[i];

            if (filter->nb_inputs){

                for (j = 0; j < filter->nb_inputs; j++){

                    if(filter->inputs[j]->in_formats && filter->inputs[j]->in_formats->format_count == 1) {

                        pick_format(filter->inputs[j], NULL);

                        change = 1;

                    }

                }

            }

            if (filter->nb_outputs){

                for (j = 0; j < filter->nb_outputs; j++){

                    if(filter->outputs[j]->in_formats && filter->outputs[j]->in_formats->format_count == 1) {

                        pick_format(filter->outputs[j], NULL);

                        change = 1;

                    }

                }

            }

            if (filter->nb_inputs && filter->nb_outputs && filter->inputs[0]->format>=0) {

                for (j = 0; j < filter->nb_outputs; j++) {

                    if(filter->outputs[j]->format<0) {

                        pick_format(filter->outputs[j], filter->inputs[0]);

                        change = 1;

                    }

                }

            }

        }

    }while(change);



    for (i = 0; i < graph->filter_count; i++) {

        AVFilterContext *filter = graph->filters[i];



        for (j = 0; j < filter->nb_inputs; j++)

            if ((ret = pick_format(filter->inputs[j], NULL)) < 0)

                return ret;

        for (j = 0; j < filter->nb_outputs; j++)

            if ((ret = pick_format(filter->outputs[j], NULL)) < 0)

                return ret;

    }

    return 0;

}

static int pick_formats(AVFilterGraph *graph)

{

    int i, j, ret;

    int change;



    do{

        change = 0;

        for (i = 0; i < graph->filter_count; i++) {

            AVFilterContext *filter = graph->filters[i];

            if (filter->nb_inputs){

                for (j = 0; j < filter->nb_inputs; j++){

                    if(filter->inputs[j]->in_formats && filter->inputs[j]->in_formats->format_count == 1) {

                        pick_format(filter->inputs[j], NULL);

                        change = 1;

                    }

                }

            }

            if (filter->nb_outputs){

                for (j = 0; j < filter->nb_outputs; j++){

                    if(filter->outputs[j]->in_formats && filter->outputs[j]->in_formats->format_count == 1) {

                        pick_format(filter->outputs[j], NULL);

                        change = 1;

                    }

                }

            }

            if (filter->nb_inputs && filter->nb_outputs && filter->inputs[0]->format>=0) {

                for (j = 0; j < filter->nb_outputs; j++) {

                    if(filter->outputs[j]->format<0) {

                        pick_format(filter->outputs[j], filter->inputs[0]);

                        change = 1;

                    }

                }

            }

        }

    }while(change);



    for (i = 0; i < graph->filter_count; i++) {

        AVFilterContext *filter = graph->filters[i];



        for (j = 0; j < filter->nb_inputs; j++)

            if ((ret = pick_format(filter->inputs[j], NULL)) < 0)

                return ret;

        for (j = 0; j < filter->nb_outputs; j++)

            if ((ret = pick_format(filter->outputs[j], NULL)) < 0)

                return ret;

    }

    return 0;

}

static int FUNC_0(AVFilterGraph *VAR_0)

{

    int VAR_1, VAR_2, VAR_3;

    int VAR_4;



    do{

        VAR_4 = 0;

        for (VAR_1 = 0; VAR_1 < VAR_0->filter_count; VAR_1++) {

            AVFilterContext *filter = VAR_0->filters[VAR_1];

            if (filter->nb_inputs){

                for (VAR_2 = 0; VAR_2 < filter->nb_inputs; VAR_2++){

                    if(filter->inputs[VAR_2]->in_formats && filter->inputs[VAR_2]->in_formats->format_count == 1) {

                        pick_format(filter->inputs[VAR_2], NULL);

                        VAR_4 = 1;

                    }

                }

            }

            if (filter->nb_outputs){

                for (VAR_2 = 0; VAR_2 < filter->nb_outputs; VAR_2++){

                    if(filter->outputs[VAR_2]->in_formats && filter->outputs[VAR_2]->in_formats->format_count == 1) {

                        pick_format(filter->outputs[VAR_2], NULL);

                        VAR_4 = 1;

                    }

                }

            }

            if (filter->nb_inputs && filter->nb_outputs && filter->inputs[0]->format>=0) {

                for (VAR_2 = 0; VAR_2 < filter->nb_outputs; VAR_2++) {

                    if(filter->outputs[VAR_2]->format<0) {

                        pick_format(filter->outputs[VAR_2], filter->inputs[0]);

                        VAR_4 = 1;

                    }

                }

            }

        }

    }while(VAR_4);



    for (VAR_1 = 0; VAR_1 < VAR_0->filter_count; VAR_1++) {

        AVFilterContext *filter = VAR_0->filters[VAR_1];



        for (VAR_2 = 0; VAR_2 < filter->nb_inputs; VAR_2++)

            if ((VAR_3 = pick_format(filter->inputs[VAR_2], NULL)) < 0)

                return VAR_3;

        for (VAR_2 = 0; VAR_2 < filter->nb_outputs; VAR_2++)

            if ((VAR_3 = pick_format(filter->outputs[VAR_2], NULL)) < 0)

                return VAR_3;

    }

    return 0;

}

static int FUNC_0(AVFilterGraph *VAR_0)
{ int VAR_1, VAR_2, VAR_3; int VAR_4; do{ VAR_4 = 0; for (VAR_1 = 0; VAR_1 < VAR_0->filter_count; VAR_1++) { AVFilterContext *filter = VAR_0->filters[VAR_1]; if (filter->nb_inputs){ for (VAR_2 = 0; VAR_2 < filter->nb_inputs; VAR_2++){ if(filter->inputs[VAR_2]->in_formats && filter->inputs[VAR_2]->in_formats->format_count == 1) { pick_format(filter->inputs[VAR_2], NULL); VAR_4 = 1; } } } if (filter->nb_outputs){ for (VAR_2 = 0; VAR_2 < filter->nb_outputs; VAR_2++){ if(filter->outputs[VAR_2]->in_formats && filter->outputs[VAR_2]->in_formats->format_count == 1) { pick_format(filter->outputs[VAR_2], NULL); VAR_4 = 1; } } } if (filter->nb_inputs && filter->nb_outputs && filter->inputs[0]->format>=0) { for (VAR_2 = 0; VAR_2 < filter->nb_outputs; VAR_2++) { if(filter->outputs[VAR_2]->format<0) { pick_format(filter->outputs[VAR_2], filter->inputs[0]); VAR_4 = 1; } } } } }while(VAR_4); for (VAR_1 = 0; VAR_1 < VAR_0->filter_count; VAR_1++) { AVFilterContext *filter = VAR_0->filters[VAR_1]; for (VAR_2 = 0; VAR_2 < filter->nb_inputs; VAR_2++) if ((VAR_3 = pick_format(filter->inputs[VAR_2], NULL)) < 0)
return VAR_3; for (VAR_2 = 0; VAR_2 < filter->nb_outputs; VAR_2++) if ((VAR_3 = pick_format(filter->outputs[VAR_2], NULL)) < 0)
return VAR_3; } return 0; }