Revision 494065ca libavformat/timefilter.c

View differences:

libavformat/timefilter.c
32 32
    double feedback2_factor;
33 33
    double feedback3_factor;
34 34
    double integrator2_state;
35
    int count;
35 36
};
36 37

  
37 38
TimeFilter * ff_timefilter_new(double feedback2_factor, double feedback3_factor)
......
51 52
void ff_timefilter_reset(TimeFilter *self)
52 53
{
53 54
    self->cycle_time = 0;
55
    self->count      = 0;
54 56
}
55 57

  
56 58
double ff_timefilter_update(TimeFilter *self, double system_time, double period)
57 59
{
60
    self->count++;
58 61
    if (!self->cycle_time) {
59 62
        /// init loop
60 63
        self->cycle_time        = system_time;
......
65 68
        loop_error = system_time - self->cycle_time;
66 69

  
67 70
        /// update loop
68
        self->cycle_time        += self->feedback2_factor * loop_error;
71
        self->cycle_time        += FFMAX(self->feedback2_factor, 1.0/(self->count)) * loop_error;
69 72
        self->integrator2_state += self->feedback3_factor * loop_error / period;
70 73
    }
71 74
    return self->cycle_time;

Also available in: Unified diff