[FFmpeg-soc] [soc]: r5231 - concat/libavformat/avplaylist.c

gkovacs subversion at mplayerhq.hu
Mon Aug 24 07:07:38 CEST 2009


Author: gkovacs
Date: Mon Aug 24 07:07:38 2009
New Revision: 5231

Log:
cache results of av_playlist_streams_offset_from_playidx for improved performance on large playlists

Modified:
   concat/libavformat/avplaylist.c

Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c	Mon Aug 24 05:20:43 2009	(r5230)
+++ concat/libavformat/avplaylist.c	Mon Aug 24 07:07:38 2009	(r5231)
@@ -272,10 +272,18 @@ int av_playlist_localstidx_from_streamid
 
 int av_playlist_streams_offset_from_playidx(AVPlaylistContext *ctx, int playidx)
 {
-    int i, total;
+    int i, total, cache_num;
+    static int cache_playidx[STREAM_CACHE_SIZE] = {-1};
+    static int cache_offset[STREAM_CACHE_SIZE] = {-1};
+    for (i = 0; i < STREAM_CACHE_SIZE; ++i) {
+        if (cache_playidx[i] == playidx)
+            return cache_offset[i];
+    }
     i = total = 0;
+    cache_num = playidx % STREAM_CACHE_SIZE;
+    cache_playidx[cache_num] = playidx;
     while (playidx > i)
         total += ctx->nb_streams_list[i++];
-    return total;
+    return (cache_offset[cache_num] = total);
 }
 


More information about the FFmpeg-soc mailing list