]> git.sesse.net Git - vlc/commitdiff
stream_filter: smooth: minor optimization
authorFrédéric Yhuel <yhuelf@gmail.com>
Sun, 30 Nov 2014 20:17:41 +0000 (21:17 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 1 Dec 2014 10:08:56 +0000 (11:08 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/stream_filter/smooth/smooth.h
modules/stream_filter/smooth/utils.c

index 06f72360c181cef1d195e99ebf2bf107f3c29b0c..1abeb7af6e562ea3cec187618635f94325de64ac 100644 (file)
@@ -93,6 +93,7 @@ typedef struct sms_stream_s
     int            type;
     quality_level_t *current_qlvl; /* current quality level for Download() */
     uint64_t       rgi_bw[SMS_BW_SHORTSTATS]; /* Measured bandwidths of the N last chunks */
+    int            rgi_tidx;       /* tail index of rgi_bw */
     uint64_t       i_obw;          /* Overwall bandwidth average */
     unsigned int   i_obw_samples;  /* used to compute overall incrementally */
 } sms_stream_t;
index 5ac45da9b1c3334fd53c9f6d318b704c6ff5fc17..18ad13d59084316b39fadf9e7664811af4b24631 100644 (file)
@@ -170,9 +170,8 @@ void bw_stats_put( sms_stream_t *sms, const uint64_t bw )
     }
     else
     {
-        memmove( sms->rgi_bw, &sms->rgi_bw[1],
-                sizeof(sms->rgi_bw[0]) * (SMS_BW_SHORTSTATS - 1) );
-        sms->rgi_bw[SMS_BW_SHORTSTATS - 1] = bw;
+        sms->rgi_tidx = (sms->rgi_tidx + 1) % SMS_BW_SHORTSTATS;
+        sms->rgi_bw[sms->rgi_tidx] = bw;
     }
 }