[vlc-devel] [PATCH] packetizer: h264: handle and do discontinuity signaling

Francois Cartegnie fcvlcdev at free.fr
Sat Mar 7 15:18:34 CET 2015


Should address the artifacts on seek problems, assuming the demuxer
correctly sets the discontinuity flag.

---
 modules/packetizer/h264.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 7fcb69c..e140ff2 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -93,6 +93,7 @@ struct decoder_sys_t
 
     /* */
     bool    b_slice;
+    bool    b_discontinuity;
     block_t *p_frame;
     bool    b_frame_sps;
     bool    b_frame_pps;
@@ -207,6 +208,7 @@ static int Open( vlc_object_t *p_this )
                      PacketizeReset, PacketizeParse, PacketizeValidate, p_dec );
 
     p_sys->b_slice = false;
+    p_sys->b_discontinuity = true;
     p_sys->p_frame = NULL;
     p_sys->b_frame_sps = false;
     p_sys->b_frame_pps = false;
@@ -507,12 +509,18 @@ static void PacketizeReset( void *p_private, bool b_broken )
     if( b_broken )
     {
         if( p_sys->p_frame )
-            block_ChainRelease( p_sys->p_frame );
-        p_sys->p_frame = NULL;
+        {
+            if( p_sys->p_frame->p_next )
+                block_ChainRelease( p_sys->p_frame->p_next );
+            p_sys->p_frame->p_next = NULL;
+            p_sys->p_frame->i_buffer = 0;
+            p_sys->p_frame->i_flags = BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED;
+        }
         p_sys->b_frame_sps = false;
         p_sys->b_frame_pps = false;
         p_sys->slice.i_frame_type = 0;
         p_sys->b_slice = false;
+        p_sys->b_discontinuity = true;
     }
     p_sys->i_frame_pts = VLC_TS_INVALID;
     p_sys->i_frame_dts = VLC_TS_INVALID;
@@ -529,8 +537,15 @@ static block_t *PacketizeParse( void *p_private, bool *pb_ts_used, block_t *p_bl
 }
 static int PacketizeValidate( void *p_private, block_t *p_au )
 {
-    VLC_UNUSED(p_private);
-    VLC_UNUSED(p_au);
+    decoder_t *p_dec = p_private;
+
+    if( p_dec->p_sys->b_discontinuity && (p_au->i_flags & BLOCK_FLAG_TYPE_MASK) )
+    {
+        if ( (p_au->i_flags & (BLOCK_FLAG_TYPE_I|BLOCK_FLAG_PREROLL) ) == 0 )
+            return VLC_EGENERIC;
+        p_dec->p_sys->b_discontinuity = false;
+    }
+
     return VLC_SUCCESS;
 }
 
-- 
2.1.0




More information about the vlc-devel mailing list