Commit ce6db786 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Ilkka Ollakka
Browse files

codec: don't drop blocks marked BLOCK_FLAG_DISCONTINUITY

parent c736ebc0
......@@ -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;
}
......
......@@ -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 ) )
......
......@@ -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;
}
......@@ -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 ) )
{
......
......@@ -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 )
......
......@@ -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 );
}
......
......@@ -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);
......
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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
......
......@@ -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 )
{
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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 )
......
......@@ -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))
......
......@@ -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 ) )
{
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment