From 8009acc0d18e18c340ecac209ffc7bbef8ef69db Mon Sep 17 00:00:00 2001 From: tonton th Date: Fri, 4 Dec 2020 19:55:34 +0100 Subject: [PATCH] is filterstack ok ? --- Fonderie/filterstack.c | 17 +++++++-- Fonderie/filterstack.h | 5 ++- Fonderie/t.c | 85 +++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 27 deletions(-) diff --git a/Fonderie/filterstack.c b/Fonderie/filterstack.c index 483de0a..adc43a0 100644 --- a/Fonderie/filterstack.c +++ b/Fonderie/filterstack.c @@ -9,8 +9,8 @@ #include "crapulator.h" #include "filterstack.h" -#undef DEBUG_LEVEL -#define DEBUG_LEVEL 1 +// #undef DEBUG_LEVEL +// #define DEBUG_LEVEL 1 /* -------------------------------------------------------------- */ static FilterSlot *stack_slots; @@ -67,12 +67,14 @@ idx_slot++; return 0; } /* -------------------------------------------------------------- */ -int filterstack_list(void) +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 #include #include +#include #include "../floatimg.h" #include "glitches.h" @@ -17,9 +18,9 @@ int verbosity; int convert_to_gray; /* WTF ? */ #define PNG "out.png" -#define W 512 -#define H 256 -#define LMAX 249.9999 +#define W 800 +#define H 600 +#define LMAX 255.0 #define TIMER 1 /* ----------------------------------------------------------- */ @@ -28,24 +29,8 @@ int essai_filterstack(FloatImg *pimg) { int foo; -foo = filterstack_init(4); -if (foo) { - fprintf(stderr, "filterstack init --> %d\n", foo); - return foo; - } -foo = filterstack_add(5, 1, 1.0); -if (foo) { - fprintf(stderr, "filterstack add 1 --> %d\n", foo); - return foo; - } -foo = filterstack_add(13, 1, 1.0); -if (foo) { - fprintf(stderr, "filterstack add 2 --> %d\n", foo); - return foo; - } - -filterstack_list(); +filterstack_list(__func__); foo = filterstack_run(pimg, 0); if (foo) { @@ -56,15 +41,71 @@ if (foo) { return 0; } /* ----------------------------------------------------------- */ +int parse_filter_chain(char *argument) +{ +char *cptr; +int value, foo; + +fprintf(stderr, "\n%s: arg = '%s'\n", __func__, argument); + +foo = filterstack_init(4); +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); + } + } + } + +filterstack_list(__func__); +return 0; +} +/* ----------------------------------------------------------- */ +int help(void) +{ +puts("yolo!"); +exit(0); +} +/* ----------------------------------------------------------- */ int main(int argc, char *argv[]) { int foo; FloatImg image; double debut, fin; +int opt; +char *filterchain = "0"; -verbosity = 2; -fimg_print_version(1); +fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__, + __DATE__, __TIME__); +fimg_print_version(2); + +while ((opt = getopt(argc, argv, "hF:v")) != -1) { + switch(opt) { + case 'h': help(); break; + case 'F': filterchain = optarg; + break; + case 'v': verbosity++; break; + } + } + +#if DEBUG_LEVEL +fprintf(stderr, "%s : argc = %d, optind = %d\n", argv[0], argc, optind); +#endif + +parse_filter_chain(filterchain); foo = fimg_create(&image, W, H, FIMG_TYPE_RGB); if (foo) {