From 0def451bf46146bb25b3fbc7d85bdfeed77affa2 Mon Sep 17 00:00:00 2001 From: tonton th Date: Tue, 15 Dec 2020 17:49:12 +0100 Subject: [PATCH] more debug or more bug ? --- Fonderie/crapulator.c | 5 +++++ Fonderie/filterstack.c | 12 ++++++------ Fonderie/filterstack.h | 3 ++- Fonderie/fonctions.c | 5 ++++- Fonderie/fonderie.c | 29 ++++++++++++++++++++++++++--- Fonderie/interpolator.c | 37 +++++++++++++++++++++++++++++-------- Fonderie/t.c | 2 +- 7 files changed, 73 insertions(+), 20 deletions(-) diff --git a/Fonderie/crapulator.c b/Fonderie/crapulator.c index 47a9ec01..a7e5b51b 100644 --- a/Fonderie/crapulator.c +++ b/Fonderie/crapulator.c @@ -213,6 +213,11 @@ return retval; /* -------------------------------------------------------------- */ char * crap_name_from_number(int num) { +switch (num) { + case 0: return "none"; + case 8: return "ctr2x2"; + case 13: return "fltr3x3"; + } return "???"; } diff --git a/Fonderie/filterstack.c b/Fonderie/filterstack.c index 0256436e..ee637687 100644 --- a/Fonderie/filterstack.c +++ b/Fonderie/filterstack.c @@ -27,7 +27,7 @@ fprintf(stderr, ">>> %s ( %d %d )\n", __func__, numid, notused); #endif if (numid < 0 || numid > NUMBER_OF_STACK) { - fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); + fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid); exit(1); } @@ -44,7 +44,7 @@ fprintf(stderr, ">>> %s ( %d %d %f )\n", __func__, code, ival, fval); #endif if (numid < 0 || numid > NUMBER_OF_STACK) { - fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); + fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid); exit(1); } @@ -69,7 +69,7 @@ int filterstack_list(int numid, const char *txt) int idx; if (numid < 0 || numid > NUMBER_OF_STACK) { - fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); + fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid); exit(1); } @@ -101,7 +101,7 @@ fprintf(stderr, ">>> %s ( %p %d )\n", __func__, target, notused); #endif if (numid < 0 || numid > NUMBER_OF_STACK) { - fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); + fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid); exit(1); } @@ -142,7 +142,7 @@ fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused); #endif if (numid < 0 || numid > NUMBER_OF_STACK) { - fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); + fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid); exit(1); } @@ -167,7 +167,7 @@ char *cptr; int value, foo; if (numid < 0 || numid > NUMBER_OF_STACK) { - fprintf(stderr, "%s: slot number %d invalid\n", __func__, numid); + fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid); exit(1); } diff --git a/Fonderie/filterstack.h b/Fonderie/filterstack.h index aafd8361..52d4ce6b 100644 --- a/Fonderie/filterstack.h +++ b/Fonderie/filterstack.h @@ -3,7 +3,8 @@ */ typedef struct { - int numero; /* id in rapulator */ + int numero; /* id in crapulator */ + char *name; int ival; float fval; } FilterSlot; diff --git a/Fonderie/fonctions.c b/Fonderie/fonctions.c index 328df762..ac464d80 100644 --- a/Fonderie/fonctions.c +++ b/Fonderie/fonctions.c @@ -86,7 +86,10 @@ if (convert_to_gray) { // fprintf(stderr, "%p gray-washed\n", &fifo.total); } -foo = crapulator(&g_fifo.total, postproc, 0.0); +if (postproc) + foo = crapulator(&g_fifo.total, postproc, 0.0); +else + foo = filterstack_run(1, &g_fifo.total, 0); if (foo) { fprintf(stderr, "%s: ERR post process picture -> %d\n", __func__, foo); diff --git a/Fonderie/fonderie.c b/Fonderie/fonderie.c index bbc815eb..3a10f767 100644 --- a/Fonderie/fonderie.c +++ b/Fonderie/fonderie.c @@ -12,6 +12,7 @@ #include "fonctions.h" #include "glitches.h" #include "crapulator.h" +#include "filterstack.h" int verbosity; int convert_to_gray; @@ -130,9 +131,14 @@ for (idx=0; idx %d\n", __func__, foo); + fprintf(stderr, "%s: input filter -> %d\n", __func__, foo); exit(1); } foo = traite_une_image(&input, outfx, step, outdir); @@ -165,6 +171,8 @@ void help(void) { puts("\tFONDERIE\noptions:"); +puts("\t-E input:filter:chain"); +puts("\t-F output:filter:chain"); puts("\t-g\tconvert to gray"); puts("\t-I\tinput glob pattern"); puts("\t-O\toutput directory"); @@ -186,13 +194,17 @@ int in_effect = 0; int out_effect = 0; int steps = 1; int blanks = 20; +char *InFchain = "0"; +char *OutFchain = "0"; fprintf(stderr, "*** %s :\n\tcompiled by tTh, %s %s\n\tpid %d\n", argv[0], __DATE__, __TIME__, getpid()); fimg_print_version(2); -while ((opt = getopt(argc, argv, "B:ghI:O:s:T:vw:x:")) != -1) { +while ((opt = getopt(argc, argv, "B:E:F:ghI:O:s:T:vw:x:")) != -1) { switch(opt) { + case 'E': InFchain = optarg; break; + case 'F': OutFchain = optarg; break; case 'B': blanks = atoi(optarg); break; case 'g': convert_to_gray = 1; @@ -221,6 +233,17 @@ if (verbosity) { fprintf(stderr, "output dir '%s'\n", out_dir); } +foo = parse_filter_chain(0, InFchain); +if (foo) { + fprintf(stderr, "err %d parsing '%s'\n", foo, InFchain); + exit(1); + } +foo = parse_filter_chain(1, OutFchain); +if (foo) { + fprintf(stderr, "err %d parsing '%s'\n", foo, OutFchain); + exit(1); + } + foo = demarre_la_machine(in_pattern, out_dir, fifosize, in_effect, out_effect, steps, blanks); fprintf(stderr, "retour du big-run de la machine -> %d\n", foo); diff --git a/Fonderie/interpolator.c b/Fonderie/interpolator.c index 83b70a04..4d8e3673 100644 --- a/Fonderie/interpolator.c +++ b/Fonderie/interpolator.c @@ -39,10 +39,12 @@ static int cmp_idxvalues(const void *pa, const void *pb) return ( ((IdxValue *)pa)->value > ((IdxValue *)pb)->value); } -int tentative_triage(glob_t *ptr_glob, IdxValue **ptr_idxval, int method) +int tentative_triage(glob_t *ptr_glob, IdxValue **ptr_idxval, + int method, double *p_average) { int idx, foo, nombre; float metrique; +double average; char *filename; IdxValue *idxvalues; @@ -62,6 +64,7 @@ if (NULL==idxvalues) { fprintf(stderr, "IdxValues array at %p\n", idxvalues); *ptr_idxval = idxvalues; +average = 0.0; /* compute all the needed values */ for (idx=0; idx 1) { fflush(stdout); } } -fprintf(stderr, "\n.\n"); +average /= (double)nombre; +*p_average = average; + +fprintf(stderr, "\naverage %f\n", average); + return 0; } @@ -109,6 +117,7 @@ int curpix; int iarray[3]; char *cptr, line[200]; float coef, value; +double meanmetric; IdxValue *idx_values; fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n", @@ -124,7 +133,7 @@ if (0 == globbuf.gl_pathc) { } idx_values = NULL; -foo = tentative_triage(&globbuf, &idx_values, sort); +foo = tentative_triage(&globbuf, &idx_values, sort, &meanmetric); if (foo) { fprintf(stderr, "sort of %p -> %d\n\n", idx_values, foo); return foo; @@ -134,8 +143,14 @@ foo = fimg_fileinfos(globbuf.gl_pathv[0], iarray); if (FIMG_TYPE_RGB != iarray[2]) { fprintf(stderr, "can work only on RGB fimg picture, was %d\n", iarray[2]); - exit(1); + exit(1); /* BLAM! */ } + +if (infx) fprintf(stderr, "\tin fx #%d\n", infx); +else fprintf(stderr, "\tno in fx\n"); +if (outfx) fprintf(stderr, "\tout fx #%d\n", outfx); +else fprintf(stderr, "\tno out fx\n"); + w = iarray[0], h = iarray[1]; fprintf(stderr, "first image size : %dx%d\n", w, h); @@ -256,6 +271,12 @@ fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__, __DATE__, __TIME__); fimg_print_version(2); +//#if DEBUG_LEVEL +/* this is for the debug off calling shellscript */ +for (foo=0; foo \n"); @@ -288,7 +309,7 @@ if (foo) { exit(1); } -if (verbosity) { +if (verbosity > 1) { puts("=============="); filterstack_list(0, __FILE__); filterstack_list(1, __FILE__); diff --git a/Fonderie/t.c b/Fonderie/t.c index fd222c10..352c7e20 100644 --- a/Fonderie/t.c +++ b/Fonderie/t.c @@ -23,7 +23,7 @@ int convert_to_gray; /* WTF ? */ #define LMAX 255.0 #define TIMER 1 -#define STK 0 +#define STK 6 /* ----------------------------------------------------------- */