is fonderie ok ?

This commit is contained in:
Tonton Th 2020-11-05 21:07:38 +01:00
parent c9de7cdc80
commit e0d154c37e
6 changed files with 55 additions and 41 deletions

View File

@ -1,6 +1,6 @@
COPT = -g -pg -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses COPT = -g -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses
LIBS = -lfloatimg -lpnglite -lm LIBS = -lfloatimg -lpnglite -lm
OBJS = fonctions.o sfx.o crapulator.o OBJS = fonctions.o sfx.o crapulator.o
DEPS = fonctions.h crapulator.h DEPS = fonctions.h crapulator.h

View File

@ -10,8 +10,8 @@ de **films flous**.
Le programme principal, utilisé à partir de la ligne de commande Le programme principal, utilisé à partir de la ligne de commande
avec une foule d'options aux mnémoniques abscons. avec une foule d'options aux mnémoniques abscons.
Rassurez-vous, en général ils sont wrappables dans des scripts Rassurez-vous, en général il est wrappable dans des scripts
shell. Il est même possible un jour qu'ils puissent lire des écrits en Bash. Il est même possible un jour qu'ils puissent lire des
paramètres dans `$(env)`. paramètres dans `$(env)`.
``` ```
@ -45,16 +45,17 @@ GLOB=${GRABDIR}'/?????.fimg'
${FONDEUR} -v -T 40 -I "$GLOB" -w 10 -x 0 ${FONDEUR} -v -T 40 -I "$GLOB" -w 10 -x 0
``` ```
Ensuite il suffit d'encoder toutes les images générées dans Ensuite il suffit d'encoder toutes les images générées dans
`p8/` (répertoire de sortie par défaut `p8/` (répertoire de sortie par défaut
avec une incantation de ffmpeg : avec une incantation de ffmpeg :
``` ```
ffmpeg -nostdin \ ffmpeg -nostdin \
-loglevel error \ -loglevel error \
-y -r 30 -f image2 -i p8/%05d.png \ -y -r 30 -f image2 -i p8/%05d.png \
-c:v libx264 -pix_fmt yuv420p \ -c:v libx264 -pix_fmt yuv420p \
foo.mp4 foo.mp4
``` ```
## crapulator.c ## crapulator.c

View File

@ -55,8 +55,8 @@ return 0;
*/ */
int crapulator(FloatImg *image, int idFx, float fval) int crapulator(FloatImg *image, int idFx, float fval)
{ {
int retval, foo; int retval;
FloatImg imgtmp; // FloatImg imgtmp;
static int count = 0; static int count = 0;
int flag_debug = 0; int flag_debug = 0;
@ -116,6 +116,10 @@ switch (idFx) {
} }
break; break;
case 10:
retval = binarize(image, 0);
break;
default : default :
fprintf(stderr, "%s : effect #%d invalid\n", fprintf(stderr, "%s : effect #%d invalid\n",
__func__, idFx); __func__, idFx);

View File

@ -41,13 +41,13 @@ numero++; /* VERY IMPORTANT :) */
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int insert_blank(FloatImg *image, int nbre, int pproc) int insert_blank(FloatImg *image, int nbre, int pproc, float fval)
{ {
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_vdeg_a(image, fval);
// 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",
@ -61,7 +61,7 @@ puts("");
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
#define BLANK 40 #define BLANK 30
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)
@ -71,11 +71,12 @@ glob_t globbuf;
char *cptr; char *cptr;
FloatImg input; FloatImg input;
double fin; double fin;
float maxvalue;
int datas[3]; int datas[3];
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' -> '%s' %d )\n", __func__, fprintf(stderr, ">>> %s ( '%s' -> '%s' %d eff:%d:%d)\n", __func__,
pattern, outdir, szfifo); pattern, outdir, szfifo, infx, outfx);
#endif #endif
if (1 != step) fprintf(stderr, "\tstep is %d\n", step); if (1 != step) fprintf(stderr, "\tstep is %d\n", step);
@ -94,21 +95,29 @@ fprintf(stderr, "glob '%s' -> %d, %ld files found\n", pattern, foo,
/* get the size of the inputs images */ /* get the size of the inputs images */
foo = fimg_fileinfos(globbuf.gl_pathv[0], datas); foo = fimg_fileinfos(globbuf.gl_pathv[0], datas);
width = datas[0]; width = datas[0]; height = datas[1];
height = datas[1]; fprintf(stderr, "image size %dx%d\n", width, height);
fimg_create(&input, width, height, 3);
/* get the maximum value of the first pic */
foo = fimg_load_from_dump(globbuf.gl_pathv[0], &input);
if (foo) {
fprintf(stderr, "%s: err %d loading %s\n",
__func__, foo, globbuf.gl_pathv[0]);
exit(1);
}
maxvalue = fimg_get_maxvalue(&input);
fprintf(stderr, "maxvalue %f\n", maxvalue);
foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB); 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);
fimg_create(&input, width, height, 3); /* XXX inject a few strange pics in the fifo */
insert_blank(&input, BLANK, outfx, maxvalue);
/* 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];
/* first step : read the current grabed picz from disk, /* first step : read the current grabed picz from disk,
and put it in our private buffer */ and put it in our private buffer */
foo = fimg_load_from_dump(cptr, &input); foo = fimg_load_from_dump(cptr, &input);
@ -116,7 +125,6 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fprintf(stderr, "load #%d from dump -> %d\n", idx, foo); fprintf(stderr, "load #%d from dump -> %d\n", idx, foo);
continue; continue;
} }
/* ========================= */ /* ========================= */
/* FSCKING INPUT FILTER HERE */ /* FSCKING INPUT FILTER HERE */
foo = crapulator(&input, infx, 0.42); foo = crapulator(&input, infx, 0.42);
@ -124,7 +132,6 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fprintf(stderr, "%s crapulator -> %d\n", __func__, foo); fprintf(stderr, "%s crapulator -> %d\n", __func__, foo);
exit(1); exit(1);
} }
foo = traite_une_image(&input, outfx, step); foo = traite_une_image(&input, outfx, step);
if (foo) { if (foo) {
fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo); fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo);
@ -132,10 +139,13 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
} }
fprintf(stderr, "\t%5d\r", idx); fprintf(stderr, "\t%5d\r", idx);
} }
fputs("\n", stderr); fputs("\n", stderr);
insert_blank(&input, BLANK, outfx); insert_blank(&input, BLANK*2, outfx, maxvalue);
/*
* PLEASE, FLUSH THE FIFO !
*/
fin = fimg_timer_get(0); fin = fimg_timer_get(0);
if (idx) { if (idx) {

View File

@ -21,8 +21,7 @@ extern int verbosity;
int binarize(FloatImg *pimg, int notused) int binarize(FloatImg *pimg, int notused)
{ {
float mm[6], mR, mG, mB; float mm[6], mR, mG, mB;
int foo, x, y; int foo, size;
float rgb[3];
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused); fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
@ -34,19 +33,17 @@ mG = (mm[3] - mm[2]) / 2.0;
mB = (mm[5] - mm[4]) / 2.0; mB = (mm[5] - mm[4]) / 2.0;
if (verbosity > 1) if (verbosity > 1)
fprintf(stderr, "%s: %f %f %f\n", __func__, mR, mG, mB); fprintf(stderr, "%s: %f %f %f\n", __func__, mR, mG, mB);
for (y=0; y<pimg->height; y++) { size = pimg->width * pimg->height;
for (x=0; x<pimg->width; x++) {
fimg_get_rgb(pimg, x, y, rgb); for (foo=0; foo<size; foo++) {
if (rgb[0] < mR) rgb[0] = mm[0]; if (pimg->R[foo] < mR) pimg->R[foo] = mm[0];
else rgb[0] = mm[1]; else pimg->R[foo] = mm[1];
if (rgb[1] < mG) rgb[1] = mm[2]; if (pimg->G[foo] < mG) pimg->G[foo] = mm[2];
else rgb[1] = mm[3]; else pimg->G[foo] = mm[3];
if (rgb[2] < mB) rgb[2] = mm[4]; if (pimg->B[foo] < mB) pimg->B[foo] = mm[4];
else rgb[2] = mm[5]; else pimg->B[foo] = mm[5];
fimg_put_rgb(pimg, x, y, rgb);
}
} }
return 0; return 0;

View File

@ -46,3 +46,5 @@ Certains outils externes sont aussi utiles :
Encore trop légère, mais déja [présente](doc/). Encore trop légère, mais déja [présente](doc/).
C'est à vous de compiler le C'est à vous de compiler le
[PDF](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf) [PDF](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
Your mileage may vary...