Commit c9e95ac9 authored by Rafaël Carré's avatar Rafaël Carré

TS mux: fix ebcc69cf

Only modify bitstream (PCR & PES), but not VLC core timestamps
parent f06d95b5
......@@ -319,11 +319,10 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
void EStoPES ( block_t **pp_pes,
es_format_t *p_fmt, int i_stream_id,
int b_mpeg2, int b_data_alignment, int i_header_size,
int i_max_pes_size )
int i_max_pes_size, mtime_t ts_offset )
{
block_t *p_es = *pp_pes;
block_t *p_pes = NULL;
mtime_t i_pts, i_dts, i_length;
uint8_t *p_data;
int i_size;
......@@ -383,8 +382,12 @@ void EStoPES ( block_t **pp_pes,
}
i_pts = p_es->i_pts <= 0 ? 0 : p_es->i_pts * 9 / 100; // 90000 units clock
i_dts = p_es->i_dts <= 0 ? 0 : p_es->i_dts * 9 / 100; // 90000 units clock
mtime_t i_dts = 0;
mtime_t i_pts = 0;
if (p_es->i_pts > VLC_TS_INVALID)
i_pts = (p_es->i_pts - ts_offset) * 9 / 100;
if (p_es->i_dts > VLC_TS_INVALID)
i_dts = (p_es->i_dts - ts_offset) * 9 / 100;
i_size = p_es->i_buffer;
p_data = p_es->p_buffer;
......@@ -434,7 +437,7 @@ void EStoPES ( block_t **pp_pes,
/* Now redate all pes */
i_dts = p_pes->i_dts;
i_length = p_pes->i_length / i_pes_count;
mtime_t i_length = p_pes->i_length / i_pes_count;
while( p_pes )
{
p_pes->i_dts = i_dts;
......
......@@ -38,4 +38,4 @@
void EStoPES ( block_t **pp_pes,
es_format_t *p_fmt, int i_stream_id,
int b_mpeg2, int b_data_alignment, int i_header_size,
int i_max_pes_size );
int i_max_pes_size, mtime_t ts_offset );
......@@ -514,7 +514,7 @@ static int Mux( sout_mux_t *p_mux )
/* Get and mux a packet */
p_data = block_FifoGet( p_input->p_fifo );
EStoPES ( &p_data, p_input->p_fmt, p_stream->i_stream_id,
p_sys->b_mpeg2, 0, 0, p_sys->i_pes_max_size );
p_sys->b_mpeg2, 0, 0, p_sys->i_pes_max_size, 0 );
block_ChainAppend( &p_ps, p_data );
......
......@@ -1274,7 +1274,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
/* Don't mux the SPU yet if it is too early */
block_t *p_spu = block_FifoShow( p_input->p_fifo );
int64_t i_spu_delay = p_spu->i_dts - p_sys->first_dts - p_pcr_stream->i_pes_dts;
int64_t i_spu_delay = p_spu->i_dts - p_pcr_stream->i_pes_dts;
if( ( i_spu_delay > i_shaping_delay ) &&
( i_spu_delay < 100 * CLOCK_FREQ ) )
continue;
......@@ -1320,9 +1320,6 @@ static bool MuxStreams(sout_mux_t *p_mux )
if (p_sys->first_dts == 0)
p_sys->first_dts = p_data->i_dts;
p_data->i_dts -= p_sys->first_dts;
p_data->i_pts -= p_sys->first_dts;
if( ( p_pcr_stream->i_pes_dts > 0 &&
p_data->i_dts - 10 * CLOCK_FREQ > p_pcr_stream->i_pes_dts +
p_pcr_stream->i_pes_length ) ||
......@@ -1384,7 +1381,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
p_spu->p_buffer[2] = ' ';
EStoPES( &p_spu, p_input->p_fmt,
p_stream->i_stream_id, 1, 0, 0, 0 );
p_stream->i_stream_id, 1, 0, 0, 0, p_sys->first_dts );
p_data->p_next = p_spu;
}
break;
......@@ -1431,7 +1428,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
EStoPES ( &p_data, p_input->p_fmt, p_stream->i_stream_id,
1, b_data_alignment, i_header_size,
i_max_pes_size );
i_max_pes_size, p_sys->first_dts );
BufferChainAppend( &p_stream->chain_pes, p_data );
......@@ -1799,7 +1796,7 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
if( p_ts->i_flags & BLOCK_FLAG_CLOCK )
{
/* msg_Dbg( p_mux, "pcr=%lld ms", p_ts->i_dts / 1000 ); */
TSSetPCR( p_ts, p_ts->i_dts - p_sys->i_dts_delay );
TSSetPCR( p_ts, p_ts->i_dts - p_sys->i_dts_delay - p_sys->first_dts );
}
if( p_ts->i_flags & BLOCK_FLAG_SCRAMBLED )
{
......
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