summaryrefslogtreecommitdiffstats
path: root/gst/goom2k1/goom_tools.h
blob: 6178dbafb192e08695061fe2f912c539827323ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef _GOOMTOOLS_H
#define _GOOMTOOLS_H

#define NB_RAND 0x10000

#define RAND_INIT(gd,i) \
        srand (i); \
        if (gd->rand_tab == NULL) \
                gd->rand_tab = g_malloc (NB_RAND * sizeof(gint)) ;\
        gd->rand_pos = 0; \
        while (gd->rand_pos < NB_RAND) \
                gd->rand_tab [gd->rand_pos++] = rand ();

#define RAND(gd) \
        (gd->rand_tab[gd->rand_pos = ((gd->rand_pos + 1) % NB_RAND)])

#define RAND_CLOSE(gd) \
        g_free (gd->rand_tab); \
        gd->rand_tab = NULL;

/*#define iRAND(i) ((guint32)((float)i * RAND()/RAND_MAX)) */
#define iRAND(gd,i) (RAND(gd) % i)
        
#endif