forked from tTh/FloatImg
		
	another bug in the wall
This commit is contained in:
		
							parent
							
								
									97698bb66f
								
							
						
					
					
						commit
						ad58bf521d
					
				@ -157,7 +157,7 @@ return retval;
 | 
			
		||||
 *	processor.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define DEBUG_THIS_CRAP		0
 | 
			
		||||
#define DEBUG_THIS_CRAP		60
 | 
			
		||||
 | 
			
		||||
int crapulator(FloatImg *image, int idFx, float fval)
 | 
			
		||||
{
 | 
			
		||||
@ -172,7 +172,7 @@ fprintf(stderr, ">>> %s ( %p %d %f )\n", __func__,
 | 
			
		||||
#if DEBUG_THIS_CRAP
 | 
			
		||||
static int		count = 0;
 | 
			
		||||
int			flag_debug = 0;
 | 
			
		||||
if (666==count) {
 | 
			
		||||
if (DEBUG_THIS_CRAP==count) {
 | 
			
		||||
	flag_debug = 1;
 | 
			
		||||
	fprintf(stderr, "DEBUG PT 1 in %s:%d\n", __func__, __LINE__);
 | 
			
		||||
	fimg_save_as_png(image, "crap_before.png", 0);
 | 
			
		||||
@ -183,7 +183,8 @@ retval = 0;
 | 
			
		||||
 | 
			
		||||
switch (idFx) {
 | 
			
		||||
	case CR_none:			/* DO NOTHING */
 | 
			
		||||
		retval = 0;			break;
 | 
			
		||||
		retval = 0;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
	case CR_cos01:
 | 
			
		||||
		fimg_cos_01(image, image,
 | 
			
		||||
 | 
			
		||||
@ -118,8 +118,8 @@ for (idx=0; idx<f_stacks[numid].count; idx++) {
 | 
			
		||||
	fv  = f_stacks[numid].slots[idx].fval;
 | 
			
		||||
 | 
			
		||||
	if (verbosity > 1)
 | 
			
		||||
		fprintf(stderr, "run %d : effect %2d on %p\n",
 | 
			
		||||
				idx, eff, target);
 | 
			
		||||
		fprintf(stderr, "stack %d pass %d : effect %2d on %p\n",
 | 
			
		||||
				numid, idx, eff, target);
 | 
			
		||||
 | 
			
		||||
	foo = crapulator(target, eff, fv);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -51,11 +51,9 @@ else	{
 | 
			
		||||
	pdest = destination;			}
 | 
			
		||||
 | 
			
		||||
fimg_clear(pdest);
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
	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;
 | 
			
		||||
}
 | 
			
		||||
/* -------------------------------------------------------------- */
 | 
			
		||||
@ -73,16 +75,13 @@ return 0;
 | 
			
		||||
 *	  - 16 bits   PNM
 | 
			
		||||
 *	  - 8 bits    PNG
 | 
			
		||||
 */
 | 
			
		||||
int export_fifo(char *fname, int postproc, int step)
 | 
			
		||||
int export_fifo(char *fname, int step)
 | 
			
		||||
{
 | 
			
		||||
int		foo, type;
 | 
			
		||||
 | 
			
		||||
foo = faire_la_somme(&g_fifo, NULL, step);
 | 
			
		||||
 | 
			
		||||
if (postproc)
 | 
			
		||||
	foo = crapulator(&g_fifo.total, postproc, 0.0);
 | 
			
		||||
else
 | 
			
		||||
	foo = filterstack_run(1, &g_fifo.total, 0);
 | 
			
		||||
foo = filterstack_run(1, &g_fifo.total, 0);
 | 
			
		||||
if (foo) {
 | 
			
		||||
	fprintf(stderr, "%s: ERR post process picture -> %d\n",
 | 
			
		||||
				__func__, foo);
 | 
			
		||||
@ -127,9 +126,11 @@ memcpy(dst->R, src->R, nbre);
 | 
			
		||||
memcpy(dst->G, src->G, nbre);
 | 
			
		||||
memcpy(dst->B, src->B, nbre);
 | 
			
		||||
 | 
			
		||||
g_fifo.next++,  g_fifo.next %= g_fifo.nbslots;
 | 
			
		||||
// maybe we can write :
 | 
			
		||||
//	(++fifo.next) %= fifo.nbslots;
 | 
			
		||||
fprintf(stderr, "*** %s %s writing debug file ***\n",
 | 
			
		||||
			__FILE__, __func__);
 | 
			
		||||
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",
 | 
			
		||||
				__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);
 | 
			
		||||
		return foo;
 | 
			
		||||
		}
 | 
			
		||||
	fimg_clear(&g_fifo.slots[idx]);
 | 
			
		||||
	}
 | 
			
		||||
foo = fimg_create(&g_fifo.total, w, h, t);
 | 
			
		||||
g_fifo.next = 0;
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@
 | 
			
		||||
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;
 | 
			
		||||
int			foo;
 | 
			
		||||
@ -29,8 +29,9 @@ if (foo) {
 | 
			
		||||
	fprintf(stderr, "%s: err %d on insert\n", __func__, foo);
 | 
			
		||||
	return foo;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
sprintf(ligne, "%s/%05d.png", outd, numero);
 | 
			
		||||
foo = export_fifo(ligne, proc, step);
 | 
			
		||||
foo = export_fifo(ligne, step);
 | 
			
		||||
if (foo) {
 | 
			
		||||
	fprintf(stderr, "%s: err %d on export\n", __func__, foo);
 | 
			
		||||
	return foo;
 | 
			
		||||
@ -39,8 +40,7 @@ numero++;			/* VERY IMPORTANT :) */
 | 
			
		||||
return 0;
 | 
			
		||||
}
 | 
			
		||||
/* -------------------------------------------------------------- */
 | 
			
		||||
int insert_blank(FloatImg *image, int nbre, int pproc,
 | 
			
		||||
						float fval, char *outd)
 | 
			
		||||
int insert_blank(FloatImg *image, int nbre, float fval, char *outd)
 | 
			
		||||
{
 | 
			
		||||
int		idx, foo;
 | 
			
		||||
int		preloaded = 0;
 | 
			
		||||
@ -69,12 +69,7 @@ for (idx=0; idx<nbre; idx++) {
 | 
			
		||||
	if (preloaded) {
 | 
			
		||||
		fimg_copy_data(&blank, image);
 | 
			
		||||
		}
 | 
			
		||||
	/* XXX
 | 
			
		||||
	else {
 | 
			
		||||
		fimg_hdeg_a(image, fval);
 | 
			
		||||
		}
 | 
			
		||||
		*/
 | 
			
		||||
	if ((foo=traite_une_image(image, pproc, 1, outd))) {
 | 
			
		||||
	if ((foo=traite_une_image(image, 1, outd))) {
 | 
			
		||||
		fprintf(stderr, "%s : err %d from 'traite_une_image'\n",
 | 
			
		||||
				__func__, foo);
 | 
			
		||||
		break;
 | 
			
		||||
@ -92,7 +87,7 @@ return 0;
 | 
			
		||||
/* -------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
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);
 | 
			
		||||
 | 
			
		||||
/* 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++) {
 | 
			
		||||
	cptr = globbuf.gl_pathv[idx];
 | 
			
		||||
@ -155,26 +150,23 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	/*		fscking input filter here 		*/
 | 
			
		||||
	if (infx) {
 | 
			
		||||
		foo = crapulator(&input, infx, maxvalue);
 | 
			
		||||
		}
 | 
			
		||||
	else	{
 | 
			
		||||
	foo = filterstack_run(0, &input, 0);
 | 
			
		||||
		}
 | 
			
		||||
	if (foo) {
 | 
			
		||||
		fprintf(stderr, "%s: input filter -> %d\n", __func__, foo);
 | 
			
		||||
		exit(1);
 | 
			
		||||
		}
 | 
			
		||||
	foo = traite_une_image(&input, outfx, step, outdir);
 | 
			
		||||
	foo = traite_une_image(&input, step, outdir);
 | 
			
		||||
 | 
			
		||||
	if (foo) {
 | 
			
		||||
		fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo);
 | 
			
		||||
		break;
 | 
			
		||||
		}
 | 
			
		||||
	fprintf(stderr, "\t%5d / %5d\r", idx, (int)globbuf.gl_pathc);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
fputs("\n", stderr);
 | 
			
		||||
 | 
			
		||||
insert_blank(&input, blk, outfx, maxvalue, outdir);
 | 
			
		||||
insert_blank(&input, blk, maxvalue, outdir);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *		PLEASE, FLUSH THE FIFO !
 | 
			
		||||
@ -213,8 +205,6 @@ int		foo, opt;
 | 
			
		||||
int		fifosize = 10;
 | 
			
		||||
char		*in_pattern = "capture/?????.fimg";
 | 
			
		||||
char		*out_dir = "p8";
 | 
			
		||||
// OBSOLETE int		in_effect = 0;
 | 
			
		||||
// OBSOLETE int		out_effect = 0;
 | 
			
		||||
int		steps = 1;
 | 
			
		||||
int		blanks = 20;
 | 
			
		||||
char		*InFchain  = "none";
 | 
			
		||||
@ -245,10 +235,6 @@ while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:s:T:vw:x:")) != -1) {
 | 
			
		||||
				break;
 | 
			
		||||
		case 'v':	verbosity++;
 | 
			
		||||
				break;
 | 
			
		||||
// OBSOLETE 		case 'w':	in_effect = atoi(optarg);
 | 
			
		||||
// OBSOLETE 				break;
 | 
			
		||||
// OBSOLETE 		case 'x':	out_effect = atoi(optarg);
 | 
			
		||||
// OBSOLETE 				break;
 | 
			
		||||
		case 's':	steps = atoi(optarg);
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
@ -278,8 +264,8 @@ if (verbosity) {
 | 
			
		||||
	fprintf(stderr, ".\n");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
foo = demarre_la_machine(in_pattern, out_dir, fifosize, 0,
 | 
			
		||||
					0, steps, blanks);
 | 
			
		||||
foo = demarre_la_machine(in_pattern, out_dir, fifosize, steps, blanks);
 | 
			
		||||
 | 
			
		||||
fprintf(stderr, "retour du big-run de la machine -> %d\n", foo);
 | 
			
		||||
 | 
			
		||||
return 0;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user