int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title)

{

    AVChapter *chapter = NULL;

    int i;



    for(i=0; i<s->num_chapters; i++)

        if(s->chapters[i]->id == id)

            chapter = s->chapters[i];



    if(!chapter){

        chapter= av_mallocz(sizeof(AVChapter));

        if(!chapter)

            return AVERROR(ENOMEM);

        dynarray_add(&s->chapters, &s->num_chapters, chapter);

    }

    if(chapter->title)

        av_free(chapter->title);

    if (title)

        chapter->title = av_strdup(title);

    chapter->id    = id;

    chapter->start = start;

    chapter->end = end;



    return 0;

}

int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title)

{

    AVChapter *chapter = NULL;

    int i;



    for(i=0; i<s->num_chapters; i++)

        if(s->chapters[i]->id == id)

            chapter = s->chapters[i];



    if(!chapter){

        chapter= av_mallocz(sizeof(AVChapter));

        if(!chapter)

            return AVERROR(ENOMEM);

        dynarray_add(&s->chapters, &s->num_chapters, chapter);

    }

    if(chapter->title)

        av_free(chapter->title);

    if (title)

        chapter->title = av_strdup(title);

    chapter->id    = id;

    chapter->start = start;

    chapter->end = end;



    return 0;

}

int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int64_t VAR_3, const char *VAR_4)

{

    AVChapter *chapter = NULL;

    int VAR_5;



    for(VAR_5=0; VAR_5<VAR_0->num_chapters; VAR_5++)

        if(VAR_0->chapters[VAR_5]->VAR_1 == VAR_1)

            chapter = VAR_0->chapters[VAR_5];



    if(!chapter){

        chapter= av_mallocz(sizeof(AVChapter));

        if(!chapter)

            return AVERROR(ENOMEM);

        dynarray_add(&VAR_0->chapters, &VAR_0->num_chapters, chapter);

    }

    if(chapter->VAR_4)

        av_free(chapter->VAR_4);

    if (VAR_4)

        chapter->VAR_4 = av_strdup(VAR_4);

    chapter->VAR_1    = VAR_1;

    chapter->VAR_2 = VAR_2;

    chapter->VAR_3 = VAR_3;



    return 0;

}

int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int64_t VAR_3, const char *VAR_4)
{ AVChapter *chapter = NULL; int VAR_5; for(VAR_5=0; VAR_5<VAR_0->num_chapters; VAR_5++) if(VAR_0->chapters[VAR_5]->VAR_1 == VAR_1)
chapter = VAR_0->chapters[VAR_5]; if(!chapter){ chapter= av_mallocz(sizeof(AVChapter)); if(!chapter)
return AVERROR(ENOMEM); dynarray_add(&VAR_0->chapters, &VAR_0->num_chapters, chapter); } if(chapter->VAR_4)
av_free(chapter->VAR_4); if (VAR_4)
chapter->VAR_4 = av_strdup(VAR_4); chapter->VAR_1    = VAR_1; chapter->VAR_2 = VAR_2; chapter->VAR_3 = VAR_3; return 0; }