summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 478029b35a..1922f68397 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -272,6 +272,7 @@ struct demux_internal {
// Cached state.
int64_t stream_size;
int64_t last_speed_query;
+ double speed_query_prev_sample;
uint64_t bytes_per_second;
int64_t next_cache_update;
@@ -4108,7 +4109,10 @@ static void update_cache(struct demux_internal *in)
uint64_t bytes = in->cache_unbuffered_read_bytes;
in->cache_unbuffered_read_bytes = 0;
in->last_speed_query = now;
- in->bytes_per_second = bytes / (diff / (double)MP_SECOND_US);
+ double speed = bytes / (diff / (double)MP_SECOND_US);
+ in->bytes_per_second = 0.5 * in->speed_query_prev_sample +
+ 0.5 * speed;
+ in->speed_query_prev_sample = speed;
}
// The idea is to update as long as there is "activity".
if (in->bytes_per_second)