fonderie can now handle images of any size

This commit is contained in:
Tonton Th 2020-11-04 17:18:58 +01:00
parent e404781d98
commit 3859777c47

View File

@ -28,19 +28,16 @@ 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, "p8/%05d.png", numero); sprintf(ligne, "p8/%05d.png", numero);
/* ^^^ /* ^^^
XXX hardcoded value ? wtf ? XXX hardcoded value ? wtf ?
*/ */
foo = export_fifo(ligne, proc, step); foo = export_fifo(ligne, proc, 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;
} }
numero++; /* VERY IMPORTANT :) */ numero++; /* VERY IMPORTANT :) */
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
@ -49,12 +46,9 @@ int insert_blank(FloatImg *image, int nbre, int pproc)
int idx, foo; int idx, foo;
fimg_clear(image); fimg_clear(image);
for (idx=0; idx<nbre; idx++) { for (idx=0; idx<nbre; idx++) {
fimg_vdeg_a(image, 16.64);
fimg_hdeg_a(image, 16.64); // brotche_rand48_b(image, drand48()*0.10, 1e5);
brotche_rand48_b(image, drand48()*0.10, 1e5);
if ((foo=traite_une_image(image, pproc, 1))) { if ((foo=traite_une_image(image, pproc, 1))) {
fprintf(stderr, "%s : err %d from 'traite_une_image'\n", fprintf(stderr, "%s : err %d from 'traite_une_image'\n",
__func__, foo); __func__, foo);
@ -62,7 +56,6 @@ for (idx=0; idx<nbre; idx++) {
} }
printf("\t%c\r", "ABCDEF"[idx%6]); fflush(stdout); printf("\t%c\r", "ABCDEF"[idx%6]); fflush(stdout);
} }
puts(""); puts("");
return 0; return 0;
@ -73,11 +66,12 @@ 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 infx, int outfx, int step)
{ {
int foo, idx; int foo, idx, width, height;
glob_t globbuf; glob_t globbuf;
char *cptr; char *cptr;
FloatImg input; FloatImg input;
double fin; double fin;
int datas[3];
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' -> '%s' %d )\n", __func__, fprintf(stderr, ">>> %s ( '%s' -> '%s' %d )\n", __func__,
@ -93,19 +87,24 @@ else fprintf(stderr, "\tno in fx\n");
if (outfx) fprintf(stderr, "\tout fx #%d\n", outfx); if (outfx) fprintf(stderr, "\tout fx #%d\n", outfx);
else fprintf(stderr, "\tno out fx\n"); else fprintf(stderr, "\tno out fx\n");
foo = create_fifo(szfifo, 640, 480, FIMG_TYPE_RGB);
fprintf(stderr, "init fifo (%d slots) --> %d\n", szfifo, foo);
fimg_create(&input, 640, 480, 3);
/* XXX inject a few stange pics in the fifo */
insert_blank(&input, BLANK, outfx);
memset(&globbuf, 0, sizeof(glob_t)); memset(&globbuf, 0, sizeof(glob_t));
foo = glob(pattern, 0, NULL, &globbuf); foo = glob(pattern, 0, NULL, &globbuf);
fprintf(stderr, "glob '%s' -> %d, %ld files found\n", pattern, foo, fprintf(stderr, "glob '%s' -> %d, %ld files found\n", pattern, foo,
globbuf.gl_pathc); globbuf.gl_pathc);
/* get the size of the inputs images */
foo = fimg_fileinfos(globbuf.gl_pathv[0], datas);
width = datas[0];
height = datas[1];
foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB);
fprintf(stderr, "init fifo (%d slots) --> %d\n", szfifo, foo);
fimg_create(&input, width, height, 3);
/* XXX inject a few stange pics in the fifo */
insert_blank(&input, BLANK, outfx);
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];