[FFmpeg-devel] [PATCH] ALSA: fix timefilter divergence
nicolas.george at normalesup.org
Fri Mar 2 11:10:58 CET 2012
Le tridi 13 ventôse, an CCXX, Michael Niedermayer a écrit :
> how does your timefilter perform compared to: ?
> --- a/libavdevice/timefilter.c
> +++ b/libavdevice/timefilter.c
> @@ -71,7 +71,7 @@ double ff_timefilter_update(TimeFilter *self, double system_time, double period)
> /// update loop
> self->cycle_time += FFMAX(self->feedback2_factor, 1.0 / self->count) * loop_error;
> - self->clock_period += self->feedback3_factor * loop_error / period;
> + self->clock_period += self->feedback3_factor * loop_error;
> return self->cycle_time;
> I was not able to reproduce unstable behavior with this change and
> it would avoid the loop.
I assume you hid a "/ constant_period" inside the value of feedback3_factor?
Otherwise, the code fails at dimensional homogeneity and actually diverges
> The filter is also identical to how it was before with a constant
> period. The difference is just for variable period and the old code
> made no sense in that case, it could not have worked in the limit of
> period -> 0 when loop_error would very likely not tend to 0.
Of course. The base point is that the feedback factors need to be adjusted
to the period, and it seems you have managed to find the right way.
There is still a problem though: the filter still diverges when the base
period is too long (>= ~12.5 ms; the person who complained in the first time
used 17 ms or more), due to the feedback factors being greater than 1.
Fortunately, this can be fixed by adding the "x -> 1 - exp(-x)" function
around M_SQRT2 * omega and omega * omega.
At these values, the time filter does not much filter the noise as move it
around, but that is not a problem, since the noise amplitude is absolute
(the delay between read and gettimeofday) while its distortions are relative
to the period.
I will use that formula and produce a new set of patches as soon as
> > By the way, V4L2 will also need to use the time filter, as some kernels have
> > started giving monotonic timestamps.
> cant that be disabled ?
For the "USB Video Class" driver, and with the kernel I have at hand, it can
be changed as a module parameter: system-wide and with root privileges. I do
not think this is acceptable.
I will try to work something out.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the ffmpeg-devel