]> git.sesse.net Git - vlc/commitdiff
* Added more stats
authorChristophe Massiot <massiot@videolan.org>
Mon, 27 Nov 2000 17:49:48 +0000 (17:49 +0000)
committerChristophe Massiot <massiot@videolan.org>
Mon, 27 Nov 2000 17:49:48 +0000 (17:49 +0000)
* Fixed a bug in the parser when trashing an already parsed frame
* Simplified (and enhanced) vpar_synchro for B pictures
* Lowered the synchro DELTA

TODO
include/video_decoder.h
include/video_fifo.h
include/video_parser.h
include/vpar_synchro.h
src/input/input.c
src/video_decoder/video_decoder.c
src/video_parser/video_parser.c
src/video_parser/vpar_headers.c
src/video_parser/vpar_synchro.c

diff --git a/TODO b/TODO
index 8fa951df20162a526b229ef5055454e906a6b3db..5521321e6854718af690c56541fbbe1155f3ac1a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -24,7 +24,7 @@ Description: Have more statistics messages displayed
  events, but there is no way to print these structures. In stats
  mode, we should print these structures regularly, or at quit
  time (whichever is the more convenient).
-Status: Todo
+Status: Done 27 Nov 2000 (Meuuh)
 
 Task: 0x3c
 Difficulty: Easy
@@ -42,7 +42,7 @@ Description: Write intf_WarnMsg and intf_StatMsg
  We have intf_ErrMsg to display fatal errors, but warnings are
  drowned in an ocean of unreadable intf_DbgMsg. Same for
  statistics messages.
-Status: Todo
+Status: Done 23 Nov 2000 (Stef)
 
 Task: 0x3a
 Difficulty: Hard
index 56c0b5527028b137b3ed7ab7eefd0febdbeb372c..4f9e630a8f29bfc3a3256b8f3ae284b823f96779 100644 (file)
@@ -61,16 +61,6 @@ typedef struct vdec_thread_s
     u8              pi_crop_buf[VDEC_CROPRANGE];
     u8 *            pi_crop;
 #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;
 
 /*****************************************************************************
index 43dd80a3ef644adcfd6b4149440ba7c937db5545..8d4f02a214400c1f48ddddbf05455c747128c51a 100644 (file)
@@ -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 );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
+        vpar_SynchroEnd( p_fifo->p_vpar, 0 );
 
         /* Unlink referenced pictures */
         if( p_mb->p_forward != NULL )
@@ -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 );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
+        vpar_SynchroEnd( p_fifo->p_vpar, 0 );
     }
 #endif
 }
@@ -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 );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
+        vpar_SynchroEnd( p_fifo->p_vpar, 1 );
 
         /* Unlink referenced pictures */
         if( p_mb->p_forward != NULL )
@@ -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 );
 
         /* Warn Synchro for its records. */
-        vpar_SynchroEnd( p_fifo->p_vpar );
+        vpar_SynchroEnd( p_fifo->p_vpar, 1 );
     }
 #endif
 }
index d822a662899dfdcd346ec3287f7f171b4eedc93c..a865d63671f296a9d5512edb8b87126a1b2941b7 100644 (file)
@@ -137,16 +137,12 @@ typedef struct vpar_thread_s
 #ifdef STATS
     /* Statistics */
     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_pictures;                   /* number of pictures read */
-    count_t         c_i_pictures;               /* number of I pictures read */
-    count_t         c_p_pictures;               /* number of P pictures read */
-    count_t         c_b_pictures;               /* number of B pictures read */
-    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 */
+    count_t         pc_pictures[4]; /* number of (coding_type) pictures read */
+    count_t         pc_decoded_pictures[4];       /* number of (coding_type)
+                                                   *        pictures decoded */
+    count_t         pc_malformed_pictures[4];  /* number of pictures trashed
+                                                * during parsing             */
 #endif
 } vpar_thread_t;
 
index fba5d02f242333bf579b91c01be070815c234113..3b371ec5c9df0ae0421e0a73e5568eb151ffd1fb 100644 (file)
@@ -91,5 +91,5 @@ void vpar_SynchroTrash          ( struct vpar_thread_s * p_vpar,
                                   int i_coding_type, int i_structure );
 void vpar_SynchroDecode         ( struct vpar_thread_s * p_vpar,
                                   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 );
index bfcf8341be0c918423757456840269058de5e32e..422058636e3d66870a875b5a0742e4c237a1350e 100644 (file)
@@ -905,6 +905,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
 #ifdef STATS
         i_dummy = p_ts_packet->i_payload_end - p_ts_packet->i_payload_start;
         p_es_descriptor->c_payload_bytes += i_dummy;
+        p_input->c_payload_bytes += i_dummy;
 #endif
 
         /* We can check if the packet is finished */
@@ -1401,6 +1402,14 @@ static void EndThread( input_thread_t * p_input )
     pi_status = p_input->pi_status;
     *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 */
     p_input->p_Close( p_input );
 
index 91aaf1e99426f7500c4106f1b2cba5baf1d60670..9a3b5ae6f6920e83420289f30a63255a05f0bc57 100644 (file)
@@ -156,16 +156,6 @@ int vdec_InitThread( vdec_thread_t *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
     /* Init crop table */
     p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1);
index 13e706630a2d4a19920dcff705d2acce4b35ed85..90b6909c2e588f09640aa9a841eea15563838614 100644 (file)
@@ -228,15 +228,11 @@ static int InitThread( vpar_thread_t *p_vpar )
     /* Initialize other properties */
 #ifdef STATS
     p_vpar->c_loops = 0;
-    p_vpar->c_idle_loops = 0;
-    p_vpar->c_pictures = 0;
-    p_vpar->c_i_pictures = 0;
-    p_vpar->c_p_pictures = 0;
-    p_vpar->c_b_pictures = 0;
-    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;
+    p_vpar->c_sequences = 0;
+    memset(p_vpar->pc_pictures, 0, sizeof(p_vpar->pc_pictures));
+    memset(p_vpar->pc_decoded_pictures, 0, sizeof(p_vpar->pc_decoded_pictures));
+    memset(p_vpar->pc_malformed_pictures, 0,
+           sizeof(p_vpar->pc_malformed_pictures));
 #endif
 
     /* Initialize video FIFO */
@@ -319,12 +315,11 @@ static void RunThread( vpar_thread_t *p_vpar )
         /* Find the next sequence header in the stream */
         p_vpar->b_error = vpar_NextSequenceHeader( p_vpar );
 
-#ifdef STATS
-        p_vpar->c_sequences++;
-#endif
-
         while( (!p_vpar->b_die) && (!p_vpar->b_error) )
         {
+#ifdef STATS
+            p_vpar->c_loops++;
+#endif
             /* Parse the next sequence, group or picture header */
             if( vpar_ParseHeader( p_vpar ) )
             {
@@ -399,6 +394,32 @@ static void EndThread( vpar_thread_t *p_vpar )
     /* XXX?? */
 #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 */
 //    vout_DestroyStream( p_vpar->p_vout, p_vpar->i_stream );
     /* XXX?? */
index aba20b110730292476a74dc3c906840a4967f0c1..3616e48b042b5a99136d78bf07cc38e4510eba8a 100644 (file)
@@ -268,7 +268,9 @@ int vpar_NextSequenceHeader( vpar_thread_t * p_vpar )
     {
         NextStartCode( p_vpar );
         if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_HEADER_CODE )
+        {
             return 0;
+        }
         RemoveBits( &p_vpar->bit_stream, 8 );
     }
     return 1;
@@ -285,6 +287,9 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar )
         switch( GetBits32( &p_vpar->bit_stream ) )
         {
         case SEQUENCE_HEADER_CODE:
+#ifdef STATS
+            p_vpar->c_sequences++;
+#endif
             SequenceHeader( p_vpar );
             return 0;
             break;
@@ -565,6 +570,10 @@ static void PictureHeader( vpar_thread_t * p_vpar )
         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 &&
         (i_structure == FRAME_STRUCTURE ||
          i_structure == p_vpar->picture.i_current_structure) )
@@ -646,6 +655,10 @@ static void PictureHeader( vpar_thread_t * p_vpar )
     }
 
     /* 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
     p_vpar->picture.b_error = 0;
     p_vpar->picture.b_frame_structure = (i_structure == FRAME_STRUCTURE);
@@ -739,8 +752,13 @@ static void PictureHeader( vpar_thread_t * p_vpar )
         }
 #endif
 
+#ifdef STATS
+        p_vpar->pc_malformed_pictures[p_vpar->picture.i_coding_type]++;
+#endif
+
         if( P_picture->i_deccount != 1 )
         {
+            vpar_SynchroEnd( p_vpar, 1 );
             vout_DestroyPicture( p_vpar->p_vout, P_picture );
         }
 
index 18612978e15b114918a13039acf0e2a4bb0e616e..5d83b1214579a1c1d1963ce83170bd6fb6579348 100644 (file)
@@ -131,7 +131,7 @@ static int  SynchroType( void );
 static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type );
 
 /* Error margins */
-#define DELTA                   (int)(0.060*CLOCK_FREQ)
+#define DELTA                   (int)(0.040*CLOCK_FREQ)
 
 #define DEFAULT_NB_P            5
 #define DEFAULT_NB_B            1
@@ -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);
 
                 /* 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
-                                 * ( 2 * S.i_n_b - S.i_eta_b - 1))
-                                   > (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);
-                }
+                b_decode &= (pts - now
+                             + period
+                             * ( 2 * S.i_n_b - S.i_eta_b + 2))
+                               > (TAU_PRIME(B_CODING_TYPE)
+                                   + TAU_PRIME(P_CODING_TYPE) + DELTA);
             }
             else
             {
@@ -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
  *****************************************************************************/
-void vpar_SynchroEnd( vpar_thread_t * p_vpar )
+void vpar_SynchroEnd( vpar_thread_t * p_vpar, int i_garbage )
 {
     mtime_t     tau;
     int         i_coding_type;
 
     vlc_mutex_lock( &p_vpar->synchro.fifo_lock );
 
-    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 )
+    if (!i_garbage)
     {
-        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 );
@@ -472,7 +464,9 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
     case I_CODING_TYPE:
         p_vpar->synchro.i_eta_p = p_vpar->synchro.i_eta_b = 0;
 #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[P_CODING_TYPE],
                   p_vpar->synchro.i_n_p,
@@ -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) -
                   p_vpar->synchro.i_trashed_pic,
                   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
         break;
     case P_CODING_TYPE: