From d7a30745618467fa0560b736af0bb0138a305073 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 3 Apr 2021 05:37:03 +0200 Subject: [PATCH] on avance vers du mieux --- Fonderie/Makefile | 2 +- Fonderie/fifo.c | 54 ++++++++++++++++++++--------------------- Fonderie/fonderie.c | 58 +++++++++++++++++++-------------------------- Fonderie/glitches.c | 2 +- 4 files changed, 53 insertions(+), 63 deletions(-) diff --git a/Fonderie/Makefile b/Fonderie/Makefile index 8c38d8c..deb910b 100644 --- a/Fonderie/Makefile +++ b/Fonderie/Makefile @@ -52,7 +52,7 @@ crapstr.h: crapulors.liste Makefile craplist2str.awk crapulator.o: crapulator.c ${DEPS} Makefile gcc ${COPT} -c $< -fonctions.o: fonctions.c fonctions.h Makefile +fifo.o: fifo.c fifo.h Makefile gcc ${COPT} -c $< sfx.o: sfx.c ${DEPS} Makefile diff --git a/Fonderie/fifo.c b/Fonderie/fifo.c index 2566ecc..3b99890 100644 --- a/Fonderie/fifo.c +++ b/Fonderie/fifo.c @@ -19,7 +19,8 @@ */ extern int verbosity; -/* private vars of this module - it was very dirty +/* private vars of this module - it was very dirty, + * but simple and efficient. */ static A_Fifo g_fifo; @@ -45,6 +46,11 @@ int faire_la_somme(A_Fifo *pfifo, FloatImg *destination, int step) int idx, foo; FloatImg *pdest; +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, + pfifo, destination, step); +#endif + if (NULL==destination) { pdest = &(pfifo->total); } else { @@ -62,24 +68,26 @@ for (idx=0; idxnbslots; idx += step) { } } -fprintf(stderr, "*** %s %s writing debug file ***\n", +/* XXX +fprintf(stderr, "*** %s:%s writing debugB file ***\n", __FILE__, __func__); fimg_dump_to_file(&g_fifo.total, "debugB.fimg", 0); +XXX */ return 0; } /* -------------------------------------------------------------- */ /* called by 'fonderie.c' - * this func save the fifo content as - * - float FIMG - * - 16 bits PNM - * - 8 bits PNG */ int export_fifo(char *fname, int step) { int foo, type; -foo = faire_la_somme(&g_fifo, NULL, step); +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, step); +#endif + +foo = faire_la_somme(&g_fifo, NULL, 1); foo = filterstack_run(1, &g_fifo.total, 0); if (foo) { @@ -88,24 +96,7 @@ if (foo) { return foo; } -type = format_from_extension(fname); -switch (type) { - case FILE_TYPE_PNG: - foo = fimg_save_as_png(&g_fifo.total, fname, 0); - break; - case FILE_TYPE_PNM: - foo = fimg_save_as_pnm(&g_fifo.total, fname, 0); - break; - case FILE_TYPE_FIMG: - foo = fimg_dump_to_file(&g_fifo.total, fname, 0); - break; - default: - fprintf(stderr, "%s : type of '%s' unknow\n", - __func__, fname); - foo = 888; - break; - } - +foo = fimg_export_picture(&g_fifo.total, fname, 0); if (foo) { fprintf(stderr, "ERR EXPORT '%s' is %d\n", fname, foo); exit(3); @@ -117,7 +108,11 @@ return 0; int insert_picture(FloatImg *src) { FloatImg *dst; -int nbre; +int nbre, foo; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p )\n", __func__, src); +#endif dst = &g_fifo.slots[g_fifo.next]; @@ -126,9 +121,12 @@ memcpy(dst->R, src->R, nbre); memcpy(dst->G, src->G, nbre); memcpy(dst->B, src->B, nbre); -fprintf(stderr, "*** %s %s writing debug file ***\n", +/* XXX +fprintf(stderr, "*** %s:%s writing debugA file ***\n", __FILE__, __func__); -fimg_dump_to_file(dst, "debugA.fimg", 0); +foo = fimg_dump_to_file(dst, "debugA.fimg", 0); +fprintf(stderr, " ok file dumped %d\n", foo); +XXX */ g_fifo.next++; g_fifo.next %= g_fifo.nbslots; diff --git a/Fonderie/fonderie.c b/Fonderie/fonderie.c index ecc8541..9eaa639 100644 --- a/Fonderie/fonderie.c +++ b/Fonderie/fonderie.c @@ -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>> %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 %d\n", idx, foo); @@ -155,7 +147,7 @@ for (idx=0; idx %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 1 fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pvictime, bits); #endif