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

gkovacs subversion at mplayerhq.hu
Wed Aug 26 07:35:18 CEST 2009


Author: gkovacs
Date: Wed Aug 26 07:35:17 2009
New Revision: 5286

Log:
switched to summed nb_streams list for improved performance

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

Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c	Wed Aug 26 04:40:35 2009	(r5285)
+++ concat/libavformat/avplaylist.c	Wed Aug 26 07:35:17 2009	(r5286)
@@ -175,11 +175,13 @@ int av_playlist_stream_index_from_time(A
 
 int av_playlist_localstidx_from_streamidx(AVPlaylistContext *ctx, int stream_index)
 {
-    int i, total;
-    i = total = 0;
-    while (stream_index >= total)
-        total += ctx->nb_streams_list[i++];
-    return stream_index - (total - ctx->nb_streams_list[i-1]);
+    int i, cur, prev;
+    cur = prev = 0;
+    for (i = 0; stream_index >= cur; ++i) {
+        prev = cur;
+        cur = ctx->nb_streams_list[i];
+    }
+    return stream_index - prev;
 }
 
 int av_playlist_streams_offset_from_playidx(AVPlaylistContext *ctx, int playidx)
@@ -187,6 +189,6 @@ int av_playlist_streams_offset_from_play
     int i, total;
     i = total = 0;
     while (playidx > i)
-        total += ctx->nb_streams_list[i++];
+        total = ctx->nb_streams_list[i++];
     return total;
 }

Modified: concat/libavformat/avplaylist.h
==============================================================================
--- concat/libavformat/avplaylist.h	Wed Aug 26 04:40:35 2009	(r5285)
+++ concat/libavformat/avplaylist.h	Wed Aug 26 07:35:17 2009	(r5286)
@@ -45,7 +45,7 @@ typedef struct AVPlaylistContext {
     int pelist_size;                       /**< Number of playlist elements stored in formatcontext_list */
     int pe_curidx;                         /**< Index of the AVFormatContext in formatcontext_list that packets are being read from */
     int64_t *durations;                    /**< Sum of previous durations, in AV_TIME_BASE units, for each playlist item */
-    int *nb_streams_list;                  /**< List of the number of streams in each playlist item*/
+    int *nb_streams_list;                  /**< Sum of previous number of streams in each playlist item*/
     AVFormatContext *master_formatcontext; /**< Parent AVFormatContext of which priv_data is this playlist. NULL if playlist is used standalone. */
 } AVPlaylistContext;
 

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Wed Aug 26 04:40:35 2009	(r5285)
+++ concat/libavformat/playlist.c	Wed Aug 26 07:35:17 2009	(r5286)
@@ -82,11 +82,13 @@ 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;
-    ctx->nb_streams_list[pe_curidx] = ctx->formatcontext_list[pe_curidx]->nb_streams;
-    if (pe_curidx > 0)
+    if (pe_curidx > 0) {
         ctx->durations[pe_curidx] = ctx->durations[pe_curidx - 1] + ctx->formatcontext_list[pe_curidx]->duration;
-    else
+        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] = 0;
+        ctx->nb_streams_list[pe_curidx] = ctx->formatcontext_list[pe_curidx]->nb_streams;
+    }
     return 0;
 }
 


More information about the FFmpeg-soc mailing list