[SCM] libav/experimental: Make ff_new_chapter() return AVChapter instead of int so its consistant with av_new_program() and its simpler to set other fields in AVChapter which arent set by ff_new_chapter().

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:21:07 UTC 2013


The following commit has been merged in the experimental branch:
commit 5c37f43a0d2131f292853f0d184acf4ec8dfb99f
Author: Michael Niedermayer <michaelni at gmx.at>
Date:   Fri May 23 13:14:11 2008 +0000

    Make ff_new_chapter() return AVChapter instead of int so its consistant with
    av_new_program() and its simpler to set other fields in AVChapter which arent
    set by ff_new_chapter().
    
    Originally committed as revision 13262 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4888105..03902d0 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -764,8 +764,10 @@ AVProgram *av_new_program(AVFormatContext *s, int id);
  * @param start chapter start time in AV_TIME_BASE units
  * @param end chapter end time in AV_TIME_BASE units
  * @param title chapter title
+ *
+ * @return AVChapter or NULL if error.
  */
-int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title);
+AVChapter *ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title);
 
 /**
  * Set the pts for a given stream.
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 7f9352e..7cbf705 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2257,7 +2257,8 @@ matroska_parse_chapters(AVFormatContext *s)
                         start = start * AV_TIME_BASE / 1000000000;
                         if (end != AV_NOPTS_VALUE)
                             end = end * AV_TIME_BASE / 1000000000;
-                        res = ff_new_chapter(s, uid, start, end, title);
+                        if(!ff_new_chapter(s, uid, start, end, title))
+                            res= AVERROR(ENOMEM);
                     }
                     av_free(title);
                     break;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5f5909b..73c28e7 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2234,7 +2234,7 @@ void av_set_program_name(AVProgram *program, char *provider_name, char *name)
     }
 }
 
-int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title)
+AVChapter *ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title)
 {
     AVChapter *chapter = NULL;
     int i;
@@ -2246,7 +2246,7 @@ int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const
     if(!chapter){
         chapter= av_mallocz(sizeof(AVChapter));
         if(!chapter)
-            return AVERROR(ENOMEM);
+            return NULL;
         dynarray_add(&s->chapters, &s->nb_chapters, chapter);
     }
     if(chapter->title)
@@ -2256,7 +2256,7 @@ int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const
     chapter->start = start;
     chapter->end   = end;
 
-    return 0;
+    return chapter;
 }
 
 /************************************************************/

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list