Bibliothèque de traitements d'images en virgule flottante. http://la.buvette.org/photos/cumul/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

119 lines
2.6 KiB

/*
* filterstack.c
*/
#include <stdio.h>
#include <stdlib.h>
#include "../floatimg.h"
#include "crapulator.h"
#include "filterstack.h"
// #undef DEBUG_LEVEL
// #define DEBUG_LEVEL 1
/* -------------------------------------------------------------- */
static FilterSlot *stack_slots;
static int nbre_filters, idx_slot;
/* -------------------------------------------------------------- */
int filterstack_init(int nbre)
{
FilterSlot *fsptr;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %d )\n", __func__, 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__);
exit(1);
}
stack_slots = fsptr;
nbre_filters = nbre;
idx_slot = 0;
fprintf(stderr, "%s: stack at %p\n", __func__, stack_slots);
return 0;
}
/* -------------------------------------------------------------- */
int filterstack_add(int code, int ival, float fval)
{
#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__);
exit(1);
}
if (idx_slot == nbre_filters) {
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;
idx_slot++;
return 0;
}
/* -------------------------------------------------------------- */
int filterstack_list(char *txt)
{
int idx;
fprintf(stderr, "------- %-20s --------\n", txt);
fprintf(stderr, "stack at %p, size %d, current %d\n",
stack_slots, nbre_filters, idx_slot);
fprintf(stderr, "idx fx# ival fval\n");
for (idx=0; idx<idx_slot; idx++) {
fprintf(stderr, "%3d %3d %3d %f\n", idx,
stack_slots[idx].numero,
stack_slots[idx].ival,
stack_slots[idx].fval);
}
return 0;
}
/* -------------------------------------------------------------- */
int filterstack_run(FloatImg *target, int notused)
{
int idx, foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d)\n", __func__, target, notused);
#endif
for (idx=0; idx<idx_slot; idx++) {
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);
if (foo) {
fprintf(stderr, "crapulator error %d\n", foo);
return foo;
}
}
return 0;
}
/* -------------------------------------------------------------- */
int load_stack_from_file(char *fname, int notused)
{
return -1;
}
/* -------------------------------------------------------------- */