08d0005673aa0e0a7fca7f59dfab37a2d3be6fb1
[platform/upstream/gst-plugins-good.git] / gst / goom / goom_tools.h
1 #ifndef _GOOMTOOLS_H
2 #define _GOOMTOOLS_H
3
4 #include "goom_config.h"
5
6 /**
7  * Random number generator wrapper for faster random number.
8  */
9
10 #define GOOM_NB_RAND 0x10000
11
12 typedef struct _GOOM_RANDOM {
13         int array[GOOM_NB_RAND];
14         unsigned short pos;
15 } GoomRandom;
16
17 GoomRandom *goom_random_init(int i);
18 void goom_random_free(GoomRandom *grandom);
19
20 inline static int goom_random(GoomRandom *grandom) {
21         
22         grandom->pos++; /* works because pos is an unsigned short */
23         return grandom->array[grandom->pos];
24 }
25
26 inline static int goom_irand(GoomRandom *grandom, int i) {
27
28         grandom->pos++;
29         return grandom->array[grandom->pos] % i;
30 }
31
32 /* called to change the specified number of value in the array, so that the array does not remain the same*/
33 void goom_random_update_array(GoomRandom *grandom, int numberOfValuesToChange);
34
35 #endif