diff utils.c @ 3314:724f338005d4 libavformat

add support for chapters definition in lavf patch by Anton Khirnov wyskas _at_ gmail _dot_ com
author aurel
date Thu, 22 May 2008 22:00:21 +0000
parents 6f61c3b36632
children 841f0bc7857c
line wrap: on
line diff
--- a/utils.c	Thu May 22 17:16:12 2008 +0000
+++ b/utils.c	Thu May 22 22:00:21 2008 +0000
@@ -2148,6 +2148,11 @@
     av_freep(&s->programs);
     flush_packet_queue(s);
     av_freep(&s->priv_data);
+    while(s->num_chapters--) {
+        av_free(s->chapters[s->num_chapters]->title);
+        av_free(s->chapters[s->num_chapters]);
+    }
+    av_freep(&s->chapters);
     av_free(s);
 }
 
@@ -2229,6 +2234,19 @@
     }
 }
 
+int ff_new_chapter(AVFormatContext *s, int64_t start, int64_t end, const char *title)
+{
+    AVChapter *chapter = av_mallocz(sizeof(AVChapter));
+    if(!chapter)
+        return AVERROR(ENOMEM);
+    chapter->title = av_strdup(title);
+    chapter->start = start;
+    chapter->end = end;
+
+    dynarray_add(&s->chapters, &s->num_chapters, chapter);
+
+    return 0;
+}
 
 /************************************************************/
 /* output media file */