[vlc-commits] demux: moving_avg: do not use durationless last packet
Francois Cartegnie
git at videolan.org
Mon Jan 13 16:47:05 CET 2020
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Dec 13 09:24:59 2019 +0100| [b8b7f94409cf2f4abdf808abd47cac230625bff8] | committer: Francois Cartegnie
demux: moving_avg: do not use durationless last packet
(cherry picked from commit 0570b0f44a5fb409e1c1785b521d457df048e380)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=b8b7f94409cf2f4abdf808abd47cac230625bff8
---
modules/demux/moving_avg.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/modules/demux/moving_avg.h b/modules/demux/moving_avg.h
index fcd2de2de9..29e2d25fc9 100644
--- a/modules/demux/moving_avg.h
+++ b/modules/demux/moving_avg.h
@@ -79,8 +79,12 @@ static mtime_t mva_get(const struct moving_average_s *m)
if(&m->packets[i % MVA_PACKETS] == min ||
&m->packets[i % MVA_PACKETS] == max)
continue;
- avgdiff += m->packets[i % MVA_PACKETS].diff;
- count++;
+ const mtime_t diff = m->packets[i % MVA_PACKETS].diff;
+ if(diff != 0 || (i+1) < m->i_packet) /* ignore last packet when we have no duration */
+ {
+ avgdiff += diff;
+ count++;
+ }
}
return count ? avgdiff / count : 0;
More information about the vlc-commits
mailing list