/* * INTERPOLATOR 2070 * * +---------------------------------------+ * ! Do not use that software in real life ! * +---------------------------------------+ * * imported in FloatImg Mon Nov 9 19:08:57 CET 2020 * */ #include #include #include #include #include #include "../floatimg.h" #include "fonctions.h" #include "glitches.h" #include "crapulator.h" #include "metriques.h" // XXX #include "fonctions.h" int verbosity; int convert_to_gray; /* needed by fonctions.c */ /* -------------------------------------------------------------- */ /* on va essayer de trier l'ordre d'apparition des images * selon une metrique approximative */ typedef struct { int idx; /* in globbuf.gl_pathv[n] */ float value; /* from metric analyse */ } IdxValue; static int cmp_idxvalues(const void *pa, const void *pb) { return ( ((IdxValue *)pa)->value > ((IdxValue *)pb)->value); } int tentative_triage(glob_t *ptr_glob, IdxValue **ptr_idxval, int method) { int idx, foo, nombre; float metrique; char *filename; IdxValue *idxvalues; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, ptr_glob, ptr_idxval, method); #endif nombre = ptr_glob->gl_pathc; /* allocate the array for the sorting action */ idxvalues = calloc(nombre, sizeof(IdxValue)); if (NULL==idxvalues) { fprintf(stderr, "MEMORY ERROR in %s\n", __func__); exit(1); } fprintf(stderr, "IdxValues array at %p\n", idxvalues); *ptr_idxval = idxvalues; /* compute all the needed values */ for (idx=0; idxgl_pathv[idx]; foo = get_float_metric_from_file(filename, &metrique); if (foo) { fprintf(stderr, "%s: err %d get metric of '%s'\n", __func__, foo, filename); return -1; } if (verbosity > 1) fprintf(stderr, "%5d %s %f\n", idx, filename, metrique); idxvalues[idx].idx = idx; idxvalues[idx].value = metrique; } if (method) { /* and now, we can massage all our datas */ qsort(idxvalues, nombre, sizeof(IdxValue), cmp_idxvalues); } if (verbosity > 1) { for (idx=0; idx %d, %ld files found\n", pattern, foo, globbuf.gl_pathc); if (0 == globbuf.gl_pathc) { fprintf(stderr, "%s : no file found, aborting\n", __func__); return -1; } idx_values = NULL; foo = tentative_triage(&globbuf, &idx_values, sort); fprintf(stderr, "\tTRI of %p -> %d\n\n", idx_values, foo); foo = fimg_fileinfos(globbuf.gl_pathv[0], iarray); if (FIMG_TYPE_RGB != iarray[2]) { fprintf(stderr, "can work only on RGB fimg picture, was %d\n", iarray[2]); exit(1); } w = iarray[0], h = iarray[1]; fprintf(stderr, "first image size : %dx%d\n", w, h); fimg_create(&A, w, h, 3); pFirst = &A; // brotche_rand48_a(&A, 0.10, 250.555); fimg_create(&B, w, h, 3); pSecond = &B; // brotche_rand48_a(&B, 0.10, 250.555); fimg_create(&Out, w, h, 3); // brotche_rand48_a(&Out, 0.10, 250.555); ipng = 0; for (idx=0; idx %d\n", cptr, foo); continue; } value = idx_values[idx].value; /* here, we can insert the input filter */ /* OK try it ... */ foo = crapulator(&B, infx, value/2.0); if (foo) { fprintf(stderr, "%s: input fx fail %d\n", __func__, foo); exit(1); } for (step=0; step "); /* may be we can make options incoherent, like * the options of 'fonderie' software ? */ puts("options:"); puts("\t-S nn\tmysterious sort"); puts("\t-v\tincrease verbosity"); puts("\t-w nn\tinput effect"); puts("\t-x nn\toutput effect"); exit(0); } /* -------------------------------------------------------------- */ int main (int argc, char *argv[]) { int foo; int nbrsteps = 9; int opt; int inFx = 0; int outFx = 0; int sort = 0; fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__, __DATE__, __TIME__); fimg_print_version(2); while ((opt = getopt(argc, argv, "hS:vw:x:")) != -1) { switch(opt) { case 'h': help(); break; case 'S': sort = atoi(optarg); break; case 'v': verbosity++; break; case 'w': inFx = atoi(optarg); break; case 'x': outFx = atoi(optarg); break; } } #if DEBUG_LEVEL fprintf(stderr, "%s : argc = %d, optind = %d\n", argv[0], argc, optind); #endif if (3 != (argc-optind)) { fprintf(stderr, "args: [options] \n"); exit(1); } nbrsteps = atoi(argv[optind+2]); foo = interpolator(argv[optind], argv[optind+1], nbrsteps, inFx, outFx, sort); fprintf(stderr, "interpolator give a %d score\n", foo); return 0; } /* -------------------------------------------------------------- */