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

gkovacs subversion at mplayerhq.hu
Sun Aug 30 00:13:23 CEST 2009


Author: gkovacs
Date: Sun Aug 30 00:13:23 2009
New Revision: 5348

Log:
set durations and nb_streams_list directly in av_playlist_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	Sat Aug 29 23:57:50 2009	(r5347)
+++ concat/libavformat/avplaylist.c	Sun Aug 30 00:13:23 2009	(r5348)
@@ -46,6 +46,7 @@ int av_playlist_insert_item(AVPlaylistCo
     int64_t *durations_tmp;
     unsigned int *nb_streams_list_tmp;
     char **flist_tmp;
+    AVFormatContext *ic;
     flist_tmp = av_realloc(ctx->flist, sizeof(*(ctx->flist)) * (++ctx->pelist_size));
     if (!flist_tmp) {
         av_log(NULL, AV_LOG_ERROR, "av_realloc error for flist in av_playlist_insert_item\n");
@@ -71,8 +72,6 @@ int av_playlist_insert_item(AVPlaylistCo
         ctx->durations[i] = ctx->durations[i - 1];
         ctx->nb_streams_list[i] = ctx->nb_streams_list[i - 1];
     }
-    ctx->durations[pos] = 0;
-    ctx->nb_streams_list[pos] = 0;
     itempath_len = strlen(itempath);
     ctx->flist[pos] = av_malloc(itempath_len + 1);
     if (!ctx->flist[pos]) {
@@ -80,6 +79,19 @@ int av_playlist_insert_item(AVPlaylistCo
         return AVERROR_NOMEM;
     }
     av_strlcpy(ctx->flist[pos], itempath, itempath_len + 1);
+    ic = ff_playlist_alloc_formatcontext(itempath);
+    if (!ic) {
+        av_log(NULL, AV_LOG_ERROR, "failed to allocate and open %s in av_playlist_insert_item\n", itempath);
+        return AVERROR_NOMEM;
+    }
+    if (pos > 0) {
+        ctx->durations[pos] = ic->duration + ctx->durations[pos - 1];
+        ctx->nb_streams_list[pos] = ic->nb_streams + ctx->nb_streams_list[pos - 1];
+    } else {
+        ctx->durations[pos] = ic->duration;
+        ctx->nb_streams_list[pos] = ic->nb_streams;
+    }
+    av_close_input_file(ic);
     return 0;
 }
 

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Sat Aug 29 23:57:50 2009	(r5347)
+++ concat/libavformat/playlist.c	Sun Aug 30 00:13:23 2009	(r5348)
@@ -83,13 +83,6 @@ int ff_playlist_populate_context(AVPlayl
     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 (pe_curidx > 0) {
-        ctx->durations[pe_curidx] = ctx->durations[pe_curidx - 1] + ctx->formatcontext_list[pe_curidx]->duration;
-        ctx->nb_streams_list[pe_curidx] = ctx->nb_streams_list[pe_curidx - 1] + ctx->formatcontext_list[pe_curidx]->nb_streams;
-    } else {
-        ctx->durations[pe_curidx] = ctx->formatcontext_list[pe_curidx]->duration;
-        ctx->nb_streams_list[pe_curidx] = ctx->formatcontext_list[pe_curidx]->nb_streams;
-    }
     return 0;
 }
 


More information about the FFmpeg-soc mailing list