* src/input/clock.c: changes to the clock resync algo to remove some sensivity to...
authorGildas Bazin <gbazin@videolan.org>
Wed, 29 Sep 2004 18:14:31 +0000 (18:14 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 29 Sep 2004 18:14:31 +0000 (18:14 +0000)
* src/input/input.c: cr-average is now increased based on the input caching value.

src/input/clock.c
src/input/input.c

index e39e653..856d833 100644 (file)
@@ -311,24 +311,12 @@ void input_ClockSetPCR( input_thread_t *p_input,
         else
         {
             /* Smooth clock reference variations. */
-            mtime_t     i_extrapoled_clock = ClockCurrent( p_input, cl );
+            mtime_t i_extrapoled_clock = ClockCurrent( p_input, cl );
 
             /* Bresenham algorithm to smooth variations. */
-            if( cl->c_average_count == cl->i_cr_average )
-            {
-                cl->delta_cr = ( cl->delta_cr
-                                        * (cl->i_cr_average - 1)
-                                      + ( i_extrapoled_clock - i_clock ) )
-                                    / cl->i_cr_average;
-            }
-            else
-            {
-                cl->delta_cr = ( cl->delta_cr
-                                        * cl->c_average_count
-                                      + ( i_extrapoled_clock - i_clock ) )
-                                    / (cl->c_average_count + 1);
-                cl->c_average_count++;
-            }
+            cl->delta_cr = ( cl->delta_cr * (cl->i_cr_average - 1)
+                               + ( i_extrapoled_clock - i_clock ) )
+                           / cl->i_cr_average;
         }
     }
 }
index 7738924..44ddf51 100644 (file)
@@ -566,6 +566,11 @@ static int Init( input_thread_t * p_input )
     var_Get( p_input, "audio-desync", &val );
     if( val.i_int < 0 ) p_input->i_pts_delay -= (val.i_int * 1000);
 
+    /* Update cr_average depending on the caching */
+    p_input->input.i_cr_average *= (10 * p_input->i_pts_delay / 200000);
+    p_input->input.i_cr_average /= 10;
+    if( p_input->input.i_cr_average <= 0 ) p_input->input.i_cr_average = 1;
+
     /* Load master infos */
     /* Init length */
     if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_LENGTH,