[FFmpeg-cvslog] r24102 - trunk/libavutil/random_seed.c
Michael Niedermayer
michaelni
Thu Jul 8 17:46:35 CEST 2010
On Thu, Jul 08, 2010 at 12:58:23AM +0100, M?ns Rullg?rd wrote:
> michael <subversion at mplayerhq.hu> writes:
>
> > Author: michael
> > Date: Thu Jul 8 01:47:48 2010
> > New Revision: 24102
> >
> > Log:
> > get_generic_seed() for the cases without /dev/random and AV_READ_TIME
>
> Thanks.
>
> > Modified:
> > trunk/libavutil/random_seed.c
> >
> > Modified: trunk/libavutil/random_seed.c
> > ==============================================================================
> > --- trunk/libavutil/random_seed.c Thu Jul 8 01:41:42 2010 (r24101)
> > +++ trunk/libavutil/random_seed.c Thu Jul 8 01:47:48 2010 (r24102)
> > @@ -21,6 +21,7 @@
> > #include <unistd.h>
> > #include <fcntl.h>
> > #include "timer.h"
> > +#include "time.h"
> > #include "random_seed.h"
> > #include "avutil.h"
> >
> > @@ -37,6 +38,38 @@ static int read_random(uint32_t *dst, co
> > return err;
> > }
> >
> > +static uint32_t get_generic_seed(void)
> > +{
> > + int last_t=0;
> > + int bits=0;
> > + uint64_t random=0;
> > + int i;
> > + int s=0;
> > +
> > + for(i=0;bits<64;i++){
> > + int t= clock()>>s;
>
> What about systems without a functioning clock() call? This is
> allowed by the specs:
>
> If the processor time used is not available or its value cannot be
> represented, the function shall return the value (clock_t)-1.
>
> If clock() always returns -1, this loop will run forever.
what else is giving us reasonable precission (1 tick per second would
need 2 minutes per seed) and is portable?
>
> > + if(last_t && t != last_t){
> > + if(i<10000U && s<24){
>
> Why the U suffix?
for unsigned compare, otherwise if i becomes negative this could behave odd
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is not what we do, but why we do it that matters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20100708/f7a6feeb/attachment-0001.pgp>
More information about the ffmpeg-cvslog
mailing list