26 #define LFG_MAX ((1LL << 32) - 1)
36 for (n0 = 0; n0 < 40; n0 = 2 * n0 + 1) {
37 for (n1 = 0; n1 < 10; n1 = 2 * n1 + 1) {
38 double best_error = 1000000000;
39 double bestpar0 = n0 ? 1 : 100000;
46 ideal[i] = samplet[i] + n1 * i / (1000);
48 if(i && samples[i]<samples[i-1])
49 samples[i]=samples[i-1]+0.001;
55 for (par0 = bestpar0 * 0.8; par0 <= bestpar0 * 1.21; par0 += bestpar0 * 0.05) {
56 for (par1 = bestpar1 * 0.8; par1 <= bestpar1 * 1.21; par1 += bestpar1 * 0.05) {
60 printf(
"Could not allocate memory for timefilter.\n");
66 if(filtered < 0 || filtered > 1000000000)
67 printf(
"filter is unstable\n");
68 error += (filtered - ideal[i]) * (filtered - ideal[i]);
71 if (error < best_error) {
86 printf(
"%f %f %f %f\n", i - samples[i] + 10, filtered - samples[i],
87 samples[
FFMAX(i, 1)] - samples[
FFMAX(i - 1, 0)], filtered - lastfil);
92 printf(
" [%12f %11f %9f]", bestpar0, bestpar1, best_error);
void ff_timefilter_destroy(TimeFilter *self)
Free all resources associated with the filter.
Opaque type representing a time filter state.
TimeFilter * ff_timefilter_new(double time_base, double period, double bandwidth)
Create a new Delay Locked Loop time filter.
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
double ff_timefilter_update(TimeFilter *self, double system_time, double period)
Update the filter.
common internal and external API header