changeset 4848:69c5cb7c0487 libavformat

Replace rand() usage by av_lfg_get().
author diego
date Fri, 10 Apr 2009 17:12:36 +0000
parents 22aad159263c
children 92468cd5b594
files timefilter.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/timefilter.c	Fri Apr 10 15:16:11 2009 +0000
+++ b/timefilter.c	Fri Apr 10 17:12:36 2009 +0000
@@ -76,9 +76,12 @@
 }
 
 #ifdef TEST
-#undef rand
+#include "libavutil/lfg.h"
+#define LFG_MAX ((1LL << 32) - 1)
+
 int main(void)
 {
+    AVLFG prng;
     double n0,n1;
 #define SAMPLES 1000
     double ideal[SAMPLES];
@@ -96,10 +99,11 @@
             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{