Improved BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED handling in packetizers.
authorLaurent Aimar <fenrir@videolan.org>
Wed, 30 May 2007 17:36:36 +0000 (17:36 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 30 May 2007 17:36:36 +0000 (17:36 +0000)
(I do not reset timestamp on purpose, it will at least break demuxer using
packetizer)

modules/codec/a52.c
modules/codec/dts.c
modules/codec/flac.c
modules/codec/mpeg_audio.c
modules/packetizer/h264.c
modules/packetizer/mpeg4audio.c
modules/packetizer/mpeg4video.c
modules/packetizer/mpegvideo.c
modules/packetizer/vc1.c

index bd3d4fd..bbff46e 100644 (file)
@@ -168,16 +168,23 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block ) return NULL;
 
-    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        /* We've just started the stream, wait for the first PTS. */
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+        }
+//        aout_DateSet( &p_sys->end_date, 0 );
         block_Release( *pp_block );
         return NULL;
     }
 
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
     {
-        p_sys->i_state = STATE_NOSYNC;
+        /* We've just started the stream, wait for the first PTS. */
+        block_Release( *pp_block );
+        return NULL;
     }
 
     block_BytestreamPush( &p_sys->bytestream, *pp_block );
index 961fa2d..eef996e 100644 (file)
@@ -170,16 +170,23 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block ) return NULL;
 
-    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        /* We've just started the stream, wait for the first PTS. */
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+        }
+//        aout_DateSet( &p_sys->end_date, 0 );
         block_Release( *pp_block );
         return NULL;
     }
 
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
     {
-        p_sys->i_state = STATE_NOSYNC;
+        /* We've just started the stream, wait for the first PTS. */
+        block_Release( *pp_block );
+        return NULL;
     }
 
     block_BytestreamPush( &p_sys->bytestream, *pp_block );
index cb2a07b..2595108 100644 (file)
@@ -376,6 +376,18 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block ) return NULL;
 
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    {
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+        }
+//        aout_DateSet( &p_sys->end_date, 0 );
+        block_Release( *pp_block );
+        return NULL;
+    }
+
     if( !p_sys->b_stream_info ) ProcessHeader( p_dec );
 
     if( p_sys->stream_info.channels > 6 )
@@ -396,11 +408,6 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
         aout_DateSet( &p_sys->end_date, (*pp_block)->i_pts );
     }
 
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
-    {
-        p_sys->i_state = STATE_NOSYNC;
-    }
-
     block_BytestreamPush( &p_sys->bytestream, *pp_block );
 
     while( 1 )
index 9308b12..a312e73 100644 (file)
@@ -196,17 +196,24 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block ) return NULL;
 
-    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        /* We've just started the stream, wait for the first PTS. */
-        msg_Dbg( p_dec, "waiting for PTS" );
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+        }
+//        aout_DateSet( &p_sys->end_date, 0 );
         block_Release( *pp_block );
         return NULL;
     }
 
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
     {
-        p_sys->i_state = STATE_NOSYNC;
+        /* We've just started the stream, wait for the first PTS. */
+        msg_Dbg( p_dec, "waiting for PTS" );
+        block_Release( *pp_block );
+        return NULL;
     }
 
     block_BytestreamPush( &p_sys->bytestream, *pp_block );
index 0825ae9..5f94b5f 100644 (file)
@@ -313,9 +313,20 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block )
         return NULL;
+
     if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        p_sys->i_state = STATE_NOSYNC;
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+
+            if( p_sys->p_frame )
+                block_ChainRelease( p_sys->p_frame );
+            p_sys->p_frame = NULL;
+            p_sys->slice.i_frame_type = 0;
+            p_sys->b_slice = VLC_FALSE;
+        }
         block_Release( *pp_block );
         return NULL;
     }
index 8aeb39e..24c43f6 100644 (file)
@@ -218,6 +218,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
+        //aout_DateSet( &p_sys->end_date, 0 );
         block_Release( *pp_block );
         return NULL;
     }
@@ -257,15 +258,21 @@ static block_t *ADTSPacketizeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block ) return NULL;
 
-    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        /* We've just started the stream, wait for the first PTS. */
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+        }
+        //aout_DateSet( &p_sys->end_date, 0 );
         block_Release( *pp_block );
         return NULL;
     }
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+
+    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
     {
-        p_sys->i_state = STATE_NOSYNC;
+        /* We've just started the stream, wait for the first PTS. */
         block_Release( *pp_block );
         return NULL;
     }
index c5b3839..3465980 100644 (file)
@@ -224,12 +224,26 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
 
     if( pp_block == NULL || *pp_block == NULL ) return NULL;
 
-    if( (*pp_block)->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        p_sys->i_state = STATE_NOSYNC;
-        if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame );
-        p_sys->p_frame = NULL;
-        p_sys->pp_last = &p_sys->p_frame;
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+
+            if( p_sys->p_frame )
+                block_ChainRelease( p_sys->p_frame );
+            p_sys->p_frame = NULL;
+            p_sys->pp_last = &p_sys->p_frame;
+        }
+//        p_sys->i_interpolated_pts =
+//        p_sys->i_interpolated_dts =
+//        p_sys->i_last_ref_pts =
+//        p_sys->i_last_time_ref =
+//        p_sys->i_time_ref =
+//        p_sys->i_last_time =
+//        p_sys->i_last_timeincr = 0;
+
         block_Release( *pp_block );
         return NULL;
     }
index 425ccab..0ab8834 100644 (file)
@@ -115,7 +115,6 @@ struct decoder_sys_t
     int i_progressive_frame;
 
     mtime_t i_interpolated_dts;
-    mtime_t i_old_duration;
     mtime_t i_last_ref_pts;
     vlc_bool_t b_second_field;
 
@@ -183,7 +182,6 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_inited = 0;
 
     p_sys->i_interpolated_dts = 0;
-    p_sys->i_old_duration = 0;
     p_sys->i_last_ref_pts = 0;
     p_sys->b_second_field = 0;
 
@@ -236,19 +234,28 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
         return NULL;
     }
 
-    if( (*pp_block)->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        p_sys->i_state = STATE_NOSYNC;
-        p_sys->b_discontinuity = VLC_TRUE;
-        if( p_sys->p_frame )
-            block_ChainRelease( p_sys->p_frame );
-        p_sys->p_frame = NULL;
-        p_sys->pp_last = &p_sys->p_frame;
-        p_sys->b_frame_slice = VLC_FALSE;
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+
+            p_sys->b_discontinuity = VLC_TRUE;
+            if( p_sys->p_frame )
+                block_ChainRelease( p_sys->p_frame );
+            p_sys->p_frame = NULL;
+            p_sys->pp_last = &p_sys->p_frame;
+            p_sys->b_frame_slice = VLC_FALSE;
+        }
+//        p_sys->i_interpolated_dts = 
+//        p_sys->i_last_ref_pts = 0;
+
         block_Release( *pp_block );
         return NULL;
     }
 
+
     block_BytestreamPush( &p_sys->bytestream, *pp_block );
 
     while( 1 )
index 4511ef1..f2c499c 100644 (file)
@@ -194,13 +194,20 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
     if( pp_block == NULL || *pp_block == NULL )
         return NULL;
 
-    if( (*pp_block)->i_flags & (BLOCK_FLAG_CORRUPTED|BLOCK_FLAG_DISCONTINUITY) )
+    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        p_sys->i_state = STATE_NOSYNC;
-        if( p_sys->p_frame )
-            block_ChainRelease( p_sys->p_frame );
-        p_sys->p_frame = NULL;
-        p_sys->pp_last = &p_sys->p_frame;
+        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamFlush( &p_sys->bytestream );
+
+            if( p_sys->p_frame )
+                block_ChainRelease( p_sys->p_frame );
+            p_sys->p_frame = NULL;
+            p_sys->pp_last = &p_sys->p_frame;
+            p_sys->b_frame = VLC_FALSE;
+        }
+//        p_sys->i_interpolated_dts = 0;
         block_Release( *pp_block );
         return NULL;
     }