Commit 4d26594b authored by Christophe Massiot's avatar Christophe Massiot

Enhanced handling of stream discontinuities.

parent a23f364a
...@@ -29,6 +29,7 @@ typedef struct es_descriptor_s ...@@ -29,6 +29,7 @@ typedef struct es_descriptor_s
struct pes_packet_s * p_pes; /* Current PES */ struct pes_packet_s * p_pes; /* Current PES */
struct data_packet_s * p_last; /* The last packet gathered at present */ struct data_packet_s * p_last; /* The last packet gathered at present */
int i_pes_real_size; /* as indicated by the header */ int i_pes_real_size; /* as indicated by the header */
boolean_t b_discontinuity; /* Stream changed */
/* Decoder information */ /* Decoder information */
struct decoder_fifo_s * p_decoder_fifo; struct decoder_fifo_s * p_decoder_fifo;
......
...@@ -390,7 +390,7 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -390,7 +390,7 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
***************************************************************************** *****************************************************************************
* Gather a PES packet. * Gather a PES packet.
*****************************************************************************/ *****************************************************************************/
void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data, void input_GatherPES( input_thread_t * p_input, data_packet_t * p_data,
es_descriptor_t * p_es, es_descriptor_t * p_es,
boolean_t b_unit_start, boolean_t b_packet_lost ) boolean_t b_unit_start, boolean_t b_packet_lost )
{ {
...@@ -401,10 +401,12 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data, ...@@ -401,10 +401,12 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data,
/* If we lost data, insert an NULL data packet (philosophy : 0 is quite /* If we lost data, insert an NULL data packet (philosophy : 0 is quite
* often an escape sequence in decoders, so that should make them wait * often an escape sequence in decoders, so that should make them wait
* for the next start code). */ * for the next start code). */
if( b_packet_lost && p_pes != NULL ) if( b_packet_lost || p_es->b_discontinuity )
{ {
data_packet_t * p_pad_data; data_packet_t * p_pad_data;
if( (p_pad_data = p_input->p_plugin->pf_new_packet( p_input,
if( (p_pad_data = p_input->p_plugin->pf_new_packet(
p_input->p_method_data,
PADDING_PACKET_SIZE )) == NULL ) PADDING_PACKET_SIZE )) == NULL )
{ {
intf_ErrMsg("Out of memory\n"); intf_ErrMsg("Out of memory\n");
...@@ -413,9 +415,29 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data, ...@@ -413,9 +415,29 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data,
} }
memset( p_data->p_buffer, 0, PADDING_PACKET_SIZE ); memset( p_data->p_buffer, 0, PADDING_PACKET_SIZE );
p_pad_data->b_discard_payload = 1; p_pad_data->b_discard_payload = 1;
p_pes->b_messed_up = 1;
if( p_pes != NULL )
{
p_pes->b_messed_up = p_pes->b_discontinuity = 1;
input_GatherPES( p_input, p_pad_data, p_es, 0, 0 ); input_GatherPES( p_input, p_pad_data, p_es, 0, 0 );
} }
else
{
if( (p_pes = p_input->p_plugin->pf_new_pes(
p_input->p_method_data )) == NULL )
{
intf_ErrMsg("Out of memory\n");
p_input->b_error = 1;
return;
}
p_pes->p_first = p_pad_data;
p_pes->b_messed_up = p_pes->b_discontinuity = 1;
input_DecodePES( p_input, p_es );
}
p_es->b_discontinuity = 0;
}
if( b_unit_start && p_pes != NULL ) if( b_unit_start && p_pes != NULL )
{ {
...@@ -571,11 +593,19 @@ static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm, ...@@ -571,11 +593,19 @@ static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
( (p_pgrm->last_cr - cr_time) > CR_MAX_GAP ( (p_pgrm->last_cr - cr_time) > CR_MAX_GAP
|| (p_pgrm->last_cr - cr_time) < - CR_MAX_GAP ) ) ) || (p_pgrm->last_cr - cr_time) < - CR_MAX_GAP ) ) )
{ {
int i_es;
/* Stream discontinuity. */ /* Stream discontinuity. */
intf_WarnMsg( 3, "CR re-initialiazed" ); intf_WarnMsg( 3, "CR re-initialiazed" );
CRReInit( p_pgrm ); CRReInit( p_pgrm );
p_pgrm->i_synchro_state = SYNCHRO_REINIT; p_pgrm->i_synchro_state = SYNCHRO_REINIT;
p_pgrm->b_discontinuity = 0; p_pgrm->b_discontinuity = 0;
/* Warn all the elementary streams */
for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
{
p_pgrm->pp_es[i_es]->b_discontinuity = 1;
}
} }
p_pgrm->last_cr = cr_time; p_pgrm->last_cr = cr_time;
......
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