2020-11-15 21:31:02 +01:00
|
|
|
/*
|
|
|
|
* test des trucs
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2020-11-16 11:12:29 +01:00
|
|
|
#include <unistd.h>
|
2020-12-04 19:55:34 +01:00
|
|
|
#include <string.h>
|
2020-11-15 21:31:02 +01:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
#include "glitches.h"
|
2020-12-02 19:24:54 +01:00
|
|
|
#include "sfx.h"
|
2020-12-03 21:56:45 +01:00
|
|
|
#include "filterstack.h"
|
2020-12-29 16:40:26 +01:00
|
|
|
#include "crapulator.h"
|
2021-01-08 22:57:45 +01:00
|
|
|
#include "single.h"
|
2020-11-15 21:31:02 +01:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
int verbosity;
|
2020-12-03 21:56:45 +01:00
|
|
|
int convert_to_gray; /* WTF ? */
|
2020-11-15 21:31:02 +01:00
|
|
|
|
|
|
|
#define PNG "out.png"
|
2020-12-04 19:55:34 +01:00
|
|
|
#define W 800
|
|
|
|
#define H 600
|
|
|
|
#define LMAX 255.0
|
2020-11-15 21:31:02 +01:00
|
|
|
#define TIMER 1
|
|
|
|
|
2020-12-15 17:49:12 +01:00
|
|
|
#define STK 6
|
2020-12-10 19:19:35 +01:00
|
|
|
|
2020-12-03 21:56:45 +01:00
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
2020-12-30 14:42:44 +01:00
|
|
|
int essai_filterstack(char *fIname, char *fOname)
|
2020-12-03 21:56:45 +01:00
|
|
|
{
|
|
|
|
int foo;
|
2020-12-07 04:45:51 +01:00
|
|
|
FloatImg image;
|
|
|
|
double debut, fin;
|
2020-12-03 21:56:45 +01:00
|
|
|
|
2020-12-30 14:42:44 +01:00
|
|
|
// filterstack_list(STK, __func__);
|
2020-12-04 19:55:34 +01:00
|
|
|
|
2020-12-30 14:42:44 +01:00
|
|
|
foo = fimg_create_from_dump(fIname, &image);
|
2020-12-03 21:56:45 +01:00
|
|
|
if (foo) {
|
2020-12-07 04:45:51 +01:00
|
|
|
fprintf(stderr, "err %d create image\n", foo);
|
|
|
|
exit(1);
|
2020-12-03 21:56:45 +01:00
|
|
|
}
|
|
|
|
|
2020-12-07 04:45:51 +01:00
|
|
|
srand(getpid()); srand48(getpid());
|
2020-12-03 21:56:45 +01:00
|
|
|
|
2020-12-07 04:45:51 +01:00
|
|
|
debut = fimg_timer_set(TIMER);
|
2020-12-04 19:55:34 +01:00
|
|
|
|
2020-12-10 19:19:35 +01:00
|
|
|
foo = filterstack_run(STK, &image, 0);
|
2020-12-03 21:56:45 +01:00
|
|
|
if (foo) {
|
2020-12-07 04:45:51 +01:00
|
|
|
fprintf(stderr, "filterstack run --> %d\n", foo);
|
2020-12-03 21:56:45 +01:00
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
2020-12-07 04:45:51 +01:00
|
|
|
fin = fimg_timer_set(TIMER);
|
|
|
|
|
2020-12-30 14:42:44 +01:00
|
|
|
foo = fimg_export_picture(&image, fOname, 0);
|
2020-12-07 04:45:51 +01:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "erreur export %d\n", foo);
|
2020-12-04 19:55:34 +01:00
|
|
|
}
|
|
|
|
|
2020-12-07 04:45:51 +01:00
|
|
|
fprintf(stderr, "elapsed %f\n", fin-debut);
|
|
|
|
|
|
|
|
fimg_destroy(&image);
|
|
|
|
|
2020-12-03 21:56:45 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* ----------------------------------------------------------- */
|
2020-12-04 19:55:34 +01:00
|
|
|
int help(void)
|
|
|
|
{
|
|
|
|
puts("yolo!");
|
2020-12-31 00:46:12 +01:00
|
|
|
|
|
|
|
puts("\t-L\tlist available filters");
|
|
|
|
|
2020-12-04 19:55:34 +01:00
|
|
|
exit(0);
|
2020-12-29 16:40:26 +01:00
|
|
|
}
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
void experiment(void)
|
|
|
|
{
|
2020-12-30 14:42:44 +01:00
|
|
|
int foo;
|
|
|
|
|
2020-12-29 16:40:26 +01:00
|
|
|
fprintf(stderr, "EXPERIMENT\n");
|
|
|
|
|
2021-01-08 22:57:45 +01:00
|
|
|
foo = essayer_single("capture/???42.fimg", "/tmp/x8/", STK);
|
2020-12-29 16:40:26 +01:00
|
|
|
|
2021-01-08 22:57:45 +01:00
|
|
|
fprintf(stderr, "essayer single -> %d\n", foo);
|
2020-12-30 14:42:44 +01:00
|
|
|
|
|
|
|
exit(0); /* back to real world */
|
2020-12-04 19:55:34 +01:00
|
|
|
}
|
|
|
|
/* ----------------------------------------------------------- */
|
2020-12-03 21:56:45 +01:00
|
|
|
|
2020-11-15 21:31:02 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2020-12-03 21:56:45 +01:00
|
|
|
int foo;
|
2021-01-08 22:57:45 +01:00
|
|
|
int opt, do_xper = 0;
|
2020-12-30 14:42:44 +01:00
|
|
|
char *filterchain = "0";
|
2020-12-29 16:40:26 +01:00
|
|
|
char *infile = "mire.fimg";
|
2020-12-30 14:42:44 +01:00
|
|
|
char *outfile = "out.png";
|
2021-01-08 22:57:45 +01:00
|
|
|
char *outdir = "/tmp/x8/";
|
2020-12-04 19:55:34 +01:00
|
|
|
|
|
|
|
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
|
|
|
|
__DATE__, __TIME__);
|
|
|
|
fimg_print_version(2);
|
|
|
|
|
2020-12-31 00:46:12 +01:00
|
|
|
while ((opt = getopt(argc, argv, "hF:i:Lo:vx")) != -1) {
|
2020-12-04 19:55:34 +01:00
|
|
|
switch(opt) {
|
|
|
|
case 'h': help(); break;
|
2020-12-07 04:45:51 +01:00
|
|
|
case 'F': filterchain = optarg; break;
|
2020-12-30 14:42:44 +01:00
|
|
|
case 'i': infile = optarg; break;
|
2020-12-31 00:46:12 +01:00
|
|
|
case 'L':
|
|
|
|
list_crapulors("available filters");
|
|
|
|
exit(0);
|
2020-12-30 14:42:44 +01:00
|
|
|
case 'o': outfile = optarg; break;
|
2020-12-04 19:55:34 +01:00
|
|
|
case 'v': verbosity++; break;
|
2021-01-08 22:57:45 +01:00
|
|
|
case 'x': do_xper = 1; break;
|
2020-12-29 16:40:26 +01:00
|
|
|
default: exit(1);
|
2020-12-04 19:55:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "%s : argc = %d, optind = %d\n", argv[0], argc, optind);
|
|
|
|
#endif
|
2020-11-25 14:38:39 +01:00
|
|
|
|
2020-12-10 19:19:35 +01:00
|
|
|
foo = parse_filter_chain(STK, filterchain);
|
2020-11-15 21:31:02 +01:00
|
|
|
if (foo) {
|
2020-12-07 04:45:51 +01:00
|
|
|
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
2020-11-15 21:31:02 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2021-01-08 22:57:45 +01:00
|
|
|
if (do_xper) {
|
|
|
|
experiment();
|
|
|
|
}
|
|
|
|
|
2020-12-30 14:42:44 +01:00
|
|
|
foo = essai_filterstack(infile, outfile);
|
2020-12-03 21:56:45 +01:00
|
|
|
if (foo) {
|
2020-12-07 04:45:51 +01:00
|
|
|
fprintf(stderr, "err %d in essai_filterstack\n", foo);
|
|
|
|
exit(1);
|
2020-11-15 21:31:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|