[vlc-commits] demux: mpgv: properly flush packetizer

Francois Cartegnie git at videolan.org
Fri Feb 17 12:00:20 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 17 11:55:51 2017 +0100| [88b19cd6995cbdfc30770660c38260dda6e9edec] | committer: Francois Cartegnie

demux: mpgv: properly flush packetizer

was always losing last frame(s)

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

 modules/demux/mpeg/mpgv.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/modules/demux/mpeg/mpgv.c b/modules/demux/mpeg/mpgv.c
index a8c534d..b6805d8 100644
--- a/modules/demux/mpeg/mpgv.c
+++ b/modules/demux/mpeg/mpgv.c
@@ -144,24 +144,21 @@ static int Demux( demux_t *p_demux )
 {
     demux_sys_t  *p_sys = p_demux->p_sys;
     block_t *p_block_in, *p_block_out;
+    bool b_eof = false;
 
     if( ( p_block_in = vlc_stream_Block( p_demux->s, MPGV_PACKET_SIZE ) ) == NULL )
     {
-        return 0;
+        b_eof = true;
     }
 
-    if( p_sys->b_start )
+    if( p_block_in )
     {
         p_block_in->i_pts =
-        p_block_in->i_dts = VLC_TS_0;
-    }
-    else
-    {
-        p_block_in->i_pts =
-        p_block_in->i_dts = VLC_TS_INVALID;
+        p_block_in->i_dts = ( p_sys->b_start ) ? VLC_TS_0 : VLC_TS_INVALID;
     }
 
-    while( (p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer, &p_block_in )) )
+    while( (p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer,
+                                                             p_block_in ? &p_block_in : NULL )) )
     {
         p_sys->b_start = false;
 
@@ -177,7 +174,7 @@ static int Demux( demux_t *p_demux )
             p_block_out = p_next;
         }
     }
-    return 1;
+    return (b_eof) ? VLC_DEMUXER_EOF : VLC_DEMUXER_SUCCESS;
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list