[FFmpeg-soc] [soc]: r5350 - in concat/libavformat: avplaylist.c playlist.c

gkovacs subversion at mplayerhq.hu
Sun Aug 30 00:22:49 CEST 2009


Author: gkovacs
Date: Sun Aug 30 00:22:49 2009
New Revision: 5350

Log:
resize formatcontext_list in insert_item rather than waiting until populate_context

Modified:
   concat/libavformat/avplaylist.c
   concat/libavformat/playlist.c

Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c	Sun Aug 30 00:14:55 2009	(r5349)
+++ concat/libavformat/avplaylist.c	Sun Aug 30 00:22:49 2009	(r5350)
@@ -45,6 +45,7 @@ int av_playlist_insert_item(AVPlaylistCo
     int i, itempath_len;
     int64_t *durations_tmp;
     unsigned int *nb_streams_list_tmp;
+    AVFormatContext **formatcontext_list_tmp;
     char **flist_tmp;
     AVFormatContext *ic;
     flist_tmp = av_realloc(ctx->flist, sizeof(*(ctx->flist)) * (++ctx->pelist_size));
@@ -67,11 +68,20 @@ int av_playlist_insert_item(AVPlaylistCo
         return AVERROR_NOMEM;
     } else
         ctx->nb_streams_list = nb_streams_list_tmp;
+    formatcontext_list_tmp = av_realloc(ctx->formatcontext_list,
+                                        sizeof(*(ctx->formatcontext_list)) * (ctx->pelist_size));
+    if (!formatcontext_list_tmp) {
+        av_log(NULL, AV_LOG_ERROR, "av_realloc error for formatcontext_list in av_playlist_insert_item\n");
+        return AVERROR_NOMEM;
+    } else
+        ctx->formatcontext_list = formatcontext_list_tmp;
     for (i = ctx->pelist_size; i > pos; --i) {
         ctx->flist[i] = ctx->flist[i - 1];
         ctx->durations[i] = ctx->durations[i - 1];
         ctx->nb_streams_list[i] = ctx->nb_streams_list[i - 1];
+        ctx->formatcontext_list[i] = ctx->formatcontext_list[i - 1];
     }
+    ctx->formatcontext_list[pos] = NULL;
     itempath_len = strlen(itempath);
     ctx->flist[pos] = av_malloc(itempath_len + 1);
     if (!ctx->flist[pos]) {

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Sun Aug 30 00:14:55 2009	(r5349)
+++ concat/libavformat/playlist.c	Sun Aug 30 00:22:49 2009	(r5350)
@@ -71,16 +71,10 @@ AVFormatContext *ff_playlist_alloc_conca
 
 int ff_playlist_populate_context(AVPlaylistContext *ctx, int pe_curidx)
 {
-    AVFormatContext **formatcontext_list_tmp = av_realloc(ctx->formatcontext_list, sizeof(*(ctx->formatcontext_list)) * (pe_curidx+2));
-    if (!formatcontext_list_tmp) {
-        av_log(NULL, AV_LOG_ERROR, "av_realloc error in ff_playlist_populate_context\n");
-        av_free(ctx->formatcontext_list);
-        return AVERROR_NOMEM;
-    } else
-        ctx->formatcontext_list = formatcontext_list_tmp;
-    ctx->formatcontext_list[pe_curidx+1] = NULL;
-    if (!(ctx->formatcontext_list[pe_curidx] = ff_playlist_alloc_formatcontext(ctx->flist[pe_curidx])))
-        return AVERROR_NOFMT;
+    if (!ctx->formatcontext_list[pe_curidx]) {
+        if (!(ctx->formatcontext_list[pe_curidx] = ff_playlist_alloc_formatcontext(ctx->flist[pe_curidx])))
+            return AVERROR_NOFMT;
+    }
     return 0;
 }
 


More information about the FFmpeg-soc mailing list