changeset 4654:d90df812a2a1 libavformat

Adapt first factor.
author michael
date Fri, 06 Mar 2009 00:20:55 +0000
parents 34a843f958b7
children d9f082019a79
files timefilter.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/timefilter.c	Fri Mar 06 00:14:44 2009 +0000
+++ b/timefilter.c	Fri Mar 06 00:20:55 2009 +0000
@@ -32,6 +32,7 @@
     double feedback2_factor;
     double feedback3_factor;
     double integrator2_state;
+    int count;
 };
 
 TimeFilter * ff_timefilter_new(double feedback2_factor, double feedback3_factor)
@@ -51,10 +52,12 @@
 void ff_timefilter_reset(TimeFilter *self)
 {
     self->cycle_time = 0;
+    self->count      = 0;
 }
 
 double ff_timefilter_update(TimeFilter *self, double system_time, double period)
 {
+    self->count++;
     if (!self->cycle_time) {
         /// init loop
         self->cycle_time        = system_time;
@@ -65,7 +68,7 @@
         loop_error = system_time - self->cycle_time;
 
         /// update loop
-        self->cycle_time        += self->feedback2_factor * loop_error;
+        self->cycle_time        += FFMAX(self->feedback2_factor, 1.0/(self->count)) * loop_error;
         self->integrator2_state += self->feedback3_factor * loop_error / period;
     }
     return self->cycle_time;