on avance vers du mieux

This commit is contained in:
tth
2021-04-03 05:37:03 +02:00
parent 0a92028c56
commit d7a3074561
4 changed files with 53 additions and 63 deletions

View File

@@ -17,12 +17,19 @@
int verbosity;
/* -------------------------------------------------------------- */
int traite_une_image(FloatImg *image, int step, char *outd)
/*
* this is the real worker ? or just a wrapper ?
*/
int traite_une_image(FloatImg *image, char *outd)
{
static int numero;
int foo;
char ligne[200];
#if DEBUG_LEVEL
fprintf(stderr, "\n>>> %s ( %p '%s' )\n", __func__, image, outd);
#endif
/* here, we put the picz in the fifo machinery */
foo = insert_picture(image);
if (foo) {
@@ -30,46 +37,33 @@ if (foo) {
return foo;
}
/* and now, we pull the result on the magic computation
*/
sprintf(ligne, "%s/%05d.png", outd, numero);
foo = export_fifo(ligne, step);
if (verbosity > 1) fprintf(stderr, " exporting to '%s'\n", ligne);
foo = export_fifo(ligne, 1);
if (foo) {
fprintf(stderr, "%s: err %d on export\n", __func__, foo);
return foo;
}
numero++; /* VERY IMPORTANT :) */
return 0;
}
/* -------------------------------------------------------------- */
int insert_blank(FloatImg *image, int nbre, float fval, char *outd)
int insert_blank(FloatImg *image, int nbre, char *outd)
{
int idx, foo;
int preloaded = 0;
FloatImg blank;
char *fname;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %f '%s' )\n", __func__,
image, nbre, pproc, fval, outd);
fprintf(stderr, ">>> %s ( %p %d '%s' )\n", __func__,
image, nbre, outd);
#endif
if (NULL != (fname=getenv("BLANK_FIMG"))) {
fprintf(stderr,"%s: try to load %s\n", __func__, fname);
fimg_clone(image, &blank, 1);
foo = fimg_load_from_dump(fname, &blank);
if (foo) {
fprintf(stderr, "epic fail %d on %s\n", foo, fname);
exit(1);
}
if (verbosity) fimg_describe(&blank, "Blank pic");
preloaded = 1;
}
fimg_clear(image);
for (idx=0; idx<nbre; idx++) {
if (preloaded) {
fimg_copy_data(&blank, image);
}
if ((foo=traite_une_image(image, 1, outd))) {
if ((foo=traite_une_image(image, outd))) {
fprintf(stderr, "%s : err %d from 'traite_une_image'\n",
__func__, foo);
break;
@@ -78,10 +72,6 @@ for (idx=0; idx<nbre; idx++) {
}
puts("");
if (preloaded) {
fimg_destroy(&blank);
}
return 0;
}
/* -------------------------------------------------------------- */
@@ -98,8 +88,8 @@ float maxvalue;
int datas[3];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' -> '%s' %d eff:%d:%d)\n", __func__,
pattern, outdir, szfifo, infx, outfx);
fprintf(stderr, "\n>>> %s ( '%s' -> '%s' %d )\n", __func__,
pattern, outdir, szfifo);
#endif
if (1 != step) fprintf(stderr, "\tstep is %d\n", step);
@@ -137,12 +127,14 @@ foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB);
fprintf(stderr, "init fifo (%d slots) --> %d\n", szfifo, foo);
/* XXX inject a few strange pics in the fifo */
insert_blank(&input, blk, maxvalue, outdir);
insert_blank(&input, blk, outdir);
for (idx=0; idx<globbuf.gl_pathc; idx++) {
cptr = globbuf.gl_pathv[idx];
/* first step : read the current grabed picz from disk,
and put it in our private buffer */
// fprintf(stderr, "\n######### loading '%s'\n", cptr);
foo = fimg_load_from_dump(cptr, &input);
if (foo) {
fprintf(stderr, "load #%d from dump -> %d\n", idx, foo);
@@ -155,7 +147,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fprintf(stderr, "%s: input filter -> %d\n", __func__, foo);
exit(1);
}
foo = traite_une_image(&input, step, outdir);
foo = traite_une_image(&input, outdir);
if (foo) {
fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo);
@@ -166,7 +158,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fputs("\n", stderr);
insert_blank(&input, blk, maxvalue, outdir);
insert_blank(&input, blk, outdir);
/*
* PLEASE, FLUSH THE FIFO !