summaryrefslogtreecommitdiffstats
path: root/gst/goom/goom_tools.h
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2006-02-05 20:43:49 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2006-02-05 20:43:49 +0000
commit07c1dceae064b547747a1513ca17225c1c1c3e0e (patch)
treeeedb8d00eade1f2fa88e9d4d481e953eca950b11 /gst/goom/goom_tools.h
parent4b5490014fb102cf65481d76222130d885eecebd (diff)
gst/goom/: Make goom reentrant by moving all important static variables into instance structures.
Original commit message from CVS: * gst/goom/filters.c: (zoomFilterNew), (calculatePXandPY), (setPixelRGB), (setPixelRGB_), (getPixelRGB), (getPixelRGB_), (zoomFilterSetResolution), (zoomFilterDestroy), (zoomFilterFastRGB), (pointFilter): * gst/goom/filters.h: * gst/goom/goom_core.c: (goom_init), (goom_set_resolution), (goom_update), (goom_close): * gst/goom/goom_core.h: * gst/goom/goom_tools.h: * gst/goom/graphic.c: * gst/goom/gstgoom.c: (gst_goom_class_init), (gst_goom_init), (gst_goom_dispose), (gst_goom_src_setcaps), (gst_goom_chain): * gst/goom/gstgoom.h: * gst/goom/lines.c: (goom_lines): * gst/goom/lines.h: Make goom reentrant by moving all important static variables into instance structures. (Fixes #329181)
Diffstat (limited to 'gst/goom/goom_tools.h')
-rw-r--r--gst/goom/goom_tools.h31
1 files changed, 13 insertions, 18 deletions
diff --git a/gst/goom/goom_tools.h b/gst/goom/goom_tools.h
index 91f310c2..6178dbaf 100644
--- a/gst/goom/goom_tools.h
+++ b/gst/goom/goom_tools.h
@@ -3,27 +3,22 @@
#define NB_RAND 0x10000
-/* in graphic.c */
-extern int * rand_tab ;
-extern unsigned short rand_pos ;
+#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_INIT(i) \
- srand (i) ;\
- if (!rand_tab)\
- rand_tab = (int *) malloc (NB_RAND * sizeof(int)) ;\
- rand_pos = 1 ;\
- while (rand_pos != 0)\
- rand_tab [rand_pos++] = rand () ;
-
-#define RAND()\
- (rand_tab[rand_pos = rand_pos + 1])
-
-#define RAND_CLOSE()\
- free (rand_tab);\
- rand_tab = 0;
+#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(i) (RAND()%i)
+#define iRAND(gd,i) (RAND(gd) % i)
#endif