Commit b1c90ec5 authored by Laurent Aimar's avatar Laurent Aimar

Moved a few vout tests+statistics to decoder.

It allows removing partially a ugly input dependency in vout as well as
finer control at decoder side.
parent 87b5a350
......@@ -880,8 +880,8 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
{
msg_Warn( p_aout, "received buffer in the future (%"PRId64")",
p_aout_buf->start_date - mdate() );
i_lost++;
}
i_lost++;
aout_DecDeleteBuffer( p_aout, p_aout_input, p_aout_buf );
}
......@@ -891,12 +891,14 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
if( i_decoded > 0 || i_lost > 0 || i_played > 0 )
{
vlc_mutex_lock( &p_input->p->counters.counters_lock);
stats_UpdateInteger( p_dec, p_input->p->counters.p_lost_abuffers,
i_lost, NULL );
stats_UpdateInteger( p_dec, p_input->p->counters.p_played_abuffers,
i_played, NULL );
stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_audio,
i_decoded, NULL );
vlc_mutex_unlock( &p_input->p->counters.counters_lock);
}
}
......@@ -1084,6 +1086,9 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
decoder_owner_sys_t *p_owner = p_dec->p_owner;
input_thread_t *p_input = p_owner->p_input;
picture_t *p_pic;
int i_lost = 0;
int i_decoded = 0;
int i_displayed = 0;
while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) )
{
......@@ -1097,9 +1102,7 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
break;
}
vlc_mutex_lock( &p_input->p->counters.counters_lock );
stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_video, 1, NULL );
vlc_mutex_unlock( &p_input->p->counters.counters_lock );
i_decoded++;
if( p_pic->date < p_owner->i_preroll_end )
{
......@@ -1124,12 +1127,51 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
DecoderVoutBufferFixTs( p_pic, p_owner->p_clock, p_input->i_pts_delay );
vout_DatePicture( p_vout, p_pic, p_pic->date );
/* Video is never delayed so simple */
const mtime_t i_max_date = mdate() + p_input->i_pts_delay + VOUT_BOGUS_DELAY;
/* Re-enable it but do it right this time */
//DecoderOptimizePtsDelay( p_dec );
if( p_pic->date > 0 && p_pic->date < i_max_date )
{
vout_DatePicture( p_vout, p_pic, p_pic->date );
vout_DisplayPicture( p_vout, p_pic );
/* Re-enable it but do it right this time */
//DecoderOptimizePtsDelay( p_dec );
vout_DisplayPicture( p_vout, p_pic );
}
else
{
if( p_pic->date <= 0 )
{
msg_Warn( p_vout, "non-dated video buffer received" );
}
else
{
msg_Warn( p_vout, "early picture skipped (%"PRId64")",
p_pic->date - mdate() );
}
i_lost++;
VoutDisplayedPicture( p_vout, p_pic );
}
int i_tmp_display;
int i_tmp_lost;
vout_GetResetStatistic( p_vout, &i_tmp_display, &i_tmp_lost );
i_displayed += i_tmp_display;
i_lost += i_tmp_lost;
}
if( i_decoded > 0 || i_lost > 0 || i_displayed > 0 )
{
vlc_mutex_lock( &p_input->p->counters.counters_lock );
stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_video,
i_decoded, NULL );
stats_UpdateInteger( p_dec, p_input->p->counters.p_lost_pictures,
i_lost , NULL);
stats_UpdateInteger( p_dec, p_input->p->counters.p_displayed_pictures,
i_displayed, NULL);
vlc_mutex_unlock( &p_input->p->counters.counters_lock );
}
}
......
......@@ -55,8 +55,10 @@
/** FIXME This is quite ugly but needed while we don't have counters
* helpers */
#include "input/input_internal.h"
//#include "input/input_internal.h"
#include <libvlc.h>
#include <vlc_input.h>
#include "modules/modules.h"
#include "vout_pictures.h"
#include "vout_internal.h"
......@@ -278,7 +280,6 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
{
vout_thread_t * p_vout; /* thread descriptor */
input_thread_t * p_input_thread;
int i_index; /* loop variable */
vlc_value_t val, text;
......@@ -364,6 +365,8 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
p_vout->i_alignment = 0;
p_vout->p->render_time = 10;
p_vout->p->c_fps_samples = 0;
p_vout->p->i_picture_lost = 0;
p_vout->p->i_picture_displayed = 0;
p_vout->p->b_filter_change = 0;
p_vout->p->b_paused = false;
p_vout->p->i_pause_date = 0;
......@@ -495,19 +498,6 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
var_Change( p_vout, "vout-filter", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_vout, "vout-filter", FilterCallback, NULL );
/* Calculate delay created by internal caching */
p_input_thread = (input_thread_t *)vlc_object_find( p_vout,
VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input_thread )
{
p_vout->p->i_pts_delay = p_input_thread->i_pts_delay;
vlc_object_release( p_input_thread );
}
else
{
p_vout->p->i_pts_delay = DEFAULT_PTS_DELAY;
}
if( vlc_thread_create( p_vout, "video output", RunThread,
VLC_THREAD_PRIORITY_OUTPUT, true ) )
{
......@@ -606,6 +596,18 @@ void vout_ChangePause( vout_thread_t *p_vout, bool b_paused, mtime_t i_date )
vlc_object_unlock( p_vout );
}
void vout_GetResetStatistic( vout_thread_t *p_vout, int *pi_displayed, int *pi_lost )
{
vlc_object_lock( p_vout );
*pi_displayed = p_vout->p->i_picture_displayed;
*pi_lost = p_vout->p->i_picture_lost;
p_vout->p->i_picture_displayed = 0;
p_vout->p->i_picture_lost = 0;
vlc_object_unlock( p_vout );
}
/*****************************************************************************
* InitThread: initialize video output thread
......@@ -822,7 +824,6 @@ static void* RunThread( vlc_object_t *p_this )
bool b_drop_late;
int i_displayed = 0, i_lost = 0;
int canc = vlc_savecancel ();
/*
......@@ -861,7 +862,6 @@ static void* RunThread( vlc_object_t *p_this )
picture_t *p_filtered_picture;
mtime_t display_date = 0;
picture_t *p_directbuffer;
input_thread_t *p_input;
int i_index;
#if 0
......@@ -873,21 +873,6 @@ static void* RunThread( vlc_object_t *p_this )
}
#endif
/* Update statistics */
p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
{
vlc_mutex_lock( &p_input->p->counters.counters_lock );
stats_UpdateInteger( p_vout, p_input->p->counters.p_lost_pictures,
i_lost , NULL);
stats_UpdateInteger( p_vout,
p_input->p->counters.p_displayed_pictures,
i_displayed , NULL);
i_displayed = i_lost = 0;
vlc_mutex_unlock( &p_input->p->counters.counters_lock );
vlc_object_release( p_input );
}
/*
* Find the picture to display (the one with the earliest date).
* This operation does not need lock, since only READY_PICTUREs
......@@ -945,24 +930,12 @@ static void* RunThread( vlc_object_t *p_this )
/* Picture is late: it will be destroyed and the thread
* will directly choose the next picture */
DropPicture( p_vout, p_picture );
i_lost++;
p_vout->p->i_picture_lost++;
msg_Warn( p_vout, "late picture skipped (%"PRId64")",
current_date - display_date );
continue;
}
if( display_date >
current_date + p_vout->p->i_pts_delay + VOUT_BOGUS_DELAY )
{
/* Picture is waaay too early: it will be destroyed */
DropPicture( p_vout, p_picture );
i_lost++;
msg_Warn( p_vout, "vout warning: early picture skipped "
"(%"PRId64")", display_date - current_date
- p_vout->p->i_pts_delay );
continue;
}
if( display_date > current_date + VOUT_DISPLAY_DELAY )
{
/* A picture is ready to be rendered, but its rendering date
......@@ -1014,7 +987,7 @@ static void* RunThread( vlc_object_t *p_this )
/*
* Perform rendering
*/
i_displayed++;
p_vout->p->i_picture_displayed++;
p_directbuffer = vout_RenderPicture( p_vout, p_filtered_picture,
p_subpic, p_vout->p->b_paused );
......
......@@ -50,8 +50,10 @@ struct vout_thread_sys_t
count_t c_fps_samples; /**< picture counts */
mtime_t p_fps_sample[VOUT_FPS_SAMPLES]; /**< FPS samples dates */
#if 0
/* Statistics */
int i_picture_lost;
int i_picture_displayed;
#if 0
count_t c_loops;
count_t c_pictures, c_late_pictures;
mtime_t display_jitter; /**< average deviation from the PTS */
......@@ -63,9 +65,6 @@ struct vout_thread_sys_t
bool b_paused;
mtime_t i_pause_date;
/** delay created by internal caching */
int i_pts_delay;
/* Filter chain */
char *psz_filter_chain;
bool b_filter_change;
......@@ -101,5 +100,10 @@ void vout_ChangePause( vout_thread_t *, bool b_paused, mtime_t i_date );
*/
void spu_OffsetSubtitleDate( spu_t *p_spu, mtime_t i_duration );
/**
* This function will return and reset internal statistics.
*/
void vout_GetResetStatistic( vout_thread_t *p_vout, int *pi_displayed, int *pi_lost );
#endif
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