diff --git a/Fonderie/single.c b/Fonderie/single.c index 905f1f4..cbb6e12 100644 --- a/Fonderie/single.c +++ b/Fonderie/single.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/floatimg.h b/floatimg.h index 91ba78d..924c415 100644 --- a/floatimg.h +++ b/floatimg.h @@ -4,7 +4,7 @@ * http://la.buvette.org/photos/cumul */ -#define FIMG_VERSION 171 +#define FIMG_VERSION 174 /* * in memory descriptor @@ -28,6 +28,16 @@ typedef struct { char magic[8]; int32_t w, h, t; } FimgFileHead; +/* + * new 11 mars 2022 + */ +typedef struct { + char magic[8]; + struct timeval timestamp; + int32_t count; + float fval; + char idcam[32]; + } FimgMetaData; /* * we MUST look at packing and endianess problems NOW */ @@ -207,11 +217,14 @@ int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags); int fimg_hdeg_a(FloatImg *img, double dcoef); int fimg_vdeg_a(FloatImg *img, double dcoef); -/* FIMG files module */ +/* FIMG native file module */ int fimg_fileinfos(char *fname, int *datas); int fimg_dump_to_file(FloatImg *head, char *fname, int notused); int fimg_load_from_dump(char *fname, FloatImg *where); int fimg_create_from_dump(char *fname, FloatImg *head); +/* FIMG metadata module */ +int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused); +int fimg_default_metadata(FimgMetaData *pmd); int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags); int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags); diff --git a/funcs/decomprgb.c b/funcs/decomprgb.c index 483fb86..7ceaa77 100644 --- a/funcs/decomprgb.c +++ b/funcs/decomprgb.c @@ -4,6 +4,7 @@ #include #include +#include #include "../floatimg.h" diff --git a/funcs/equalize.c b/funcs/equalize.c index d95afa1..fe2e07f 100644 --- a/funcs/equalize.c +++ b/funcs/equalize.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/fimg-dicom.c b/funcs/fimg-dicom.c index 6afa07f..c6f77d7 100644 --- a/funcs/fimg-dicom.c +++ b/funcs/fimg-dicom.c @@ -7,6 +7,7 @@ #include #include +#include #include "../floatimg.h" diff --git a/funcs/fimg-fits.c b/funcs/fimg-fits.c index 9e78f91..33f2697 100644 --- a/funcs/fimg-fits.c +++ b/funcs/fimg-fits.c @@ -9,6 +9,7 @@ #include #include #include +#include #include diff --git a/funcs/plasmas.c b/funcs/plasmas.c index 6c9aed1..591865b 100644 --- a/funcs/plasmas.c +++ b/funcs/plasmas.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/rampes.c b/funcs/rampes.c index 42f196e..c6a76b2 100644 --- a/funcs/rampes.c +++ b/funcs/rampes.c @@ -5,6 +5,7 @@ #include #include +#include #include "../floatimg.h" diff --git a/funcs/recurse.c b/funcs/recurse.c index 90b3fde..e2d080d 100644 --- a/funcs/recurse.c +++ b/funcs/recurse.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/rotate.c b/funcs/rotate.c index 2ca1477..9fbdd94 100644 --- a/funcs/rotate.c +++ b/funcs/rotate.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/saturation.c b/funcs/saturation.c index 8cd9d5c..fc31264 100644 --- a/funcs/saturation.c +++ b/funcs/saturation.c @@ -4,6 +4,7 @@ #include #include +#include #include "../floatimg.h" diff --git a/funcs/sfx0.c b/funcs/sfx0.c index 1de4c65..fa2fce1 100644 --- a/funcs/sfx0.c +++ b/funcs/sfx0.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/sfx1.c b/funcs/sfx1.c index 1430668..0ef9945 100644 --- a/funcs/sfx1.c +++ b/funcs/sfx1.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/sfx2.c b/funcs/sfx2.c index 3ca589c..888c08f 100644 --- a/funcs/sfx2.c +++ b/funcs/sfx2.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/sfx3.c b/funcs/sfx3.c index f694416..4442a6b 100644 --- a/funcs/sfx3.c +++ b/funcs/sfx3.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/funcs/sfx4.c b/funcs/sfx4.c index 0643146..9c16316 100644 --- a/funcs/sfx4.c +++ b/funcs/sfx4.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "../floatimg.h" diff --git a/lib/Makefile b/lib/Makefile index 7a9a06f..3ffea72 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -6,7 +6,8 @@ COPT = -Wall -Wextra -fpic -g -no-pie -DDEBUG_LEVEL=0 OBJS = fimg-core.o fimg-pnm.o fimg-file.o fimg-math.o \ fimg-timers.o operators.o fimg-2gray.o \ - interpolate.o fimg-compare.o contrast.o + interpolate.o fimg-compare.o contrast.o \ + metadata.o DEPS = Makefile ../floatimg.h @@ -35,6 +36,9 @@ fimg-2gray.o: fimg-2gray.c $(DEPS) operators.o: operators.c $(DEPS) gcc $(COPT) -c $< +metadata.o: metadata.c $(DEPS) + gcc $(COPT) -c $< + contrast.o: contrast.c $(DEPS) gcc $(COPT) -c $< diff --git a/lib/fimg-file.c b/lib/fimg-file.c index b5da57f..b6ab586 100644 --- a/lib/fimg-file.c +++ b/lib/fimg-file.c @@ -46,6 +46,11 @@ if (memcmp(filehead.magic, "FIMG", 4)) { return -3; } +/* XXX preparer la gestion des metadata */ +if ('a' == filehead.magic[4]) { + fprintf(stderr,"****** %s have metadata\n", fname); + } + datas[0] = filehead.w; datas[1] = filehead.h; datas[2] = filehead.t; @@ -143,6 +148,11 @@ if ( (filehead.w != where->width) || return -17; } +/* XXX preparer la gestion des metadata */ +if ('a' == filehead.magic[4]) { + fprintf(stderr,"****** %s have metadata\n", fname); + } + nbre = filehead.w * filehead.h; /* number of pixels per frame */ foo = fread(where->R, sizeof(float), nbre, fp); if (nbre != foo) { diff --git a/lib/metadata.c b/lib/metadata.c new file mode 100644 index 0000000..4d9c7c5 --- /dev/null +++ b/lib/metadata.c @@ -0,0 +1,42 @@ +/* + * metadata.c + */ + +#include +#include +#include +#include +#include "string.h" + +#include "../floatimg.h" + +extern int verbosity; /* must be declared around main() */ + +/* ---------------------------------------------------------------- */ +int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused) +{ + +fprintf(stderr, ">>> %s ( %p '%s' 0x%08x )\n", __func__, + pmd, title, notused); + +fprintf(stderr, "sizeof metadata = %ld\n", sizeof(FimgMetaData)); +fprintf(stderr, "magic = '%8s'\n", pmd->magic); +/* TIMESTAMP HERE */ +fprintf(stderr, "counter = %d\n", pmd->count); +fprintf(stderr, "float value = %.3f\n", pmd->fval); +fprintf(stderr, "id camera = '%s'\n", pmd->idcam); + +return -1; +} +/* ---------------------------------------------------------------- */ +int fimg_default_metadata(FimgMetaData *pmd) +{ + +memcpy(pmd->magic, "metadata", 8); +pmd->count = 0; +pmd->fval = 255.0; +strcpy(pmd->idcam, "unknow"); + +return -1; +} +/* ---------------------------------------------------------------- */ diff --git a/lib/t.c b/lib/t.c index 0190060..70db717 100644 --- a/lib/t.c +++ b/lib/t.c @@ -14,6 +14,20 @@ int verbosity; +/* ---------------------------------------------------------------- */ +int essai_metadata(char *fname) +{ +FimgMetaData Md; +int foo; + +fprintf(stderr, "-------- %s ( %s ) --------\n", __func__, fname); + +foo = fimg_default_metadata(&Md); + +foo = fimg_show_metadata(&Md, "from t.c", 0); + +return -1; +} /* ---------------------------------------------------------------- */ int essai_save_plane(int wot) { @@ -300,9 +314,12 @@ if (verbosity) { fimg_print_sizeof(); } -foo = essai_save_plane(0); +foo = essai_metadata("foo.fimg"); fprintf(stderr, "retour essai -> %d\n", foo); +// foo = essai_save_plane(0); +// fprintf(stderr, "retour essai -> %d\n", foo); + // foo = essai_clone_et_copy(0); // fprintf(stderr, "retour essai clone'n'copy -> %d\n", foo);