summaryrefslogtreecommitdiff
path: root/ffmpeg/libavdevice/timefilter.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavdevice/timefilter.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavdevice/timefilter.c')
-rw-r--r--ffmpeg/libavdevice/timefilter.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ffmpeg/libavdevice/timefilter.c b/ffmpeg/libavdevice/timefilter.c
index ba2e54e..9d38f93 100644
--- a/ffmpeg/libavdevice/timefilter.c
+++ b/ffmpeg/libavdevice/timefilter.c
@@ -49,6 +49,10 @@ TimeFilter *ff_timefilter_new(double time_base,
{
TimeFilter *self = av_mallocz(sizeof(TimeFilter));
double o = 2 * M_PI * bandwidth * period * time_base;
+
+ if (!self)
+ return NULL;
+
self->clock_period = time_base;
self->feedback2_factor = qexpneg(M_SQRT2 * o);
self->feedback3_factor = qexpneg(o * o) / period;
@@ -101,7 +105,7 @@ int main(void)
for (n0 = 0; n0 < 40; n0 = 2 * n0 + 1) {
for (n1 = 0; n1 < 10; n1 = 2 * n1 + 1) {
double best_error = 1000000000;
- double bestpar0 = 1;
+ double bestpar0 = n0 ? 1 : 100000;
double bestpar1 = 1;
int better, i;
@@ -121,6 +125,10 @@ int main(void)
for (par1 = bestpar1 * 0.8; par1 <= bestpar1 * 1.21; par1 += bestpar1 * 0.05) {
double error = 0;
TimeFilter *tf = ff_timefilter_new(1, par0, par1);
+ if (!tf) {
+ printf("Could not allocate memory for timefilter.\n");
+ exit(1);
+ }
for (i = 0; i < SAMPLES; i++) {
double filtered;
filtered = ff_timefilter_update(tf, samples[i], i ? (samplet[i] - samplet[i-1]) : 1);
@@ -150,7 +158,7 @@ int main(void)
}
ff_timefilter_destroy(tf);
#else
- printf(" [%f %f %9f]", bestpar0, bestpar1, best_error);
+ printf(" [%12f %11f %9f]", bestpar0, bestpar1, best_error);
#endif
}
printf("\n");