Add id to AVChapter, untested (where do i find matroska files with chapters?).

Originally committed as revision 13255 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer
2008-05-23 13:02:27 +00:00
parent 8931e7b48a
commit 7a2a3e8e40
3 changed files with 23 additions and 8 deletions

View File

@@ -2234,18 +2234,29 @@ void av_set_program_name(AVProgram *program, char *provider_name, char *name)
}
}
int ff_new_chapter(AVFormatContext *s, int64_t start, int64_t end, const char *title)
int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title)
{
AVChapter *chapter = av_mallocz(sizeof(AVChapter));
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;
dynarray_add(&s->chapters, &s->num_chapters, chapter);
return 0;
}