Originally committed as revision 17840 to svn://svn.ffmpeg.org/ffmpeg/trunk
Michael Niedermayer authored on 2009/03/06 09:09:14... | ... |
@@ -34,10 +34,10 @@ struct TimeFilter { |
34 | 34 |
double integrator2_state; |
35 | 35 |
}; |
36 | 36 |
|
37 |
-TimeFilter * ff_timefilter_new(double period, double feedback2_factor, double feedback3_factor) |
|
37 |
+TimeFilter * ff_timefilter_new(double feedback2_factor, double feedback3_factor) |
|
38 | 38 |
{ |
39 | 39 |
TimeFilter *self = av_mallocz(sizeof(TimeFilter)); |
40 |
- self->integrator2_state = period; |
|
40 |
+ self->integrator2_state = 1.0; |
|
41 | 41 |
self->feedback2_factor = feedback2_factor; |
42 | 42 |
self->feedback3_factor = feedback3_factor; |
43 | 43 |
return self; |
... | ... |
@@ -53,20 +53,20 @@ void ff_timefilter_reset(TimeFilter *self) |
53 | 53 |
self->cycle_time = 0; |
54 | 54 |
} |
55 | 55 |
|
56 |
-void ff_timefilter_update(TimeFilter *self, double system_time) |
|
56 |
+void ff_timefilter_update(TimeFilter *self, double system_time, double period) |
|
57 | 57 |
{ |
58 | 58 |
if (!self->cycle_time) { |
59 | 59 |
/// init loop |
60 | 60 |
self->cycle_time = system_time; |
61 | 61 |
} else { |
62 | 62 |
double loop_error; |
63 |
- self->cycle_time+= self->integrator2_state; |
|
63 |
+ self->cycle_time+= self->integrator2_state * period; |
|
64 | 64 |
/// calculate loop error |
65 | 65 |
loop_error = system_time - self->cycle_time; |
66 | 66 |
|
67 | 67 |
/// update loop |
68 | 68 |
self->cycle_time += self->feedback2_factor * loop_error; |
69 |
- self->integrator2_state += self->feedback3_factor * loop_error; |
|
69 |
+ self->integrator2_state += self->feedback3_factor * loop_error / period; |
|
70 | 70 |
} |
71 | 71 |
} |
72 | 72 |
|
... | ... |
@@ -37,10 +37,6 @@ typedef struct TimeFilter TimeFilter; |
37 | 37 |
/** |
38 | 38 |
* Create a new Delay Locked Loop time filter |
39 | 39 |
* |
40 |
- * period is the device cycle duration in seconds. For example, at |
|
41 |
- * 44.1Hz and a buffer size of 512 frames, period = 512 / 44100. The filter |
|
42 |
- * only works if the cycle duration is fixed. |
|
43 |
- * |
|
44 | 40 |
* feedback2_factor and feedback3_factor are the factors used for the |
45 | 41 |
* multiplications that are respectively performed in the second and third |
46 | 42 |
* feedback paths of the loop. |
... | ... |
@@ -58,19 +54,22 @@ typedef struct TimeFilter TimeFilter; |
58 | 58 |
* For more details about these parameters and background concepts please see: |
59 | 59 |
* http://www.kokkinizita.net/papers/usingdll.pdf |
60 | 60 |
*/ |
61 |
-TimeFilter * ff_timefilter_new(double period, double feedback2_factor, double feedback3_factor); |
|
61 |
+TimeFilter * ff_timefilter_new(double feedback2_factor, double feedback3_factor); |
|
62 | 62 |
|
63 | 63 |
/** |
64 | 64 |
* Update the filter |
65 | 65 |
* |
66 | 66 |
* This function must be called in real time, at each process cycle. |
67 | 67 |
* |
68 |
+ * period is the device cycle duration in seconds. For example, at |
|
69 |
+ * 44.1Hz and a buffer size of 512 frames, period = 512 / 44100. |
|
70 |
+ * |
|
68 | 71 |
* system_time, in seconds, should be the value of the system clock time, |
69 | 72 |
* at (or as close as possible to) the moment the device hardware interrupt |
70 | 73 |
* occured (or any other event the device clock raises at the beginning of a |
71 | 74 |
* cycle). |
72 | 75 |
*/ |
73 |
-void ff_timefilter_update(TimeFilter *self, double system_time); |
|
76 |
+void ff_timefilter_update(TimeFilter *self, double system_time, double period); |
|
74 | 77 |
|
75 | 78 |
/** |
76 | 79 |
* Retrieve the filtered time |