123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef FFMPEG_RANDOM_H
- #define FFMPEG_RANDOM_H
- #define AV_RANDOM_N 624
- typedef struct {
- unsigned int mt[AV_RANDOM_N];
- int index;
- } AVRandomState;
- void av_init_random(unsigned int seed, AVRandomState *state);
- void av_random_generate_untempered_numbers(AVRandomState *state);
- static inline unsigned int av_random(AVRandomState *state)
- {
- unsigned int y;
-
- if (state->index >= AV_RANDOM_N)
- av_random_generate_untempered_numbers(state);
-
- y = state->mt[state->index++];
-
- y ^= (y >> 11);
- y ^= (y << 7) & 0x9d2c5680;
- y ^= (y << 15) & 0xefc60000;
- y ^= (y >> 18);
- return y;
- }
- static inline double av_random_real1(AVRandomState *state)
- {
-
- return av_random(state) * (1.0 / 4294967296.0);
- }
- void av_benchmark_random(void);
- #endif
|