Commit f1e16994 authored by Laurent Aimar's avatar Laurent Aimar

No functionnal changes (clean up)

parent bf304527
...@@ -322,13 +322,16 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl ) ...@@ -322,13 +322,16 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl )
/***************************************************************************** /*****************************************************************************
* input_clock_GetTS: manages a PTS or DTS * input_clock_GetTS: manages a PTS or DTS
*****************************************************************************/ *****************************************************************************/
mtime_t input_clock_GetTS( input_clock_t *cl, mtime_t input_clock_GetTS( input_clock_t *cl, int *pi_rate,
mtime_t i_pts_delay, mtime_t i_ts ) mtime_t i_pts_delay, mtime_t i_ts )
{ {
mtime_t i_converted_ts; mtime_t i_converted_ts;
vlc_mutex_lock( &cl->lock ); vlc_mutex_lock( &cl->lock );
if( pi_rate )
*pi_rate = cl->i_rate;
if( !cl->b_has_reference ) if( !cl->b_has_reference )
{ {
vlc_mutex_unlock( &cl->lock ); vlc_mutex_unlock( &cl->lock );
......
...@@ -159,7 +159,7 @@ mtime_t decoder_GetDisplayDate( decoder_t *p_dec, mtime_t i_ts ) ...@@ -159,7 +159,7 @@ mtime_t decoder_GetDisplayDate( decoder_t *p_dec, mtime_t i_ts )
if( !p_owner->p_clock ) if( !p_owner->p_clock )
return i_ts; return i_ts;
return input_clock_GetTS( p_owner->p_clock, p_owner->p_input->i_pts_delay, i_ts ); return input_clock_GetTS( p_owner->p_clock, NULL, p_owner->p_input->i_pts_delay, i_ts );
} }
/* decoder_GetDisplayRate: /* decoder_GetDisplayRate:
*/ */
...@@ -363,29 +363,7 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block ) ...@@ -363,29 +363,7 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block )
} }
} }
void input_DecoderDiscontinuity( decoder_t * p_dec, bool b_flush ) bool input_DecoderIsEmpty( decoder_t * p_dec )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
block_t *p_null;
/* Empty the fifo */
if( p_owner->b_own_thread && b_flush )
block_FifoEmpty( p_owner->p_fifo );
/* Send a special block */
p_null = block_New( p_dec, 128 );
p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY;
if( b_flush && p_dec->fmt_in.i_cat == SPU_ES )
p_null->i_flags |= BLOCK_FLAG_CORE_FLUSH;
/* FIXME check for p_packetizer or b_packitized from es_format_t of input ? */
if( p_owner->p_packetizer && b_flush )
p_null->i_flags |= BLOCK_FLAG_CORRUPTED;
memset( p_null->p_buffer, 0, p_null->i_buffer );
input_DecoderDecode( p_dec, p_null );
}
bool input_DecoderEmpty( decoder_t * p_dec )
{ {
if( p_dec->p_owner->b_own_thread && if( p_dec->p_owner->b_own_thread &&
block_FifoCount( p_dec->p_owner->p_fifo ) > 0 ) block_FifoCount( p_dec->p_owner->p_fifo ) > 0 )
...@@ -504,6 +482,29 @@ void input_DecoderChangeDelay( decoder_t *p_dec, mtime_t i_delay ) ...@@ -504,6 +482,29 @@ void input_DecoderChangeDelay( decoder_t *p_dec, mtime_t i_delay )
p_owner->i_ts_delay = i_delay; p_owner->i_ts_delay = i_delay;
vlc_mutex_unlock( &p_owner->lock ); vlc_mutex_unlock( &p_owner->lock );
} }
void input_DecoderFlush( decoder_t *p_dec )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
block_t *p_null;
/* Empty the fifo */
if( p_owner->b_own_thread )
block_FifoEmpty( p_owner->p_fifo );
/* Send a special block */
p_null = block_New( p_dec, 128 );
p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY;
if( p_dec->fmt_in.i_cat == SPU_ES )
p_null->i_flags |= BLOCK_FLAG_CORE_FLUSH;
/* FIXME check for p_packetizer or b_packitized from es_format_t of input ? */
if( p_owner->p_packetizer )
p_null->i_flags |= BLOCK_FLAG_CORRUPTED;
memset( p_null->p_buffer, 0, p_null->i_buffer );
input_DecoderDecode( p_dec, p_null );
}
/** /**
* Create a decoder object * Create a decoder object
* *
...@@ -769,13 +770,15 @@ static void DecoderSoutBufferFixTs( block_t *p_block, ...@@ -769,13 +770,15 @@ static void DecoderSoutBufferFixTs( block_t *p_block,
{ {
assert( p_clock ); assert( p_clock );
p_block->i_rate = input_clock_GetRate( p_clock ); p_block->i_rate = 0;
if( p_block->i_dts > 0 ) if( p_block->i_dts > 0 )
p_block->i_dts = input_clock_GetTS( p_clock, i_ts_delay, p_block->i_dts ); p_block->i_dts = input_clock_GetTS( p_clock, &p_block->i_rate,
i_ts_delay, p_block->i_dts );
if( p_block->i_pts > 0 ) if( p_block->i_pts > 0 )
p_block->i_pts = input_clock_GetTS( p_clock, i_ts_delay, p_block->i_pts ); p_block->i_pts = input_clock_GetTS( p_clock, &p_block->i_rate,
i_ts_delay, p_block->i_pts );
if( p_block->i_length > 0 ) if( p_block->i_length > 0 )
p_block->i_length = ( p_block->i_length * p_block->i_rate + p_block->i_length = ( p_block->i_length * p_block->i_rate +
...@@ -784,18 +787,23 @@ static void DecoderSoutBufferFixTs( block_t *p_block, ...@@ -784,18 +787,23 @@ static void DecoderSoutBufferFixTs( block_t *p_block,
if( b_teletext ) if( b_teletext )
p_block->i_pts = DecoderTeletextFixTs( p_block->i_pts, i_ts_delay ); p_block->i_pts = DecoderTeletextFixTs( p_block->i_pts, i_ts_delay );
} }
static void DecoderAoutBufferFixTs( aout_buffer_t *p_buffer, static void DecoderAoutBufferFixTs( aout_buffer_t *p_buffer, int *pi_rate,
input_clock_t *p_clock, mtime_t i_ts_delay ) input_clock_t *p_clock, mtime_t i_ts_delay )
{ {
/* sout display module does not set clock */ /* sout display module does not set clock */
if( !p_clock ) if( !p_clock )
return; return;
if( !p_buffer->start_date && !p_buffer->end_date )
*pi_rate = input_clock_GetRate( p_clock );
if( p_buffer->start_date ) if( p_buffer->start_date )
p_buffer->start_date = input_clock_GetTS( p_clock, i_ts_delay, p_buffer->start_date ); p_buffer->start_date = input_clock_GetTS( p_clock, pi_rate,
i_ts_delay, p_buffer->start_date );
if( p_buffer->end_date ) if( p_buffer->end_date )
p_buffer->end_date = input_clock_GetTS( p_clock, i_ts_delay, p_buffer->end_date ); p_buffer->end_date = input_clock_GetTS( p_clock, pi_rate,
i_ts_delay, p_buffer->end_date );
} }
static void DecoderVoutBufferFixTs( picture_t *p_picture, static void DecoderVoutBufferFixTs( picture_t *p_picture,
input_clock_t *p_clock, mtime_t i_ts_delay ) input_clock_t *p_clock, mtime_t i_ts_delay )
...@@ -805,7 +813,8 @@ static void DecoderVoutBufferFixTs( picture_t *p_picture, ...@@ -805,7 +813,8 @@ static void DecoderVoutBufferFixTs( picture_t *p_picture,
return; return;
if( p_picture->date ) if( p_picture->date )
p_picture->date = input_clock_GetTS( p_clock, i_ts_delay, p_picture->date ); p_picture->date = input_clock_GetTS( p_clock, NULL,
i_ts_delay, p_picture->date );
} }
static void DecoderSpuBufferFixTs( subpicture_t *p_subpic, static void DecoderSpuBufferFixTs( subpicture_t *p_subpic,
input_clock_t *p_clock, mtime_t i_ts_delay, input_clock_t *p_clock, mtime_t i_ts_delay,
...@@ -818,10 +827,12 @@ static void DecoderSpuBufferFixTs( subpicture_t *p_subpic, ...@@ -818,10 +827,12 @@ static void DecoderSpuBufferFixTs( subpicture_t *p_subpic,
return; return;
if( p_subpic->i_start ) if( p_subpic->i_start )
p_subpic->i_start = input_clock_GetTS( p_clock, i_ts_delay, p_subpic->i_start ); p_subpic->i_start = input_clock_GetTS( p_clock, NULL,
i_ts_delay, p_subpic->i_start );
if( p_subpic->i_stop ) if( p_subpic->i_stop )
p_subpic->i_stop = input_clock_GetTS( p_clock, i_ts_delay, p_subpic->i_stop ); p_subpic->i_stop = input_clock_GetTS( p_clock, NULL,
i_ts_delay, p_subpic->i_stop );
/* Do not create ephemere picture because of rounding errors */ /* Do not create ephemere picture because of rounding errors */
if( !b_ephemere && p_subpic->i_start == p_subpic->i_stop ) if( !b_ephemere && p_subpic->i_start == p_subpic->i_stop )
...@@ -845,7 +856,6 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block ) ...@@ -845,7 +856,6 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
{ {
aout_instance_t *p_aout = p_owner->p_aout; aout_instance_t *p_aout = p_owner->p_aout;
aout_input_t *p_aout_input = p_owner->p_aout_input; aout_input_t *p_aout_input = p_owner->p_aout_input;
int i_rate;
int i_lost; int i_lost;
int i_played; int i_played;
...@@ -875,15 +885,12 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block ) ...@@ -875,15 +885,12 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
DecoderWaitUnpause( p_dec ); DecoderWaitUnpause( p_dec );
const mtime_t i_delay = DecoderGetTotalDelay( p_dec ); const mtime_t i_delay = DecoderGetTotalDelay( p_dec );
int i_rate = INPUT_RATE_DEFAULT;
DecoderAoutBufferFixTs( p_aout_buf, p_clock, i_delay ); DecoderAoutBufferFixTs( p_aout_buf, &i_rate, p_clock, i_delay );
if( p_clock ) if( !p_clock && p_block && p_block->i_rate > 0 )
i_rate = input_clock_GetRate( p_clock );
else if( p_block && p_block->i_rate > 0 )
i_rate = p_block->i_rate; i_rate = p_block->i_rate;
else
i_rate = INPUT_RATE_DEFAULT;
/* FIXME TODO take care of audio-delay for mdate check */ /* FIXME TODO take care of audio-delay for mdate check */
const mtime_t i_max_date = mdate() + i_delay + AOUT_MAX_ADVANCE_TIME; const mtime_t i_max_date = mdate() + i_delay + AOUT_MAX_ADVANCE_TIME;
......
...@@ -367,25 +367,6 @@ mtime_t input_EsOutGetWakeup( es_out_t *out ) ...@@ -367,25 +367,6 @@ mtime_t input_EsOutGetWakeup( es_out_t *out )
return input_clock_GetWakeup( p_sys->p_pgrm->p_clock ); return input_clock_GetWakeup( p_sys->p_pgrm->p_clock );
} }
static void EsOutDiscontinuity( es_out_t *out, bool b_flush, bool b_audio )
{
es_out_sys_t *p_sys = out->p_sys;
int i;
for( i = 0; i < p_sys->i_es; i++ )
{
es_out_id_t *es = p_sys->es[i];
/* Send a dummy block to let decoder know that
* there is a discontinuity */
if( es->p_dec && ( !b_audio || es->fmt.i_cat == AUDIO_ES ) )
{
input_DecoderDiscontinuity( es->p_dec, b_flush );
if( es->p_dec_record )
input_DecoderDiscontinuity( es->p_dec_record, b_flush );
}
}
}
static void EsOutDecodersChangePause( es_out_t *out, bool b_paused, mtime_t i_date ) static void EsOutDecodersChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
{ {
es_out_sys_t *p_sys = out->p_sys; es_out_sys_t *p_sys = out->p_sys;
...@@ -542,10 +523,23 @@ void input_EsOutChangePause( es_out_t *out, bool b_paused, mtime_t i_date ) ...@@ -542,10 +523,23 @@ void input_EsOutChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
} }
void input_EsOutChangePosition( es_out_t *out ) void input_EsOutChangePosition( es_out_t *out )
{ {
//es_out_sys_t *p_sys = out->p_sys; es_out_sys_t *p_sys = out->p_sys;
for( int i = 0; i < p_sys->i_es; i++ )
{
es_out_id_t *es = p_sys->es[i];
/* Send a dummy block to let decoder know that
* there is a discontinuity */
if( es->p_dec )
{
input_DecoderFlush( es->p_dec );
if( es->p_dec_record )
input_DecoderFlush( es->p_dec_record );
}
}
es_out_Control( out, ES_OUT_RESET_PCR ); es_out_Control( out, ES_OUT_RESET_PCR );
EsOutDiscontinuity( out, true, false );
} }
bool input_EsOutDecodersEmpty( es_out_t *out ) bool input_EsOutDecodersEmpty( es_out_t *out )
...@@ -557,9 +551,9 @@ bool input_EsOutDecodersEmpty( es_out_t *out ) ...@@ -557,9 +551,9 @@ bool input_EsOutDecodersEmpty( es_out_t *out )
{ {
es_out_id_t *es = p_sys->es[i]; es_out_id_t *es = p_sys->es[i];
if( es->p_dec && !input_DecoderEmpty( es->p_dec ) ) if( es->p_dec && !input_DecoderIsEmpty( es->p_dec ) )
return false; return false;
if( es->p_dec_record && !input_DecoderEmpty( es->p_dec_record ) ) if( es->p_dec_record && !input_DecoderIsEmpty( es->p_dec_record ) )
return false; return false;
} }
return true; return true;
...@@ -1558,7 +1552,6 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) ...@@ -1558,7 +1552,6 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
{ {
es_out_sys_t *p_sys = out->p_sys; es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input; input_thread_t *p_input = p_sys->p_input;
es_out_pgrm_t *p_pgrm = es->p_pgrm;
int i_total = 0; int i_total = 0;
if( libvlc_stats( p_input ) ) if( libvlc_stats( p_input ) )
...@@ -1653,8 +1646,8 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es ) ...@@ -1653,8 +1646,8 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es )
{ {
while( !out->p_sys->p_input->b_die && es->p_dec ) while( !out->p_sys->p_input->b_die && es->p_dec )
{ {
if( input_DecoderEmpty( es->p_dec ) && if( input_DecoderIsEmpty( es->p_dec ) &&
( !es->p_dec_record || input_DecoderEmpty( es->p_dec_record ) )) ( !es->p_dec_record || input_DecoderIsEmpty( es->p_dec_record ) ))
break; break;
msleep( 20*1000 ); msleep( 20*1000 );
} }
...@@ -1933,7 +1926,7 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args ) ...@@ -1933,7 +1926,7 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
{ {
int64_t i_ts = (int64_t)va_arg( args, int64_t ); int64_t i_ts = (int64_t)va_arg( args, int64_t );
int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * ); int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * );
*pi_ts = input_clock_GetTS( p_sys->p_pgrm->p_clock, *pi_ts = input_clock_GetTS( p_sys->p_pgrm->p_clock, NULL,
p_sys->p_input->i_pts_delay, i_ts ); p_sys->p_input->i_pts_delay, i_ts );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -77,8 +77,11 @@ void input_clock_ChangePause( input_clock_t *, bool b_paused, mtime_t i_date ...@@ -77,8 +77,11 @@ void input_clock_ChangePause( input_clock_t *, bool b_paused, mtime_t i_date
/** /**
* This function converts a timestamp from stream clock to system clock. * This function converts a timestamp from stream clock to system clock.
*
* If pi_rate is provided it will be field with the rate value used for
* the conversion.
*/ */
mtime_t input_clock_GetTS( input_clock_t *, mtime_t i_pts_delay, mtime_t ); mtime_t input_clock_GetTS( input_clock_t *, int *pi_rate, mtime_t i_pts_delay, mtime_t );
/** /**
* This function returns the current rate. * This function returns the current rate.
......
...@@ -47,15 +47,14 @@ void input_DecoderChangePause( decoder_t *, bool b_paused, mtime_t i_date ); ...@@ -47,15 +47,14 @@ void input_DecoderChangePause( decoder_t *, bool b_paused, mtime_t i_date );
void input_DecoderChangeDelay( decoder_t *, mtime_t i_delay ); void input_DecoderChangeDelay( decoder_t *, mtime_t i_delay );
/** /**
* This function warn the decoder about a discontinuity and allow flushing * This function will cause a flush of the decoder.
* if requested.
*/ */
void input_DecoderDiscontinuity( decoder_t *, bool b_flush ); void input_DecoderFlush( decoder_t * );
/** /**
* This function returns true if the decoder fifo is empty and false otherwise. * This function returns true if the decoder fifo is empty and false otherwise.
*/ */
bool input_DecoderEmpty( decoder_t * ); bool input_DecoderIsEmpty( decoder_t * );
/** /**
* This function activates the request closed caption channel. * This function activates the request closed caption channel.
......
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