another bug in the wall

This commit is contained in:
tth 2021-04-02 04:16:26 +02:00
parent 97698bb66f
commit ad58bf521d
5 changed files with 37 additions and 48 deletions

View File

@ -157,7 +157,7 @@ return retval;
* processor. * processor.
*/ */
#define DEBUG_THIS_CRAP 0 #define DEBUG_THIS_CRAP 60
int crapulator(FloatImg *image, int idFx, float fval) int crapulator(FloatImg *image, int idFx, float fval)
{ {
@ -172,7 +172,7 @@ fprintf(stderr, ">>> %s ( %p %d %f )\n", __func__,
#if DEBUG_THIS_CRAP #if DEBUG_THIS_CRAP
static int count = 0; static int count = 0;
int flag_debug = 0; int flag_debug = 0;
if (666==count) { if (DEBUG_THIS_CRAP==count) {
flag_debug = 1; flag_debug = 1;
fprintf(stderr, "DEBUG PT 1 in %s:%d\n", __func__, __LINE__); fprintf(stderr, "DEBUG PT 1 in %s:%d\n", __func__, __LINE__);
fimg_save_as_png(image, "crap_before.png", 0); fimg_save_as_png(image, "crap_before.png", 0);
@ -183,7 +183,8 @@ retval = 0;
switch (idFx) { switch (idFx) {
case CR_none: /* DO NOTHING */ case CR_none: /* DO NOTHING */
retval = 0; break; retval = 0;
break;
case CR_cos01: case CR_cos01:
fimg_cos_01(image, image, fimg_cos_01(image, image,

View File

@ -118,8 +118,8 @@ for (idx=0; idx<f_stacks[numid].count; idx++) {
fv = f_stacks[numid].slots[idx].fval; fv = f_stacks[numid].slots[idx].fval;
if (verbosity > 1) if (verbosity > 1)
fprintf(stderr, "run %d : effect %2d on %p\n", fprintf(stderr, "stack %d pass %d : effect %2d on %p\n",
idx, eff, target); numid, idx, eff, target);
foo = crapulator(target, eff, fv); foo = crapulator(target, eff, fv);

View File

@ -51,11 +51,9 @@ else {
pdest = destination; } pdest = destination; }
fimg_clear(pdest); fimg_clear(pdest);
for (idx=0; idx<pfifo->nbslots; idx += step) { for (idx=0; idx<pfifo->nbslots; idx += step) {
/***************************************
* Here was the giant bootleneck *
***************************************/
// HERE -> foo = fimg_add_2(&(pfifo->slots[idx]), pdest);
foo = big_adder(&(pfifo->slots[idx]), pdest); foo = big_adder(&(pfifo->slots[idx]), pdest);
if (foo) if (foo)
{ {
@ -64,6 +62,10 @@ for (idx=0; idx<pfifo->nbslots; idx += step) {
} }
} }
fprintf(stderr, "*** %s %s writing debug file ***\n",
__FILE__, __func__);
fimg_dump_to_file(&g_fifo.total, "debugB.fimg", 0);
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
@ -73,16 +75,13 @@ return 0;
* - 16 bits PNM * - 16 bits PNM
* - 8 bits PNG * - 8 bits PNG
*/ */
int export_fifo(char *fname, int postproc, int step) int export_fifo(char *fname, int step)
{ {
int foo, type; int foo, type;
foo = faire_la_somme(&g_fifo, NULL, step); foo = faire_la_somme(&g_fifo, NULL, step);
if (postproc) foo = filterstack_run(1, &g_fifo.total, 0);
foo = crapulator(&g_fifo.total, postproc, 0.0);
else
foo = filterstack_run(1, &g_fifo.total, 0);
if (foo) { if (foo) {
fprintf(stderr, "%s: ERR post process picture -> %d\n", fprintf(stderr, "%s: ERR post process picture -> %d\n",
__func__, foo); __func__, foo);
@ -127,9 +126,11 @@ memcpy(dst->R, src->R, nbre);
memcpy(dst->G, src->G, nbre); memcpy(dst->G, src->G, nbre);
memcpy(dst->B, src->B, nbre); memcpy(dst->B, src->B, nbre);
g_fifo.next++, g_fifo.next %= g_fifo.nbslots; fprintf(stderr, "*** %s %s writing debug file ***\n",
// maybe we can write : __FILE__, __func__);
// (++fifo.next) %= fifo.nbslots; fimg_dump_to_file(dst, "debugA.fimg", 0);
g_fifo.next++; g_fifo.next %= g_fifo.nbslots;
if (verbosity > 2) fprintf(stderr, "%s : next slot %d\n", if (verbosity > 2) fprintf(stderr, "%s : next slot %d\n",
__func__, g_fifo.next); __func__, g_fifo.next);
@ -158,6 +159,7 @@ for (idx=0; idx<nbslot; idx++) {
fprintf(stderr, "%s idx %d err%d\n", __func__, idx, foo); fprintf(stderr, "%s idx %d err%d\n", __func__, idx, foo);
return foo; return foo;
} }
fimg_clear(&g_fifo.slots[idx]);
} }
foo = fimg_create(&g_fifo.total, w, h, t); foo = fimg_create(&g_fifo.total, w, h, t);
g_fifo.next = 0; g_fifo.next = 0;

View File

@ -29,7 +29,7 @@ typedef struct {
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int export_fifo(char *fname, int postproc, int step); int export_fifo(char *fname, int step);
int insert_picture(FloatImg *src); int insert_picture(FloatImg *src);

View File

@ -17,7 +17,7 @@
int verbosity; int verbosity;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int traite_une_image(FloatImg *image, int proc, int step, char *outd) int traite_une_image(FloatImg *image, int step, char *outd)
{ {
static int numero; static int numero;
int foo; int foo;
@ -29,8 +29,9 @@ if (foo) {
fprintf(stderr, "%s: err %d on insert\n", __func__, foo); fprintf(stderr, "%s: err %d on insert\n", __func__, foo);
return foo; return foo;
} }
sprintf(ligne, "%s/%05d.png", outd, numero); sprintf(ligne, "%s/%05d.png", outd, numero);
foo = export_fifo(ligne, proc, step); foo = export_fifo(ligne, step);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d on export\n", __func__, foo); fprintf(stderr, "%s: err %d on export\n", __func__, foo);
return foo; return foo;
@ -39,8 +40,7 @@ numero++; /* VERY IMPORTANT :) */
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int insert_blank(FloatImg *image, int nbre, int pproc, int insert_blank(FloatImg *image, int nbre, float fval, char *outd)
float fval, char *outd)
{ {
int idx, foo; int idx, foo;
int preloaded = 0; int preloaded = 0;
@ -69,12 +69,7 @@ for (idx=0; idx<nbre; idx++) {
if (preloaded) { if (preloaded) {
fimg_copy_data(&blank, image); fimg_copy_data(&blank, image);
} }
/* XXX if ((foo=traite_une_image(image, 1, outd))) {
else {
fimg_hdeg_a(image, fval);
}
*/
if ((foo=traite_une_image(image, pproc, 1, outd))) {
fprintf(stderr, "%s : err %d from 'traite_une_image'\n", fprintf(stderr, "%s : err %d from 'traite_une_image'\n",
__func__, foo); __func__, foo);
break; break;
@ -92,7 +87,7 @@ return 0;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int demarre_la_machine(char *pattern, char *outdir, int szfifo, int demarre_la_machine(char *pattern, char *outdir, int szfifo,
int infx, int outfx, int step, int blk) int step, int blk)
{ {
int foo, idx, width, height; int foo, idx, width, height;
glob_t globbuf; glob_t globbuf;
@ -142,7 +137,7 @@ foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB);
fprintf(stderr, "init fifo (%d slots) --> %d\n", szfifo, foo); fprintf(stderr, "init fifo (%d slots) --> %d\n", szfifo, foo);
/* XXX inject a few strange pics in the fifo */ /* XXX inject a few strange pics in the fifo */
insert_blank(&input, blk, outfx, maxvalue, outdir); insert_blank(&input, blk, maxvalue, outdir);
for (idx=0; idx<globbuf.gl_pathc; idx++) { for (idx=0; idx<globbuf.gl_pathc; idx++) {
cptr = globbuf.gl_pathv[idx]; cptr = globbuf.gl_pathv[idx];
@ -155,26 +150,23 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
} }
/* fscking input filter here */ /* fscking input filter here */
if (infx) {
foo = crapulator(&input, infx, maxvalue);
}
else {
foo = filterstack_run(0, &input, 0); foo = filterstack_run(0, &input, 0);
}
if (foo) { if (foo) {
fprintf(stderr, "%s: input filter -> %d\n", __func__, foo); fprintf(stderr, "%s: input filter -> %d\n", __func__, foo);
exit(1); exit(1);
} }
foo = traite_une_image(&input, outfx, step, outdir); foo = traite_une_image(&input, step, outdir);
if (foo) { if (foo) {
fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo); fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo);
break; break;
} }
fprintf(stderr, "\t%5d / %5d\r", idx, (int)globbuf.gl_pathc); fprintf(stderr, "\t%5d / %5d\r", idx, (int)globbuf.gl_pathc);
} }
fputs("\n", stderr); fputs("\n", stderr);
insert_blank(&input, blk, outfx, maxvalue, outdir); insert_blank(&input, blk, maxvalue, outdir);
/* /*
* PLEASE, FLUSH THE FIFO ! * PLEASE, FLUSH THE FIFO !
@ -213,8 +205,6 @@ int foo, opt;
int fifosize = 10; int fifosize = 10;
char *in_pattern = "capture/?????.fimg"; char *in_pattern = "capture/?????.fimg";
char *out_dir = "p8"; char *out_dir = "p8";
// OBSOLETE int in_effect = 0;
// OBSOLETE int out_effect = 0;
int steps = 1; int steps = 1;
int blanks = 20; int blanks = 20;
char *InFchain = "none"; char *InFchain = "none";
@ -245,10 +235,6 @@ while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:s:T:vw:x:")) != -1) {
break; break;
case 'v': verbosity++; case 'v': verbosity++;
break; break;
// OBSOLETE case 'w': in_effect = atoi(optarg);
// OBSOLETE break;
// OBSOLETE case 'x': out_effect = atoi(optarg);
// OBSOLETE break;
case 's': steps = atoi(optarg); case 's': steps = atoi(optarg);
break; break;
} }
@ -278,8 +264,8 @@ if (verbosity) {
fprintf(stderr, ".\n"); fprintf(stderr, ".\n");
} }
foo = demarre_la_machine(in_pattern, out_dir, fifosize, 0, foo = demarre_la_machine(in_pattern, out_dir, fifosize, steps, blanks);
0, steps, blanks);
fprintf(stderr, "retour du big-run de la machine -> %d\n", foo); fprintf(stderr, "retour du big-run de la machine -> %d\n", foo);
return 0; return 0;