Commit d2ca341d authored by Christophe Massiot's avatar Christophe Massiot

* Fixed two typos in the Makefile (sam you owe me at least one beer)

* Moved b_discontinuity to pgrm_descriptor_t, cleaned up CRDecode
(needs some more cleaning for discontinuities)
* Added pf_new_pes in plugins
parent 3c7d6bbc
...@@ -251,7 +251,7 @@ C_OBJ = $(INTERFACE) \ ...@@ -251,7 +251,7 @@ C_OBJ = $(INTERFACE) \
$(AC3_DECODER) \ $(AC3_DECODER) \
$(LPCM_DECODER) \ $(LPCM_DECODER) \
$(AUDIO_DECODER) \ $(AUDIO_DECODER) \
$(SPU_DEOCDER) \ $(SPU_DECODER) \
$(GEN_DECODER) \ $(GEN_DECODER) \
$(VIDEO_PARSER) \ $(VIDEO_PARSER) \
$(VIDEO_DECODER) \ $(VIDEO_DECODER) \
...@@ -378,7 +378,7 @@ export ...@@ -378,7 +378,7 @@ export
all: vlc @ALIASES@ plugins all: vlc @ALIASES@ plugins
clean: clean:
rm -f $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) $(PLUGIN_OBJ) rm -f $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) $(STD_PLUGIN_OBJ)
rm -f vlc @ALIASES@ lib/*.so rm -f vlc @ALIASES@ lib/*.so
distclean: clean distclean: clean
......
...@@ -24,7 +24,6 @@ typedef struct es_descriptor_s ...@@ -24,7 +24,6 @@ typedef struct es_descriptor_s
void * p_demux_data; void * p_demux_data;
struct pgrm_descriptor_s * struct pgrm_descriptor_s *
p_pgrm; /* very convenient in the demultiplexer */ p_pgrm; /* very convenient in the demultiplexer */
boolean_t b_discontinuity;
/* PES parser information */ /* PES parser information */
struct pes_packet_s * p_pes; /* Current PES */ struct pes_packet_s * p_pes; /* Current PES */
...@@ -82,6 +81,7 @@ typedef struct pgrm_descriptor_s ...@@ -82,6 +81,7 @@ typedef struct pgrm_descriptor_s
count_t c_average_count; count_t c_average_count;
/* counter used to compute dynamic average values */ /* counter used to compute dynamic average values */
int i_synchro_state; int i_synchro_state;
boolean_t b_discontinuity;
/* Demultiplexer data */ /* Demultiplexer data */
void * p_demux_data; void * p_demux_data;
......
...@@ -29,6 +29,7 @@ typedef struct input_capabilities_s ...@@ -29,6 +29,7 @@ typedef struct input_capabilities_s
/* Packet management facilities */ /* Packet management facilities */
struct data_packet_s *(* pf_new_packet)( void *, size_t ); struct data_packet_s *(* pf_new_packet)( void *, size_t );
struct pes_packet_s *(* pf_new_pes)( void * );
void (* pf_delete_packet)( void *, void (* pf_delete_packet)( void *,
struct data_packet_s * ); struct data_packet_s * );
void (* pf_delete_pes)( void *, struct pes_packet_s * ); void (* pf_delete_pes)( void *, struct pes_packet_s * );
......
...@@ -281,6 +281,27 @@ static struct data_packet_s * NewPacket( void * p_garbage, ...@@ -281,6 +281,27 @@ static struct data_packet_s * NewPacket( void * p_garbage,
return( p_data ); return( p_data );
} }
/*****************************************************************************
* NewPES: allocates a pes packet
*****************************************************************************/
static pes_packet_t * NewPES( void * p_garbage )
{
pes_packet_t * p_pes;
if( (p_pes = (pes_packet_t *)malloc( sizeof(pes_packet_t) )) == NULL )
{
intf_DbgMsg( "Out of memory" );
return NULL;
}
p_pes->b_messed_up = p_pes->b_data_alignment = p_pes->b_discontinuity =
p_pes->b_has_pts = 0;
p_pes->i_pes_size = 0;
p_pes->p_first = NULL;
return( p_pes );
}
/***************************************************************************** /*****************************************************************************
* DeletePacket: deletes a data packet * DeletePacket: deletes a data packet
*****************************************************************************/ *****************************************************************************/
...@@ -326,6 +347,7 @@ input_capabilities_t * PSKludge( void ) ...@@ -326,6 +347,7 @@ input_capabilities_t * PSKludge( void )
p_plugin->pf_read = PSRead; p_plugin->pf_read = PSRead;
p_plugin->pf_demux = input_DemuxPS; /* FIXME: use i_p_config_t ! */ p_plugin->pf_demux = input_DemuxPS; /* FIXME: use i_p_config_t ! */
p_plugin->pf_new_packet = NewPacket; p_plugin->pf_new_packet = NewPacket;
p_plugin->pf_new_pes = NewPES;
p_plugin->pf_delete_packet = DeletePacket; p_plugin->pf_delete_packet = DeletePacket;
p_plugin->pf_delete_pes = DeletePES; p_plugin->pf_delete_pes = DeletePES;
p_plugin->pf_rewind = NULL; p_plugin->pf_rewind = NULL;
......
...@@ -439,19 +439,14 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data, ...@@ -439,19 +439,14 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data,
* packet. This is also here that we can synchronize with the * packet. This is also here that we can synchronize with the
* stream if we lost packets or if the decoder has just * stream if we lost packets or if the decoder has just
* started. */ * started. */
if( (p_pes = (pes_packet_t *)malloc( sizeof(pes_packet_t) )) == NULL ) if( (p_pes = p_input->p_plugin->pf_new_pes( p_input->p_method_data ) ) == NULL )
{ {
intf_ErrMsg("Out of memory"); intf_ErrMsg("Out of memory");
p_input->b_error = 1; p_input->b_error = 1;
return; return;
} }
//intf_DbgMsg("New PES packet %p (first data: %p)\n", p_pes, p_data); //intf_DbgMsg("New PES packet %p (first data: %p)\n", p_pes, p_data);
/* Init the PES fields so that the first data packet could be
* correctly added to the PES packet (see below). */
p_pes->p_first = p_data; p_pes->p_first = p_data;
p_pes->b_messed_up = p_pes->b_discontinuity = 0;
p_pes->i_pes_size = 0;
/* If the PES header fits in the first data packet, we can /* If the PES header fits in the first data packet, we can
* already set p_gather->i_pes_real_size. */ * already set p_gather->i_pes_real_size. */
...@@ -549,19 +544,9 @@ static void CRReInit( pgrm_descriptor_t * p_pgrm ) ...@@ -549,19 +544,9 @@ static void CRReInit( pgrm_descriptor_t * p_pgrm )
/***************************************************************************** /*****************************************************************************
* CRDecode : Decode a clock reference * CRDecode : Decode a clock reference
*****************************************************************************/ *****************************************************************************/
static void CRDecode( input_thread_t * p_input, es_descriptor_t * p_es, static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
mtime_t cr_time ) mtime_t cr_time )
{ {
pgrm_descriptor_t * p_pgrm;
if( p_es != NULL )
{
p_pgrm = p_es->p_pgrm;
}
else
{
p_pgrm = p_input->stream.pp_programs[0];
}
if( p_pgrm->i_synchro_state != SYNCHRO_OK ) if( p_pgrm->i_synchro_state != SYNCHRO_OK )
{ {
switch( p_pgrm->i_synchro_state ) switch( p_pgrm->i_synchro_state )
...@@ -571,54 +556,54 @@ static void CRDecode( input_thread_t * p_input, es_descriptor_t * p_es, ...@@ -571,54 +556,54 @@ static void CRDecode( input_thread_t * p_input, es_descriptor_t * p_es,
p_pgrm->i_synchro_state = SYNCHRO_OK; p_pgrm->i_synchro_state = SYNCHRO_OK;
break; break;
case SYNCHRO_NOT_STARTED:
p_pgrm->i_synchro_state = SYNCHRO_START;
break;
default: default:
break; break;
} }
} }
else if( p_input->stream.b_pace_control )
{
/* Wait a while before delivering the packets to the decoder. */
mwait( cr_time + p_pgrm->delta_absolute );
}
else else
{ {
mtime_t sys_time, delta_cr; if( p_pgrm->b_discontinuity ||
sys_time = mdate();
delta_cr = sys_time - cr_time;
if( (p_es != NULL && p_es->b_discontinuity) ||
( p_pgrm->last_cr != 0 && ( p_pgrm->last_cr != 0 &&
( (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 ) ) )
{ {
/* 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;
if( p_es != NULL ) p_pgrm->b_discontinuity = 0;
{
p_es->b_discontinuity = 0;
}
} }
p_pgrm->last_cr = cr_time; p_pgrm->last_cr = cr_time;
if( p_pgrm->c_average_count == CR_MAX_AVERAGE_COUNTER ) if( p_input->stream.b_pace_control )
{ {
p_pgrm->delta_cr = ( delta_cr + (p_pgrm->delta_cr /* Wait a while before delivering the packets to the decoder. */
* (CR_MAX_AVERAGE_COUNTER - 1)) ) mwait( cr_time + p_pgrm->delta_absolute );
/ CR_MAX_AVERAGE_COUNTER;
} }
else else
{ {
p_pgrm->delta_cr = ( delta_cr + (p_pgrm->delta_cr mtime_t sys_time, delta_cr;
* p_pgrm->c_average_count) )
/ ( p_pgrm->c_average_count + 1 );
p_pgrm->c_average_count++;
}
if( p_pgrm->i_synchro_state == SYNCHRO_NOT_STARTED ) sys_time = mdate();
{ delta_cr = sys_time - cr_time;
p_pgrm->i_synchro_state = SYNCHRO_START;
if( p_pgrm->c_average_count == CR_MAX_AVERAGE_COUNTER )
{
p_pgrm->delta_cr = ( delta_cr + (p_pgrm->delta_cr
* (CR_MAX_AVERAGE_COUNTER - 1)) )
/ CR_MAX_AVERAGE_COUNTER;
}
else
{
p_pgrm->delta_cr = ( delta_cr + (p_pgrm->delta_cr
* p_pgrm->c_average_count) )
/ ( p_pgrm->c_average_count + 1 );
p_pgrm->c_average_count++;
}
} }
} }
} }
...@@ -678,7 +663,6 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -678,7 +663,6 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
= p_byte[1]; = p_byte[1];
p_input->p_es[i_es].i_type = p_byte[0]; p_input->p_es[i_es].i_type = p_byte[0];
p_input->p_es[i_es].p_pgrm = p_input->stream.pp_programs[0]; p_input->p_es[i_es].p_pgrm = p_input->stream.pp_programs[0];
p_input->p_es[i_es].b_discontinuity = 0;
p_input->p_es[i_es].p_pes = NULL; p_input->p_es[i_es].p_pes = NULL;
p_byte += 4 + U16_AT(&p_byte[2]); p_byte += 4 + U16_AT(&p_byte[2]);
...@@ -738,12 +722,10 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -738,12 +722,10 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
/* MPEG-2 */ /* MPEG-2 */
scr_time = scr_time =
(( ((mtime_t)(p_data->p_buffer[4] & 0x38) << 27) | (( ((mtime_t)(p_data->p_buffer[4] & 0x38) << 27) |
((mtime_t)(p_data->p_buffer[4] & 0x3) << 28) | ((mtime_t)(U32_AT(p_data->p_buffer + 4) & 0x03FFF800)
((mtime_t)(p_data->p_buffer[5]) << 20) | << 4) |
((mtime_t)(p_data->p_buffer[6] & 0xF8) << 12) | ((mtime_t)(U32_AT(p_data->p_buffer + 6) & 0x03FFF800)
((mtime_t)(p_data->p_buffer[6] & 0x3) << 13) | >> 11)
((mtime_t)(p_data->p_buffer[7]) << 5) |
((mtime_t)(p_data->p_buffer[8] & 0xF8) >> 3)
) * 300) / 27; ) * 300) / 27;
} }
else else
...@@ -758,7 +740,8 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -758,7 +740,8 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
} }
/* Call the pace control. */ /* Call the pace control. */
//intf_Msg("+%lld\n", scr_time); //intf_Msg("+%lld\n", scr_time);
CRDecode( p_input, NULL, scr_time - 200000 ); CRDecode( p_input, p_input->stream.pp_programs[0],
scr_time );
b_trash = 1; b_trash = 1;
} }
break; break;
...@@ -826,7 +809,6 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -826,7 +809,6 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
p_es->i_id = p_es->i_stream_id = i_id; p_es->i_id = p_es->i_stream_id = i_id;
p_es->i_type = MPEG2_VIDEO_ES; p_es->i_type = MPEG2_VIDEO_ES;
p_es->p_pgrm = p_input->stream.pp_programs[0]; p_es->p_pgrm = p_input->stream.pp_programs[0];
p_es->b_discontinuity = 0;
p_es->p_pes = NULL; p_es->p_pes = NULL;
#ifdef AUTO_SPAWN #ifdef AUTO_SPAWN
...@@ -870,7 +852,6 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -870,7 +852,6 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
p_es->i_id = p_es->i_stream_id = i_id; p_es->i_id = p_es->i_stream_id = i_id;
p_es->i_type = MPEG2_AUDIO_ES; p_es->i_type = MPEG2_AUDIO_ES;
p_es->p_pgrm = p_input->stream.pp_programs[0]; p_es->p_pgrm = p_input->stream.pp_programs[0];
p_es->b_discontinuity = 0;
p_es->p_pes = NULL; p_es->p_pes = NULL;
#ifdef AUTO_SPAWN #ifdef AUTO_SPAWN
...@@ -1046,7 +1027,7 @@ void input_DemuxTS( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -1046,7 +1027,7 @@ void input_DemuxTS( input_thread_t * p_input, data_packet_t * p_data )
/* If the PID carries the PCR, there will be a system /* If the PID carries the PCR, there will be a system
* time-based discontinuity. We let the PCR decoder * time-based discontinuity. We let the PCR decoder
* handle that. */ * handle that. */
p_es->b_discontinuity = 1; p_es->p_pgrm->b_discontinuity = 1;
/* There also may be a continuity_counter /* There also may be a continuity_counter
* discontinuity: resynchronise our counter with * discontinuity: resynchronise our counter with
...@@ -1071,7 +1052,7 @@ void input_DemuxTS( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -1071,7 +1052,7 @@ void input_DemuxTS( input_thread_t * p_input, data_packet_t * p_data )
( (( (mtime_t)U32_AT((u32*)&p[6]) << 1 ) ( (( (mtime_t)U32_AT((u32*)&p[6]) << 1 )
| ( p[10] >> 7 )) * 300 ) / 27; | ( p[10] >> 7 )) * 300 ) / 27;
/* Call the pace control. */ /* Call the pace control. */
CRDecode( p_input, p_es, pcr_time ); CRDecode( p_input, p_es->p_pgrm, pcr_time );
} }
} /* PCR ? */ } /* PCR ? */
} /* valid TS adaptation field ? */ } /* valid TS adaptation field ? */
......
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