* mpeg_system.c: TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: mpeg_system.c,v 1.40 2001/03/02 13:20:29 massiot Exp $
+ * $Id: mpeg_system.c,v 1.45 2001/03/15 01:42:20 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
}
p_pes->i_pts = input_ClockGetTS( p_input, p_es->p_pgrm,
( ((mtime_t)(p_full_header[2] & 0x0E) << 29) |
- (((mtime_t)U32_AT(p_full_header + 2) & 0xFFFE00) << 6) |
+ ((mtime_t)(p_full_header[3]) << 22) |
+ ((mtime_t)(p_full_header[4] & 0xFE) << 14) |
((mtime_t)p_full_header[5] << 7) |
((mtime_t)p_full_header[6] >> 1) ) );
/* Cannot fail because the previous one succeeded. */
MoveChunk( NULL, &p_data, &p_byte, 6 );
- while( *p_byte == 0xFF && i_pes_header_size < 22 )
+ while( *p_byte == 0xFF && i_pes_header_size < 23 )
{
i_pes_header_size++;
if( MoveChunk( NULL, &p_data, &p_byte, 1 ) != 1 )
return;
}
}
- if( i_pes_header_size == 22 )
+ if( i_pes_header_size == 23 )
{
intf_ErrMsg( "Too much MPEG-1 stuffing" );
p_input->pf_delete_pes( p_input->p_method_data, p_pes );
{
/* Subtitles video (0x20->0x3F) */
p_es->i_type = DVD_SPU_ES;
+ p_es->b_spu = 1;
#ifdef AUTO_SPAWN
if( main_GetIntVariable( INPUT_SUBTITLE_VAR, -1 )
== ((p_es->i_id & 0x1F00) >> 8) )
>> 11);
/* mux_rate */
- i_mux_rate = (( ((u32)U16_AT(p_header + 10) << 16)
- | (u32)U16_AT(p_header + 12) ) & 0xFFFFFC00)
- >> 11;
+ i_mux_rate = ((u32)U16_AT(p_header + 10) << 6)
+ | (p_header[12] >> 2);
}
else
{
((mtime_t)p_header[8] >> 1);
/* mux_rate */
- i_mux_rate = (U32_AT(p_header + 8) & 0x8FFFFE) >> 11;
+ i_mux_rate = (U32_AT(p_header + 8) & 0x7FFFFE) >> 1;
}
/* Call the pace control. */
input_ClockManageRef( p_input, p_input->stream.pp_programs[0],
default:
/* This should not happen */
b_trash = 1;
- intf_WarnMsg( 1, "Unwanted packet received with start code %x",
+ intf_WarnMsg( 1, "Unwanted packet received with start code 0x%.8x",
i_code );
}
}
pgrm_ts_data_t * p_pgrm_demux = NULL;
#define p (p_data->p_buffer)
-
/* Extract flags values from TS common header. */
i_pid = U16_AT(&p[1]) & 0x1fff;
b_unit_start = (p[1] & 0x40);
/* Find out the elementary stream. */
vlc_mutex_lock( &p_input->stream.stream_lock );
-
p_es= input_FindES( p_input, i_pid );
if( p_es_demux->b_psi )
b_psi = 1;
+ else
+ p_pgrm_demux = (pgrm_ts_data_t *)p_es->p_pgrm->p_demux_data;
}
vlc_mutex_lock( &p_input->stream.control.control_lock );
-
if( ( p_es == NULL ) || (p_es->b_audio && p_input->stream.control.b_mute) )
{
/* Not selected. Just read the adaptation field for a PCR. */
vlc_mutex_unlock( &p_input->stream.stream_lock );
+ /* Don't change the order of the tests : if b_psi then p_pgrm_demux
+ * may still be null. Who said it was ugly ? */
if( ( p_es != NULL ) &&
((p_es->p_decoder_fifo != NULL) || b_psi
|| (p_pgrm_demux->i_pcr_pid == i_pid) ) )
{
- p_es_demux = (es_ts_data_t *)p_es->p_demux_data;
-
- if( ! p_es_demux->b_psi )
- {
- p_pgrm_demux = (pgrm_ts_data_t *)p_es->p_pgrm->p_demux_data;
- }
-
#ifdef STATS
p_es->c_packets++;
#endif
stream_ts_data_t * p_stream_data;
es_ts_data_t * p_demux_data;
-
p_demux_data = (es_ts_data_t *)p_es->p_demux_data;
p_stream_data = (stream_ts_data_t *)p_input->stream.p_demux_data;
p_current_data = p_psi->buffer;
p_pgrm_data->i_pcr_pid = U16_AT(p_current_section + 8) & 0x1fff;
+
+ /* Lock stream information */
+ vlc_mutex_lock( &p_input->stream.stream_lock );
/* Delete all ES in this program except the PSI */
for( i_loop=0; i_loop < p_es->p_pgrm->i_es_number; i_loop++ )
/* We want to decode */
input_SelectES( p_input, p_new_es );
-
p_current_data += 5 + i_es_info_length;
}
}
#undef p_psi
+
+ /* Remove lock */
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
}