Skip to content

Commit

Permalink
codec: don't drop discontinue blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Paul Saman <[email protected]>
  • Loading branch information
ilkka-ollakka committed Oct 13, 2015
1 parent d700966 commit 5e36cb2
Show file tree
Hide file tree
Showing 30 changed files with 65 additions and 50 deletions.
6 changes: 5 additions & 1 deletion modules/codec/a52.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ 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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( (*pp_block)->i_flags&(BLOCK_FLAG_CORRUPTED) )
{
if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
{
Expand All @@ -185,6 +185,10 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
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)
{
Expand Down
7 changes: 6 additions & 1 deletion modules/codec/avcodec/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
{
avcodec_flush_buffers( ctx );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
Expand All @@ -272,6 +272,11 @@ 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 );
}

/* We've just started the stream, wait for the first PTS. */
if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TS_INVALID )
Expand Down
4 changes: 3 additions & 1 deletion modules/codec/avcodec/subtitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ static subpicture_t *DecodeSubtitle(decoder_t *dec, block_t **block_ptr)

block_t *block = *block_ptr;

if (block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) {
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)
avcodec_flush_buffers(sys->p_context);

if (block->i_buffer <= 0) {
block_Release(block);
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/bpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )

p_block = *pp_block;

if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
block_Release(p_block);
*pp_block = NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/cdg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
{
p_sys->i_packet = 0;
goto exit;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/crystalhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ 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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) == 0 )
if( ( p_block->i_flags&(BLOCK_FLAG_CORRUPTED) ) == 0 )
{
/* Valid input block, so we can send to HW to decode */

Expand Down
2 changes: 1 addition & 1 deletion modules/codec/daala.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ 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 )
if( ( p_block->i_flags&(BLOCK_FLAG_CORRUPTED) ) != 0 )
{
/* Don't send the the first packet after a discontinuity to
* daala_decode, otherwise we get purple/green display artifacts
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/ddummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )

if( stream != NULL
&& p_block->i_buffer > 0
&& !(p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) )
&& !(p_block->i_flags & (BLOCK_FLAG_CORRUPTED)) )
{
fwrite( p_block->p_buffer, 1, p_block->i_buffer, stream );
msg_Dbg( p_dec, "dumped %zu bytes", p_block->i_buffer );
Expand Down
11 changes: 5 additions & 6 deletions modules/codec/dts.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,16 @@ 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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( (*pp_block)->i_flags&(BLOCK_FLAG_CORRUPTED) )
{
if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
{
p_sys->i_state = STATE_NOSYNC;
block_BytestreamEmpty( &p_sys->bytestream );
}
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_DISCONTINUITY )
date_Set( &p_sys->end_date, 0 );

if( !date_Get( &p_sys->end_date ) && (*pp_block)->i_pts <= VLC_TS_INVALID )
{
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/faad.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static block_t *DecodeBlock( 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_CORRUPTED) )
{
block_Release( p_block );
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/flac.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ 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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( (*pp_block)->i_flags&(BLOCK_FLAG_CORRUPTED) )
{
block_Release( *pp_block );
return NULL;
Expand Down
7 changes: 5 additions & 2 deletions modules/codec/gstdecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,11 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_sys->b_prerolled = false;
}

block_Release( p_block );
goto done;
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
block_Release( p_block );
goto done;
}
}

if( likely( p_block->i_buffer ) )
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t **pp_block)

p_block = *pp_block;

if (p_block->i_flags & BLOCK_FLAG_DISCONTINUITY)
if (p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
block_Release(p_block);
*pp_block = NULL;
Expand Down
9 changes: 6 additions & 3 deletions modules/codec/kate.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,12 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
vlc_mutex_unlock( &p_sys->lock );
}
#endif
p_sys->i_max_stop = VLC_TS_INVALID;
block_Release( p_block );
return NULL;
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
p_sys->i_max_stop = VLC_TS_INVALID;
block_Release( p_block );
return NULL;
}
}

/* Block to Kate packet */
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/libass.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ 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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
{
p_sys->i_max_stop = VLC_TS_INVALID;
block_Release( p_block );
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/libmpeg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
return NULL;

p_block = *pp_block;
if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED) )
if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
Reset( p_dec );

while( 1 )
Expand Down
5 changes: 2 additions & 3 deletions modules/codec/mft.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ static void *DecodeSync(decoder_t *p_dec, block_t **pp_block)
return NULL;

block_t *p_block = *pp_block;
if (p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED))
if (p_block->i_flags & (BLOCK_FLAG_CORRUPTED))
{
block_Release(p_block);
return NULL;
Expand Down Expand Up @@ -839,10 +839,9 @@ static void *DecodeAsync(decoder_t *p_dec, block_t **pp_block)
return NULL;

block_t *p_block = *pp_block;
if (p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED))
if (p_block->i_flags & (BLOCK_FLAG_CORRUPTED))
{
block_Release(p_block);

return NULL;
}

Expand Down
17 changes: 8 additions & 9 deletions modules/codec/mpeg_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( p_block->i_flags&(BLOCK_FLAG_CORRUPTED) )
{
if( p_block->i_flags&BLOCK_FLAG_CORRUPTED )
{
p_sys->i_state = STATE_NOSYNC;
block_BytestreamEmpty( &p_sys->bytestream );
}
p_sys->i_state = STATE_NOSYNC;
block_BytestreamEmpty( &p_sys->bytestream );
date_Set( &p_sys->end_date, 0 );
block_Release( p_block );
p_sys->b_discontinuity = true;
return NULL;
}
if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
{
date_Set( &p_sys->end_date, 0 );
p_sys->b_discontinuity = true;
}

if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TS_INVALID )
{
Expand Down Expand Up @@ -292,7 +293,6 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
msg_Dbg( p_dec, "emulated startcode" );
block_SkipByte( &p_sys->bytestream );
p_sys->i_state = STATE_NOSYNC;
p_sys->b_discontinuity = true;
break;
}

Expand Down Expand Up @@ -367,7 +367,6 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
msg_Dbg( p_dec, "emulated startcode on next frame" );
block_SkipByte( &p_sys->bytestream );
p_sys->i_state = STATE_NOSYNC;
p_sys->b_discontinuity = true;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/codec/mpg123.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
goto error;
}

if( p_block->i_flags & ( BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED ) )
if( p_block->i_flags & ( BLOCK_FLAG_CORRUPTED ) )
{
date_Set( &p_sys->end_date, 0 );
goto error;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/png.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_block = *pp_block;
p_sys->b_error = false;

if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
block_Release( p_block ); *pp_block = NULL;
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/scte27.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ static subpicture_t *Decode(decoder_t *dec, block_t **block)
subpicture_t *sub_first = NULL;
subpicture_t **sub_last = &sub_first;

if (b->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED))
if (b->i_flags & (BLOCK_FLAG_CORRUPTED))
goto exit;

while (b->i_buffer > 3) {
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/sdl_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
if( pp_block == NULL || *pp_block == NULL ) return NULL;
p_block = *pp_block;

if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
{
block_Release( p_block ); *pp_block = NULL;
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/stl.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static subpicture_t *Decode(decoder_t *dec, block_t **block)
subpicture_t *sub = NULL;

block_t *b = *block; *block = NULL;
if (b->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED))
if (b->i_flags & (BLOCK_FLAG_CORRUPTED))
goto exit;
if (b->i_buffer < 128)
goto exit;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/subsdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ 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_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
{
block_Release( p_block );
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/substx3g.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ 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) ) ||
if( ( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) ) ||
p_block->i_buffer < sizeof(uint16_t) )
{
block_Release( p_block );
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/svcdsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
uint16_t i_expected_image;
uint8_t i_packet, i_expected_packet;

if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
if( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) )
{
block_Release( p_block );
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/svg.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ 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_DISCONTINUITY )
if( p_block->i_flags & BLOCK_FLAG_CORRUPTED)
{
block_Release( p_block );
return NULL;
Expand Down
7 changes: 4 additions & 3 deletions modules/codec/uleaddvaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ static block_t *Decode(decoder_t *dec, block_t **block_ptr)
return NULL;

block_t *block = *block_ptr;
if (block->i_flags & (BLOCK_FLAG_DISCONTINUITY | BLOCK_FLAG_CORRUPTED)) {
if (block->i_flags & BLOCK_FLAG_CORRUPTED) {
}
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) {
date_Set(&sys->end_date, 0);
}

if (block->i_pts > VLC_TS_INVALID &&
block->i_pts != date_Get(&sys->end_date))
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/videotoolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ static void copy420YpCbCr8Planar(picture_t *p_pic,
p_block = *pp_block;

if (likely(p_block != NULL)) {
if (unlikely(p_block->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED))) {
if (unlikely(p_block->i_flags&(BLOCK_FLAG_CORRUPTED))) {
if (likely(p_sys->b_started)) {
@synchronized(p_sys->outputTimeStamps) {
[p_sys->outputTimeStamps removeAllObjects];
Expand Down
2 changes: 1 addition & 1 deletion modules/codec/vpx.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static picture_t *Decode(decoder_t *dec, block_t **pp_block)
if (!block)
return NULL;

if (block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED))
if (block->i_flags & (BLOCK_FLAG_CORRUPTED))
return NULL;

/* Associate packet PTS with decoded frame */
Expand Down

0 comments on commit 5e36cb2

Please sign in to comment.