codec: don't drop blocks marked BLOCK_FLAG_DISCONTINUITY
authorJean-Paul Saman <jpsaman@videolan.org>
Sat, 17 Oct 2015 07:51:16 +0000 (10:51 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Thu, 5 Nov 2015 04:46:55 +0000 (06:46 +0200)
40 files changed:
modules/codec/a52.c
modules/codec/adpcm.c
modules/codec/aes3.c
modules/codec/araw.c
modules/codec/arib/aribsub.c
modules/codec/avcodec/audio.c
modules/codec/avcodec/subtitle.c
modules/codec/avcodec/video.c
modules/codec/bpg.c
modules/codec/cdg.c
modules/codec/crystalhd.c
modules/codec/cvdsub.c
modules/codec/ddummy.c
modules/codec/dts.c
modules/codec/dvbsub.c
modules/codec/faad.c
modules/codec/flac.c
modules/codec/fluidsynth.c
modules/codec/g711.c
modules/codec/jpeg.c
modules/codec/kate.c
modules/codec/libass.c
modules/codec/lpcm.c
modules/codec/mft.c
modules/codec/mpeg_audio.c
modules/codec/mpg123.c
modules/codec/omxil/omxil.c
modules/codec/opus.c
modules/codec/rawvideo.c
modules/codec/schroedinger.c
modules/codec/speex.c
modules/codec/spudec/spudec.c
modules/codec/stl.c
modules/codec/subsdec.c
modules/codec/substtml.c
modules/codec/subsusf.c
modules/codec/theora.c
modules/codec/uleaddvaudio.c
modules/codec/vorbis.c
modules/codec/wmafixed/wma.c

index 6a9d9ba..7450d6b 100644 (file)
@@ -174,26 +174,24 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block ) return NULL;
 
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_CORRUPTED) )
+    if( (*pp_block)->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) )
     {
-        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+        date_Set( &p_sys->end_date, 0 );
+        if( (*pp_block)->i_flags & BLOCK_FLAG_CORRUPTED )
         {
             p_sys->i_state = STATE_NOSYNC;
             block_BytestreamEmpty( &p_sys->bytestream );
+            block_Release( *pp_block );
+            *pp_block = NULL;
+            return NULL;
         }
-        date_Set( &p_sys->end_date, 0 );
-        block_Release( *pp_block );
-        return NULL;
-    }
-    if( (*pp_block)->i_flags & BLOCK_FLAG_DISCONTINUITY )
-    {
-        date_Set( &p_sys->end_date, 0 );
     }
 
     if( !date_Get( &p_sys->end_date ) && (*pp_block)->i_pts <= VLC_TS_INVALID)
     {
         /* We've just started the stream, wait for the first PTS. */
         block_Release( *pp_block );
+        *pp_block = NULL;
         return NULL;
     }
 
index e655c45..fd72308 100644 (file)
@@ -276,6 +276,16 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     if( !pp_block || !*pp_block ) return NULL;
 
     p_block = *pp_block;
+    *pp_block = NULL; /* So the packet doesn't get re-sent */
+
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
 
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
index 61feef4..e6a8795 100644 (file)
@@ -310,6 +310,15 @@ static block_t *Parse( decoder_t *p_dec, int *pi_frame_length, int *pi_bits,
     p_block = *pp_block;
     *pp_block = NULL; /* So the packet doesn't get re-sent */
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
+
     /* Date management */
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
@@ -371,4 +380,3 @@ static block_t *Parse( decoder_t *p_dec, int *pi_frame_length, int *pi_bits,
     *pi_bits = i_bits;
     return p_block;
 }
-
index 0746a5e..54db33b 100644 (file)
@@ -314,6 +314,12 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         return NULL;
     *pp_block = NULL;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        goto skip;
+
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
+
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
index d22a474..84f54d3 100644 (file)
@@ -173,6 +173,12 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     }
     p_block = *pp_block;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
     arib_parser_t *p_parser = arib_get_parser( p_sys->p_arib_instance );
     arib_decoder_t *p_decoder = arib_get_decoder( p_sys->p_arib_instance );
     if ( p_parser && p_decoder )
index 841060b..2a5b5de 100644 (file)
@@ -261,7 +261,7 @@ static block_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
     if( p_sys->b_delayed_open )
         goto end;
 
-    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
     {
         avcodec_flush_buffers( ctx );
         date_Set( &p_sys->end_date, VLC_TS_INVALID );
@@ -272,9 +272,9 @@ static block_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
 
         goto end;
     }
+
     if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
     {
-        avcodec_flush_buffers( ctx );
         date_Set( &p_sys->end_date, VLC_TS_INVALID );
     }
 
index c867e8a..0bdbb5d 100644 (file)
@@ -124,13 +124,13 @@ static subpicture_t *DecodeSubtitle(decoder_t *dec, block_t **block_ptr)
 
     block_t *block = *block_ptr;
 
-    if (block->i_flags & (BLOCK_FLAG_CORRUPTED)) {
-        block_Release(block);
-        avcodec_flush_buffers(sys->p_context);
-        return NULL;
+    if (block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED)) {
+        if (block->i_flags & BLOCK_FLAG_CORRUPTED) {
+            avcodec_flush_buffers(sys->p_context);
+            block_Release(block);
+            return NULL;
+        }
     }
-    if (block->i_flags & BLOCK_FLAG_DISCONTINUITY)
-        avcodec_flush_buffers(sys->p_context);
 
     if (block->i_buffer <= 0) {
         block_Release(block);
index bd65a5e..8c11d94 100644 (file)
@@ -531,12 +531,13 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             p_sys->i_pts = VLC_TS_INVALID; /* To make sure we recover properly */
 
             p_sys->i_late_frames = 0;
-
+#if 0
+            /* NOTE: data is good only the timeline changed so do not flush decoder */
             post_mt( p_sys );
             if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
                 avcodec_flush_buffers( p_context );
             wait_mt( p_sys );
-
+#endif
             if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
             {
                 block_Release( p_block );
index 255ab4a..a39b0ce 100644 (file)
@@ -96,18 +96,13 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     BPGImageInfo img_info;
 
     if( !pp_block || !*pp_block )
-    {
         return NULL;
-    }
 
     p_block = *pp_block;
+    *pp_block = NULL;
 
     if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
-    {
-        block_Release(p_block);
-        *pp_block = NULL;
-        return NULL;
-    }
+        goto error;
 
     /* Decode picture */
 
@@ -163,15 +158,10 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
 
     block_Release( p_block );
-    *pp_block = NULL;
-
     return p_pic;
 
 error:
-
     block_Release( p_block );
-    *pp_block = NULL;
-
     return NULL;
 }
 
index 7bcaad9..98c07c8 100644 (file)
@@ -143,7 +143,7 @@ static picture_t *Decode( decoder_t *p_dec, block_t **pp_block )
         return NULL;
     p_block = *pp_block;
 
-    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
     {
         p_sys->i_packet = 0;
         goto exit;
@@ -170,7 +170,8 @@ static picture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     }
 
 exit:
-    block_Release( p_block ); *pp_block = NULL;
+    block_Release( p_block );
+    *pp_block = NULL;
     return p_pic;
 }
 
index 2cc43fb..16f2aec 100644 (file)
@@ -443,10 +443,9 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     if( p_block )
     {
-        if( ( p_block->i_flags&(BLOCK_FLAG_CORRUPTED) ) == 0 )
+        if( ( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) ) == 0 )
         {
             /* Valid input block, so we can send to HW to decode */
-
             BC_STATUS status = BC_FUNC_PSYS(DtsProcInput)( p_sys->bcm_handle,
                                             p_block->p_buffer,
                                             p_block->i_buffer,
index 21098b1..01fac3d 100644 (file)
@@ -169,6 +169,12 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
     if( !(p_spu = Reassemble( p_dec, p_block )) ) return NULL;
 
     /* Parse and decode */
index b6d37b9..2e88bbc 100644 (file)
@@ -127,6 +127,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block ) return NULL;
     p_block = *pp_block;
+    *pp_block = NULL;
 
     if( stream != NULL
      && p_block->i_buffer > 0
index ebe5414..b90eba3 100644 (file)
@@ -174,16 +174,18 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     if( !pp_block || !*pp_block )
         return NULL;
 
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_CORRUPTED) )
+    if( (*pp_block)->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        p_sys->i_state = STATE_NOSYNC;
-        block_BytestreamEmpty( &p_sys->bytestream );
         date_Set( &p_sys->end_date, 0 );
-        block_Release( *pp_block );
-        return NULL;
+        if( (*pp_block)->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            p_sys->i_state = STATE_NOSYNC;
+            block_BytestreamEmpty( &p_sys->bytestream );
+            block_Release( *pp_block );
+            *pp_block = NULL;
+            return NULL;
+        }
     }
-    if( (*pp_block)->i_flags & BLOCK_FLAG_DISCONTINUITY )
-        date_Set( &p_sys->end_date, 0 );
 
     if( !date_Get( &p_sys->end_date ) && (*pp_block)->i_pts <= VLC_TS_INVALID )
     {
index cf2ebfa..e73c9d5 100644 (file)
@@ -402,9 +402,19 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL;
 
+    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) )
+    {
+        p_sys->i_pts = VLC_TS_INVALID;
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release( p_block );
+            return NULL;
+        }
+    }
+
     /* configure for SD res in case DDS is not present */
     /* a change of PTS is a good indication we must get a new DDS */
-    if (p_sys->i_pts != p_block->i_pts)
+    if( p_sys->i_pts != p_block->i_pts )
         default_dds_init( p_dec );
 
     p_sys->i_pts = p_block->i_pts;
index 944c376..bf05018 100644 (file)
@@ -209,11 +209,16 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     if( !pp_block || !*pp_block ) return NULL;
 
     p_block = *pp_block;
+    *pp_block = NULL;
 
-    if( p_block->i_flags&(BLOCK_FLAG_CORRUPTED) )
+    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) )
     {
-        block_Release( p_block );
-        return NULL;
+        date_Set( &p_sys->date, 0 );
+        if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
+        {
+            block_Release( p_block );
+            return NULL;
+        }
     }
 
     /* Remove ADTS header if we have decoder specific config */
index 8ed2b5c..9a7d1d1 100644 (file)
@@ -500,10 +500,15 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( !pp_block || !*pp_block )
         return NULL;
-    if( (*pp_block)->i_flags&(BLOCK_FLAG_CORRUPTED) )
+    if( (*pp_block)->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) )
     {
-        block_Release( *pp_block );
-        return NULL;
+        date_Set( &p_sys->end_date, 0 );
+        if( (*pp_block)->i_flags & BLOCK_FLAG_CORRUPTED )
+        {
+            block_Release( *pp_block );
+            *pp_block = NULL;
+            return NULL;
+        }
     }
 
     if( !p_sys->b_stream_info )
index 43a91f2..65cb208 100644 (file)
@@ -208,12 +208,17 @@ static block_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
 
     if (p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED))
     {
-        date_Set (&p_sys->end_date, 0);
+        date_Set (&p_sys->end_date, VLC_TS_INVALID);
         //fluid_synth_system_reset (p_sys->synth);
         fluid_synth_program_reset (p_sys->synth);
         for (unsigned channel = 0; channel < 16; channel++)
             for (unsigned note = 0; note < 128; note++)
                 fluid_synth_noteoff (p_sys->synth, channel, note);
+        if (p_block->i_flags & BLOCK_FLAG_CORRUPTED)
+        {
+            block_Release(p_block);
+            return NULL;
+        }
     }
 
     if (p_block->i_pts > VLC_TS_INVALID && !date_Get (&p_sys->end_date))
index 0473c73..c5540b1 100644 (file)
@@ -219,9 +219,19 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     if( pp_block == NULL )
         return NULL;
     block_t *p_block = *pp_block;
+    *pp_block = NULL;
     if( p_block == NULL )
         return NULL;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block);
+        return NULL;
+    }
+
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
+
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
index c9053ae..fdb91c7 100644 (file)
@@ -198,11 +198,11 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
     }
 
     p_block = *pp_block;
+    *pp_block = NULL;
 
     if (p_block->i_flags & BLOCK_FLAG_CORRUPTED )
     {
         block_Release(p_block);
-        *pp_block = NULL;
         return NULL;
     }
 
@@ -261,8 +261,6 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)
     p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
 
     block_Release(p_block);
-    *pp_block = NULL;
-
     return p_pic;
 
 error:
@@ -271,8 +269,6 @@ error:
     free(p_row_pointers);
 
     block_Release(p_block);
-    *pp_block = NULL;
-
     return NULL;
 }
 
index eea28b3..e3bb494 100644 (file)
@@ -468,6 +468,7 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         return NULL;
 
     p_block = *pp_block;
+    *pp_block = NULL;
 
     if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
index dd738a5..3d08717 100644 (file)
@@ -306,13 +306,14 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         return NULL;
 
     p_block = *pp_block;
-    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
+    *pp_block = NULL;
+
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
     {
         p_sys->i_max_stop = VLC_TS_INVALID;
         block_Release( p_block );
         return NULL;
     }
-    *pp_block = NULL;
 
     if( p_block->i_buffer == 0 || p_block->p_buffer[0] == '\0' )
     {
index a9f6a4b..0c0ba35 100644 (file)
@@ -327,6 +327,15 @@ static block_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL; /* So the packet doesn't get re-sent */
 
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
+
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
     /* Date management */
     if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
index e95c4ca..797018c 100644 (file)
@@ -780,6 +780,7 @@ static void *DecodeSync(decoder_t *p_dec, block_t **pp_block)
     if (p_block->i_flags & (BLOCK_FLAG_CORRUPTED))
     {
         block_Release(p_block);
+        *pp_block = NULL;
         return NULL;
     }
 
@@ -802,6 +803,7 @@ error:
     msg_Err(p_dec, "Error in DecodeSync()");
     if (p_block)
         block_Release(p_block);
+    *pp_block = NULL;
     return NULL;
 }
 
@@ -842,6 +844,7 @@ static void *DecodeAsync(decoder_t *p_dec, block_t **pp_block)
     if (p_block->i_flags & (BLOCK_FLAG_CORRUPTED))
     {
         block_Release(p_block);
+        *pp_block = NULL;
         return NULL;
     }
 
@@ -896,6 +899,7 @@ static void *DecodeAsync(decoder_t *p_dec, block_t **pp_block)
 error:
     msg_Err(p_dec, "Error in DecodeAsync()");
     block_Release(p_block);
+    *pp_block = NULL;
     return NULL;
 }
 
index 9956091..12aa704 100644 (file)
@@ -200,18 +200,19 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     block_t *p_block = pp_block ? *pp_block : NULL;
 
-    if (p_block) {
-        if( p_block->i_flags&(BLOCK_FLAG_CORRUPTED) )
-        {
-            p_sys->i_state = STATE_NOSYNC;
-            block_BytestreamEmpty( &p_sys->bytestream );
-            date_Set( &p_sys->end_date, 0 );
-            block_Release( p_block );
-            return NULL;
-        }
-        if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+    if (p_block)
+    {
+        if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
         {
             date_Set( &p_sys->end_date, 0 );
+            if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+            {
+                p_sys->i_state = STATE_NOSYNC;
+                block_BytestreamEmpty( &p_sys->bytestream );
+                block_Release( p_block );
+                *pp_block = NULL;
+                return NULL;
+            }
             p_sys->b_discontinuity = true;
         }
 
index aefbe6d..a7e1ffe 100644 (file)
@@ -93,10 +93,11 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         goto error;
     }
 
-    if( p_block->i_flags & ( BLOCK_FLAG_CORRUPTED ) )
+    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) )
     {
         date_Set( &p_sys->end_date, 0 );
-        goto error;
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+            goto error;
     }
 
     /* Feed mpg123 with raw data */
index 3fef1c8..979a151 100644 (file)
@@ -1539,7 +1539,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         return 0;
     }
 
-    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
     {
         block_Release( p_block );
         if(!p_sys->in.b_flushed)
@@ -1657,7 +1657,7 @@ block_t *DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
         return 0;
     }
 
-    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
     {
         block_Release( p_block );
         date_Set( &p_sys->end_date, 0 );
index 1e93cd4..044ce0d 100644 (file)
@@ -367,9 +367,22 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     block_t *p_block = *pp_block;
+    *pp_block = NULL; /* To avoid being fed the same packet again */
+
+    if( !p_block )
+        return NULL;
+
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
 
     /* Date management */
-    if( p_block && p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
@@ -378,15 +391,10 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     if( !date_Get( &p_sys->end_date ) )
     {
         /* We've just started the stream, wait for the first PTS. */
-        if( p_block ) block_Release( p_block );
+        block_Release( p_block );
         return NULL;
     }
 
-    *pp_block = NULL; /* To avoid being fed the same packet again */
-
-    if( !p_block )
-        return NULL;
-
     block_t *p_aout_buffer = DecodePacket( p_dec, p_oggpacket,
                                            p_block->i_nb_samples,
                                            (int)p_block->i_length );
index 63fd39d..1abd66f 100644 (file)
@@ -143,6 +143,9 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     block_t *p_block = *pp_block;
 
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->pts, p_block->i_dts );
+
     if( p_block->i_pts <= VLC_TS_INVALID && p_block->i_dts <= VLC_TS_INVALID &&
         !date_Get( &p_sys->pts ) )
     {
index 977afca..cf0932b 100644 (file)
@@ -760,7 +760,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
         /* reset the decoder when seeking as the decode in progress is invalid */
         /* discard the block as it is just a null magic block */
-        if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY ) {
+        if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) ) {
             schro_decoder_reset( p_sys->p_schro );
 
             p_sys->i_lastpts = VLC_TS_INVALID;
index e21c7fa..2d35527 100644 (file)
@@ -534,6 +534,9 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     decoder_sys_t *p_sys = p_dec->p_sys;
     block_t *p_block = *pp_block;
 
+    if( p_block && p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
+
     /* Date management */
     if( p_block && p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
index 1ec6243..4179e95 100644 (file)
@@ -207,6 +207,12 @@ static block_t *Reassemble( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
     if( p_sys->i_spu_size <= 0 &&
         ( p_block->i_pts <= VLC_TS_INVALID || p_block->i_buffer < 4 ) )
     {
index 4bfa25e..fee7b53 100644 (file)
@@ -112,7 +112,8 @@ static subpicture_t *Decode(decoder_t *dec, block_t **block)
 
     subpicture_t *sub = NULL;
 
-    block_t *b = *block; *block = NULL;
+    block_t *b = *block;
+    *block = NULL;
     if (b->i_flags & (BLOCK_FLAG_CORRUPTED))
         goto exit;
     if (b->i_buffer < 128)
index c005192..3d5d7b4 100644 (file)
@@ -329,7 +329,9 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         return NULL;
 
     p_block = *pp_block;
-    if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
+    *pp_block = NULL;
+
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
     {
         block_Release( p_block );
         return NULL;
@@ -338,8 +340,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     p_spu = ParseText( p_dec, p_block );
 
     block_Release( p_block );
-    *pp_block = NULL;
-
     return p_spu;
 }
 
@@ -366,6 +366,9 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     subpicture_t *p_spu = NULL;
     char *psz_subtitle = NULL;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        return NULL;
+
     /* We cannot display a subpicture with no date */
     if( p_block->i_pts <= VLC_TS_INVALID )
     {
index f5a217d..45e43c7 100644 (file)
@@ -497,6 +497,9 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     subpicture_t *p_spu = NULL;
     char *psz_subtitle = NULL;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        return NULL;
+
     /* We cannot display a subpicture with no date */
     if( p_block->i_pts <= VLC_TS_INVALID )
     {
index 8968fcb..474212c 100644 (file)
@@ -223,6 +223,9 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     subpicture_t *p_spu = NULL;
     char *psz_subtitle = NULL;
 
+    if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
+        return NULL;
+
     /* We cannot display a subpicture with no date */
     if( p_block->i_pts <= VLC_TS_INVALID )
     {
index 03510dc..735dfbb 100644 (file)
@@ -424,9 +424,17 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     block_t *p_block = *pp_block;
     void *p_buf;
 
-    if( ( p_block->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) != 0 )
+    *pp_block = NULL; /* To avoid being fed the same packet again */
+
+    if( !p_block )
+        return NULL;
+
+    if( ( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY ) != 0 )
+        p_sys->i_pts = p_block->i_pts;
+
+    if( ( p_block->i_flags & BLOCK_FLAG_CORRUPTED ) != 0 )
     {
-        /* Don't send the the first packet after a discontinuity to
+        /* Don't send the a corrupted packet to
          * theora_decode, otherwise we get purple/green display artifacts
          * appearing in the video output */
         block_Release(p_block);
@@ -439,8 +447,6 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
         p_sys->i_pts = p_block->i_pts;
     }
 
-    *pp_block = NULL; /* To avoid being fed the same packet again */
-
     if( p_sys->b_packetizer )
     {
         /* Date management */
index 6f698fe..5fdba60 100644 (file)
@@ -62,13 +62,13 @@ static block_t *Decode(decoder_t *dec, block_t **block_ptr)
         return NULL;
 
     block_t *block = *block_ptr;
-    if (block->i_flags & BLOCK_FLAG_CORRUPTED) {
-        date_Set(&sys->end_date, 0);
-        block_Release(block);
-        return NULL;
-    }
-    if (block->i_flags & BLOCK_FLAG_DISCONTINUITY) {
+    if (block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) {
         date_Set(&sys->end_date, 0);
+        if (block->i_flags & BLOCK_FLAG_CORRUPTED) {
+            block_Release(block);
+            *block_ptr = NULL;
+            return NULL;
+        }
     }
 
     if (block->i_pts > VLC_TS_INVALID &&
index 077a1c3..ef3c7b8 100644 (file)
@@ -434,8 +434,21 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     decoder_sys_t *p_sys = p_dec->p_sys;
     block_t *p_block = *pp_block;
 
+    *pp_block = NULL; /* To avoid being fed the same packet again */
+    if( !p_block )
+        return NULL;
+
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+        date_Set( &p_sys->end_date, 0 );
+
+    if( ( p_block->i_flags & BLOCK_FLAG_CORRUPTED ) != 0 )
+    {
+        block_Release(p_block);
+        return NULL;
+    }
+
     /* Date management */
-    if( p_block && p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TS_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
@@ -448,7 +461,6 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
         return NULL;
     }
 
-    *pp_block = NULL; /* To avoid being fed the same packet again */
 
     if( p_sys->b_packetizer )
     {
index 5722ed5..7f385e0 100644 (file)
@@ -201,12 +201,15 @@ static block_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
 
     p_block = *pp_block;
 
-    if( p_block->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+    if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        date_Set( &p_sys->end_date, 0 );
-        block_Release( p_block );
-        *pp_block = NULL;
-        return NULL;
+        date_Set( &p_sys->end_date, VLC_TS_INVALID );
+        if( p_block->i_flags & BLOCK_FLAG_CORRUPTED)
+        {
+            block_Release( p_block );
+            *pp_block = NULL;
+            return NULL;
+        }
     }
 
     if( p_block->i_buffer <= 0 )