Browse code

Fix infinite loop with clock() returning (clock_t)-1.

Originally committed as revision 24116 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2010/07/09 03:13:31
Showing 1 changed files
... ...
@@ -40,17 +40,17 @@ static int read_random(uint32_t *dst, const char *file)
40 40
 
41 41
 static uint32_t get_generic_seed(void)
42 42
 {
43
-    int last_t=0;
43
+    clock_t last_t=0;
44 44
     int bits=0;
45 45
     uint64_t random=0;
46 46
     unsigned i;
47
-    int s=0;
47
+    float s=0.000000000001;
48 48
 
49 49
     for(i=0;bits<64;i++){
50
-        int t= clock()>>s;
51
-        if(last_t && t != last_t){
52
-            if(i<10000 && s<24){
53
-                s++;
50
+        clock_t t= clock();
51
+        if(last_t && fabs(t-last_t)>s || t==(clock_t)-1){
52
+            if(i<10000 && s<(1<<24)){
53
+                s+=s;
54 54
                 i=t=0;
55 55
             }else{
56 56
                 random= 2*random + (i&1);