is filterstack really ok ?

This commit is contained in:
2020-12-07 04:45:51 +01:00
parent b1e613276d
commit 62aa91e434
5 changed files with 185 additions and 109 deletions

View File

@@ -20,8 +20,7 @@
#include "glitches.h"
#include "crapulator.h"
#include "metriques.h"
// XXX #include "fonctions.h"
#include "filterstack.h"
int verbosity;
int convert_to_gray; /* needed by fonctions.c */
@@ -73,14 +72,15 @@ for (idx=0; idx<nombre; idx++) {
foo, filename);
return -1;
}
if (verbosity > 1)
fprintf(stderr, "%5d %s %f\n", idx, filename, metrique);
if (verbosity)
fprintf(stderr, "%5d %s %f\r", idx, filename, metrique);
idxvalues[idx].idx = idx;
idxvalues[idx].value = metrique;
}
if (method) {
/* and now, we can massage all our datas */
fprintf(stderr, "sorting %d ...\n", method);
qsort(idxvalues, nombre, sizeof(IdxValue), cmp_idxvalues);
}
@@ -116,8 +116,8 @@ fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n",
memset(&globbuf, 0, sizeof(glob_t));
foo = glob(pattern, 0, NULL, &globbuf);
fprintf(stderr, "globbing '%s' -> %d, %ld files found\n",
pattern, foo, globbuf.gl_pathc);
fprintf(stderr, "globbing '%s' -> %d, %d files found\n",
pattern, foo, (int)globbuf.gl_pathc);
if (0 == globbuf.gl_pathc) {
fprintf(stderr, "%s : no file found, aborting\n", __func__);
return -1;
@@ -125,7 +125,10 @@ if (0 == globbuf.gl_pathc) {
idx_values = NULL;
foo = tentative_triage(&globbuf, &idx_values, sort);
fprintf(stderr, "\tTRI of %p -> %d\n\n", idx_values, foo);
if (foo) {
fprintf(stderr, "sort of %p -> %d\n\n", idx_values, foo);
return foo;
}
foo = fimg_fileinfos(globbuf.gl_pathv[0], iarray);
if (FIMG_TYPE_RGB != iarray[2]) {
@@ -148,8 +151,8 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
cptr = globbuf.gl_pathv[curpix]; /* aliasing filename */
/* read the next file in B */
fprintf(stderr, "%5d / %5ld %s\r", idx,
globbuf.gl_pathc, cptr);
fprintf(stderr, "%5d / %5d %s\r", idx,
(int)globbuf.gl_pathc, cptr);
foo = fimg_load_from_dump(cptr, &B);
if (foo) {
fprintf(stderr, "load %s from dump -> %d\n", cptr, foo);
@@ -169,7 +172,19 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fimg_interpolate(pSecond, pFirst, &Out, coef);
/* here we can insert the OUTPUT filter */
foo = crapulator(&Out, outfx, value);
// foo = crapulator(&Out, outfx, value);
//if (foo) {
// fprintf(stderr, "\n%s: out fx %d failure %d\n",
// __func__, outfx, foo);
// exit(1);
// }
foo = filterstack_run(&Out, 0);
if (foo) {
fprintf(stderr, "run filt stk--> %d\n", foo);
return foo;
}
if (foo) {
fprintf(stderr, "\n%s: out fx %d failure %d\n",
__func__, outfx, foo);
@@ -195,6 +210,10 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
pFirst = pTmp;
/* XXX THIS CODE DON'T WORK !!! */
#endif
}
fprintf(stderr, "\ngenerated %d png files\n", ipng);
@@ -212,9 +231,10 @@ puts("usage:\n\tinterpolator [options] <inglob> <outdir> <nbsteep>");
*/
puts("options:");
puts("\t-S nn\tmysterious sort");
puts("\t-v\tincrease verbosity");
puts("\t-F i:j\tfilter chain");
puts("\t-w nn\tinput effect");
puts("\t-x nn\toutput effect");
puts("\t-v\tincrease verbosity");
exit(0);
}
@@ -227,13 +247,15 @@ int opt;
int inFx = 0;
int outFx = 0;
int sort = 0;
char *filterchain = "0";
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
__DATE__, __TIME__);
fimg_print_version(2);
while ((opt = getopt(argc, argv, "hS:vw:x:")) != -1) {
while ((opt = getopt(argc, argv, "F:hS:vw:x:")) != -1) {
switch(opt) {
case 'F': filterchain = optarg; break;
case 'h': help(); break;
case 'S': sort = atoi(optarg); break;
case 'v': verbosity++; break;
@@ -251,6 +273,14 @@ if (3 != (argc-optind)) {
exit(1);
}
foo = parse_filter_chain(filterchain);
if (foo) {
fprintf(stderr, "err %d parsing '%s'\n", foo, filterchain);
exit(1);
}
// filterstack_list(__FILE__);
nbrsteps = atoi(argv[optind+2]);
foo = interpolator(argv[optind], argv[optind+1], nbrsteps,
inFx, outFx, sort);