|
|
|
@ -17,107 +17,105 @@
@@ -17,107 +17,105 @@
|
|
|
|
|
|
|
|
|
|
extern int verbosity; |
|
|
|
|
|
|
|
|
|
static FilterSlot *stack_slots; |
|
|
|
|
static int nbre_filters, idx_slot; |
|
|
|
|
static FilterStack f_stacks[NUMBER_OF_STACK]; |
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------- */ |
|
|
|
|
int filterstack_init(int nbre) |
|
|
|
|
int filterstack_init(int numid, int nbre) |
|
|
|
|
{ |
|
|
|
|
FilterSlot *fsptr; |
|
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL |
|
|
|
|
fprintf(stderr, ">>> %s ( %d )\n", __func__, nbre); |
|
|
|
|
fprintf(stderr, ">>> %s ( %d %d )\n", __func__, numid, nbre); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (NULL != stack_slots) { |
|
|
|
|
fprintf(stderr, "ERR stack_slots = %p\n",stack_slots); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
fsptr = calloc(nbre, sizeof(FilterSlot)); |
|
|
|
|
if (NULL == fsptr) { |
|
|
|
|
fprintf(stderr, "%s : no memory\n", __func__); |
|
|
|
|
if (numid < 0 || numid > NUMBER_OF_STACK) { |
|
|
|
|
fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stack_slots = fsptr; |
|
|
|
|
nbre_filters = nbre; |
|
|
|
|
idx_slot = 0; |
|
|
|
|
|
|
|
|
|
fprintf(stderr, "%s: stack at %p\n", __func__, stack_slots); |
|
|
|
|
memset(&f_stacks[numid], 0, sizeof(FilterSlot)); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
/* -------------------------------------------------------------- */ |
|
|
|
|
int filterstack_add(int code, int ival, float fval) |
|
|
|
|
int filterstack_add(int numid, int code, int ival, float fval) |
|
|
|
|
{ |
|
|
|
|
int idxsl; |
|
|
|
|
#if DEBUG_LEVEL |
|
|
|
|
fprintf(stderr, ">>> %s ( %d %d %f )\n", __func__, code, ival, fval); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (NULL==stack_slots) { |
|
|
|
|
fprintf(stderr, "%s: NULL statck !\n", __func__); |
|
|
|
|
if (numid < 0 || numid > NUMBER_OF_STACK) { |
|
|
|
|
fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
if (idx_slot == nbre_filters) { |
|
|
|
|
|
|
|
|
|
if (f_stacks[numid].count == FILTER_BY_STACK) { |
|
|
|
|
fprintf(stderr, "%s: stack is full\n", __func__); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stack_slots[idx_slot].numero = code; |
|
|
|
|
stack_slots[idx_slot].ival = ival; |
|
|
|
|
stack_slots[idx_slot].fval = fval; |
|
|
|
|
idxsl = f_stacks[numid].count; /* aliasing */ |
|
|
|
|
|
|
|
|
|
f_stacks[numid].slots[idxsl].numero = code; |
|
|
|
|
f_stacks[numid].slots[idxsl].ival = ival; |
|
|
|
|
f_stacks[numid].slots[idxsl].fval = fval; |
|
|
|
|
|
|
|
|
|
idx_slot++; |
|
|
|
|
f_stacks[numid].count++; |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
/* -------------------------------------------------------------- */ |
|
|
|
|
int filterstack_list(const char *txt) |
|
|
|
|
int filterstack_list(int numid, const char *txt) |
|
|
|
|
{ |
|
|
|
|
int idx; |
|
|
|
|
|
|
|
|
|
if (NULL==stack_slots) { |
|
|
|
|
fprintf(stderr, "%s: NULL statck !\n", __func__); |
|
|
|
|
if (numid < 0 || numid > NUMBER_OF_STACK) { |
|
|
|
|
fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fprintf(stderr, "------- %-20s --------\n", txt); |
|
|
|
|
fprintf(stderr, "stack at %p, size %d, current %d\n", |
|
|
|
|
stack_slots, nbre_filters, idx_slot); |
|
|
|
|
fprintf(stderr, "--- %2d -- %-20s --------\n", numid, txt); |
|
|
|
|
// fprintf(stderr, "stack at %p, size %d, current %d\n",
|
|
|
|
|
// f_slots, nbre_filters, idx_slot);
|
|
|
|
|
fprintf(stderr, "idx fx# name ival fval\n"); |
|
|
|
|
for (idx=0; idx<idx_slot; idx++) { |
|
|
|
|
|
|
|
|
|
for (idx=0; idx<f_stacks[numid].count; idx++) { |
|
|
|
|
|
|
|
|
|
fprintf(stderr, "%3d %3d %-10s %3d %f\n", idx, |
|
|
|
|
stack_slots[idx].numero, |
|
|
|
|
crap_name_from_number(stack_slots[idx].numero), |
|
|
|
|
stack_slots[idx].ival, |
|
|
|
|
stack_slots[idx].fval); |
|
|
|
|
f_stacks[numid].slots[idx].numero, |
|
|
|
|
crap_name_from_number(f_stacks[numid].slots[idx].numero), |
|
|
|
|
f_stacks[numid].slots[idx].ival, |
|
|
|
|
f_stacks[numid].slots[idx].fval); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
/* -------------------------------------------------------------- */ |
|
|
|
|
int filterstack_run(FloatImg *target, int notused) |
|
|
|
|
int filterstack_run(int numid, FloatImg *target, int notused) |
|
|
|
|
{ |
|
|
|
|
int idx, foo; |
|
|
|
|
int idx, foo, eff; |
|
|
|
|
float fv; |
|
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL |
|
|
|
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, target, notused); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (NULL==stack_slots) { |
|
|
|
|
fprintf(stderr, "%s: NULL statck !\n", __func__); |
|
|
|
|
if (numid < 0 || numid > NUMBER_OF_STACK) { |
|
|
|
|
fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (idx=0; idx<idx_slot; idx++) { |
|
|
|
|
for (idx=0; idx<f_stacks[numid].count; idx++) { |
|
|
|
|
|
|
|
|
|
eff = f_stacks[numid].slots[idx].numero; |
|
|
|
|
fv = f_stacks[numid].slots[idx].fval; |
|
|
|
|
|
|
|
|
|
if (verbosity > 1) |
|
|
|
|
fprintf(stderr, "%d : effect %2d on %p\n", |
|
|
|
|
idx, stack_slots[idx].numero, target); |
|
|
|
|
idx, eff, target); |
|
|
|
|
|
|
|
|
|
foo = crapulator(target, eff, fv); |
|
|
|
|
|
|
|
|
|
foo = crapulator(target, stack_slots[idx].numero, |
|
|
|
|
stack_slots[idx].fval); |
|
|
|
|
if (foo) { |
|
|
|
|
fprintf(stderr, "crapulator error %d\n", foo); |
|
|
|
|
return foo; |
|
|
|
@ -127,7 +125,7 @@ for (idx=0; idx<idx_slot; idx++) {
@@ -127,7 +125,7 @@ for (idx=0; idx<idx_slot; idx++) {
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
/* -------------------------------------------------------------- */ |
|
|
|
|
int load_stack_from_file(char *fname, int notused) |
|
|
|
|
int load_stack_from_file(int numid, char *fname, int notused) |
|
|
|
|
{ |
|
|
|
|
FILE *fp; |
|
|
|
|
// int a, b;
|
|
|
|
@ -138,8 +136,8 @@ FILE *fp;
@@ -138,8 +136,8 @@ FILE *fp;
|
|
|
|
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (NULL==stack_slots) { |
|
|
|
|
fprintf(stderr, "%s: NULL statck !\n", __func__); |
|
|
|
|
if (numid < 0 || numid > NUMBER_OF_STACK) { |
|
|
|
|
fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -151,8 +149,6 @@ if (NULL==(fp=fopen(fname, "r"))) {
@@ -151,8 +149,6 @@ if (NULL==(fp=fopen(fname, "r"))) {
|
|
|
|
|
/*
|
|
|
|
|
* here was dragons |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* hadoc parser ? */ |
|
|
|
|
|
|
|
|
|
fclose(fp); |
|
|
|
@ -160,14 +156,19 @@ fclose(fp);
@@ -160,14 +156,19 @@ fclose(fp);
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
/* -------------------------------------------------------------- */ |
|
|
|
|
int parse_filter_chain(const char *argument) |
|
|
|
|
int parse_filter_chain(int numid, char *argument) |
|
|
|
|
{ |
|
|
|
|
char *cptr; |
|
|
|
|
int value, foo; |
|
|
|
|
|
|
|
|
|
if (numid < 0 || numid > NUMBER_OF_STACK) { |
|
|
|
|
fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fprintf(stderr, "\n%s: arg = '%s'\n", __func__, argument); |
|
|
|
|
|
|
|
|
|
foo = filterstack_init(8); |
|
|
|
|
foo = filterstack_init(numid, 8); |
|
|
|
|
if (foo) { |
|
|
|
|
fprintf(stderr, "%s: filterstack init --> %d\n", __func__, foo); |
|
|
|
|
return foo; |
|
|
|
@ -180,7 +181,7 @@ for (;;) {
@@ -180,7 +181,7 @@ for (;;) {
|
|
|
|
|
argument = NULL; |
|
|
|
|
// fprintf(stderr, " parsing '%s'\n", cptr);
|
|
|
|
|
if (1 == sscanf(cptr, "%d", &value)) { |
|
|
|
|
foo = filterstack_add(value, 1, 1.0); |
|
|
|
|
foo = filterstack_add(numid, value, 1, 1.0); |
|
|
|
|
if (foo) { |
|
|
|
|
fprintf(stderr, "%s: err %d add\n", |
|
|
|
|
__func__, foo); |
|
|
|
@ -188,7 +189,7 @@ for (;;) {
@@ -188,7 +189,7 @@ for (;;) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (verbosity) filterstack_list(__func__); |
|
|
|
|
if (verbosity) filterstack_list(numid, __func__); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
/* ----------------------------------------------------------- */ |
|
|
|
|