]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/timefilter.c
Merge commit 'f0a41afd8a37ebe972436fabfa3d289178bbd83b'
[ffmpeg] / libavformat / timefilter.c
index 0c3099d6072c64c056a928bc8460a96f4e381293..5c780c8d90fe4ee8131d131017d58a39b34eb72b 100644 (file)
@@ -1,7 +1,9 @@
 /*
  * Delay Locked Loop based time filter
  * Copyright (c) 2009 Samalyse
+ * Copyright (c) 2009 Michael Niedermayer
  * Author: Olivier Guilyardi <olivier samalyse com>
+ *         Michael Niedermayer <michaelni gmx at>
  *
  * This file is part of FFmpeg.
  *
@@ -74,9 +76,14 @@ double ff_timefilter_update(TimeFilter *self, double system_time, double period)
 }
 
 #ifdef TEST
-#undef rand
+#include "libavutil/lfg.h"
+#define LFG_MAX ((1LL << 32) - 1)
+
+#undef printf
+
 int main(void)
 {
+    AVLFG prng;
     double n0,n1;
 #define SAMPLES 1000
     double ideal[SAMPLES];
@@ -94,10 +101,11 @@ int main(void)
             double bestpar1=0.001;
             int better, i;
 
-            srandom(123);
+            av_lfg_init(&prng, 123);
             for(i=0; i<SAMPLES; i++){
                 ideal[i]  = 10 + i + n1*i/(1000);
-                samples[i]= ideal[i] + n0*(rand()-RAND_MAX/2)/(RAND_MAX*10LL);
+                samples[i] = ideal[i] + n0 * (av_lfg_get(&prng) - LFG_MAX / 2)
+                                           / (LFG_MAX * 10LL);
             }
 
             do{
@@ -133,7 +141,7 @@ int main(void)
             }
             ff_timefilter_destroy(tf);
 #else
-            printf(" [%f %f %f]", bestpar0, bestpar1, best_error);
+            printf(" [%f %f %9f]", bestpar0, bestpar1, best_error);
 #endif
         }
         printf("\n");