From 35e73543969958b5715213b9d8e6842cc581cecc Mon Sep 17 00:00:00 2001 From: tonton th Date: Wed, 13 Jan 2021 16:09:27 +0100 Subject: [PATCH] first working version of singlepass --- .gitignore | 1 + Fonderie/README.md | 13 ++++++ Fonderie/crapulator.c | 4 +- Fonderie/essai.sh | 18 ++++---- Fonderie/filterstack.c | 2 +- Fonderie/fonctions.c | 8 ---- Fonderie/fonderie.c | 5 +-- Fonderie/interpolator.c | 1 - Fonderie/sfx.c | 1 + Fonderie/single.c | 9 +++- Fonderie/singlepass.c | 95 ++++++++++++++++++++++++++++++++++++++++- Fonderie/t.c | 8 ++-- 12 files changed, 135 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 3cb54147..cb771632 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,7 @@ Fonderie/*.gif Fonderie/fonderie Fonderie/interpolator Fonderie/t +Fonderie/singlepass Fonderie/crapdef.h Fonderie/crapstr.h diff --git a/Fonderie/README.md b/Fonderie/README.md index cc7ee244..7d8aa43b 100644 --- a/Fonderie/README.md +++ b/Fonderie/README.md @@ -99,6 +99,19 @@ Un logiciel dont l'inspiration vient du passé et les améliorations d'une résidence à Terre-Blanque, ça ne peut pas être complètement malsain. +``` +*** interpolator.c : compiled by tTh, Jan 12 2021 16:18:58 +*** FloatImg library, alpha v116 (Dec 27 2020, 22:39:28) + INTERPOLATOR +usage: + interpolator [options] +options: + -S nn mysterious sort + -E i:bla:k input filter chain + -F name:j output filter chain + -L list available filters + -v increase verbosity +``` ## Conclusion diff --git a/Fonderie/crapulator.c b/Fonderie/crapulator.c index 81fabf3b..28d525fc 100644 --- a/Fonderie/crapulator.c +++ b/Fonderie/crapulator.c @@ -22,7 +22,7 @@ int foo; fimg_clone(pimg, ©, 1); -foo = fimg_qsort_rgb_b(pimg, ©, 0); +foo = fimg_qsort_rgb_a(pimg, ©, 0); if (foo) { fprintf(stderr, "%s: err qsort rgb = %d\n", __func__, foo); return foo; @@ -209,7 +209,7 @@ switch (idFx) { image->height/20); break; case CR_water: - retval = bouger_les_pixels(image, 8); + retval = bouger_les_pixels(image, 12); break; case CR_mirsplit: retval = mirror_split(image, 0); diff --git a/Fonderie/essai.sh b/Fonderie/essai.sh index 56379b68..0bbe3e30 100755 --- a/Fonderie/essai.sh +++ b/Fonderie/essai.sh @@ -28,24 +28,24 @@ echo ; echo "making gif89a..." convert -delay 200 /tmp/fstack*.png foo.gif } # ------------------------------------------------------------ -essai_single () +essai_singlepass () { MP4="/home/tth/Essais/FondageDePlomb/foo.mp4" -INPUT="/home/tth/Essais/FondageDePlomb/capture/?[23]???.fimg" -FILTRE="classtrial:liss3x3" +INPUT="/home/tth/Essais/FondageDePlomb/capture/???[04]0.fimg" +FILTRE="water:water:liss3x3" +OUTDIR="/tmp/x8/" echo '********* essai single *********' +rm $OUTDIR/*.png -rm /tmp/x8/*.png +time ./singlepass -v -g "$INPUT" -F $FILTRE -O $OUTDIR -s -time ./t -v -g "$INPUT" -F $FILTRE -s - -echo ; echo "encoding to " $MP4 +echo ; echo "encoding picz to " $MP4 ffmpeg -nostdin \ -loglevel error \ - -y -r 30 -f image2 -i /tmp/x8/%05d.png \ + -y -r 25 -f image2 -i /tmp/x8/%05d.png \ -c:v libx264 -pix_fmt yuv420p \ $MP4 @@ -53,6 +53,6 @@ ffmpeg -nostdin \ # ------------------------------------------------------------ # MAIN -essai_single +essai_singlepass # ------------------------------------------------------------ diff --git a/Fonderie/filterstack.c b/Fonderie/filterstack.c index 526f7549..f92322eb 100644 --- a/Fonderie/filterstack.c +++ b/Fonderie/filterstack.c @@ -233,7 +233,7 @@ for (;;) { } } -if (verbosity) filterstack_list(numid, __func__); +if (verbosity > 1) filterstack_list(numid, __func__); return 0; } /* ----------------------------------------------------------- */ diff --git a/Fonderie/fonctions.c b/Fonderie/fonctions.c index 01a04f61..c2b394fd 100644 --- a/Fonderie/fonctions.c +++ b/Fonderie/fonctions.c @@ -79,14 +79,6 @@ int foo, type; foo = faire_la_somme(&g_fifo, NULL, step); -/* BEGIN GRUIK CODE */ -extern int convert_to_gray; -/* END OF THE KLUGE */ -if (convert_to_gray) { - fimg_to_gray(&g_fifo.total); - // fprintf(stderr, "%p gray-washed\n", &fifo.total); - } - if (postproc) foo = crapulator(&g_fifo.total, postproc, 0.0); else diff --git a/Fonderie/fonderie.c b/Fonderie/fonderie.c index 8d0e8e80..4abe8361 100644 --- a/Fonderie/fonderie.c +++ b/Fonderie/fonderie.c @@ -15,7 +15,6 @@ #include "filterstack.h" int verbosity; -int convert_to_gray; /* -------------------------------------------------------------- */ int traite_une_image(FloatImg *image, int proc, int step, char *outd) @@ -168,7 +167,7 @@ puts("\tFONDERIE\noptions:"); puts("\t-E\tinput:filter:chain"); puts("\t-F\toutput:filter:chain"); -puts("\t-g\tconvert to gray"); +// puts("\t-g\tconvert to gray"); puts("\t-I\tinput glob pattern"); puts("\t-L\tlist available filters"); puts("\t-O\toutput directory"); @@ -201,7 +200,7 @@ while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:s:T:vw:x:")) != -1) { case 'F': OutFchain = optarg; break; case 'B': blanks = atoi(optarg); break; - case 'g': convert_to_gray = 1; + case 'g': // convert_to_gray = 1; break; case 'h': help(); break; diff --git a/Fonderie/interpolator.c b/Fonderie/interpolator.c index 9f3ea883..d38ba674 100644 --- a/Fonderie/interpolator.c +++ b/Fonderie/interpolator.c @@ -23,7 +23,6 @@ #include "filterstack.h" int verbosity; -int convert_to_gray; /* needed by fonctions.c */ /* -------------------------------------------------------------- */ /* on va essayer de trier l'ordre d'apparition des images diff --git a/Fonderie/sfx.c b/Fonderie/sfx.c index 902841b4..8d4b9201 100644 --- a/Fonderie/sfx.c +++ b/Fonderie/sfx.c @@ -242,6 +242,7 @@ for (x=0; xwidth; x++) { || ny>=pimg->height ) continue; + /* XXX optimize here ? */ fimg_get_rgb(pimg, nx, ny, rgb); fimg_put_rgb(pimg, x, y, rgb); diff --git a/Fonderie/single.c b/Fonderie/single.c index f400e531..fea6f480 100644 --- a/Fonderie/single.c +++ b/Fonderie/single.c @@ -31,7 +31,10 @@ int single_init(int next, char *dest, int fxchain) int foo; struct stat stbuf; -fprintf(stderr, ">>> %s ( %d '%s' )\n", __func__, next, dest); +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %d '%s' %d )\n", __func__, + next, dest, fxchain); +#endif nextpng = next; chainfilter = fxchain; @@ -95,6 +98,10 @@ fprintf(stderr, " chainfilter %d\n", chainfilter); fprintf(stderr, " destination %s\n", destination); +if (k) { + + } + return -1; } /* -------------------------------------------------------------- */ diff --git a/Fonderie/singlepass.c b/Fonderie/singlepass.c index 2152a7f1..5a2ebd46 100644 --- a/Fonderie/singlepass.c +++ b/Fonderie/singlepass.c @@ -7,17 +7,101 @@ #include #include #include +#include +#include #include "../floatimg.h" +#include "crapulator.h" +#include "filterstack.h" #include "single.h" /* ----------------------------------------------------------- */ +#define FILTERS 0 + int verbosity; /* ----------------------------------------------------------- */ +int run_the_singlepass(char *globber, char *destdir, int fchain) +{ +FloatImg image = { 0 }; +int idx, foo; +glob_t globbuf; +char *fname; +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, + globber, destdir, fchain); +#endif + +// filterstack_list(fchain, "Run the single pass"); + +foo = single_init(0, destdir, fchain); +if (foo) { + fprintf(stderr, "erreur %d single_init\n", foo); + return foo; + } +// single_print_state("just after init", 0); + +memset(&globbuf, 0, sizeof(glob_t)); +foo = glob(globber, 0, NULL, &globbuf); +// fprintf(stderr, "globbing '%s' -> %d, %d files found\n", +// globber, foo, (int)globbuf.gl_pathc); +switch (foo) { + case GLOB_NOSPACE: + fprintf(stderr, "%s: glob run out of memory\n", __func__); + break; + case GLOB_ABORTED: + fprintf(stderr, "%s: glob read error\n", __func__); + break; + case GLOB_NOMATCH: + fprintf(stderr, "%s: glob found no matches\n", __func__); + break; + } + +if (0 == globbuf.gl_pathc) { + fprintf(stderr, "%s: no file found, aborting\n", __func__); + return -1; + } + +for (idx=0; idx %d\n", foo); + return -1; + } + + foo = filterstack_run(fchain, &image, 0); + if (foo) { + fprintf(stderr, "%s: filterstack run --> %d\n", + __func__, foo); + return foo; + } + + foo = single_push_picture(&image); + if (foo) { + fprintf(stderr, "error %d on push_picture\n", foo); + return foo; + } + } + +fprintf(stderr, "\n"); +single_print_state("end of run :)", 0); + +fimg_destroy(&image); + +return -1; +} /* ----------------------------------------------------------- */ static void help(void) { @@ -39,7 +123,7 @@ int main(int argc, char *argv[]) int foo, opt; char *filterchain = "none"; char *globbing = "./capture/?????.fimg"; -char *outdir = "./png/"; +char *outdir = "./p8"; int do_xper = 0; fprintf(stderr, "*** %s : compiled %s %s\n", __FILE__, @@ -67,6 +151,15 @@ while ((opt = getopt(argc, argv, "hF:g:LO:svx")) != -1) { } +foo = parse_filter_chain(FILTERS, filterchain); +if (foo) { + fprintf(stderr, "err %d in parse_filter_chain\n", foo); + exit(1); + } + +foo = run_the_singlepass(globbing, outdir, FILTERS); +fprintf(stderr, "\n\tRun the single pass --> %d\n", foo); + return 0; } diff --git a/Fonderie/t.c b/Fonderie/t.c index 951db680..450fe25e 100644 --- a/Fonderie/t.c +++ b/Fonderie/t.c @@ -18,7 +18,6 @@ /* ----------------------------------------------------------- */ int verbosity; -int convert_to_gray; /* WTF ? */ #define PNG "out.png" #define W 800 @@ -83,9 +82,10 @@ int idx, foo; glob_t globbuf; char *fname; +#if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, globpattern, destdir, chain); - +#endif filterstack_list(chain, "essai du single"); @@ -137,11 +137,11 @@ for (idx=0; idx