more debug or more bug ?

This commit is contained in:
Tonton Th 2020-12-15 17:49:12 +01:00
parent 2187c1e062
commit 0def451bf4
7 changed files with 73 additions and 20 deletions

View File

@ -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 "???";
}

View File

@ -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);
}

View File

@ -3,7 +3,8 @@
*/
typedef struct {
int numero; /* id in rapulator */
int numero; /* id in crapulator */
char *name;
int ival;
float fval;
} FilterSlot;

View File

@ -86,7 +86,10 @@ if (convert_to_gray) {
// fprintf(stderr, "%p gray-washed\n", &fifo.total);
}
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);

View File

@ -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<globbuf.gl_pathc; idx++) {
}
/* fscking input filter here */
foo = crapulator(&input, infx, 0.42);
if (infx) {
foo = crapulator(&input, infx, maxvalue);
}
else {
foo = filterstack_run(0, &input, 0);
}
if (foo) {
fprintf(stderr, "%s crapulator -> %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);

View File

@ -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<nombre; idx++) {
@ -76,6 +79,7 @@ for (idx=0; idx<nombre; idx++) {
fprintf(stderr, "%5d %s %f\r", idx, filename, metrique);
idxvalues[idx].idx = idx;
idxvalues[idx].value = metrique;
average += (double)metrique;
}
if (method) {
@ -91,7 +95,11 @@ if (verbosity > 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<argc; foo++)
fprintf(stderr, "%5d %s\n", foo, argv[foo]);
//#endif
while ((opt = getopt(argc, argv, "E:F:hS:vw:x:")) != -1) {
switch(opt) {
case 'E': InFchain = optarg; break;
@ -268,9 +289,9 @@ while ((opt = getopt(argc, argv, "E:F:hS:vw:x:")) != -1) {
}
}
#if DEBUG_LEVEL
//#if DEBUG_LEVEL
fprintf(stderr, "%s: argc = %d, optind = %d\n", argv[0], argc, optind);
#endif
//#endif
if (3 != (argc-optind)) {
fprintf(stderr, "args: [options] <inglob> <outdir> <nbsteep>\n");
@ -288,7 +309,7 @@ if (foo) {
exit(1);
}
if (verbosity) {
if (verbosity > 1) {
puts("==============");
filterstack_list(0, __FILE__);
filterstack_list(1, __FILE__);

View File

@ -23,7 +23,7 @@ int convert_to_gray; /* WTF ? */
#define LMAX 255.0
#define TIMER 1
#define STK 0
#define STK 6
/* ----------------------------------------------------------- */