[vlc-devel] [PATCH 6/6] codec: don't drop blocks marked BLOCK_FLAG_DISCONTINUITY
Ilkka Ollakka
ileoo at videolan.org
Sat Oct 31 15:05:56 CET 2015
From: Jean-Paul Saman <jpsaman at videolan.org>
---
modules/codec/a52.c | 16 +++++++---------
modules/codec/adpcm.c | 10 ++++++++++
modules/codec/aes3.c | 10 +++++++++-
modules/codec/araw.c | 6 ++++++
modules/codec/arib/aribsub.c | 6 ++++++
modules/codec/avcodec/audio.c | 4 ++--
modules/codec/avcodec/subtitle.c | 12 ++++++------
modules/codec/avcodec/video.c | 5 +++--
modules/codec/bpg.c | 14 ++------------
modules/codec/cdg.c | 5 +++--
modules/codec/crystalhd.c | 3 +--
modules/codec/cvdsub.c | 6 ++++++
modules/codec/ddummy.c | 1 +
modules/codec/dts.c | 16 +++++++++-------
modules/codec/dvbsub.c | 12 +++++++++++-
modules/codec/faad.c | 11 ++++++++---
modules/codec/flac.c | 11 ++++++++---
modules/codec/fluidsynth.c | 7 ++++++-
modules/codec/g711.c | 10 ++++++++++
modules/codec/jpeg.c | 6 +-----
modules/codec/kate.c | 1 +
modules/codec/libass.c | 5 +++--
modules/codec/lpcm.c | 9 +++++++++
modules/codec/mft.c | 4 ++++
modules/codec/mpeg_audio.c | 21 +++++++++++----------
modules/codec/mpg123.c | 5 +++--
modules/codec/omxil/omxil.c | 4 ++--
modules/codec/opus.c | 22 +++++++++++++++-------
modules/codec/rawvideo.c | 3 +++
modules/codec/schroedinger.c | 2 +-
modules/codec/speex.c | 3 +++
modules/codec/spudec/spudec.c | 6 ++++++
modules/codec/stl.c | 3 ++-
modules/codec/subsdec.c | 9 ++++++---
modules/codec/substtml.c | 3 +++
modules/codec/subsusf.c | 3 +++
modules/codec/theora.c | 14 ++++++++++----
modules/codec/uleaddvaudio.c | 12 ++++++------
modules/codec/vorbis.c | 16 ++++++++++++++--
modules/codec/wmafixed/wma.c | 13 ++++++++-----
40 files changed, 228 insertions(+), 101 deletions(-)
diff --git a/modules/codec/a52.c b/modules/codec/a52.c
index 6a9d9ba..7450d6b 100644
--- a/modules/codec/a52.c
+++ b/modules/codec/a52.c
@@ -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;
}
diff --git a/modules/codec/adpcm.c b/modules/codec/adpcm.c
index e655c45..fd72308 100644
--- a/modules/codec/adpcm.c
+++ b/modules/codec/adpcm.c
@@ -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 ) )
diff --git a/modules/codec/aes3.c b/modules/codec/aes3.c
index 61feef4..e6a8795 100644
--- a/modules/codec/aes3.c
+++ b/modules/codec/aes3.c
@@ -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;
}
-
diff --git a/modules/codec/araw.c b/modules/codec/araw.c
index 0746a5e..54db33b 100644
--- a/modules/codec/araw.c
+++ b/modules/codec/araw.c
@@ -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 ) )
{
diff --git a/modules/codec/arib/aribsub.c b/modules/codec/arib/aribsub.c
index d22a474..84f54d3 100644
--- a/modules/codec/arib/aribsub.c
+++ b/modules/codec/arib/aribsub.c
@@ -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 )
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 841060b..2a5b5de 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -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 );
}
diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index c867e8a..0bdbb5d 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -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);
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index bd65a5e..8c11d94 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -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 );
diff --git a/modules/codec/bpg.c b/modules/codec/bpg.c
index 255ab4a..a39b0ce 100644
--- a/modules/codec/bpg.c
+++ b/modules/codec/bpg.c
@@ -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;
}
diff --git a/modules/codec/cdg.c b/modules/codec/cdg.c
index 7bcaad9..98c07c8 100644
--- a/modules/codec/cdg.c
+++ b/modules/codec/cdg.c
@@ -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;
}
diff --git a/modules/codec/crystalhd.c b/modules/codec/crystalhd.c
index 2cc43fb..16f2aec 100644
--- a/modules/codec/crystalhd.c
+++ b/modules/codec/crystalhd.c
@@ -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,
diff --git a/modules/codec/cvdsub.c b/modules/codec/cvdsub.c
index 21098b1..01fac3d 100644
--- a/modules/codec/cvdsub.c
+++ b/modules/codec/cvdsub.c
@@ -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 */
diff --git a/modules/codec/ddummy.c b/modules/codec/ddummy.c
index 9bcdf97..59a0beb 100644
--- a/modules/codec/ddummy.c
+++ b/modules/codec/ddummy.c
@@ -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
diff --git a/modules/codec/dts.c b/modules/codec/dts.c
index ebe5414..b90eba3 100644
--- a/modules/codec/dts.c
+++ b/modules/codec/dts.c
@@ -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 )
{
diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c
index cf2ebfa..e73c9d5 100644
--- a/modules/codec/dvbsub.c
+++ b/modules/codec/dvbsub.c
@@ -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;
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 944c376..bf05018 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -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 */
diff --git a/modules/codec/flac.c b/modules/codec/flac.c
index 8ed2b5c..9a7d1d1 100644
--- a/modules/codec/flac.c
+++ b/modules/codec/flac.c
@@ -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 )
diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index 43a91f2..65cb208 100644
--- a/modules/codec/fluidsynth.c
+++ b/modules/codec/fluidsynth.c
@@ -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))
diff --git a/modules/codec/g711.c b/modules/codec/g711.c
index 0473c73..c5540b1 100644
--- a/modules/codec/g711.c
+++ b/modules/codec/g711.c
@@ -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 ) )
{
diff --git a/modules/codec/jpeg.c b/modules/codec/jpeg.c
index c9053ae..fdb91c7 100644
--- a/modules/codec/jpeg.c
+++ b/modules/codec/jpeg.c
@@ -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;
}
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index eea28b3..e3bb494 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -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) )
{
diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index b171142..5cd48bc 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -307,13 +307,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' )
{
diff --git a/modules/codec/lpcm.c b/modules/codec/lpcm.c
index a9f6a4b..0c0ba35 100644
--- a/modules/codec/lpcm.c
+++ b/modules/codec/lpcm.c
@@ -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 ) )
diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index e95c4ca..797018c 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -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;
}
diff --git a/modules/codec/mpeg_audio.c b/modules/codec/mpeg_audio.c
index 9956091..12aa704 100644
--- a/modules/codec/mpeg_audio.c
+++ b/modules/codec/mpeg_audio.c
@@ -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;
}
diff --git a/modules/codec/mpg123.c b/modules/codec/mpg123.c
index aefbe6d..a7e1ffe 100644
--- a/modules/codec/mpg123.c
+++ b/modules/codec/mpg123.c
@@ -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 */
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 3a94680..8420501 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1534,7 +1534,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)
@@ -1652,7 +1652,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 );
diff --git a/modules/codec/opus.c b/modules/codec/opus.c
index 1e93cd4..044ce0d 100644
--- a/modules/codec/opus.c
+++ b/modules/codec/opus.c
@@ -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 );
diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index 63fd39d..1abd66f 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -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 ) )
{
diff --git a/modules/codec/schroedinger.c b/modules/codec/schroedinger.c
index 977afca..cf0932b 100644
--- a/modules/codec/schroedinger.c
+++ b/modules/codec/schroedinger.c
@@ -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;
diff --git a/modules/codec/speex.c b/modules/codec/speex.c
index e21c7fa..2d35527 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -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 ) )
diff --git a/modules/codec/spudec/spudec.c b/modules/codec/spudec/spudec.c
index 1ec6243..4179e95 100644
--- a/modules/codec/spudec/spudec.c
+++ b/modules/codec/spudec/spudec.c
@@ -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 ) )
{
diff --git a/modules/codec/stl.c b/modules/codec/stl.c
index 4bfa25e..fee7b53 100644
--- a/modules/codec/stl.c
+++ b/modules/codec/stl.c
@@ -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)
diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c
index c005192..3d5d7b4 100644
--- a/modules/codec/subsdec.c
+++ b/modules/codec/subsdec.c
@@ -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 )
{
diff --git a/modules/codec/substtml.c b/modules/codec/substtml.c
index f5a217d..45e43c7 100644
--- a/modules/codec/substtml.c
+++ b/modules/codec/substtml.c
@@ -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 )
{
diff --git a/modules/codec/subsusf.c b/modules/codec/subsusf.c
index 8968fcb..474212c 100644
--- a/modules/codec/subsusf.c
+++ b/modules/codec/subsusf.c
@@ -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 )
{
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index 03510dc..735dfbb 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -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 */
diff --git a/modules/codec/uleaddvaudio.c b/modules/codec/uleaddvaudio.c
index 6f698fe..5fdba60 100644
--- a/modules/codec/uleaddvaudio.c
+++ b/modules/codec/uleaddvaudio.c
@@ -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 &&
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index 077a1c3..ef3c7b8 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -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 )
{
diff --git a/modules/codec/wmafixed/wma.c b/modules/codec/wmafixed/wma.c
index 5722ed5..7f385e0 100644
--- a/modules/codec/wmafixed/wma.c
+++ b/modules/codec/wmafixed/wma.c
@@ -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 )
--
2.6.2
More information about the vlc-devel
mailing list