]> git.sesse.net Git - vlc/commitdiff
. correction d'un bug dans l'interface framebuffer
authorSam Hocevar <sam@videolan.org>
Tue, 25 Jan 2000 05:44:12 +0000 (05:44 +0000)
committerSam Hocevar <sam@videolan.org>
Tue, 25 Jan 2000 05:44:12 +0000 (05:44 +0000)
 . d�but de synchro qui marchouille, mais tous mes flux merdent

Makefile
include/vpar_synchro.h
src/video_parser/video_parser.c
src/video_parser/vpar_synchro.c

index 57a68a8d1e8f84435be509864dc0ea113584e376..3dc3793f65582295ce14d7534af8a7927078cd61 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -32,8 +32,8 @@ SYS=LINUX
 #SYS=BEOS
 
 # Decoder choice - ?? old decoder will be removed soon
-DECODER=old
-#DECODER=new
+#DECODER=old
+DECODER=new
 
 # Debugging mode on or off
 DEBUG=1
index 6016ceacd474080ff631081a72624af9e1763e8e..c519a5738c3d3379bca70c301e5587d6b86debc1 100644 (file)
@@ -29,7 +29,8 @@ typedef struct video_synchro_fifo_s
 {
     /* type of image to be decoded, and decoding date */
     int i_image_type;
-    mtime_t decode_date;
+    mtime_t i_decode_date;
+    mtime_t i_pts;
     
 } video_synchro_fifo_t;
 
@@ -40,11 +41,14 @@ typedef struct video_synchro_s
     unsigned int i_fifo_start;
     unsigned int i_fifo_stop;
 
-    /* 0: I
-     * 1: P
-     * 2: B
-     */
-    mtime_t decode_time;
+    /* mean decoding time */
+    mtime_t i_mean_decode_time;
+    /* tells whether we accumulated delay */
+    mtime_t i_delay;
+    /* dates */
+    mtime_t i_last_pts;
+    mtime_t i_last_i_pts;
+    unsigned int i_images_since_pts;
     
     /* il manquait un compteur */
     unsigned int modulo;
@@ -60,6 +64,9 @@ typedef struct video_synchro_s
     video_synchro_tab_t tab_p[6];
     video_synchro_tab_t tab_b[6];
 
+    double theorical_fps;
+    double actual_fps;
+
 } video_synchro_t;
 
 /*****************************************************************************
index 21f4f764172f2f738fe84efad98792c4f941eb96..3279f29df3ff26c8f5210365be750db6c1f4539e 100644 (file)
@@ -245,13 +245,18 @@ static int InitThread( vpar_thread_t *p_vpar )
     /*
      * Initialize the synchro properties
      */
+    p_vpar->synchro.i_last_i_pts = 0;
+    p_vpar->synchro.theorical_fps = 30;
+    p_vpar->synchro.actual_fps = 25;
     /* the fifo */
     p_vpar->synchro.i_fifo_start = 0;
     p_vpar->synchro.i_fifo_stop = 0;
     /* the counter */
     p_vpar->synchro.modulo = 0;
-    /* mean decoding time - at least 100 ms */
-    p_vpar->synchro.decode_time = 500000;
+    /* mean decoding time - at least 200 ms for a slow machine */
+    p_vpar->synchro.i_mean_decode_time = 200000;
+    /* suppose we have no delay */
+    p_vpar->synchro.i_delay = 0;
     /* assume there were about 3 P and 6 B images between I's */
     p_vpar->synchro.current_p_count = 1;
     p_vpar->synchro.p_count_predict = 3;
index c684b2250db2e5fcbd89ed3de7741f050139f46f..51a7541fb0f3b52e138d5b29ba3f7362f48170d6 100644 (file)
@@ -65,17 +65,48 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
     float candidate_deviation;
     float optimal_deviation;
     float predict;
+    mtime_t i_current_pts;
+    decoder_fifo_t * decoder_fifo;
 
+    /* interpolate the current PTS */
+    decoder_fifo = p_vpar->bit_stream.p_decoder_fifo;
+    /* see if the current image has a pts - if not, interpolate */
+    if( i_current_pts = decoder_fifo->buffer[decoder_fifo->i_start]->i_pts )
+    {
+        p_vpar->synchro.i_images_since_pts = 1;
+    }
+    else
+    {
+        i_current_pts = p_vpar->synchro.i_last_pts
+                        + (1000000 / p_vpar->synchro.theorical_fps);
+        p_vpar->synchro.i_images_since_pts++;
+    }
+    p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_pts = i_current_pts;
+    p_vpar->synchro.i_last_pts = i_current_pts;
+
+       
+    /* update structures */
     switch(i_coding_type)
     {
         case P_CODING_TYPE:
+
             p_vpar->synchro.current_p_count++;
             break;
+
         case B_CODING_TYPE:
             p_vpar->synchro.current_b_count++;
             break;
+
         case I_CODING_TYPE:
 
+            /* update information about images we can decode */
+           if ( p_vpar->synchro.i_last_i_pts )
+            {
+                p_vpar->synchro.theorical_fps = 1000000 * (1 + p_vpar->synchro.current_b_count + p_vpar->synchro.current_p_count) / (i_current_pts - p_vpar->synchro.i_last_i_pts);
+           }
+            p_vpar->synchro.i_last_i_pts = i_current_pts;
+
+
             /* update all the structures for P images */
 
             /* period == 1 */
@@ -138,12 +169,12 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
 
            p_vpar->synchro.b_count_predict = predict;
             p_vpar->synchro.current_b_count = 0;
-
-
+           
             break;
     }
 
     p_vpar->synchro.modulo++;
+
 }
 
 /*****************************************************************************
@@ -152,24 +183,15 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
 boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
                               int i_structure )
 {
-    static int meuh = 1;
-    static int truc = 0;
-//    return( 1 );
-    if( i_coding_type == 1 )
-        meuh = 1;
-    if( i_coding_type == 2 )
-        meuh++;
-    truc++;
-    if( truc == 3 )
+
+    if( p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_decode_date + ((p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start) & 0xf) * p_vpar->synchro.i_mean_decode_time > mdate() )
     {
-       // while(1);
+        //fprintf( stderr, "chooser : we are à la bourre !\n");
+        return( i_coding_type == I_CODING_TYPE );
     }
-    return( i_coding_type == I_CODING_TYPE || (i_coding_type == P_CODING_TYPE) && (meuh == 2));
-    intf_DbgMsg("vpar debug: synchro image %i - modulo is %i\n", i_coding_type, p_vpar->synchro.modulo);
-    intf_DbgMsg("vpar debug: synchro predict P %e - predict B %e\n", p_vpar->synchro.p_count_predict, p_vpar->synchro.b_count_predict);
 
-    return(0);
-    return( i_coding_type == I_CODING_TYPE );
+    return( i_coding_type == I_CODING_TYPE || (i_coding_type == P_CODING_TYPE));
+
 }
 
 /*****************************************************************************
@@ -178,8 +200,6 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
 void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
                         int i_structure )
 {
-    //fprintf ( stderr, "trashing type %i\n", p_vpar->picture.i_coding_type );
-    
     vpar_SynchroUpdateStructures (p_vpar, i_coding_type);
 
 }
@@ -190,16 +210,13 @@ void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
 void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
                             int i_structure )
 {
-    //fprintf ( stderr, "decoding type %i\n", p_vpar->picture.i_coding_type );
-
     vpar_SynchroUpdateStructures (p_vpar, i_coding_type);
 
-    p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].decode_date = mdate();
+    p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_decode_date = mdate();
     p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_image_type
         = i_coding_type;
     p_vpar->synchro.i_fifo_stop = (p_vpar->synchro.i_fifo_stop + 1) & 0xf;
 
-    fprintf ( stderr, "%i images in synchro fifo\n", ( p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start ) & 0xf );
 }
 
 /*****************************************************************************
@@ -207,19 +224,14 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
  *****************************************************************************/
 void vpar_SynchroEnd( vpar_thread_t * p_vpar )
 {
-    mtime_t * p_decode_time;
+    mtime_t i_decode_time;
 
-    fprintf ( stderr, "type %i decoding time was %lli\n",
-        p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_image_type,
-       ( mdate()
-           - p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].decode_date )
-           / (( p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start ) & 0xf ));
+    i_decode_time = (mdate() -
+            p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_decode_date)
+        / (p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start & 0x0f);
 
-    p_vpar->synchro.decode_time =
-        ( (p_vpar->synchro.decode_time * 3) + (mdate()
-            - p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].decode_date)
-            / (( p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start)
-          & 0xf) ) >> 2;
+    p_vpar->synchro.i_mean_decode_time =
+        ( 3 * p_vpar->synchro.i_mean_decode_time + i_decode_time ) / 4;
 
     p_vpar->synchro.i_fifo_start = (p_vpar->synchro.i_fifo_start + 1) & 0xf;
 }
@@ -230,12 +242,17 @@ void vpar_SynchroEnd( vpar_thread_t * p_vpar )
 mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
 {
     decoder_fifo_t * fifo;
-    mtime_t displaydate;
-
-    fifo = p_vpar->bit_stream.p_decoder_fifo;
-    displaydate = fifo->buffer[fifo->i_start]->i_pts;
+    mtime_t i_displaydate;
+    mtime_t i_delay;
+
+    i_displaydate =
+        p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_decode_date;
+    /* this value should be removed */
+    i_displaydate += 500000;
+    i_delay = i_displaydate - mdate();
+    
+    //fprintf(stderr, "displaying type %i with delay %lli)\n", p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_image_type, i_delay);
 
-    if (displaydate) fprintf(stderr, "displaying type %i at %lli, (time %lli, delta %lli)\n", p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_image_type, displaydate, mdate() + 1000000, displaydate - mdate() - 1000000);
-    return displaydate;
+    return i_displaydate;
 }