Commit cc7b62af authored by Diego Biurrun's avatar Diego Biurrun

Replace rand() usage by av_lfg_get().

Originally committed as revision 18420 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent a2085ccc
...@@ -76,9 +76,12 @@ double ff_timefilter_update(TimeFilter *self, double system_time, double period) ...@@ -76,9 +76,12 @@ double ff_timefilter_update(TimeFilter *self, double system_time, double period)
} }
#ifdef TEST #ifdef TEST
#undef rand #include "libavutil/lfg.h"
#define LFG_MAX ((1LL << 32) - 1)
int main(void) int main(void)
{ {
AVLFG prng;
double n0,n1; double n0,n1;
#define SAMPLES 1000 #define SAMPLES 1000
double ideal[SAMPLES]; double ideal[SAMPLES];
...@@ -96,10 +99,11 @@ int main(void) ...@@ -96,10 +99,11 @@ int main(void)
double bestpar1=0.001; double bestpar1=0.001;
int better, i; int better, i;
srandom(123); av_lfg_init(&prng, 123);
for(i=0; i<SAMPLES; i++){ for(i=0; i<SAMPLES; i++){
ideal[i] = 10 + i + n1*i/(1000); 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{ do{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment