diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2010-07-08 22:13:31 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2010-07-08 22:13:31 +0400 |
commit | 6a522c49c2f6c33c047df5e5ebb448a03effa817 (patch) | |
tree | 4faa09ca18e114398b6cba47a54b61bd11b20c3c /libavutil | |
parent | 65e3f89ffde2a710c593a2d77663f6878730a0ae (diff) |
Fix infinite loop with clock() returning (clock_t)-1.
Originally committed as revision 24116 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/random_seed.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 762e02e0dd..db1ba39cf2 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -40,17 +40,17 @@ static int read_random(uint32_t *dst, const char *file) static uint32_t get_generic_seed(void) { - int last_t=0; + clock_t last_t=0; int bits=0; uint64_t random=0; unsigned i; - int s=0; + float s=0.000000000001; for(i=0;bits<64;i++){ - int t= clock()>>s; - if(last_t && t != last_t){ - if(i<10000 && s<24){ - s++; + clock_t t= clock(); + if(last_t && fabs(t-last_t)>s || t==(clock_t)-1){ + if(i<10000 && s<(1<<24)){ + s+=s; i=t=0; }else{ random= 2*random + (i&1); |