first working version of singlepass
This commit is contained in:
@@ -7,17 +7,101 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <glob.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
#include "crapulator.h"
|
||||
#include "filterstack.h"
|
||||
#include "single.h"
|
||||
|
||||
/* ----------------------------------------------------------- */
|
||||
|
||||
#define FILTERS 0
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* ----------------------------------------------------------- */
|
||||
int run_the_singlepass(char *globber, char *destdir, int fchain)
|
||||
{
|
||||
FloatImg image = { 0 };
|
||||
int idx, foo;
|
||||
glob_t globbuf;
|
||||
char *fname;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
|
||||
globber, destdir, fchain);
|
||||
#endif
|
||||
|
||||
// filterstack_list(fchain, "Run the single pass");
|
||||
|
||||
foo = single_init(0, destdir, fchain);
|
||||
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<globbuf.gl_pathc; idx++) {
|
||||
|
||||
fname = globbuf.gl_pathv[idx]; /* alias of filename */
|
||||
fprintf(stderr, " %6d %s\r", globbuf.gl_pathc-idx, fname);
|
||||
|
||||
if (0==image.width && 0==image.height) {
|
||||
foo = fimg_create_from_dump(fname, &image);
|
||||
}
|
||||
else {
|
||||
foo = fimg_load_from_dump(fname, &image);
|
||||
}
|
||||
if (foo) {
|
||||
fprintf(stderr, "get image -> %d\n", foo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
foo = filterstack_run(fchain, &image, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: filterstack run --> %d\n",
|
||||
__func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = single_push_picture(&image);
|
||||
if (foo) {
|
||||
fprintf(stderr, "error %d on push_picture\n", foo);
|
||||
return foo;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
single_print_state("end of run :)", 0);
|
||||
|
||||
fimg_destroy(&image);
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* ----------------------------------------------------------- */
|
||||
static void help(void)
|
||||
{
|
||||
@@ -39,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
int foo, opt;
|
||||
char *filterchain = "none";
|
||||
char *globbing = "./capture/?????.fimg";
|
||||
char *outdir = "./png/";
|
||||
char *outdir = "./p8";
|
||||
int do_xper = 0;
|
||||
|
||||
fprintf(stderr, "*** %s : compiled %s %s\n", __FILE__,
|
||||
@@ -67,6 +151,15 @@ while ((opt = getopt(argc, argv, "hF:g:LO:svx")) != -1) {
|
||||
|
||||
}
|
||||
|
||||
foo = parse_filter_chain(FILTERS, filterchain);
|
||||
if (foo) {
|
||||
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foo = run_the_singlepass(globbing, outdir, FILTERS);
|
||||
fprintf(stderr, "\n\tRun the single pass --> %d\n", foo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user