static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,

                                        AVFilterInOut *in)

{

    AVFilterContext *last_filter;

    const AVFilter *buffer_filt = avfilter_get_by_name("buffer");

    InputStream *ist = ifilter->ist;

    InputFile     *f = input_files[ist->file_index];

    AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :

                                         ist->st->time_base;

    AVRational sar;

    char args[255], name[255];

    int ret, pad_idx = 0;



    sar = ist->st->sample_aspect_ratio.num ?

          ist->st->sample_aspect_ratio :

          ist->st->codec->sample_aspect_ratio;

    snprintf(args, sizeof(args), "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width,

             ist->st->codec->height, ist->st->codec->pix_fmt,

             tb.num, tb.den, sar.num, sar.den);

    snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,

             ist->file_index, ist->st->index);



    if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,

                                            args, NULL, fg->graph)) < 0)

        return ret;

    last_filter = ifilter->filter;



    if (ist->framerate.num) {

        AVFilterContext *setpts;



        snprintf(name, sizeof(name), "force CFR for input from stream %d:%d",

                 ist->file_index, ist->st->index);

        if ((ret = avfilter_graph_create_filter(&setpts,

                                                avfilter_get_by_name("setpts"),

                                                name, "N", NULL,

                                                fg->graph)) < 0)

            return ret;



        if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0)

            return ret;



        last_filter = setpts;

    }



    snprintf(name, sizeof(name), "trim for input stream %d:%d",

             ist->file_index, ist->st->index);

    ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?

                      AV_NOPTS_VALUE : 0, INT64_MAX, &last_filter, &pad_idx, name);

    if (ret < 0)

        return ret;



    if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)

        return ret;

    return 0;

}

static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,

                                        AVFilterInOut *in)

{

    AVFilterContext *last_filter;

    const AVFilter *buffer_filt = avfilter_get_by_name("buffer");

    InputStream *ist = ifilter->ist;

    InputFile     *f = input_files[ist->file_index];

    AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :

                                         ist->st->time_base;

    AVRational sar;

    char args[255], name[255];

    int ret, pad_idx = 0;



    sar = ist->st->sample_aspect_ratio.num ?

          ist->st->sample_aspect_ratio :

          ist->st->codec->sample_aspect_ratio;

    snprintf(args, sizeof(args), "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width,

             ist->st->codec->height, ist->st->codec->pix_fmt,

             tb.num, tb.den, sar.num, sar.den);

    snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,

             ist->file_index, ist->st->index);



    if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,

                                            args, NULL, fg->graph)) < 0)

        return ret;

    last_filter = ifilter->filter;



    if (ist->framerate.num) {

        AVFilterContext *setpts;



        snprintf(name, sizeof(name), "force CFR for input from stream %d:%d",

                 ist->file_index, ist->st->index);

        if ((ret = avfilter_graph_create_filter(&setpts,

                                                avfilter_get_by_name("setpts"),

                                                name, "N", NULL,

                                                fg->graph)) < 0)

            return ret;



        if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0)

            return ret;



        last_filter = setpts;

    }



    snprintf(name, sizeof(name), "trim for input stream %d:%d",

             ist->file_index, ist->st->index);

    ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?

                      AV_NOPTS_VALUE : 0, INT64_MAX, &last_filter, &pad_idx, name);

    if (ret < 0)

        return ret;



    if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)

        return ret;

    return 0;

}

static int FUNC_0(FilterGraph *VAR_0, InputFilter *VAR_1,

                                        AVFilterInOut *VAR_2)

{

    AVFilterContext *last_filter;

    const AVFilter *VAR_3 = avfilter_get_by_name("buffer");

    InputStream *ist = VAR_1->ist;

    InputFile     *f = input_files[ist->file_index];

    AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :

                                         ist->st->time_base;

    AVRational sar;

    char VAR_4[255], VAR_5[255];

    int VAR_6, VAR_7 = 0;



    sar = ist->st->sample_aspect_ratio.num ?

          ist->st->sample_aspect_ratio :

          ist->st->codec->sample_aspect_ratio;

    snprintf(VAR_4, sizeof(VAR_4), "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width,

             ist->st->codec->height, ist->st->codec->pix_fmt,

             tb.num, tb.den, sar.num, sar.den);

    snprintf(VAR_5, sizeof(VAR_5), "graph %d input from stream %d:%d", VAR_0->index,

             ist->file_index, ist->st->index);



    if ((VAR_6 = avfilter_graph_create_filter(&VAR_1->filter, VAR_3, VAR_5,

                                            VAR_4, NULL, VAR_0->graph)) < 0)

        return VAR_6;

    last_filter = VAR_1->filter;



    if (ist->framerate.num) {

        AVFilterContext *setpts;



        snprintf(VAR_5, sizeof(VAR_5), "force CFR for input from stream %d:%d",

                 ist->file_index, ist->st->index);

        if ((VAR_6 = avfilter_graph_create_filter(&setpts,

                                                avfilter_get_by_name("setpts"),

                                                VAR_5, "N", NULL,

                                                VAR_0->graph)) < 0)

            return VAR_6;



        if ((VAR_6 = avfilter_link(last_filter, 0, setpts, 0)) < 0)

            return VAR_6;



        last_filter = setpts;

    }



    snprintf(VAR_5, sizeof(VAR_5), "trim for input stream %d:%d",

             ist->file_index, ist->st->index);

    VAR_6 = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?

                      AV_NOPTS_VALUE : 0, INT64_MAX, &last_filter, &VAR_7, VAR_5);

    if (VAR_6 < 0)

        return VAR_6;



    if ((VAR_6 = avfilter_link(last_filter, 0, VAR_2->filter_ctx, VAR_2->VAR_7)) < 0)

        return VAR_6;

    return 0;

}

static int FUNC_0(FilterGraph *VAR_0, InputFilter *VAR_1,
AVFilterInOut *VAR_2)
{ AVFilterContext *last_filter; const AVFilter *VAR_3 = avfilter_get_by_name("buffer"); InputStream *ist = VAR_1->ist; InputFile     *f = input_files[ist->file_index]; AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
ist->st->time_base; AVRational sar; char VAR_4[255], VAR_5[255]; int VAR_6, VAR_7 = 0; sar = ist->st->sample_aspect_ratio.num ?
ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio; snprintf(VAR_4, sizeof(VAR_4), "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width,
ist->st->codec->height, ist->st->codec->pix_fmt,
tb.num, tb.den, sar.num, sar.den); snprintf(VAR_5, sizeof(VAR_5), "graph %d input from stream %d:%d", VAR_0->index,
ist->file_index, ist->st->index); if ((VAR_6 = avfilter_graph_create_filter(&VAR_1->filter, VAR_3, VAR_5,
VAR_4, NULL, VAR_0->graph)) < 0)
return VAR_6; last_filter = VAR_1->filter; if (ist->framerate.num) { AVFilterContext *setpts; snprintf(VAR_5, sizeof(VAR_5), "force CFR for input from stream %d:%d",
ist->file_index, ist->st->index); if ((VAR_6 = avfilter_graph_create_filter(&setpts,
avfilter_get_by_name("setpts"),
VAR_5, "N", NULL,
VAR_0->graph)) < 0)
return VAR_6; if ((VAR_6 = avfilter_link(last_filter, 0, setpts, 0)) < 0)
return VAR_6; last_filter = setpts; } snprintf(VAR_5, sizeof(VAR_5), "trim for input stream %d:%d",
ist->file_index, ist->st->index); VAR_6 = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
AV_NOPTS_VALUE : 0, INT64_MAX, &last_filter, &VAR_7, VAR_5); if (VAR_6 < 0)
return VAR_6; if ((VAR_6 = avfilter_link(last_filter, 0, VAR_2->filter_ctx, VAR_2->VAR_7)) < 0)
return VAR_6; return 0; }