Mercurial > libavutil.hg
changeset 986:093c69c7b752 libavutil
Fix infinite loop with clock() returning (clock_t)-1.
author | michael |
---|---|
date | Thu, 08 Jul 2010 18:13:31 +0000 |
parents | e6d6b3506d76 |
children | f2fa8ffe7a05 |
files | random_seed.c |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/random_seed.c Thu Jul 08 17:49:39 2010 +0000 +++ b/random_seed.c Thu Jul 08 18:13:31 2010 +0000 @@ -40,17 +40,17 @@ 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);