[vlc-commits] demux: moving_avg: do not use durationless last packet

Francois Cartegnie git at videolan.org
Wed Dec 18 20:59:30 CET 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Dec 13 09:24:59 2019 +0100| [0570b0f44a5fb409e1c1785b521d457df048e380] | committer: Francois Cartegnie

demux: moving_avg: do not use durationless last packet

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0570b0f44a5fb409e1c1785b521d457df048e380
---

 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 cb4cf9e62b..81bc8dc387 100644
--- a/modules/demux/moving_avg.h
+++ b/modules/demux/moving_avg.h
@@ -79,8 +79,12 @@ static vlc_tick_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 vlc_tick_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