/* * +-------------------------+ * | S I N G L E P A S S | * +-------------------------+ */ #include #include #include #include #include #include #include "../floatimg.h" #include "utilfuncs.h" #include "crapulator.h" #include "filterstack.h" #include "single.h" #include "glitches.h" /* ----------------------------------------------------------- */ #define FILTERS 0 int verbosity; /* ----------------------------------------------------------- */ /* * parameter 'duplic' is the repetition factor */ int run_the_singlepass(char *globber, char *destdir, int duplic, int fchain, int outfmt) { FloatImg image = { 0 }; int idx, foo, loop; glob_t globbuf; char *fname; double elapsed; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' '%s' %d %d %d )\n", __func__, globber, destdir, duplic, fchain, outfmt); #endif if (verbosity) filterstack_list(fchain, "Run the single pass"); (void)fimg_timer_set(0); foo = single_init(0, destdir, fchain, outfmt); if (foo) { fprintf(stderr, "erreur %d single_init\n", foo); return foo; } // single_print_state("just after init", 0); memset(&globbuf, 0, sizeof(glob_t)); foo = glob(globber, 0, NULL, &globbuf); // fprintf(stderr, "globbing '%s' -> %d, %d files found\n", // globber, foo, (int)globbuf.gl_pathc); switch (foo) { case GLOB_NOSPACE: fprintf(stderr, "%s: glob run out of memory\n", __func__); break; case GLOB_ABORTED: fprintf(stderr, "%s: glob read error\n", __func__); break; case GLOB_NOMATCH: fprintf(stderr, "%s: glob found no matches\n", __func__); break; } if (0 == globbuf.gl_pathc) { fprintf(stderr, "%s: no file found, aborting\n", __func__); return -1; } for (idx=0; idx 1) { fprintf(stderr, "%s: image '%s' loaded in %p\n", __func__, fname, &image); } if (foo) { fprintf(stderr, "get image -> %d\n", foo); return -1; } if (0==idx && verbosity) { fprintf(stderr, "\tfirst image size %dx%d\n", image.width, image.height); } // fprintf(stderr, " %6ld %s\r", (long)globbuf.gl_pathc-idx, fname); foo = filterstack_run(fchain, &image, 0); if (foo) { fprintf(stderr, "%s: filterstack run --> %d\n", __func__, foo); return foo; } /* HERE WE CAN REPEAT THE INSERT OF THE PICZ */ for (loop=0; loop %d\n", foo); return 0; } /* ----------------------------------------------------------- */