~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-updates

« back to all changes in this revision

Viewing changes to libavutil/random.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-02-05 21:45:05 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090205214505-fvn0jkiv3lrkaaq4
Tags: 3:0.svn20090204-2ubuntu1+unstripped1
rebuild using a clean, uncrippled ffmpeg tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Mersenne Twister Random Algorithm
3
 
 * Copyright (c) 2006 Ryan Martell.
4
 
 * Based on A C-program for MT19937, with initialization improved 2002/1/26. Coded by
5
 
 * Takuji Nishimura and Makoto Matsumoto.
 
2
 * Mersenne Twister PRNG algorithm
 
3
 * Copyright (c) 2006 Ryan Martell
 
4
 * Based on a C program for MT19937, with initialization improved 2002/1/26.
 
5
 * Coded by Takuji Nishimura and Makoto Matsumoto.
6
6
 *
7
7
 * This file is part of FFmpeg.
8
8
 *
26
26
 
27
27
#define AV_RANDOM_N 624
28
28
 
 
29
#include "avutil.h"
29
30
#include "common.h"
30
31
 
31
32
typedef struct {
34
35
} AVRandomState;
35
36
 
36
37
 
 
38
#if LIBAVUTIL_VERSION_MAJOR < 50
37
39
attribute_deprecated void av_init_random(unsigned int seed, AVRandomState *state);
 
40
#endif
38
41
void av_random_init(AVRandomState *state, unsigned int seed); ///< To be inlined, the struct must be visible. So it does not make sense to try and keep it opaque with malloc/free-like calls.
39
42
void av_random_generate_untempered_numbers(AVRandomState *state); ///< Regenerate the untempered numbers (must be done every 624 iterations, or it will loop).
40
43
 
41
44
/**
42
45
 * Generates a random number from the interval [0,0xffffffff].
43
46
 *
44
 
 * Please do NOT use the Mersenne Twister, it is slow. Use the random generator
45
 
 * from lfg.c/h or a simple LCG like state= state*1664525+1013904223.
 
47
 * Please do NOT use the Mersenne Twister, it is slow. Use the random number
 
48
 * generator from lfg.c/h or a simple LCG like state = state*1664525+1013904223.
46
49
 * If you still choose to use MT, expect that you will have to provide
47
50
 * some evidence that it makes a difference for the case where you use it.
48
51
 */
66
69
    return y;
67
70
}
68
71
 
69
 
/** Return random in range [0-1] as double. */
 
72
/** Returns a random number in the range [0-1] as double. */
70
73
static inline double av_random_real1(AVRandomState *state)
71
74
{
72
75
    /* divided by 2^32-1 */