Commit aa7cf7ba authored by Christophe Massiot's avatar Christophe Massiot

* Added more stats

* Fixed a bug in the parser when trashing an already parsed frame
* Simplified (and enhanced) vpar_synchro for B pictures
* Lowered the synchro DELTA
parent b335e3b4
...@@ -24,7 +24,7 @@ Description: Have more statistics messages displayed ...@@ -24,7 +24,7 @@ Description: Have more statistics messages displayed
events, but there is no way to print these structures. In stats events, but there is no way to print these structures. In stats
mode, we should print these structures regularly, or at quit mode, we should print these structures regularly, or at quit
time (whichever is the more convenient). time (whichever is the more convenient).
Status: Todo Status: Done 27 Nov 2000 (Meuuh)
Task: 0x3c Task: 0x3c
Difficulty: Easy Difficulty: Easy
...@@ -42,7 +42,7 @@ Description: Write intf_WarnMsg and intf_StatMsg ...@@ -42,7 +42,7 @@ Description: Write intf_WarnMsg and intf_StatMsg
We have intf_ErrMsg to display fatal errors, but warnings are We have intf_ErrMsg to display fatal errors, but warnings are
drowned in an ocean of unreadable intf_DbgMsg. Same for drowned in an ocean of unreadable intf_DbgMsg. Same for
statistics messages. statistics messages.
Status: Todo Status: Done 23 Nov 2000 (Stef)
Task: 0x3a Task: 0x3a
Difficulty: Hard Difficulty: Hard
......
...@@ -61,16 +61,6 @@ typedef struct vdec_thread_s ...@@ -61,16 +61,6 @@ typedef struct vdec_thread_s
u8 pi_crop_buf[VDEC_CROPRANGE]; u8 pi_crop_buf[VDEC_CROPRANGE];
u8 * pi_crop; u8 * pi_crop;
#endif #endif
#ifdef STATS
/* Statistics */
count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */
count_t c_decoded_pictures; /* number of pictures decoded */
count_t c_decoded_i_pictures; /* number of I pictures decoded */
count_t c_decoded_p_pictures; /* number of P pictures decoded */
count_t c_decoded_b_pictures; /* number of B pictures decoded */
#endif
} vdec_thread_t; } vdec_thread_t;
/***************************************************************************** /*****************************************************************************
......
...@@ -155,7 +155,7 @@ static __inline__ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, ...@@ -155,7 +155,7 @@ static __inline__ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo,
vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture ); vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
/* Warn Synchro for its records. */ /* Warn Synchro for its records. */
vpar_SynchroEnd( p_fifo->p_vpar ); vpar_SynchroEnd( p_fifo->p_vpar, 0 );
/* Unlink referenced pictures */ /* Unlink referenced pictures */
if( p_mb->p_forward != NULL ) if( p_mb->p_forward != NULL )
...@@ -183,7 +183,7 @@ static __inline__ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, ...@@ -183,7 +183,7 @@ static __inline__ void vpar_ReleaseMacroblock( video_fifo_t * p_fifo,
vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture ); vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
/* Warn Synchro for its records. */ /* Warn Synchro for its records. */
vpar_SynchroEnd( p_fifo->p_vpar ); vpar_SynchroEnd( p_fifo->p_vpar, 0 );
} }
#endif #endif
} }
...@@ -211,7 +211,7 @@ static __inline__ void vpar_DestroyMacroblock( video_fifo_t * p_fifo, ...@@ -211,7 +211,7 @@ static __inline__ void vpar_DestroyMacroblock( video_fifo_t * p_fifo,
vout_DestroyPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture ); vout_DestroyPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
/* Warn Synchro for its records. */ /* Warn Synchro for its records. */
vpar_SynchroEnd( p_fifo->p_vpar ); vpar_SynchroEnd( p_fifo->p_vpar, 1 );
/* Unlink referenced pictures */ /* Unlink referenced pictures */
if( p_mb->p_forward != NULL ) if( p_mb->p_forward != NULL )
...@@ -239,7 +239,7 @@ static __inline__ void vpar_DestroyMacroblock( video_fifo_t * p_fifo, ...@@ -239,7 +239,7 @@ static __inline__ void vpar_DestroyMacroblock( video_fifo_t * p_fifo,
vout_DestroyPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture ); vout_DestroyPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
/* Warn Synchro for its records. */ /* Warn Synchro for its records. */
vpar_SynchroEnd( p_fifo->p_vpar ); vpar_SynchroEnd( p_fifo->p_vpar, 1 );
} }
#endif #endif
} }
......
...@@ -137,16 +137,12 @@ typedef struct vpar_thread_s ...@@ -137,16 +137,12 @@ typedef struct vpar_thread_s
#ifdef STATS #ifdef STATS
/* Statistics */ /* Statistics */
count_t c_loops; /* number of loops */ count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */
count_t c_sequences; /* number of sequences */ count_t c_sequences; /* number of sequences */
count_t c_pictures; /* number of pictures read */ count_t pc_pictures[4]; /* number of (coding_type) pictures read */
count_t c_i_pictures; /* number of I pictures read */ count_t pc_decoded_pictures[4]; /* number of (coding_type)
count_t c_p_pictures; /* number of P pictures read */ * pictures decoded */
count_t c_b_pictures; /* number of B pictures read */ count_t pc_malformed_pictures[4]; /* number of pictures trashed
count_t c_decoded_pictures; /* number of pictures decoded */ * during parsing */
count_t c_decoded_i_pictures; /* number of I pictures decoded */
count_t c_decoded_p_pictures; /* number of P pictures decoded */
count_t c_decoded_b_pictures; /* number of B pictures decoded */
#endif #endif
} vpar_thread_t; } vpar_thread_t;
......
...@@ -91,5 +91,5 @@ void vpar_SynchroTrash ( struct vpar_thread_s * p_vpar, ...@@ -91,5 +91,5 @@ void vpar_SynchroTrash ( struct vpar_thread_s * p_vpar,
int i_coding_type, int i_structure ); int i_coding_type, int i_structure );
void vpar_SynchroDecode ( struct vpar_thread_s * p_vpar, void vpar_SynchroDecode ( struct vpar_thread_s * p_vpar,
int i_coding_type, int i_structure ); int i_coding_type, int i_structure );
void vpar_SynchroEnd ( struct vpar_thread_s * p_vpar ); void vpar_SynchroEnd ( struct vpar_thread_s * p_vpar, int i_garbage );
mtime_t vpar_SynchroDate ( struct vpar_thread_s * p_vpar ); mtime_t vpar_SynchroDate ( struct vpar_thread_s * p_vpar );
...@@ -905,6 +905,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input, ...@@ -905,6 +905,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
#ifdef STATS #ifdef STATS
i_dummy = p_ts_packet->i_payload_end - p_ts_packet->i_payload_start; i_dummy = p_ts_packet->i_payload_end - p_ts_packet->i_payload_start;
p_es_descriptor->c_payload_bytes += i_dummy; p_es_descriptor->c_payload_bytes += i_dummy;
p_input->c_payload_bytes += i_dummy;
#endif #endif
/* We can check if the packet is finished */ /* We can check if the packet is finished */
...@@ -1401,6 +1402,14 @@ static void EndThread( input_thread_t * p_input ) ...@@ -1401,6 +1402,14 @@ static void EndThread( input_thread_t * p_input )
pi_status = p_input->pi_status; pi_status = p_input->pi_status;
*pi_status = THREAD_END; *pi_status = THREAD_END;
#ifdef STATS
intf_Msg("input stats: Done %d loops\n", p_input->c_loops);
intf_Msg("input stats: Read %d bytes (payload : %d)\n", p_input->c_bytes,
p_input->c_payload_bytes);
intf_Msg("input stats: Read %d packets (trashed : %d)\n",
p_input->c_packets_read, p_input->c_packets_trashed);
#endif
/* Close input method */ /* Close input method */
p_input->p_Close( p_input ); p_input->p_Close( p_input );
......
...@@ -156,16 +156,6 @@ int vdec_InitThread( vdec_thread_t *p_vdec ) ...@@ -156,16 +156,6 @@ int vdec_InitThread( vdec_thread_t *p_vdec )
intf_DbgMsg("vdec debug: initializing video decoder thread %p\n", p_vdec); intf_DbgMsg("vdec debug: initializing video decoder thread %p\n", p_vdec);
/* Initialize other properties */
#ifdef STATS
p_vdec->c_loops = 0;
p_vdec->c_idle_loops = 0;
p_vdec->c_decoded_pictures = 0;
p_vdec->c_decoded_i_pictures = 0;
p_vdec->c_decoded_p_pictures = 0;
p_vdec->c_decoded_b_pictures = 0;
#endif
#ifndef HAVE_MMX #ifndef HAVE_MMX
/* Init crop table */ /* Init crop table */
p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1); p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1);
......
...@@ -228,15 +228,11 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -228,15 +228,11 @@ static int InitThread( vpar_thread_t *p_vpar )
/* Initialize other properties */ /* Initialize other properties */
#ifdef STATS #ifdef STATS
p_vpar->c_loops = 0; p_vpar->c_loops = 0;
p_vpar->c_idle_loops = 0; p_vpar->c_sequences = 0;
p_vpar->c_pictures = 0; memset(p_vpar->pc_pictures, 0, sizeof(p_vpar->pc_pictures));
p_vpar->c_i_pictures = 0; memset(p_vpar->pc_decoded_pictures, 0, sizeof(p_vpar->pc_decoded_pictures));
p_vpar->c_p_pictures = 0; memset(p_vpar->pc_malformed_pictures, 0,
p_vpar->c_b_pictures = 0; sizeof(p_vpar->pc_malformed_pictures));
p_vpar->c_decoded_pictures = 0;
p_vpar->c_decoded_i_pictures = 0;
p_vpar->c_decoded_p_pictures = 0;
p_vpar->c_decoded_b_pictures = 0;
#endif #endif
/* Initialize video FIFO */ /* Initialize video FIFO */
...@@ -319,12 +315,11 @@ static void RunThread( vpar_thread_t *p_vpar ) ...@@ -319,12 +315,11 @@ static void RunThread( vpar_thread_t *p_vpar )
/* Find the next sequence header in the stream */ /* Find the next sequence header in the stream */
p_vpar->b_error = vpar_NextSequenceHeader( p_vpar ); p_vpar->b_error = vpar_NextSequenceHeader( p_vpar );
#ifdef STATS
p_vpar->c_sequences++;
#endif
while( (!p_vpar->b_die) && (!p_vpar->b_error) ) while( (!p_vpar->b_die) && (!p_vpar->b_error) )
{ {
#ifdef STATS
p_vpar->c_loops++;
#endif
/* Parse the next sequence, group or picture header */ /* Parse the next sequence, group or picture header */
if( vpar_ParseHeader( p_vpar ) ) if( vpar_ParseHeader( p_vpar ) )
{ {
...@@ -399,6 +394,32 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -399,6 +394,32 @@ static void EndThread( vpar_thread_t *p_vpar )
/* XXX?? */ /* XXX?? */
#endif #endif
#ifdef STATS
intf_Msg("vpar stats: %d loops among %d sequence(s)\n",
p_vpar->c_loops, p_vpar->c_sequences);
intf_Msg("vpar stats: Read %d frames/fields (I %d/P %d/B %d)\n",
p_vpar->pc_pictures[I_CODING_TYPE]
+ p_vpar->pc_pictures[P_CODING_TYPE]
+ p_vpar->pc_pictures[B_CODING_TYPE],
p_vpar->pc_pictures[I_CODING_TYPE],
p_vpar->pc_pictures[P_CODING_TYPE],
p_vpar->pc_pictures[B_CODING_TYPE]);
intf_Msg("vpar stats: Decoded %d frames/fields (I %d/P %d/B %d)\n",
p_vpar->pc_decoded_pictures[I_CODING_TYPE]
+ p_vpar->pc_decoded_pictures[P_CODING_TYPE]
+ p_vpar->pc_decoded_pictures[B_CODING_TYPE],
p_vpar->pc_decoded_pictures[I_CODING_TYPE],
p_vpar->pc_decoded_pictures[P_CODING_TYPE],
p_vpar->pc_decoded_pictures[B_CODING_TYPE]);
intf_Msg("vpar stats: Read %d malformed frames/fields (I %d/P %d/B %d)\n",
p_vpar->pc_malformed_pictures[I_CODING_TYPE]
+ p_vpar->pc_malformed_pictures[P_CODING_TYPE]
+ p_vpar->pc_malformed_pictures[B_CODING_TYPE],
p_vpar->pc_malformed_pictures[I_CODING_TYPE],
p_vpar->pc_malformed_pictures[P_CODING_TYPE],
p_vpar->pc_malformed_pictures[B_CODING_TYPE]);
#endif
/* Destroy thread structures allocated by InitThread */ /* Destroy thread structures allocated by InitThread */
// vout_DestroyStream( p_vpar->p_vout, p_vpar->i_stream ); // vout_DestroyStream( p_vpar->p_vout, p_vpar->i_stream );
/* XXX?? */ /* XXX?? */
......
...@@ -268,7 +268,9 @@ int vpar_NextSequenceHeader( vpar_thread_t * p_vpar ) ...@@ -268,7 +268,9 @@ int vpar_NextSequenceHeader( vpar_thread_t * p_vpar )
{ {
NextStartCode( p_vpar ); NextStartCode( p_vpar );
if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_HEADER_CODE ) if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_HEADER_CODE )
{
return 0; return 0;
}
RemoveBits( &p_vpar->bit_stream, 8 ); RemoveBits( &p_vpar->bit_stream, 8 );
} }
return 1; return 1;
...@@ -285,6 +287,9 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar ) ...@@ -285,6 +287,9 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar )
switch( GetBits32( &p_vpar->bit_stream ) ) switch( GetBits32( &p_vpar->bit_stream ) )
{ {
case SEQUENCE_HEADER_CODE: case SEQUENCE_HEADER_CODE:
#ifdef STATS
p_vpar->c_sequences++;
#endif
SequenceHeader( p_vpar ); SequenceHeader( p_vpar );
return 0; return 0;
break; break;
...@@ -565,6 +570,10 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -565,6 +570,10 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar->picture.b_progressive_frame = 1; p_vpar->picture.b_progressive_frame = 1;
} }
#ifdef STATS
p_vpar->pc_pictures[p_vpar->picture.i_coding_type]++;
#endif
if( p_vpar->picture.i_current_structure && if( p_vpar->picture.i_current_structure &&
(i_structure == FRAME_STRUCTURE || (i_structure == FRAME_STRUCTURE ||
i_structure == p_vpar->picture.i_current_structure) ) i_structure == p_vpar->picture.i_current_structure) )
...@@ -646,6 +655,10 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -646,6 +655,10 @@ static void PictureHeader( vpar_thread_t * p_vpar )
} }
/* OK, now we are sure we will decode the picture. */ /* OK, now we are sure we will decode the picture. */
#ifdef STATS
p_vpar->pc_decoded_pictures[p_vpar->picture.i_coding_type]++;
#endif
#define P_picture p_vpar->picture.p_picture #define P_picture p_vpar->picture.p_picture
p_vpar->picture.b_error = 0; p_vpar->picture.b_error = 0;
p_vpar->picture.b_frame_structure = (i_structure == FRAME_STRUCTURE); p_vpar->picture.b_frame_structure = (i_structure == FRAME_STRUCTURE);
...@@ -739,8 +752,13 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -739,8 +752,13 @@ static void PictureHeader( vpar_thread_t * p_vpar )
} }
#endif #endif
#ifdef STATS
p_vpar->pc_malformed_pictures[p_vpar->picture.i_coding_type]++;
#endif
if( P_picture->i_deccount != 1 ) if( P_picture->i_deccount != 1 )
{ {
vpar_SynchroEnd( p_vpar, 1 );
vout_DestroyPicture( p_vpar->p_vout, P_picture ); vout_DestroyPicture( p_vpar->p_vout, P_picture );
} }
......
...@@ -131,7 +131,7 @@ static int SynchroType( void ); ...@@ -131,7 +131,7 @@ static int SynchroType( void );
static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type ); static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type );
/* Error margins */ /* Error margins */
#define DELTA (int)(0.060*CLOCK_FREQ) #define DELTA (int)(0.040*CLOCK_FREQ)
#define DEFAULT_NB_P 5 #define DEFAULT_NB_P 5
#define DEFAULT_NB_B 1 #define DEFAULT_NB_B 1
...@@ -299,22 +299,11 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type, ...@@ -299,22 +299,11 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
b_decode = (pts - now) > (TAU_PRIME(B_CODING_TYPE) + DELTA); b_decode = (pts - now) > (TAU_PRIME(B_CODING_TYPE) + DELTA);
/* Remember that S.i_eta_b is for the moment only eta_b - 1. */ /* Remember that S.i_eta_b is for the moment only eta_b - 1. */
if( S.i_eta_p != S.i_n_p ) /* next P */ b_decode &= (pts - now
{ + period
b_decode &= (pts - now * ( 2 * S.i_n_b - S.i_eta_b + 2))
+ period > (TAU_PRIME(B_CODING_TYPE)
* ( 2 * S.i_n_b - S.i_eta_b - 1)) + TAU_PRIME(P_CODING_TYPE) + DELTA);
> (TAU_PRIME(B_CODING_TYPE)
+ TAU_PRIME(P_CODING_TYPE) + DELTA);
}
else /* next I */
{
b_decode &= (pts - now
+ period
* ( 2 * S.i_n_b - S.i_eta_b - 1))
> (TAU_PRIME(B_CODING_TYPE)
+ TAU_PRIME(I_CODING_TYPE) + DELTA);
}
} }
else else
{ {
...@@ -370,24 +359,27 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type, ...@@ -370,24 +359,27 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
/***************************************************************************** /*****************************************************************************
* vpar_SynchroEnd : Called when the image is totally decoded * vpar_SynchroEnd : Called when the image is totally decoded
*****************************************************************************/ *****************************************************************************/
void vpar_SynchroEnd( vpar_thread_t * p_vpar ) void vpar_SynchroEnd( vpar_thread_t * p_vpar, int i_garbage )
{ {
mtime_t tau; mtime_t tau;
int i_coding_type; int i_coding_type;
vlc_mutex_lock( &p_vpar->synchro.fifo_lock ); vlc_mutex_lock( &p_vpar->synchro.fifo_lock );
tau = mdate() - p_vpar->synchro.p_date_fifo[p_vpar->synchro.i_start]; if (!i_garbage)
i_coding_type = p_vpar->synchro.pi_coding_types[p_vpar->synchro.i_start];
/* Mean with average tau, to ensure stability. */
p_vpar->synchro.p_tau[i_coding_type] =
(p_vpar->synchro.pi_meaningful[i_coding_type]
* p_vpar->synchro.p_tau[i_coding_type] + tau)
/ (p_vpar->synchro.pi_meaningful[i_coding_type] + 1);
if( p_vpar->synchro.pi_meaningful[i_coding_type] < MAX_PIC_AVERAGE )
{ {
p_vpar->synchro.pi_meaningful[i_coding_type]++; tau = mdate() - p_vpar->synchro.p_date_fifo[p_vpar->synchro.i_start];
i_coding_type = p_vpar->synchro.pi_coding_types[p_vpar->synchro.i_start];
/* Mean with average tau, to ensure stability. */
p_vpar->synchro.p_tau[i_coding_type] =
(p_vpar->synchro.pi_meaningful[i_coding_type]
* p_vpar->synchro.p_tau[i_coding_type] + tau)
/ (p_vpar->synchro.pi_meaningful[i_coding_type] + 1);
if( p_vpar->synchro.pi_meaningful[i_coding_type] < MAX_PIC_AVERAGE )
{
p_vpar->synchro.pi_meaningful[i_coding_type]++;
}
} }
FIFO_INCREMENT( i_start ); FIFO_INCREMENT( i_start );
...@@ -472,7 +464,9 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type ) ...@@ -472,7 +464,9 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
case I_CODING_TYPE: case I_CODING_TYPE:
p_vpar->synchro.i_eta_p = p_vpar->synchro.i_eta_b = 0; p_vpar->synchro.i_eta_p = p_vpar->synchro.i_eta_b = 0;
#ifdef STATS #ifdef STATS
intf_Msg( "vpar synchro stats: I(%lld) P(%lld)[%d] B(%lld)[%d] YUV(%lld) : %d/%d\n", if( p_vpar->synchro.i_type == VPAR_SYNCHRO_DEFAULT )
{
intf_Msg( "vpar synchro stats: I(%lld) P(%lld)[%d] B(%lld)[%d] YUV(%lld) : %d/%d\n",
p_vpar->synchro.p_tau[I_CODING_TYPE], p_vpar->synchro.p_tau[I_CODING_TYPE],
p_vpar->synchro.p_tau[P_CODING_TYPE], p_vpar->synchro.p_tau[P_CODING_TYPE],
p_vpar->synchro.i_n_p, p_vpar->synchro.i_n_p,
...@@ -482,7 +476,8 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type ) ...@@ -482,7 +476,8 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
1 + p_vpar->synchro.i_n_p * (1 + p_vpar->synchro.i_n_b) - 1 + p_vpar->synchro.i_n_p * (1 + p_vpar->synchro.i_n_b) -
p_vpar->synchro.i_trashed_pic, p_vpar->synchro.i_trashed_pic,
1 + p_vpar->synchro.i_n_p * (1 + p_vpar->synchro.i_n_b) ); 1 + p_vpar->synchro.i_n_p * (1 + p_vpar->synchro.i_n_b) );
p_vpar->synchro.i_trashed_pic = 0; p_vpar->synchro.i_trashed_pic = 0;
}
#endif #endif
break; break;
case P_CODING_TYPE: case P_CODING_TYPE:
......
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