Commit a8dec12d authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

Strip out the config/script parsing stuff, we don't need it.

Original commit message from CVS:
* configure.ac:
* gst/goom/Makefile.am:
* gst/goom/convolve_fx.c:
* gst/goom/default_scripts.h:
* gst/goom/goom.h:
* gst/goom/goom_core.c: (choose_a_goom_line):
* gst/goom/goom_plugin_info.h:
* gst/goom/goomsl.c:
* gst/goom/goomsl.h:
* gst/goom/goomsl_hash.c:
* gst/goom/goomsl_hash.h:
* gst/goom/goomsl_heap.c:
* gst/goom/goomsl_heap.h:
* gst/goom/goomsl_private.h:
* gst/goom/plugin_info.c:
Strip out the config/script parsing stuff, we don't need it.
Fixes #527999.
parent edf6625c
2008-04-16 Tim-Philipp Müller <tim at centricular dot net>
* configure.ac:
* gst/goom/Makefile.am:
* gst/goom/convolve_fx.c:
* gst/goom/default_scripts.h:
* gst/goom/goom.h:
* gst/goom/goom_core.c: (choose_a_goom_line):
* gst/goom/goom_plugin_info.h:
* gst/goom/goomsl.c:
* gst/goom/goomsl.h:
* gst/goom/goomsl_hash.c:
* gst/goom/goomsl_hash.h:
* gst/goom/goomsl_heap.c:
* gst/goom/goomsl_heap.h:
* gst/goom/goomsl_private.h:
* gst/goom/plugin_info.c:
Strip out the config/script parsing stuff, we don't need it.
Fixes #527999.
2008-04-15 Tim-Philipp Müller <tim at centricular dot net>
* gst/goom/plugin_info.c: (setOptimizedMethods):
......
common @ 3bb6edfe
Subproject commit f88ff852da7631ad2d0be835763da6d551a63883
Subproject commit 3bb6edfe927d6d3020d2f2a4604f54caa61cd104
......@@ -116,10 +116,6 @@ AM_PROG_CC_C_O
dnl find an assembler
AM_PROG_AS
dnl we require flex and bison for building the goom plugin
AG_GST_BISON_CHECK
AG_GST_FLEX_CHECK
AC_PATH_PROG(VALGRIND_PATH, valgrind, no)
AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno")
......
plugin_LTLIBRARIES = libgstgoom.la
PPC_FILES=ppc_zoom_ultimate.s ppc_drawings.s ppc_drawings.h ppc_zoom_ultimate.h
......@@ -23,16 +24,13 @@ libgstgoom_la_SOURCES = \
drawmethods.c drawmethods.h \
sound_tester.c sound_tester.h \
mathtools.c mathtools.h \
goomsl_heap.c goomsl_heap.h \
goomsl_hash.c goomsl_hash.h \
goomsl.c goomsl_private.h \
lines.c lines.h ifs.c ifs.h surf3d.c surf3d.h \
tentacle3d.c tentacle3d.h v3d.c v3d.h \
convolve_fx.c flying_stars_fx.c \
goom_fx.h goom_visual_fx.h \
motif_goom1.h motif_goom2.h \
plugin_info.c goom_plugin_info.h \
default_scripts.h goom_tools.c \
goom_tools.c \
config_param.c filters.c goom_core.c graphic.c \
goom.h goom_typedefs.h goom_graphic.h \
goom_config_param.h goom_visual_fx.h goom_filters.h \
......@@ -40,45 +38,10 @@ libgstgoom_la_SOURCES = \
$(ARCH_FILES)
libgstgoom_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GOOM_FILTER_CFLAGS) $(LIBOIL_CFLAGS) $(ARCH_CFLAGS)
libgstgoom_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) $(LIBOIL_LIBS) libgstgoomconfigparse.la
libgstgoom_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) $(LIBOIL_LIBS)
libgstgoom_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
EXTRA_DIST = filters.c $(PPC_FILES) $(MMX_FILES)
goomsl_yacc.c goomsl_yacc.h: goomsl_yacc.y
$(BISON_PATH) -d $(srcdir)/goomsl_yacc.y -o goomsl_yacc.c && \
mv goomsl_yacc.c goomsl_yacc_tmp.c && \
echo '#ifdef HAVE_CONFIG_H' > goomsl_yacc_tmp2.c && \
echo '#include <config.h>' >> goomsl_yacc_tmp2.c && \
echo '#endif' >> goomsl_yacc_tmp2.c && \
cat goomsl_yacc_tmp.c >> goomsl_yacc_tmp2.c && \
rm goomsl_yacc_tmp.c && \
mv goomsl_yacc_tmp2.c goomsl_yacc.c
goomsl_lex.c: goomsl_lex.l goomsl_yacc.h
$(FLEX_PATH) -ogoomsl_lex.c $(srcdir)/goomsl_lex.l && \
mv goomsl_lex.c goomsl_lex_tmp.c && \
echo '#ifdef HAVE_CONFIG_H' > goomsl_lex_tmp2.c && \
echo '#include <config.h>' >> goomsl_lex_tmp2.c && \
echo '#endif' >> goomsl_lex_tmp2.c && \
cat goomsl_lex_tmp.c >> goomsl_lex_tmp2.c && \
rm goomsl_lex_tmp.c && \
mv goomsl_lex_tmp2.c goomsl_lex.c
# libgstgoomconfigparse.la is library linked into the goom plugin
noinst_LTLIBRARIES = libgstgoomconfigparse.la
# uncomment these lines to dist the generated sources
#BUILT_SOURCES = goomsl_yacc.h goomsl_yacc.c goomsl_lex.c
#libgstgoomconfigparse_la_SOURCES = goomsl_lex.c goomsl_yacc.c goomsl_yacc.h
#libgstgoomconfigparse_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GOOM_FILTER_CFLAGS) $(LIBOIL_CFLAGS) $(ARCH_CFLAGS)
# uncomment these lines to _NOT_ dist the generated sources
nodist_libgstgoomconfigparse_la_SOURCES = goomsl_lex.c goomsl_yacc.c
libgstgoomconfigparse_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GOOM_FILTER_CFLAGS) $(LIBOIL_CFLAGS) $(ARCH_CFLAGS)
CLEANFILES=goomsl_yacc.c goomsl_lex.c goomsl_yacc.h
EXTRA_DIST += goomsl_yacc.y goomsl_lex.l
.NOTPARALLEL:
#include "goom_fx.h"
#include "goom_plugin_info.h"
#include "goomsl.h"
#include "goom_config.h"
#include <math.h>
#include <stdio.h>
......@@ -29,8 +28,6 @@ typedef struct _CONV_DATA
PluginParam factor_p;
PluginParameters params;
GoomSL *script;
/* rotozoom */
int theta;
float ftheta;
......
#ifndef _DEFAULT_SCRIPTS_H
#define _DEFAULT_SCRIPTS_H
#define GOOM_MAIN_SCRIPT ""
#endif
......@@ -3,7 +3,6 @@
#include "goom_config.h"
#include "goom_plugin_info.h"
#include "goomsl.h"
#define NB_FX 10
......
......@@ -24,7 +24,6 @@
#include "sound_tester.h"
#include "goom_plugin_info.h"
#include "goom_fx.h"
#include "goomsl.h"
/* #define VERBOSE */
......
......@@ -10,7 +10,6 @@
#include "goom_visual_fx.h"
#include "goom_filters.h"
#include "goom_tools.h"
#include "goomsl.h"
typedef struct {
char drawIFS;
......@@ -153,10 +152,6 @@ struct _PLUGIN_INFO {
} methods;
GoomRandom *gRandom;
GoomSL *scanner;
GoomSL *main_scanner;
const char *main_script_str;
};
void plugin_info_init(PluginInfo *p, int nbVisual);
......
This diff is collapsed.
#ifndef _GOOMSL_H
#define _GOOMSL_H
#include "goomsl_hash.h"
typedef struct _GoomSL GoomSL;
typedef void (*GoomSL_ExternalFunction)(GoomSL *gsl, GoomHash *global_vars, GoomHash *local_vars);
GoomSL*gsl_new(void);
void gsl_free(GoomSL *gss);
char *gsl_init_buffer(const char *file_name);
void gsl_append_file_to_buffer(const char *file_name, char **buffer);
void gsl_compile (GoomSL *scanner, const char *script);
void gsl_execute (GoomSL *scanner);
int gsl_is_compiled (GoomSL *gss);
void gsl_bind_function(GoomSL *gss, const char *fname, GoomSL_ExternalFunction func);
int gsl_malloc (GoomSL *_this, int size);
void *gsl_get_ptr (GoomSL *_this, int id);
void gsl_free_ptr(GoomSL *_this, int id);
GoomHash *gsl_globals(GoomSL *_this);
#define GSL_LOCAL_PTR(gsl,local,name) gsl_get_ptr(gsl, *(int*)goom_hash_get(local,name)->ptr)
#define GSL_LOCAL_INT(gsl,local,name) (*(int*)goom_hash_get(local,name)->ptr)
#define GSL_LOCAL_FLOAT(gsl,local,name) (*(float*)goom_hash_get(local,name)->ptr)
#define GSL_GLOBAL_PTR(gsl,name) gsl_get_ptr(gsl, *(int*)goom_hash_get(gsl_globals(gsl),name)->ptr)
#define GSL_GLOBAL_INT(gsl,name) (*(int*)goom_hash_get(gsl_globals(gsl),name)->ptr)
#define GSL_GLOBAL_FLOAT(gsl,name) (*(float*)goom_hash_get(gsl_globals(gsl),name)->ptr)
#endif
#include "goomsl_hash.h"
#include <string.h>
#include <stdlib.h>
static GoomHashEntry *
entry_new (const char *key, HashValue value)
{
int len = strlen (key);
GoomHashEntry *entry = (GoomHashEntry *) malloc (sizeof (GoomHashEntry));
entry->key = (char *) malloc (len + 1);
memcpy (entry->key, key, len + 1);
entry->value = value;
entry->lower = NULL;
entry->upper = NULL;
return entry;
}
static void
entry_free (GoomHashEntry * entry)
{
if (entry != NULL) {
entry_free (entry->lower);
entry_free (entry->upper);
free (entry->key);
free (entry);
}
}
static void
entry_put (GoomHashEntry * entry, const char *key, HashValue value)
{
int cmp = strcmp (key, entry->key);
if (cmp == 0) {
entry->value = value;
} else if (cmp > 0) {
if (entry->upper == NULL)
entry->upper = entry_new (key, value);
else
entry_put (entry->upper, key, value);
} else {
if (entry->lower == NULL)
entry->lower = entry_new (key, value);
else
entry_put (entry->lower, key, value);
}
}
static HashValue *
entry_get (GoomHashEntry * entry, const char *key)
{
int cmp;
if (entry == NULL)
return NULL;
cmp = strcmp (key, entry->key);
if (cmp > 0)
return entry_get (entry->upper, key);
else if (cmp < 0)
return entry_get (entry->lower, key);
else
return &(entry->value);
}
GoomHash *
goom_hash_new ()
{
GoomHash *_this = (GoomHash *) malloc (sizeof (GoomHash));
_this->root = NULL;
_this->number_of_puts = 0;
return _this;
}
void
goom_hash_free (GoomHash * _this)
{
entry_free (_this->root);
free (_this);
}
void
goom_hash_put (GoomHash * _this, const char *key, HashValue value)
{
_this->number_of_puts += 1;
if (_this->root == NULL)
_this->root = entry_new (key, value);
else
entry_put (_this->root, key, value);
}
HashValue *
goom_hash_get (GoomHash * _this, const char *key)
{
if (_this == NULL)
return NULL;
return entry_get (_this->root, key);
}
void
goom_hash_put_int (GoomHash * _this, const char *key, int i)
{
HashValue value;
value.i = i;
goom_hash_put (_this, key, value);
}
void
goom_hash_put_float (GoomHash * _this, const char *key, float f)
{
HashValue value;
value.f = f;
goom_hash_put (_this, key, value);
}
void
goom_hash_put_ptr (GoomHash * _this, const char *key, void *ptr)
{
HashValue value;
value.ptr = ptr;
goom_hash_put (_this, key, value);
}
/* FOR EACH */
static void
_goom_hash_for_each (GoomHash * _this, GoomHashEntry * entry, GH_Func func)
{
if (entry == NULL)
return;
func (_this, entry->key, &(entry->value));
_goom_hash_for_each (_this, entry->lower, func);
_goom_hash_for_each (_this, entry->upper, func);
}
void
goom_hash_for_each (GoomHash * _this, GH_Func func)
{
_goom_hash_for_each (_this, _this->root, func);
}
int
goom_hash_number_of_puts (GoomHash * _this)
{
return _this->number_of_puts;
}
#ifndef _GOOMSL_HASH_H
#define _GOOMSL_HASH_H
typedef struct GOOM_HASH_ENTRY GoomHashEntry;
typedef struct GOOM_HASH GoomHash;
typedef union {
void *ptr;
int i;
float f;
} HashValue;
struct GOOM_HASH_ENTRY {
char *key;
HashValue value;
GoomHashEntry *lower;
GoomHashEntry *upper;
};
struct GOOM_HASH {
GoomHashEntry *root;
int number_of_puts;
};
GoomHash *goom_hash_new();
void goom_hash_free(GoomHash *gh);
void goom_hash_put(GoomHash *gh, const char *key, HashValue value);
HashValue *goom_hash_get(GoomHash *gh, const char *key);
void goom_hash_put_int (GoomHash *_this, const char *key, int i);
void goom_hash_put_float(GoomHash *_this, const char *key, float f);
void goom_hash_put_ptr (GoomHash *_this, const char *key, void *ptr);
typedef void (*GH_Func)(GoomHash *caller, const char *key, HashValue *value);
void goom_hash_for_each(GoomHash *_this, GH_Func func);
int goom_hash_number_of_puts(GoomHash *_this);
#endif /* _GOOM_HASH_H */
#include "goomsl_heap.h"
#include <stdlib.h>
struct _GOOM_HEAP
{
void **arrays;
int number_of_arrays;
int size_of_each_array;
int consumed_in_last_array;
};
/* Constructors / Destructor */
GoomHeap *
goom_heap_new (void)
{
return goom_heap_new_with_granularity (4096);
}
GoomHeap *
goom_heap_new_with_granularity (int granularity)
{
GoomHeap *_this;
_this = (GoomHeap *) malloc (sizeof (GoomHeap));
_this->number_of_arrays = 0;
_this->size_of_each_array = granularity;
_this->consumed_in_last_array = 0;
_this->arrays = (void **) malloc (sizeof (void *));
return _this;
}
void
goom_heap_delete (GoomHeap * _this)
{
int i;
for (i = 0; i < _this->number_of_arrays; ++i) {
free (_this->arrays[i]);
}
free (_this->arrays);
free (_this);
}
static void
align_it (GoomHeap * _this, int alignment)
{
if ((alignment > 1) && (_this->number_of_arrays > 0)) {
void *last_array = _this->arrays[_this->number_of_arrays - 1];
long last_address = (long) last_array + _this->consumed_in_last_array;
long decal = (last_address % alignment);
if (decal != 0) {
_this->consumed_in_last_array += alignment - decal;
}
}
}
void *
goom_heap_malloc_with_alignment_prefixed (GoomHeap * _this, int nb_bytes,
int alignment, int prefix_bytes)
{
void *retval = NULL;
/* d'abord on gere les problemes d'alignement */
_this->consumed_in_last_array += prefix_bytes;
align_it (_this, alignment);
/* ensuite on verifie que la quantite de memoire demandee tient dans le buffer */
if ((_this->consumed_in_last_array + nb_bytes >= _this->size_of_each_array)
|| (_this->number_of_arrays == 0)) {
if (prefix_bytes + nb_bytes + alignment >= _this->size_of_each_array) {
/* Si la zone demandee est plus grosse que la granularitee */
/* On alloue un buffer plus gros que les autres */
_this->arrays =
(void **) realloc (_this->arrays,
sizeof (void *) * (_this->number_of_arrays + 2));
_this->number_of_arrays += 1;
_this->consumed_in_last_array = prefix_bytes;
_this->arrays[_this->number_of_arrays - 1] =
malloc (prefix_bytes + nb_bytes + alignment);
align_it (_this, alignment);
retval =
(void *) ((char *) _this->arrays[_this->number_of_arrays - 1] +
_this->consumed_in_last_array);
/* puis on repart sur un nouveau buffer vide */
_this->number_of_arrays += 1;
_this->consumed_in_last_array = 0;
_this->arrays[_this->number_of_arrays - 1] =
malloc (_this->size_of_each_array);
return retval;
} else {
_this->number_of_arrays += 1;
_this->consumed_in_last_array = prefix_bytes;
_this->arrays =
(void **) realloc (_this->arrays,
sizeof (void *) * _this->number_of_arrays);
_this->arrays[_this->number_of_arrays - 1] =
malloc (_this->size_of_each_array);
align_it (_this, alignment);
}
}
retval =
(void *) ((char *) _this->arrays[_this->number_of_arrays - 1] +
_this->consumed_in_last_array);
_this->consumed_in_last_array += nb_bytes;
return retval;
}
void *
goom_heap_malloc_with_alignment (GoomHeap * _this, int nb_bytes, int alignment)
{
return goom_heap_malloc_with_alignment_prefixed (_this, nb_bytes, alignment,
0);
}
void *
goom_heap_malloc (GoomHeap * _this, int nb_bytes)
{
return goom_heap_malloc_with_alignment (_this, nb_bytes, 1);
}
#ifndef GOOMSL_HEAP
#define GOOMSL_HEAP
/**
* Resizable Array that guarranty that resizes don't change address of
* the stored datas.
*
* This is implemented as an array of arrays... granularity is the size
* of each arrays.
*/
typedef struct _GOOM_HEAP GoomHeap;
/* Constructors / Destructor */
GoomHeap *goom_heap_new(void);
GoomHeap *goom_heap_new_with_granularity(int granularity);
void goom_heap_delete(GoomHeap *_this);
/* This method behaves like malloc. */
void *goom_heap_malloc(GoomHeap *_this, int nb_bytes);
/* This adds an alignment constraint. */
void *goom_heap_malloc_with_alignment(GoomHeap *_this, int nb_bytes, int alignment);
/* Returns a pointeur on the bytes... prefix is before */
void *goom_heap_malloc_with_alignment_prefixed(GoomHeap *_this, int nb_bytes,
int alignment, int prefix_bytes);
#endif
#ifndef _GSL_PRIVATE_H
#define _GSL_PRIVATE_H
/* -- internal use -- */
#include "goomsl.h"
#ifdef USE_JITC_X86
#include "jitc_x86.h"
#endif
#include "goomsl_heap.h"
/* {{{ type of nodes */
#define EMPTY_NODE 0
#define CONST_INT_NODE 1
#define CONST_FLOAT_NODE 2
#define CONST_PTR_NODE 3
#define VAR_NODE 4
#define PARAM_NODE 5
#define READ_PARAM_NODE 6
#define OPR_NODE 7
/* }}} */
/* {{{ type of operations */
#define OPR_SET 1
#define OPR_IF 2
#define OPR_WHILE 3
#define OPR_BLOCK 4
#define OPR_ADD 5
#define OPR_MUL 6
#define OPR_EQU 7
#define OPR_NOT 8
#define OPR_LOW 9
#define OPR_DIV 10
#define OPR_SUB 11
#define OPR_FUNC_INTRO 12
#define OPR_FUNC_OUTRO 13
#define OPR_CALL 14
#define OPR_EXT_CALL 15
#define OPR_PLUS_EQ 16
#define OPR_SUB_EQ 17
#define OPR_MUL_EQ 18
#define OPR_DIV_EQ 19
#define OPR_CALL_EXPR 20
#define OPR_AFFECT_LIST 21
#define OPR_FOREACH 22
#define OPR_VAR_LIST 23
/* }}} */
typedef struct _ConstIntNodeType { /* {{{ */
int val;
} ConstIntNodeType; /* }}} */
typedef struct _ConstFloatNodeType { /* {{{ */
float val;
} ConstFloatNodeType; /* }}} */
typedef struct _ConstPtrNodeType { /* {{{ */
int id;
} ConstPtrNodeType; /* }}} */
typedef struct _OprNodeType { /* {{{ */
int type;
int nbOp;
struct _NODE_TYPE *op[3]; /* maximal number of operand needed */
struct _NODE_TYPE *next;
} OprNodeType; /* }}} */
typedef struct _NODE_TYPE { /* {{{ */
int type;
char *str;
GoomHash *vnamespace;
int line_number;
union {
ConstIntNodeType constInt;
ConstFloatNodeType constFloat;
ConstPtrNodeType constPtr;
OprNodeType opr;
} unode;
} NodeType; /* }}} */
typedef struct _INSTRUCTION_DATA { /* {{{ */
union {
void *var;
int *var_int;
int *var_ptr;
float *var_float;
int jump_offset;
struct _ExternalFunctionStruct *external_function;
} udest;
union {
void *var;
int *var_int;
int *var_ptr;
float *var_float;
int value_int;
int value_ptr;
float