is filterstack really ok ?
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
#include "crapulator.h"
|
||||
@@ -13,6 +14,9 @@
|
||||
// #define DEBUG_LEVEL 1
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
static FilterSlot *stack_slots;
|
||||
static int nbre_filters, idx_slot;
|
||||
/* -------------------------------------------------------------- */
|
||||
@@ -67,10 +71,15 @@ idx_slot++;
|
||||
return 0;
|
||||
}
|
||||
/* -------------------------------------------------------------- */
|
||||
int filterstack_list(char *txt)
|
||||
int filterstack_list(const char *txt)
|
||||
{
|
||||
int idx;
|
||||
|
||||
if (NULL==stack_slots) {
|
||||
fprintf(stderr, "%s: NULL statck !\n", __func__);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "------- %-20s --------\n", txt);
|
||||
fprintf(stderr, "stack at %p, size %d, current %d\n",
|
||||
stack_slots, nbre_filters, idx_slot);
|
||||
@@ -92,13 +101,19 @@ int filterstack_run(FloatImg *target, int notused)
|
||||
int idx, foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %d)\n", __func__, target, notused);
|
||||
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, target, notused);
|
||||
#endif
|
||||
|
||||
if (NULL==stack_slots) {
|
||||
fprintf(stderr, "%s: NULL statck !\n", __func__);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (idx=0; idx<idx_slot; idx++) {
|
||||
|
||||
fprintf(stderr, "%d : effect %2d on %p\n",
|
||||
idx, stack_slots[idx].numero, target);
|
||||
if (verbosity > 1)
|
||||
fprintf(stderr, "%d : effect %2d on %p\n",
|
||||
idx, stack_slots[idx].numero, target);
|
||||
|
||||
foo = crapulator(target, stack_slots[idx].numero,
|
||||
stack_slots[idx].fval);
|
||||
@@ -113,7 +128,66 @@ return 0;
|
||||
/* -------------------------------------------------------------- */
|
||||
int load_stack_from_file(char *fname, int notused)
|
||||
{
|
||||
FILE *fp;
|
||||
// int a, b;
|
||||
// float f;
|
||||
// char line[100];
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
||||
#endif
|
||||
|
||||
if (NULL==stack_slots) {
|
||||
fprintf(stderr, "%s: NULL statck !\n", __func__);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (NULL==(fp=fopen(fname, "r"))) {
|
||||
perror(fname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* here was dragons
|
||||
*/
|
||||
|
||||
|
||||
/* hadoc parser ? */
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* -------------------------------------------------------------- */
|
||||
int parse_filter_chain(const char *argument)
|
||||
{
|
||||
char *cptr;
|
||||
int value, foo;
|
||||
|
||||
fprintf(stderr, "\n%s: arg = '%s'\n", __func__, argument);
|
||||
|
||||
foo = filterstack_init(8);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: filterstack init --> %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
cptr = strtok(argument, ":");
|
||||
// fprintf(stderr, "cptr %p\n", cptr);
|
||||
if (NULL==cptr) break;
|
||||
argument = NULL;
|
||||
// fprintf(stderr, " parsing '%s'\n", cptr);
|
||||
if (1 == sscanf(cptr, "%d", &value)) {
|
||||
foo = filterstack_add(value, 1, 1.0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err %d add\n",
|
||||
__func__, foo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (verbosity) filterstack_list(__func__);
|
||||
return 0;
|
||||
}
|
||||
/* ----------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user