static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,

                    unsigned *nb_files_alloc)

{

    ConcatContext *cat = avf->priv_data;

    ConcatFile *file;

    char *url;

    size_t url_len;



    url_len = strlen(avf->filename) + strlen(filename) + 16;

    if (!(url = av_malloc(url_len)))

        return AVERROR(ENOMEM);

    ff_make_absolute_url(url, url_len, avf->filename, filename);

    av_free(filename);



    if (cat->nb_files >= *nb_files_alloc) {

        unsigned n = FFMAX(*nb_files_alloc * 2, 16);

        ConcatFile *new_files;

        if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||

            !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))

            return AVERROR(ENOMEM);

        cat->files = new_files;

        *nb_files_alloc = n;

    }



    file = &cat->files[cat->nb_files++];

    memset(file, 0, sizeof(*file));

    *rfile = file;



    file->url        = url;

    file->start_time = AV_NOPTS_VALUE;

    file->duration   = AV_NOPTS_VALUE;



    return 0;

}

static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,

                    unsigned *nb_files_alloc)

{

    ConcatContext *cat = avf->priv_data;

    ConcatFile *file;

    char *url;

    size_t url_len;



    url_len = strlen(avf->filename) + strlen(filename) + 16;

    if (!(url = av_malloc(url_len)))

        return AVERROR(ENOMEM);

    ff_make_absolute_url(url, url_len, avf->filename, filename);

    av_free(filename);



    if (cat->nb_files >= *nb_files_alloc) {

        unsigned n = FFMAX(*nb_files_alloc * 2, 16);

        ConcatFile *new_files;

        if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||

            !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))

            return AVERROR(ENOMEM);

        cat->files = new_files;

        *nb_files_alloc = n;

    }



    file = &cat->files[cat->nb_files++];

    memset(file, 0, sizeof(*file));

    *rfile = file;



    file->url        = url;

    file->start_time = AV_NOPTS_VALUE;

    file->duration   = AV_NOPTS_VALUE;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2,

                    unsigned *VAR_3)

{

    ConcatContext *cat = VAR_0->priv_data;

    ConcatFile *file;

    char *VAR_4;

    size_t url_len;



    url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16;

    if (!(VAR_4 = av_malloc(url_len)))

        return AVERROR(ENOMEM);

    ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1);

    av_free(VAR_1);



    if (cat->nb_files >= *VAR_3) {

        unsigned VAR_5 = FFMAX(*VAR_3 * 2, 16);

        ConcatFile *new_files;

        if (VAR_5 <= cat->nb_files || VAR_5 > SIZE_MAX / sizeof(*cat->files) ||

            !(new_files = av_realloc(cat->files, VAR_5 * sizeof(*cat->files))))

            return AVERROR(ENOMEM);

        cat->files = new_files;

        *VAR_3 = VAR_5;

    }



    file = &cat->files[cat->nb_files++];

    memset(file, 0, sizeof(*file));

    *VAR_2 = file;



    file->VAR_4        = VAR_4;

    file->start_time = AV_NOPTS_VALUE;

    file->duration   = AV_NOPTS_VALUE;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2,
unsigned *VAR_3)
{ ConcatContext *cat = VAR_0->priv_data; ConcatFile *file; char *VAR_4; size_t url_len; url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16; if (!(VAR_4 = av_malloc(url_len)))
return AVERROR(ENOMEM); ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1); av_free(VAR_1); if (cat->nb_files >= *VAR_3) { unsigned VAR_5 = FFMAX(*VAR_3 * 2, 16); ConcatFile *new_files; if (VAR_5 <= cat->nb_files || VAR_5 > SIZE_MAX / sizeof(*cat->files) ||
!(new_files = av_realloc(cat->files, VAR_5 * sizeof(*cat->files))))
return AVERROR(ENOMEM); cat->files = new_files; *VAR_3 = VAR_5; } file = &cat->files[cat->nb_files++]; memset(file, 0, sizeof(*file)); *VAR_2 = file; file->VAR_4        = VAR_4; file->start_time = AV_NOPTS_VALUE; file->duration   = AV_NOPTS_VALUE; return 0; }